help_init(). (DLR, suggested by Benno Schulenberg)
- Reduce NO_RCFILE to a static bool in nano.c, since it's only
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:
open_file()
- Remove redundant wording in the error message when we try to
- 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
its equivalents. (DLR)
+ - Clean up the handling of NANO_REFRESH_KEY. (DLR)
help_init()
- If we have at least two entries' worth of blank space, use it
to display more of "^Space" and "M-Space". (DLR, suggested by
disabled, so that we aren't erroneously kicked out of the
statusbar prompt under any circumstances. (DLR, found by Benno
Schulenberg)
+ do_yesno()
+ - Handle the keys in a switch statement instead of a long if
+ block, for simplicity. (DLR)
- rcfile.c:
parse_argument()
- Rename variable ptr_bak to ptr_save, for consistency. (DLR)
/* 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 Pico's file
+ * process, convert certain non-shortcut keys used by e.g. Pico's file
* browser into their corresponding shortcut keys. */
void parse_browser_input(int *kbinput, bool *meta_key, bool *func_key)
{
case '?':
*kbinput = NANO_HELP_KEY;
break;
+ /* Cancel is equivalent to Exit here. */
+ case NANO_CANCEL_KEY:
case 'E':
case 'e':
*kbinput = NANO_EXIT_KEY;
if (!no_more)
line++;
break;
+ case NANO_REFRESH_KEY:
+ total_redraw();
+ break;
}
- if (kbinput == NANO_REFRESH_KEY)
- /* Redraw the screen. */
- total_redraw();
- else {
- if (kbinput != ERR && line == old_line)
- goto skip_redisplay;
+ if ((kbinput != ERR && line == old_line) || kbinput ==
+ NANO_REFRESH_KEY)
+ goto skip_redisplay;
- blank_edit();
- }
+ blank_edit();
/* Calculate where in the text we should be, based on the
* page. */
skip_redisplay:
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);
#ifndef DISABLE_MOUSE
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. */
size_t help_line_len(const char *ptr)
{
kbinput = get_kbinput(bottomwin, &meta_key, &func_key);
- if (kbinput == NANO_REFRESH_KEY) {
- total_redraw();
- continue;
- } else if (kbinput == NANO_CANCEL_KEY)
- ok = -1;
+ switch (kbinput) {
+ case NANO_CANCEL_KEY:
+ ok = -1;
+ break;
#ifndef DISABLE_MOUSE
- else if (kbinput == KEY_MOUSE) {
- get_mouseinput(&mouse_x, &mouse_y, FALSE);
-
- if (mouse_x != -1 && mouse_y != -1 && !ISSET(NO_HELP) &&
- wenclose(bottomwin, mouse_y, mouse_x) &&
- mouse_x < (width * 2) && mouse_y - (2 -
- no_more_space()) - editwinrows - 1 >= 0) {
- int x = mouse_x / width;
+ case KEY_MOUSE:
+ get_mouseinput(&mouse_x, &mouse_y, FALSE);
+
+ if (mouse_x != -1 && mouse_y != -1 && !ISSET(NO_HELP) &&
+ wenclose(bottomwin, mouse_y, mouse_x) &&
+ mouse_x < (width * 2) && mouse_y - (2 -
+ no_more_space()) - editwinrows - 1 >= 0) {
+ int x = mouse_x / width;
/* Calculate the x-coordinate relative to the
* two columns of the Yes/No/All shortcuts in
* bottomwin. */
- int y = mouse_y - (2 - no_more_space()) -
+ int y = mouse_y - (2 - no_more_space()) -
editwinrows - 1;
/* Calculate the y-coordinate relative to the
* beginning of the Yes/No/All shortcuts in
* edit, and the first line of bottomwin
* 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
- * Yes or All. */
- ok = -2 * x * y + x - y + 1;
+ /* x == 0 means they clicked Yes or No. y == 0
+ * means Yes or All. */
+ ok = -2 * x * y + x - y + 1;
- if (ok == 2 && !all)
- ok = -2;
- }
+ if (ok == 2 && !all)
+ 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);
return ok;
void do_browser_help(void);
#endif
void help_init(void);
+void parse_help_input(int *kbinput, bool *meta_key, bool *func_key);
size_t help_line_len(const char *ptr);
#endif