From 305d889e9d3305e6f2527706f8763934e2fc5981 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Wed, 24 May 2006 19:48:03 +0000 Subject: [PATCH] more cleanly ignore unhandled meta key sequences and escape sequences; to get this to work properly, add a shortcut for moving to the next search/replace string git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3559 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 6 ++++-- src/global.c | 43 +++++++++++++++++++++++++++++++------------ src/help.c | 6 +++--- src/nano.c | 11 ++++------- src/prompt.c | 28 +++++++++++++++++----------- src/winio.c | 4 ++-- 6 files changed, 61 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6baaccfc..641f04b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -99,8 +99,10 @@ CVS code - do_delete(). (DLR) - Ignore unhandled meta key sequences and escape sequences, and indicate it on the statusbar when we get an unhandled shortcut - or toggle, as Pico does. New function is_ascii_cntrl_char(); - changes to do_input(), do_statusbar_input(), and + or toggle, as Pico does. To get this to work properly, add a + shortcut for moving to the next search/replace string. New + function is_ascii_cntrl_char(); changes to shortcut_init(), + do_input(), do_statusbar_input(), get_prompt_string(), and parse_kbinput(). (DLR, suggested by Nick Warne and Benno Schulenberg) - browser.c: diff --git a/src/global.c b/src/global.c index 6e4c9c32..b3ffb3f5 100644 --- a/src/global.c +++ b/src/global.c @@ -298,8 +298,9 @@ void shortcut_init(bool unjustify) const char *regexp_msg = N_("Regexp"); #endif #ifndef NANO_TINY + const char *prev_history_msg = N_("PrevHstory"); /* TRANSLATORS: Try to keep this and previous strings at most 10 characters. */ - const char *history_msg = N_("History"); + const char *next_history_msg = N_("NextHstory"); #ifdef ENABLE_MULTIBUFFER /* TRANSLATORS: Try to keep this at most 16 characters. */ const char *new_buffer_msg = N_("New Buffer"); @@ -419,8 +420,10 @@ void shortcut_init(bool unjustify) const char *nano_regexp_msg = N_("Use regular expressions"); #endif #ifndef NANO_TINY - const char *nano_history_msg = - N_("Edit the previous search/replace strings"); + const char *nano_prev_history_msg = + N_("Edit the previous search/replace string"); + const char *nano_next_history_msg = + N_("Edit the next search/replace string"); #endif #ifndef DISABLE_BROWSER const char *nano_tofiles_msg = N_("Go to file browser"); @@ -779,8 +782,12 @@ void shortcut_init(bool unjustify) #endif #ifndef NANO_TINY - sc_init_one(&whereis_list, NANO_PREVLINE_KEY, history_msg, - IFHELP(nano_history_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY, + sc_init_one(&whereis_list, NANO_PREVLINE_KEY, prev_history_msg, + IFHELP(nano_prev_history_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY, + NANO_NO_KEY, VIEW, NULL); + + sc_init_one(&whereis_list, NANO_NEXTLINE_KEY, next_history_msg, + IFHELP(nano_next_history_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY, NANO_NO_KEY, VIEW, NULL); sc_init_one(&whereis_list, NANO_CUTTILLEND_KEY, cut_till_end_msg, @@ -819,7 +826,7 @@ void shortcut_init(bool unjustify) IFHELP(nano_lastline_msg, FALSE), NANO_LASTLINE_ALTKEY, NANO_LASTLINE_FKEY, NANO_LASTLINE_ALTKEY2, VIEW, do_last_line); - /* TRANSLATORS: Try to keep this at most 12 characters. */ + /* TRANSLATORS: Try to keep this at most 10 characters. */ sc_init_one(&replace_list, NANO_TOOTHERSEARCH_KEY, N_("No Replace"), IFHELP(nano_whereis_msg, FALSE), NANO_NO_KEY, NANO_REPLACE_FKEY, NANO_NO_KEY, VIEW, NULL); @@ -845,8 +852,12 @@ void shortcut_init(bool unjustify) #endif #ifndef NANO_TINY - sc_init_one(&replace_list, NANO_PREVLINE_KEY, history_msg, - IFHELP(nano_history_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY, + sc_init_one(&replace_list, NANO_PREVLINE_KEY, prev_history_msg, + IFHELP(nano_prev_history_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY, + NANO_NO_KEY, VIEW, NULL); + + sc_init_one(&replace_list, NANO_NEXTLINE_KEY, next_history_msg, + IFHELP(nano_next_history_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY, NANO_NO_KEY, VIEW, NULL); #endif @@ -876,8 +887,12 @@ void shortcut_init(bool unjustify) NANO_LASTLINE_FKEY, NANO_LASTLINE_ALTKEY2, VIEW, do_last_line); #ifndef NANO_TINY - sc_init_one(&replace_list_2, NANO_PREVLINE_KEY, history_msg, - IFHELP(nano_history_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY, + sc_init_one(&replace_list_2, NANO_PREVLINE_KEY, prev_history_msg, + IFHELP(nano_prev_history_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY, + NANO_NO_KEY, VIEW, NULL); + + sc_init_one(&replace_list_2, NANO_NEXTLINE_KEY, next_history_msg, + IFHELP(nano_next_history_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY, NANO_NO_KEY, VIEW, NULL); #endif @@ -1188,8 +1203,12 @@ void shortcut_init(bool unjustify) #endif #ifndef NANO_SMALL - sc_init_one(&whereis_file_list, NANO_PREVLINE_KEY, history_msg, - IFHELP(nano_history_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY, + sc_init_one(&whereis_file_list, NANO_PREVLINE_KEY, prev_history_msg, + IFHELP(nano_prev_history_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY, + NANO_NO_KEY, VIEW, NULL); + + sc_init_one(&whereis_file_list, NANO_NEXTLINE_KEY, next_history_msg, + IFHELP(nano_next_history_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY, NANO_NO_KEY, VIEW, NULL); #endif diff --git a/src/help.c b/src/help.c index 611045b2..62aa66f6 100644 --- a/src/help.c +++ b/src/help.c @@ -32,7 +32,7 @@ static char *help_text = NULL; /* The text displayed in the help window. */ -/* Our dynamic, shortcut-list-compliant help function. refresh_func is +/* Our dynamic, shortcut list-compliant help function. refresh_func is * the function we will call to refresh the edit window.*/ void do_help(void (*refresh_func)(void)) { @@ -423,8 +423,8 @@ void help_init(void) /* Now add our shortcut info. Assume that each shortcut has, at the * very least, an equivalent control key, an equivalent primary meta * key sequence, or both. Also assume that the meta key values are - * not control characters. We can display a maximum of 3 shortcut - * entries. */ + * not control characters. We can display a maximum of three + * shortcut entries. */ for (s = currshortcut; s != NULL; s = s->next) { int entries = 0; diff --git a/src/nano.c b/src/nano.c index ece0195a..c4dd9377 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1298,16 +1298,13 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool ); /* If we got a non-high-bit control key or a meta key sequence, and - * it's not a shortcut or toggle, ignore it. If it's a meta key - * sequence, throw it out completely, so that we don't end up - * inserting its second character as though it were typed. */ + * it's not a shortcut or toggle, throw it out. */ if (*s_or_t == FALSE) { if (is_ascii_cntrl_char(input) || *meta_key == TRUE) { - if (*meta_key == TRUE) { - *meta_key = FALSE; - input = ERR; - } statusbar(_("Unknown Command")); + if (*meta_key == TRUE) + *meta_key = FALSE; + input = ERR; } } diff --git a/src/prompt.c b/src/prompt.c index 0fdac602..5f5430c7 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -82,11 +82,11 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t, /* If we got a shortcut from the current list, or a "universal" * statusbar prompt shortcut, set have_shortcut to TRUE. */ - have_shortcut = (s != NULL || input == NANO_REFRESH_KEY || input == - NANO_HOME_KEY || input == NANO_END_KEY || input == - NANO_BACK_KEY || input == NANO_FORWARD_KEY || input == - NANO_BACKSPACE_KEY || input == NANO_DELETE_KEY || input == - NANO_CUT_KEY || + have_shortcut = (s != NULL || input == NANO_ENTER_KEY || input == + NANO_REFRESH_KEY || input == NANO_HOME_KEY || input == + NANO_END_KEY || input == NANO_BACK_KEY || input == + NANO_FORWARD_KEY || input == NANO_BACKSPACE_KEY || input == + NANO_DELETE_KEY || input == NANO_CUT_KEY || #ifndef NANO_TINY input == NANO_NEXTWORD_KEY || #endif @@ -100,15 +100,12 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t, *s_or_t = have_shortcut; /* If we got a non-high-bit control key or a meta key sequence, and - * it's not a shortcut or toggle, ignore it. If it's a meta key - * sequence, throw it out completely, so that we don't end up - * inserting its second character as though it were typed. */ + * it's not a shortcut or toggle, throw it out. */ if (*s_or_t == FALSE) { if (is_ascii_cntrl_char(input) || *meta_key == TRUE) { - if (*meta_key == TRUE) { + if (*meta_key == TRUE) *meta_key = FALSE; - input = ERR; - } + input = ERR; } } @@ -161,6 +158,8 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t, if (have_shortcut) { switch (input) { /* Handle the "universal" statusbar prompt shortcuts. */ + case NANO_ENTER_KEY: + break; case NANO_REFRESH_KEY: total_statusbar_refresh(refresh_func); break; @@ -1062,6 +1061,13 @@ int get_prompt_string(bool allow_tabs, } update_statusbar_line(answer, statusbar_x); + + /* This key has a shortcut list entry when it's used + * to move to an older search, which means that + * finished has been set to TRUE. Set it back to + * FALSE here, so that we aren't kicked out of the + * statusbar prompt. */ + finished = FALSE; } break; #endif /* !NANO_TINY */ diff --git a/src/winio.c b/src/winio.c index 6f3360ef..36b96812 100644 --- a/src/winio.c +++ b/src/winio.c @@ -536,8 +536,8 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key) &ignore_seq); /* If the escape sequence is unrecognized and - * not ignored, throw it out completely and - * indicate this on the statusbar. */ + * not ignored, throw it out, and indicate this + * on the statusbar. */ if (retval == ERR && !ignore_seq) statusbar(_("Unknown Command")); -- 2.39.5