diff -u nano/global.c nano-mspace/global.c --- nano/global.c Mon Apr 22 20:32:57 2002 +++ nano-mspace/global.c Tue Apr 23 05:36:05 2002 @@ -132,12 +132,11 @@ #endif -int length_of_list(shortcut *s) +int length_of_list(const shortcut *s) { int i = 0; - shortcut *t; - for (t = s; t != NULL; t = t->next) + for (; s != NULL; s = s->next) i++; return i; @@ -488,12 +487,21 @@ #endif #ifdef ENABLE_MULTIBUFFER - sc_init_one(&main_list, -9, _("Previous File"), + sc_init_one(&main_list, NANO_OPENPREV_KEY + 32, _("Previous File"), nano_openprev_msg, NANO_OPENPREV_KEY, 0, 0, VIEW, open_prevfile_void); - sc_init_one(&main_list, -9, _("Next File"), + sc_init_one(&main_list, NANO_OPENNEXT_KEY + 32, _("Next File"), nano_opennext_msg, NANO_OPENNEXT_KEY, 0, 0, VIEW, open_nextfile_void); +#endif + +#ifndef NANO_SMALL + sc_init_one(&main_list, NANO_NEXTWORD_KEY, _("Next Word"), + _("Move forward one word"), + 0, 0, 0, VIEW, do_next_word_void); + sc_init_one(&main_list, NANO_PREVWORD_KEY + 32, _("Prev Word"), + _("Move backward one word"), NANO_PREVWORD_KEY, 0, 0, + VIEW, do_prev_word_void); #endif if (whereis_list != NULL) diff -u nano/nano.c nano-mspace/nano.c --- nano/nano.c Tue Apr 23 02:30:40 2002 +++ nano-mspace/nano.c Tue Apr 23 06:21:29 2002 @@ -868,6 +868,11 @@ } } +int do_next_word_void(void) { + do_next_word(); + return 0; +} + /* the same thing for backwards */ void do_prev_word(void) { @@ -941,6 +946,11 @@ } } + +int do_prev_word_void(void) { + do_prev_word(); + return 0; +} #endif /* NANO_SMALL */ #ifndef DISABLE_WRAPPING @@ -2474,9 +2484,9 @@ #ifndef DISABLE_HELP 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 */ - char buf[BUFSIZ] = "", *ptr = NULL; + char *ptr = NULL; toggle *t; shortcut *s; @@ -2596,64 +2606,60 @@ /* Now add the text we want */ strcpy(help_text, ptr); + sofar = strlen(help_text); /* Now add our shortcut info */ s = currshortcut; for (i = 0; i <= helplen - 1; i++) { - if (s->val > 0 && s->val < 'a') - sofar = snprintf(buf, BUFSIZ, "^%c ", s->val + 64); - else { - if (s->altval > 0) { - sofar = 0; - meta_shortcut = 1; - } - else - sofar = snprintf(buf, BUFSIZ, " "); - } + int meta_shortcut = 0; + + if (s->val > 0 && s->val < 32) + sofar += sprintf(help_text + sofar, "^%c\t", s->val + 64); +#ifndef NANO_SMALL + else if (s->val == NANO_CONTROL_SPACE) + sofar += sprintf(help_text + sofar, "^%s\t", _("Space")); +#endif + else if (s->altval > 0) + meta_shortcut = 1; + else + help_text[sofar++] = '\t'; if (!meta_shortcut) { if (s->misc1 > KEY_F0 && s->misc1 <= KEY_F(64)) - sofar += snprintf(&buf[sofar], BUFSIZ - sofar, "(F%d) ", - s->misc1 - KEY_F0); - else - sofar += snprintf(&buf[sofar], BUFSIZ - sofar, " "); + sofar += sprintf(help_text + sofar, "(F%d)", + s->misc1 - KEY_F0); + help_text[sofar++] = '\t'; } - if (s->altval > 0 && s->altval < 91 - && (s->altval - 32) > 32) - sofar += snprintf(&buf[sofar], BUFSIZ - sofar, - (meta_shortcut ? "M-%c " : "(M-%c) "), - s->altval - 32); - else if (s->altval >= 'a') - sofar += snprintf(&buf[sofar], BUFSIZ - sofar, - (meta_shortcut ? "M-%c " : "(M-%c) "), - s->altval - 32); - else if (s->altval > 0) - sofar += snprintf(&buf[sofar], BUFSIZ - sofar, - (meta_shortcut ? "M-%c " : "(M-%c) "), - s->altval); +#ifndef NANO_SMALL + if (s->altval == NANO_ALT_SPACE) + sofar += sprintf(help_text + sofar, "M-%s", _("Space")); + else +#endif + if (s->altval > 0) + sofar += sprintf(help_text + sofar, + (meta_shortcut ? "M-%c" : "(M-%c)"), s->altval - + ((64 < s->altval && s->altval < 91) || 'a' < s->altval + ? 32 : 0)); /* Hack */ else if (s->val >= 'a') - sofar += snprintf(&buf[sofar], BUFSIZ - sofar, - (meta_shortcut ? "(M-%c) " : "M-%c "), - s->val - 32); - else - sofar += snprintf(&buf[sofar], BUFSIZ - sofar, " "); + sofar += sprintf(help_text + sofar, + (meta_shortcut ? "(M-%c)\t" : "M-%c\t"), s->val - 32); + + help_text[sofar++] = '\t'; if (meta_shortcut) { if (s->misc1 > KEY_F0 && s->misc1 <= KEY_F(64)) - sofar += snprintf(&buf[sofar], BUFSIZ - sofar, - "(F%d) ", s->misc1 - KEY_F0); - else - sofar += snprintf(&buf[sofar], BUFSIZ - sofar, - " "); + sofar += sprintf(help_text + sofar, + "(F%d)", s->misc1 - KEY_F0); + help_text[sofar++] = '\t'; + help_text[sofar++] = '\t'; } if (s->help != NULL) - snprintf(&buf[sofar], BUFSIZ - sofar, "%s", s->help); + sofar += sprintf(help_text + sofar, "%s", s->help); - strcat(help_text, buf); - strcat(help_text, "\n"); + help_text[sofar++] = '\n'; s = s->next; } @@ -2661,16 +2667,14 @@ /* And the toggles... */ if (currshortcut == main_list) for (t = toggles; t != NULL; t = t->next) { - sofar = snprintf(buf, BUFSIZ, - "M-%c ", t->val - 32); + sofar += sprintf(help_text + sofar, "M-%c\t\t\t", + t->val - 32); if (t->desc != NULL) { - snprintf(&buf[sofar], BUFSIZ - sofar, _("%s enable/disable"), - t->desc); + sofar += sprintf(help_text + sofar, + _("%s enable/disable"), t->desc); + } + help_text[sofar++] = '\n'; } - strcat(help_text, buf); - strcat(help_text, "\n"); - } - } #endif @@ -3149,13 +3153,6 @@ modify_control_seq = 1; keyhandled = 1; 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 '[': switch (kbinput = wgetch(edit)) { case '1': /* Alt-[-1-[0-5,7-9] = F1-F8 in X at least */ @@ -3290,19 +3287,16 @@ break; #endif -#if !defined (NANO_SMALL) && defined (HAVE_REGEX_H) - case NANO_BRACKET_KEY: - do_find_bracket(); - keyhandled = 1; - break; -#endif - default: /* Check for the altkey defs.... */ for (s = main_list; s != NULL; s = s->next) if (kbinput == s->altval || - kbinput == s->altval - 32) { - kbinput = s->val; + kbinput == s->altval - 32) { + if (ISSET(VIEW_MODE) && !s->viewok) + print_view_warning(); + else + s->func(); + keyhandled = 1; break; } #ifndef NANO_SMALL @@ -3399,11 +3393,6 @@ #endif case 0: /* Erg */ -#ifndef NANO_SMALL - do_next_word(); - break; -#endif - case -1: /* Stuff that we don't want to do squat */ case 410: /* Must ignore this, it gets sent when we resize */ case 29: /* Ctrl-] */ diff -u nano/nano.h nano-mspace/nano.h --- nano/nano.h Tue Apr 23 01:53:14 2002 +++ nano-mspace/nano.h Tue Apr 23 04:08:06 2002 @@ -170,6 +170,9 @@ /* 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_B 2 #define NANO_CONTROL_C 3 @@ -233,6 +236,9 @@ #define NANO_ALT_LCARAT '<' #define NANO_ALT_RCARAT '>' #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 know what you're doing */ @@ -296,6 +302,10 @@ #define NANO_OPENNEXT_ALTKEY NANO_ALT_PERIOD #define NANO_BRACKET_KEY NANO_ALT_BRACKET #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_AUTOINDENT_KEY NANO_ALT_I diff -u nano/proto.h nano-mspace/proto.h --- nano/proto.h Mon Apr 22 20:20:37 2002 +++ nano-mspace/proto.h Tue Apr 23 04:10:20 2002 @@ -122,7 +122,7 @@ int renumber_all(void); int open_file(char *filename, int insert, int quiet); int do_insertfile(int loading_file); -int length_of_list(shortcut *s); +int length_of_list(const shortcut *s); int num_of_digits(int n); int open_pipe(char *command); int read_file(FILE *f, char *filename, int quiet); @@ -135,6 +135,11 @@ int check_operating_dir(char *currpath, int allow_tabcomp); #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_gotoline(int line, int save_pos); int is_whole_word(int curr_pos, filestruct *fileptr, char *searchword); @@ -183,7 +188,7 @@ void titlebar(char *path); void previous_line(void); void center_cursor(void); -void bottombars(shortcut *s); +void bottombars(const shortcut *s); void blank_statusbar_refresh(void); void nperror(const char *s); void *mallocstrcpy(char *dest, char *src); diff -u nano/winio.c nano-mspace/winio.c --- nano/winio.c Fri Mar 29 10:15:38 2002 +++ nano-mspace/winio.c Tue Apr 23 05:29:51 2002 @@ -25,6 +25,7 @@ #include #include #include +#include #include "proto.h" #include "nano.h" @@ -579,7 +580,7 @@ reset_cursor(); } -void onekey(char *keystroke, char *desc, int len) +static void onekey(const char *keystroke, const char *desc, int len) { int i; @@ -588,8 +589,8 @@ wattroff(bottomwin, A_REVERSE); waddch(bottomwin, ' '); waddnstr(bottomwin, desc, len - 3); - for (i = strlen(desc); i < len - 3; i++) - waddch(bottomwin, ' '); + for (i = strlen(keystroke) + 1 + strlen(desc); i < len; i++) + waddch(bottomwin, ' '); } void clear_bottomwin(void) @@ -601,21 +602,21 @@ mvwaddstr(bottomwin, 2, 0, hblank); } -void bottombars(shortcut *s) +void bottombars(const shortcut *s) { int i, j, numcols; char keystr[10]; - shortcut *t; int slen; - if (s == main_list) - slen = MAIN_VISIBLE; - else - slen = length_of_list(s); - if (ISSET(NO_HELP)) return; + if (s == main_list) { + slen = MAIN_VISIBLE; + assert(MAIN_VISIBLE <= length_of_list(s)); + } else + slen = length_of_list(s); + #ifdef ENABLE_COLOR color_on(bottomwin, COLOR_BOTTOMBARS); if (!colors[COLOR_BOTTOMBARS - FIRST_COLORNUM].set || @@ -631,25 +632,29 @@ clear_bottomwin(); - t = s; for (i = 0; i < numcols; i++) { for (j = 0; j <= 1; j++) { wmove(bottomwin, 1 + j, i * ((COLS - 1) / numcols)); - if (t->val < 97) - snprintf(keystr, 10, "^%c", t->val + 64); +#ifndef NANO_SMALL + if (s->val == NANO_CONTROL_SPACE) + snprintf(keystr, 10, "^%c", ' '); + else +#endif /* !NANO_SMALL */ + if (s->val < 64) + snprintf(keystr, 10, "^%c", s->val + 64); else - snprintf(keystr, 10, "M-%c", t->val - 32); + snprintf(keystr, 10, "M-%c", s->val - 32); - onekey(keystr, t->desc, (COLS - 1) / numcols); + onekey(keystr, s->desc, (COLS - 1) / numcols); - if (t->next == NULL) - break; - t = t->next; - } - + s = s->next; + if (s == NULL) + goto break_completely_out; + } } +break_completely_out: #ifdef ENABLE_COLOR color_off(bottomwin, COLOR_BOTTOMBARS); @@ -1381,7 +1386,6 @@ char *yesstr; /* String of yes characters accepted */ char *nostr; /* Same for no */ char *allstr; /* And all, surprise! */ - char shortstr[5]; /* Temp string for above */ #ifndef DISABLE_MOUSE #ifdef NCURSES_MOUSE_VERSION MEVENT mevent; @@ -1405,18 +1409,20 @@ /* Remove gettext call for keybindings until we clear the thing up */ if (!ISSET(NO_HELP)) { + char shortstr[3]; /* Temp string for Y, N, A */ + wmove(bottomwin, 1, 0); - snprintf(shortstr, 3, " %c", yesstr[0]); + sprintf(shortstr, " %c", yesstr[0]); onekey(shortstr, _("Yes"), 16); if (all) { - snprintf(shortstr, 3, " %c", allstr[0]); + shortstr[1] = allstr[0]; onekey(shortstr, _("All"), 16); } wmove(bottomwin, 2, 0); - snprintf(shortstr, 3, " %c", nostr[0]); + shortstr[1] = nostr[0]; onekey(shortstr, _("No"), 16); onekey("^C", _("Cancel"), 16);