Commit bc80cb1b authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

readd the Cancel -> Exit aliases for the file browser and help browser,

per Benno Schulenberg's suggestion, and clean up a few other
miscellaneous things


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3428 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 74 additions and 40 deletions
+74 -40
...@@ -51,6 +51,10 @@ CVS code - ...@@ -51,6 +51,10 @@ CVS code -
help_init(). (DLR, suggested by Benno Schulenberg) help_init(). (DLR, suggested by Benno Schulenberg)
- Reduce NO_RCFILE to a static bool in nano.c, since it's only - Reduce NO_RCFILE to a static bool in nano.c, since it's only
used there. Changes to finish() and main(). (DLR) used there. Changes to finish() and main(). (DLR)
- Readd the Cancel -> Exit aliases for the file browser and help
browser. New function parse_help_input(); changes to
parse_browser_input() and do_help(). (DLR, suggested by Benno
Schulenberg)
- files.c: - files.c:
open_file() open_file()
- Remove redundant wording in the error message when we try to - Remove redundant wording in the error message when we try to
...@@ -106,6 +110,7 @@ CVS code - ...@@ -106,6 +110,7 @@ CVS code -
- Call get_shortcut() after getting input, so that we only have - Call get_shortcut() after getting input, so that we only have
to check for a main shortcut key instead of both it and all of to check for a main shortcut key instead of both it and all of
its equivalents. (DLR) its equivalents. (DLR)
- Clean up the handling of NANO_REFRESH_KEY. (DLR)
help_init() help_init()
- If we have at least two entries' worth of blank space, use it - If we have at least two entries' worth of blank space, use it
to display more of "^Space" and "M-Space". (DLR, suggested by to display more of "^Space" and "M-Space". (DLR, suggested by
...@@ -122,6 +127,9 @@ CVS code - ...@@ -122,6 +127,9 @@ CVS code -
disabled, so that we aren't erroneously kicked out of the disabled, so that we aren't erroneously kicked out of the
statusbar prompt under any circumstances. (DLR, found by Benno statusbar prompt under any circumstances. (DLR, found by Benno
Schulenberg) Schulenberg)
do_yesno()
- Handle the keys in a switch statement instead of a long if
block, for simplicity. (DLR)
- rcfile.c: - rcfile.c:
parse_argument() parse_argument()
- Rename variable ptr_bak to ptr_save, for consistency. (DLR) - Rename variable ptr_bak to ptr_save, for consistency. (DLR)
......
...@@ -486,7 +486,7 @@ void browser_init(const char *path, DIR *dir) ...@@ -486,7 +486,7 @@ void browser_init(const char *path, DIR *dir)
/* Determine the shortcut key corresponding to the values of kbinput /* Determine the shortcut key corresponding to the values of kbinput
* (the key itself), meta_key (whether the key is a meta sequence), and * (the key itself), meta_key (whether the key is a meta sequence), and
* func_key (whether the key is a function key), if any. In the * func_key (whether the key is a function key), if any. In the
* process, convert certain non-shortcut keys used by Pico's file * process, convert certain non-shortcut keys used by e.g. Pico's file
* browser into their corresponding shortcut keys. */ * browser into their corresponding shortcut keys. */
void parse_browser_input(int *kbinput, bool *meta_key, bool *func_key) void parse_browser_input(int *kbinput, bool *meta_key, bool *func_key)
{ {
...@@ -504,6 +504,8 @@ void parse_browser_input(int *kbinput, bool *meta_key, bool *func_key) ...@@ -504,6 +504,8 @@ void parse_browser_input(int *kbinput, bool *meta_key, bool *func_key)
case '?': case '?':
*kbinput = NANO_HELP_KEY; *kbinput = NANO_HELP_KEY;
break; break;
/* Cancel is equivalent to Exit here. */
case NANO_CANCEL_KEY:
case 'E': case 'E':
case 'e': case 'e':
*kbinput = NANO_EXIT_KEY; *kbinput = NANO_EXIT_KEY;
......
...@@ -111,17 +111,16 @@ void do_help(void (*refresh_func)(void)) ...@@ -111,17 +111,16 @@ void do_help(void (*refresh_func)(void))
if (!no_more) if (!no_more)
line++; line++;
break; break;
case NANO_REFRESH_KEY:
total_redraw();
break;
} }
if (kbinput == NANO_REFRESH_KEY) if ((kbinput != ERR && line == old_line) || kbinput ==
/* Redraw the screen. */ NANO_REFRESH_KEY)
total_redraw(); goto skip_redisplay;
else {
if (kbinput != ERR && line == old_line)
goto skip_redisplay;
blank_edit(); blank_edit();
}
/* Calculate where in the text we should be, based on the /* Calculate where in the text we should be, based on the
* page. */ * page. */
...@@ -143,7 +142,7 @@ void do_help(void (*refresh_func)(void)) ...@@ -143,7 +142,7 @@ void do_help(void (*refresh_func)(void))
skip_redisplay: skip_redisplay:
kbinput = get_kbinput(edit, &meta_key, &func_key); kbinput = get_kbinput(edit, &meta_key, &func_key);
get_shortcut(help_list, &kbinput, &meta_key, &func_key); parse_help_input(&kbinput, &meta_key, &func_key);
} while (kbinput != NANO_EXIT_KEY); } while (kbinput != NANO_EXIT_KEY);
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
...@@ -547,6 +546,26 @@ void help_init(void) ...@@ -547,6 +546,26 @@ void help_init(void)
assert(strlen(help_text) <= allocsize + 1); assert(strlen(help_text) <= allocsize + 1);
} }
/* Determine the shortcut key corresponding to the values of kbinput
* (the key itself), meta_key (whether the key is a meta sequence), and
* func_key (whether the key is a function key), if any. In the
* process, convert certain non-shortcut keys used by e.g. Pico's help
* browser into their corresponding shortcut keys. */
void parse_help_input(int *kbinput, bool *meta_key, bool *func_key)
{
get_shortcut(help_list, kbinput, meta_key, func_key);
/* Pico compatibility. */
if (*meta_key == FALSE && *func_key == FALSE) {
switch (*kbinput) {
/* Cancel is equivalent to Exit here. */
case NANO_CANCEL_KEY:
*kbinput = NANO_EXIT_KEY;
break;
}
}
}
/* Calculate the next line of help_text, starting at ptr. */ /* Calculate the next line of help_text, starting at ptr. */
size_t help_line_len(const char *ptr) size_t help_line_len(const char *ptr)
{ {
......
...@@ -1268,24 +1268,23 @@ int do_yesno_prompt(bool all, const char *msg) ...@@ -1268,24 +1268,23 @@ int do_yesno_prompt(bool all, const char *msg)
kbinput = get_kbinput(bottomwin, &meta_key, &func_key); kbinput = get_kbinput(bottomwin, &meta_key, &func_key);
if (kbinput == NANO_REFRESH_KEY) { switch (kbinput) {
total_redraw(); case NANO_CANCEL_KEY:
continue; ok = -1;
} else if (kbinput == NANO_CANCEL_KEY) break;
ok = -1;
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
else if (kbinput == KEY_MOUSE) { case KEY_MOUSE:
get_mouseinput(&mouse_x, &mouse_y, FALSE); get_mouseinput(&mouse_x, &mouse_y, FALSE);
if (mouse_x != -1 && mouse_y != -1 && !ISSET(NO_HELP) && if (mouse_x != -1 && mouse_y != -1 && !ISSET(NO_HELP) &&
wenclose(bottomwin, mouse_y, mouse_x) && wenclose(bottomwin, mouse_y, mouse_x) &&
mouse_x < (width * 2) && mouse_y - (2 - mouse_x < (width * 2) && mouse_y - (2 -
no_more_space()) - editwinrows - 1 >= 0) { no_more_space()) - editwinrows - 1 >= 0) {
int x = mouse_x / width; int x = mouse_x / width;
/* Calculate the x-coordinate relative to the /* Calculate the x-coordinate relative to the
* two columns of the Yes/No/All shortcuts in * two columns of the Yes/No/All shortcuts in
* bottomwin. */ * bottomwin. */
int y = mouse_y - (2 - no_more_space()) - int y = mouse_y - (2 - no_more_space()) -
editwinrows - 1; editwinrows - 1;
/* Calculate the y-coordinate relative to the /* Calculate the y-coordinate relative to the
* beginning of the Yes/No/All shortcuts in * beginning of the Yes/No/All shortcuts in
...@@ -1293,25 +1292,30 @@ int do_yesno_prompt(bool all, const char *msg) ...@@ -1293,25 +1292,30 @@ int do_yesno_prompt(bool all, const char *msg)
* edit, and the first line of bottomwin * edit, and the first line of bottomwin
* subtracted out. */ * subtracted out. */
assert(0 <= x && x <= 1 && 0 <= y && y <= 1); assert(0 <= x && x <= 1 && 0 <= y && y <= 1);
/* x == 0 means they clicked Yes or No. y == 0 means /* x == 0 means they clicked Yes or No. y == 0
* Yes or All. */ * means Yes or All. */
ok = -2 * x * y + x - y + 1; ok = -2 * x * y + x - y + 1;
if (ok == 2 && !all) if (ok == 2 && !all)
ok = -2; ok = -2;
} }
break;
#endif /* !DISABLE_MOUSE */
case NANO_REFRESH_KEY:
total_redraw();
continue;
default:
/* Look for the kbinput in the Yes, No and (optionally)
* All strings. */
if (strchr(yesstr, kbinput) != NULL)
ok = 1;
else if (strchr(nostr, kbinput) != NULL)
ok = 0;
else if (all && strchr(allstr, kbinput) != NULL)
ok = 2;
} }
#endif
/* Look for the kbinput in the Yes, No and (optionally) All
* strings. */
else if (strchr(yesstr, kbinput) != NULL)
ok = 1;
else if (strchr(nostr, kbinput) != NULL)
ok = 0;
else if (all && strchr(allstr, kbinput) != NULL)
ok = 2;
} while (ok == -2); } while (ok == -2);
return ok; return ok;
......
...@@ -351,6 +351,7 @@ void do_help_void(void); ...@@ -351,6 +351,7 @@ void do_help_void(void);
void do_browser_help(void); void do_browser_help(void);
#endif #endif
void help_init(void); void help_init(void);
void parse_help_input(int *kbinput, bool *meta_key, bool *func_key);
size_t help_line_len(const char *ptr); size_t help_line_len(const char *ptr);
#endif #endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment