DB's latest patch, minus one totsize--. Also fixed a < in help_init that should be <=

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1206 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Chris Allegretta 2002-05-12 19:52:15 +00:00
parent 403f8dc0a3
commit 6232d6659f
13 changed files with 190 additions and 156 deletions

View File

@ -29,6 +29,10 @@ CVS code -
- Many chanes to allow marked cutting to work with multiple - Many chanes to allow marked cutting to work with multiple
file buffers: changes to openfilestruct type in nano.h and file buffers: changes to openfilestruct type in nano.h and
files.c (David Lawrence Ramsey). files.c (David Lawrence Ramsey).
- Changed NANO_SMALL to ENABLE_NLS for gettext disabling
(David Benbennick).
- Move next_key and pev_key definitions out of main() and into
global.c where they belong (David Benbennick).
- configure.ac: - configure.ac:
- Define NDEBUG to silence asserts (David Benbennick). - Define NDEBUG to silence asserts (David Benbennick).
- files.c: - files.c:
@ -37,6 +41,8 @@ CVS code -
- global.c: - global.c:
shortcut_init() shortcut_init()
- Add missing free_shortcutage()s (David Benbennick). - Add missing free_shortcutage()s (David Benbennick).
thanks_for_all_the_fish()
- Only defined when using DEBUG, makes sense (David Benbennick).
- nano.c: - nano.c:
die_save_file() die_save_file()
- Add missing free (David Benbennick). - Add missing free (David Benbennick).
@ -44,6 +50,10 @@ CVS code -
- Optimizations (David Benbennick). - Optimizations (David Benbennick).
do_wrap() do_wrap()
- Complete rewrite (David Benbennick). - Complete rewrite (David Benbennick).
help_init()
- A little les readable, a lot shorer :-) (David Benbennick).
- Fix Meta-A not getting capitalized, and convert the ASCII
#s to their character equivalent.
main() main()
- Changed charalloc(), strcpy()s to mallocstrcpy()s. - Changed charalloc(), strcpy()s to mallocstrcpy()s.
- nano.h: - nano.h:
@ -57,13 +67,15 @@ CVS code -
- Changed references to Debian GNU/Linux to Debian GNU (Jordi). - Changed references to Debian GNU/Linux to Debian GNU (Jordi).
- nano.1.html: - nano.1.html:
- Updated for -Y option (David Lawrence Ramsey). - Updated for -Y option (David Lawrence Ramsey).
- rcfile.c - rcfile.c:
- Made some rc file errors less fatal. - Made some rc file errors less fatal.
- Added in my patch for getpwent instead of relying on $HOME - Added in my patch for getpwent instead of relying on $HOME
(David Lawrence Ramsey). (David Lawrence Ramsey).
- winio.c: - winio.c:
edit_add() edit_add()
- Changed some syntax hilight computations for the sake of COLS. - Changed some syntax hilight computations for the sake of COLS.
botombars(), onekey()
- Cleanups (David Benbennick).
- po/gl.po: - po/gl.po:
- Galician translation updates (Jacobo Tarrio). - Galician translation updates (Jacobo Tarrio).
- po/de.po: - po/de.po:

View File

@ -33,7 +33,7 @@
#include "proto.h" #include "proto.h"
#include "nano.h" #include "nano.h"
#ifndef NANO_SMALL #ifdef ENABLE_NLS
#include <libintl.h> #include <libintl.h>
#define _(string) gettext(string) #define _(string) gettext(string)
#else #else

2
cut.c
View File

@ -27,7 +27,7 @@
#include "proto.h" #include "proto.h"
#include "nano.h" #include "nano.h"
#ifndef NANO_SMALL #ifdef ENABLE_NLS
#include <libintl.h> #include <libintl.h>
#define _(string) gettext(string) #define _(string) gettext(string)
#else #else

View File

@ -37,7 +37,7 @@
#include "proto.h" #include "proto.h"
#include "nano.h" #include "nano.h"
#ifndef NANO_SMALL #ifdef ENABLE_NLS
#include <libintl.h> #include <libintl.h>
#define _(string) gettext(string) #define _(string) gettext(string)
#else #else
@ -450,6 +450,13 @@ int do_insertfile(int loading_file)
} }
#endif #endif
/* Here is a kludge. If the current file is blank (including
* after new_file()), then totlines==1 and totsize==0. Thus
* after open_pipe() or open_file() below, the totsize is short
* by one. */
if (totlines==1 && totsize==0)
totsize++;
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (i == NANO_EXTCMD_KEY) { if (i == NANO_EXTCMD_KEY) {
i = open_pipe(answer); i = open_pipe(answer);

View File

@ -26,7 +26,7 @@
#include "nano.h" #include "nano.h"
#include "proto.h" #include "proto.h"
#ifndef NANO_SMALL #ifdef ENABLE_NLS
#include <libintl.h> #include <libintl.h>
#define _(string) gettext(string) #define _(string) gettext(string)
#else #else
@ -561,6 +561,15 @@ void shortcut_init(int unjustify)
NANO_OPENNEXT_KEY, 0, 0, VIEW, open_nextfile_void); NANO_OPENNEXT_KEY, 0, 0, VIEW, open_nextfile_void);
#endif #endif
#ifndef NANO_SMALL
sc_init_one(&main_list, NANO_NEXTWORD_KEY, _("Next Word"),
IFHELP(_("Move forward one word"),)
0, 0, 0, VIEW, do_next_word_void);
sc_init_one(&main_list, -9, _("Prev Word"),
IFHELP(_("Move backward one word"),) NANO_PREVWORD_KEY, 0, 0,
VIEW, do_prev_word_void);
#endif
free_shortcutage(&whereis_list); free_shortcutage(&whereis_list);
sc_init_one(&whereis_list, NANO_HELP_KEY, sc_init_one(&whereis_list, NANO_HELP_KEY,
@ -820,13 +829,15 @@ void shortcut_init(int unjustify)
#endif #endif
} }
/* This function is called just before calling exit(). Practically, the
* only effect is to cause a segmentation fault if the various data
* structures got bolloxed earlier. Thus, we don't bother having this
* function unless debugging is turned on.
*/
#ifdef DEBUG
/* added by SPK for memory cleanup, gracefully return our malloc()s */ /* added by SPK for memory cleanup, gracefully return our malloc()s */
void thanks_for_all_the_fish(void) void thanks_for_all_the_fish(void)
{ {
#ifdef ENABLE_MULTIBUFFER
openfilestruct * current_open_file;
#endif
#ifndef DISABLE_OPERATINGDIR #ifndef DISABLE_OPERATINGDIR
if (operating_dir != NULL) if (operating_dir != NULL)
free(operating_dir); free(operating_dir);
@ -871,29 +882,21 @@ void thanks_for_all_the_fish(void)
#endif #endif
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
/* Cleanup of Multibuffers . . .
Do not cleanup the current one, that is fileage . . . do the
rest of them though! (should be none if all went well) */
current_open_file = open_files;
if (open_files != NULL) { if (open_files != NULL) {
/* We free the memory associated with each open file. */
openfilestruct *next;
while (open_files->prev != NULL) while (open_files->prev != NULL)
open_files = open_files->prev; open_files = open_files->prev;
while (open_files->next != NULL) { do {
/* cleanup of a multi buf . . . */ next = open_files->next;
open_files = open_files->next; free_openfilestruct(open_files);
if (open_files->prev != current_open_file) open_files = next;
free_openfilestruct(open_files->prev); } while (open_files != NULL);
}
/* cleanup of last multi buf . . . */
free_openfilestruct(open_files);
} }
#else #else
/* starting the cleanup of fileage now . . . */
if (fileage != NULL) if (fileage != NULL)
free_filestruct(fileage); free_filestruct(fileage);
#endif #endif
/* that is all for now */
} }
#endif /* DEBUG */

2
move.c
View File

@ -27,7 +27,7 @@
#include "proto.h" #include "proto.h"
#include "nano.h" #include "nano.h"
#ifndef NANO_SMALL #ifdef ENABLE_NLS
#include <libintl.h> #include <libintl.h>
#define _(string) gettext(string) #define _(string) gettext(string)
#else #else

153
nano.c
View File

@ -43,7 +43,7 @@
#include "proto.h" #include "proto.h"
#include "nano.h" #include "nano.h"
#ifndef NANO_SMALL #ifdef ENABLE_NLS
#include <libintl.h> #include <libintl.h>
#define _(string) gettext(string) #define _(string) gettext(string)
#else #else
@ -100,7 +100,9 @@ RETSIGTYPE finish(int sigage)
/* Restore the old term settings */ /* Restore the old term settings */
tcsetattr(0, TCSANOW, &oldterm); tcsetattr(0, TCSANOW, &oldterm);
#ifdef DEBUG
thanks_for_all_the_fish(); thanks_for_all_the_fish();
#endif
exit(sigage); exit(sigage);
} }
@ -882,6 +884,11 @@ void do_next_word(void)
} }
} }
int do_next_word_void(void) {
do_next_word();
return 0;
}
/* the same thing for backwards */ /* the same thing for backwards */
void do_prev_word(void) void do_prev_word(void)
{ {
@ -955,6 +962,11 @@ void do_prev_word(void)
} }
} }
int do_prev_word_void(void) {
do_prev_word();
return 0;
}
#endif /* NANO_SMALL */ #endif /* NANO_SMALL */
#ifndef DISABLE_WRAPPING #ifndef DISABLE_WRAPPING
@ -1298,8 +1310,6 @@ int do_backspace(void)
int do_delete(void) int do_delete(void)
{ {
filestruct *foo;
/* blbf -> blank line before filebot (see below) */ /* blbf -> blank line before filebot (see below) */
int blbf = 0; int blbf = 0;
@ -1313,11 +1323,12 @@ int do_delete(void)
align(&current->data); align(&current->data);
/* Now that we have a magic line again, we can check for both being
on the line before filebot as well as at filebot; it's a special
case if we're on the line before filebot and it's blank, since we
should be able to delete it */
} else if (current->next != NULL && (current->next != filebot || blbf)) { } else if (current->next != NULL && (current->next != filebot || blbf)) {
/* We can delete the line before filebot only if it is blank: it
* becomes the new magic line then. */
filestruct *foo;
current->data = nrealloc(current->data, current->data = nrealloc(current->data,
strlen(current->data) + strlen(current->data) +
strlen(current->next->data) + 1); strlen(current->next->data) + 1);
@ -1332,14 +1343,6 @@ int do_delete(void)
unlink_node(foo); unlink_node(foo);
delete_node(foo); delete_node(foo);
update_line(current, current_x); update_line(current, current_x);
/* Please see the comment in do_backspace if you don't understand
this test */
if (current == filebot && current->data[0] != '\0') {
new_magicline();
fix_editbot();
totsize++;
}
renumber(current); renumber(current);
totlines--; totlines--;
} else } else
@ -2486,9 +2489,9 @@ int do_justify(void)
#ifndef DISABLE_HELP #ifndef DISABLE_HELP
void help_init(void) void help_init(void)
{ {
int i, sofar = 0, meta_shortcut = 0, helplen; int i, sofar = 0, helplen;
long allocsize = 1; /* How much space we're gonna need for the help text */ long allocsize = 1; /* How much space we're gonna need for the help text */
char buf[BUFSIZ] = "", *ptr = NULL; char *ptr = NULL;
#ifndef NANO_SMALL #ifndef NANO_SMALL
toggle *t; toggle *t;
#endif #endif
@ -2612,64 +2615,60 @@ void help_init(void)
/* Now add the text we want */ /* Now add the text we want */
strcpy(help_text, ptr); strcpy(help_text, ptr);
sofar = strlen(help_text);
/* Now add our shortcut info */ /* Now add our shortcut info */
s = currshortcut; s = currshortcut;
for (i = 0; i <= helplen - 1; i++) { for (i = 0; i <= helplen - 1; i++) {
if (s->val > 0 && s->val < 'a') int meta_shortcut = 0;
sofar = snprintf(buf, BUFSIZ, "^%c ", s->val + 64);
else { if (s->val > 0 && s->val < 32)
if (s->altval > 0) { sofar += sprintf(help_text + sofar, "^%c\t", s->val + 64);
sofar = 0; #ifndef NANO_SMALL
meta_shortcut = 1; else if (s->val == NANO_CONTROL_SPACE)
} sofar += sprintf(help_text + sofar, "^%s\t", _("Space"));
else #endif
sofar = snprintf(buf, BUFSIZ, " "); else if (s->altval > 0)
} meta_shortcut = 1;
else
help_text[sofar++] = '\t';
if (!meta_shortcut) { if (!meta_shortcut) {
if (s->misc1 > KEY_F0 && s->misc1 <= KEY_F(64)) if (s->misc1 > KEY_F0 && s->misc1 <= KEY_F(64))
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, "(F%d) ", sofar += sprintf(help_text + sofar, "(F%d)",
s->misc1 - KEY_F0); s->misc1 - KEY_F0);
else help_text[sofar++] = '\t';
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, " ");
} }
if (s->altval > 0 && s->altval < 91 #ifndef NANO_SMALL
&& (s->altval - 32) > 32) if (s->altval == NANO_ALT_SPACE)
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, sofar += sprintf(help_text + sofar, "M-%s", _("Space"));
(meta_shortcut ? "M-%c " : "(M-%c) "), else
s->altval - 32); #endif
else if (s->altval >= 'a') if (s->altval > 0)
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, sofar += sprintf(help_text + sofar,
(meta_shortcut ? "M-%c " : "(M-%c) "), (meta_shortcut ? "M-%c" : "(M-%c)"), s->altval -
s->altval - 32); (('A' <= s->altval && s->altval <= 'Z') || 'a' <= s->altval
else if (s->altval > 0) ? 32 : 0));
sofar += snprintf(&buf[sofar], BUFSIZ - sofar,
(meta_shortcut ? "M-%c " : "(M-%c) "),
s->altval);
/* Hack */ /* Hack */
else if (s->val >= 'a') else if (s->val >= 'a')
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, sofar += sprintf(help_text + sofar,
(meta_shortcut ? "(M-%c) " : "M-%c "), (meta_shortcut ? "(M-%c)\t" : "M-%c\t"), s->val - 32);
s->val - 32);
else help_text[sofar++] = '\t';
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, " ");
if (meta_shortcut) { if (meta_shortcut) {
if (s->misc1 > KEY_F0 && s->misc1 <= KEY_F(64)) if (s->misc1 > KEY_F0 && s->misc1 <= KEY_F(64))
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, sofar += sprintf(help_text + sofar,
"(F%d) ", s->misc1 - KEY_F0); "(F%d)", s->misc1 - KEY_F0);
else help_text[sofar++] = '\t';
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, help_text[sofar++] = '\t';
" ");
} }
if (s->help != NULL) if (s->help != NULL)
snprintf(&buf[sofar], BUFSIZ - sofar, "%s", s->help); sofar += sprintf(help_text + sofar, "%s", s->help);
strcat(help_text, buf); help_text[sofar++] = '\n';
strcat(help_text, "\n");
s = s->next; s = s->next;
} }
@ -2678,15 +2677,14 @@ void help_init(void)
/* And the toggles... */ /* And the toggles... */
if (currshortcut == main_list) if (currshortcut == main_list)
for (t = toggles; t != NULL; t = t->next) { for (t = toggles; t != NULL; t = t->next) {
sofar = snprintf(buf, BUFSIZ, sofar += sprintf(help_text + sofar, "M-%c\t\t\t",
"M-%c ", t->val - 32); t->val - 32);
if (t->desc != NULL) { if (t->desc != NULL) {
snprintf(&buf[sofar], BUFSIZ - sofar, _("%s enable/disable"), sofar += sprintf(help_text + sofar,
t->desc); _("%s enable/disable"), t->desc);
}
help_text[sofar++] = '\n';
} }
strcat(help_text, buf);
strcat(help_text, "\n");
}
#endif /* !NANO_SMALL */ #endif /* !NANO_SMALL */
} }
#endif #endif
@ -3169,13 +3167,6 @@ int main(int argc, char *argv[])
modify_control_seq = 1; modify_control_seq = 1;
keyhandled = 1; keyhandled = 1;
break; break;
#ifndef NANO_SMALL
case ' ':
/* If control-space is next word, Alt-space should be previous word */
do_prev_word();
keyhandled = 1;
break;
#endif
case '[': case '[':
switch (kbinput = wgetch(edit)) { switch (kbinput = wgetch(edit)) {
case '1': /* Alt-[-1-[0-5,7-9] = F1-F8 in X at least */ case '1': /* Alt-[-1-[0-5,7-9] = F1-F8 in X at least */
@ -3310,19 +3301,16 @@ int main(int argc, char *argv[])
break; break;
#endif #endif
#if !defined (NANO_SMALL) && defined (HAVE_REGEX_H)
case NANO_BRACKET_KEY:
do_find_bracket();
keyhandled = 1;
break;
#endif
default: default:
/* Check for the altkey defs.... */ /* Check for the altkey defs.... */
for (s = main_list; s != NULL; s = s->next) for (s = main_list; s != NULL; s = s->next)
if (kbinput == s->altval || if (kbinput == s->altval ||
kbinput == s->altval - 32) { kbinput == s->altval - 32) {
kbinput = s->val; if (ISSET(VIEW_MODE) && !s->viewok)
print_view_warning();
else
s->func();
keyhandled = 1;
break; break;
} }
#ifndef NANO_SMALL #ifndef NANO_SMALL
@ -3419,11 +3407,6 @@ int main(int argc, char *argv[])
#endif #endif
case 0: /* Erg */ case 0: /* Erg */
#ifndef NANO_SMALL
do_next_word();
break;
#endif
case -1: /* Stuff that we don't want to do squat */ case -1: /* Stuff that we don't want to do squat */
case 410: /* Must ignore this, it gets sent when we resize */ case 410: /* Must ignore this, it gets sent when we resize */
case 29: /* Ctrl-] */ case 29: /* Ctrl-] */

10
nano.h
View File

@ -193,6 +193,9 @@ typedef struct syntaxtype {
/* Control key sequences, changing these would be very very bad */ /* Control key sequences, changing these would be very very bad */
#ifndef NANO_SMALL
# define NANO_CONTROL_SPACE 0
#endif
#define NANO_CONTROL_A 1 #define NANO_CONTROL_A 1
#define NANO_CONTROL_B 2 #define NANO_CONTROL_B 2
#define NANO_CONTROL_C 3 #define NANO_CONTROL_C 3
@ -256,6 +259,9 @@ typedef struct syntaxtype {
#define NANO_ALT_LCARAT '<' #define NANO_ALT_LCARAT '<'
#define NANO_ALT_RCARAT '>' #define NANO_ALT_RCARAT '>'
#define NANO_ALT_BRACKET ']' #define NANO_ALT_BRACKET ']'
#ifndef NANO_SMALL
# define NANO_ALT_SPACE ' '
#endif
/* Some semi-changeable keybindings; don't play with unless you're sure you /* Some semi-changeable keybindings; don't play with unless you're sure you
know what you're doing */ know what you're doing */
@ -319,6 +325,10 @@ know what you're doing */
#define NANO_OPENNEXT_ALTKEY NANO_ALT_PERIOD #define NANO_OPENNEXT_ALTKEY NANO_ALT_PERIOD
#define NANO_BRACKET_KEY NANO_ALT_BRACKET #define NANO_BRACKET_KEY NANO_ALT_BRACKET
#define NANO_EXTCMD_KEY NANO_CONTROL_X #define NANO_EXTCMD_KEY NANO_CONTROL_X
#ifndef NANO_SMALL
# define NANO_NEXTWORD_KEY NANO_CONTROL_SPACE
# define NANO_PREVWORD_KEY NANO_ALT_SPACE
#endif
#define TOGGLE_CONST_KEY NANO_ALT_C #define TOGGLE_CONST_KEY NANO_ALT_C
#define TOGGLE_AUTOINDENT_KEY NANO_ALT_I #define TOGGLE_AUTOINDENT_KEY NANO_ALT_I

View File

@ -105,7 +105,9 @@ extern toggle *toggles;
/* public functions in global.c */ /* public functions in global.c */
int length_of_list(const shortcut *s); int length_of_list(const shortcut *s);
void shortcut_init(int unjustify); void shortcut_init(int unjustify);
#ifdef DEBUG
void thanks_for_all_the_fish(void); void thanks_for_all_the_fish(void);
#endif
@ -146,6 +148,11 @@ int add_open_file(int update);
int check_operating_dir(char *currpath, int allow_tabcomp); int check_operating_dir(char *currpath, int allow_tabcomp);
#endif #endif
#ifndef NANO_SMALL
int do_next_word_void(void);
int do_prev_word_void(void);
#endif /* !NANO_SMALL */
int do_writeout(char *path, int exiting, int append); int do_writeout(char *path, int exiting, int append);
int do_gotoline(int line, int save_pos); int do_gotoline(int line, int save_pos);
int is_whole_word(int curr_pos, filestruct *fileptr, char *searchword); int is_whole_word(int curr_pos, filestruct *fileptr, char *searchword);
@ -193,7 +200,7 @@ void blank_statusbar(void);
void titlebar(char *path); void titlebar(char *path);
void previous_line(void); void previous_line(void);
void center_cursor(void); void center_cursor(void);
void bottombars(shortcut *s); void bottombars(const shortcut *s);
void blank_statusbar_refresh(void); void blank_statusbar_refresh(void);
void nperror(const char *s); void nperror(const char *s);
void *mallocstrcpy(char *dest, char *src); void *mallocstrcpy(char *dest, char *src);

View File

@ -35,7 +35,7 @@
#ifdef ENABLE_NANORC #ifdef ENABLE_NANORC
#ifndef NANO_SMALL #ifdef ENABLE_NLS
#include <libintl.h> #include <libintl.h>
#define _(string) gettext(string) #define _(string) gettext(string)
#else #else
@ -222,7 +222,7 @@ void parse_syntax(FILE * rcstream, char *buf, char *ptr)
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, fprintf(stderr,
"Starting a new syntax type\n"); "Starting a new syntax type\n");
fprintf(stderr, "string val=%s\n", tmp); fprintf(stderr, "string val=%s\n", nameptr);
#endif #endif
} else { } else {

View File

@ -29,7 +29,7 @@
#include "proto.h" #include "proto.h"
#include "nano.h" #include "nano.h"
#ifndef NANO_SMALL #ifdef ENABLE_NLS
#include <libintl.h> #include <libintl.h>
#define _(string) gettext(string) #define _(string) gettext(string)
#else #else

View File

@ -30,7 +30,7 @@
#include "nano.h" #include "nano.h"
#include "proto.h" #include "proto.h"
#ifndef NANO_SMALL #ifdef ENABLE_NLS
#include <libintl.h> #include <libintl.h>
#define _(string) gettext(string) #define _(string) gettext(string)
#else #else

86
winio.c
View File

@ -25,10 +25,11 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <assert.h>
#include "proto.h" #include "proto.h"
#include "nano.h" #include "nano.h"
#ifndef NANO_SMALL #ifdef ENABLE_NLS
#include <libintl.h> #include <libintl.h>
#define _(string) gettext(string) #define _(string) gettext(string)
#else #else
@ -578,17 +579,24 @@ void titlebar(char *path)
reset_cursor(); reset_cursor();
} }
void onekey(char *keystroke, const char *desc, int len) /* Write a shortcut key to the help area at the bottom of the window.
* keystroke is e.g. "^G" and desc is e.g. "Get Help".
* We are careful to write exactly len characters, even if len is
* very small and keystroke and desc are long. */
static void onekey(const char *keystroke, const char *desc, int len)
{ {
int i;
wattron(bottomwin, A_REVERSE); wattron(bottomwin, A_REVERSE);
waddstr(bottomwin, keystroke); waddnstr(bottomwin, keystroke, len);
wattroff(bottomwin, A_REVERSE); wattroff(bottomwin, A_REVERSE);
waddch(bottomwin, ' '); len -= strlen(keystroke);
waddnstr(bottomwin, desc, len - 3); if (len > 0) {
for (i = strlen(desc); i < len - 3; i++) waddch(bottomwin, ' ');
waddch(bottomwin, ' '); len--;
waddnstr(bottomwin, desc, len);
len -= strlen(desc);
for (; len > 0; len--)
waddch(bottomwin, ' ');
}
} }
void clear_bottomwin(void) void clear_bottomwin(void)
@ -600,21 +608,21 @@ void clear_bottomwin(void)
mvwaddstr(bottomwin, 2, 0, hblank); mvwaddstr(bottomwin, 2, 0, hblank);
} }
void bottombars(shortcut *s) void bottombars(const shortcut *s)
{ {
int i, j, numcols; int i, j, numcols;
char keystr[10]; char keystr[4];
shortcut *t;
int slen; int slen;
if (s == main_list)
slen = MAIN_VISIBLE;
else
slen = length_of_list(s);
if (ISSET(NO_HELP)) if (ISSET(NO_HELP))
return; return;
if (s == main_list) {
slen = MAIN_VISIBLE;
assert(MAIN_VISIBLE <= length_of_list(s));
} else
slen = length_of_list(s);
#ifdef ENABLE_COLOR #ifdef ENABLE_COLOR
color_on(bottomwin, COLOR_BOTTOMBARS); color_on(bottomwin, COLOR_BOTTOMBARS);
if (!colors[COLOR_BOTTOMBARS - FIRST_COLORNUM].set || if (!colors[COLOR_BOTTOMBARS - FIRST_COLORNUM].set ||
@ -622,40 +630,43 @@ void bottombars(shortcut *s)
wattroff(bottomwin, A_REVERSE); wattroff(bottomwin, A_REVERSE);
#endif #endif
/* Determine how many extra spaces are needed to fill the bottom of the screen */ /* There will be this many columns of shortcuts */
if (slen < 2) numcols = (slen + (slen % 2)) / 2;
numcols = 6;
else
numcols = (slen + (slen % 2)) / 2;
clear_bottomwin(); clear_bottomwin();
t = s;
for (i = 0; i < numcols; i++) { for (i = 0; i < numcols; i++) {
for (j = 0; j <= 1; j++) { for (j = 0; j <= 1; j++) {
wmove(bottomwin, 1 + j, i * ((COLS - 1) / numcols)); wmove(bottomwin, 1 + j, i * (COLS / numcols));
if (t->val < 97) #ifndef NANO_SMALL
snprintf(keystr, 10, "^%c", t->val + 64); if (s->val == NANO_CONTROL_SPACE)
strcpy(keystr, "^ ");
else else
snprintf(keystr, 10, "M-%c", t->val - 32); #endif /* !NANO_SMALL */
if (s->val > 0) {
if (s->val < 64)
sprintf(keystr, "^%c", s->val + 64);
else
sprintf(keystr, "M-%c", s->val - 32);
} else if (s->altval > 0)
sprintf(keystr, "M-%c", s->altval);
onekey(keystr, t->desc, (COLS - 1) / numcols); onekey(keystr, s->desc, COLS / numcols);
if (t->next == NULL) s = s->next;
break; if (s == NULL)
t = t->next; goto break_completely_out;
} }
} }
break_completely_out:
#ifdef ENABLE_COLOR #ifdef ENABLE_COLOR
color_off(bottomwin, COLOR_BOTTOMBARS); color_off(bottomwin, COLOR_BOTTOMBARS);
#endif #endif
wrefresh(bottomwin); wrefresh(bottomwin);
} }
/* If modified is not already set, set it and update titlebar */ /* If modified is not already set, set it and update titlebar */
@ -1396,7 +1407,6 @@ int do_yesno(int all, int leavecursor, char *msg, ...)
char *yesstr; /* String of yes characters accepted */ char *yesstr; /* String of yes characters accepted */
char *nostr; /* Same for no */ char *nostr; /* Same for no */
char *allstr; /* And all, surprise! */ char *allstr; /* And all, surprise! */
char shortstr[5]; /* Temp string for above */
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
#ifdef NCURSES_MOUSE_VERSION #ifdef NCURSES_MOUSE_VERSION
MEVENT mevent; MEVENT mevent;
@ -1420,18 +1430,20 @@ int do_yesno(int all, int leavecursor, char *msg, ...)
/* Remove gettext call for keybindings until we clear the thing up */ /* Remove gettext call for keybindings until we clear the thing up */
if (!ISSET(NO_HELP)) { if (!ISSET(NO_HELP)) {
char shortstr[3]; /* Temp string for Y, N, A */
wmove(bottomwin, 1, 0); wmove(bottomwin, 1, 0);
snprintf(shortstr, 3, " %c", yesstr[0]); sprintf(shortstr, " %c", yesstr[0]);
onekey(shortstr, _("Yes"), 16); onekey(shortstr, _("Yes"), 16);
if (all) { if (all) {
snprintf(shortstr, 3, " %c", allstr[0]); shortstr[1] = allstr[0];
onekey(shortstr, _("All"), 16); onekey(shortstr, _("All"), 16);
} }
wmove(bottomwin, 2, 0); wmove(bottomwin, 2, 0);
snprintf(shortstr, 3, " %c", nostr[0]); shortstr[1] = nostr[0];
onekey(shortstr, _("No"), 16); onekey(shortstr, _("No"), 16);
onekey("^C", _("Cancel"), 16); onekey("^C", _("Cancel"), 16);