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-d3aeb78583b8master
parent
8aa9ac3657
commit
305d889e9d
|
@ -99,8 +99,10 @@ CVS code -
|
||||||
do_delete(). (DLR)
|
do_delete(). (DLR)
|
||||||
- Ignore unhandled meta key sequences and escape sequences, and
|
- Ignore unhandled meta key sequences and escape sequences, and
|
||||||
indicate it on the statusbar when we get an unhandled shortcut
|
indicate it on the statusbar when we get an unhandled shortcut
|
||||||
or toggle, as Pico does. New function is_ascii_cntrl_char();
|
or toggle, as Pico does. To get this to work properly, add a
|
||||||
changes to do_input(), do_statusbar_input(), and
|
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
|
parse_kbinput(). (DLR, suggested by Nick Warne and Benno
|
||||||
Schulenberg)
|
Schulenberg)
|
||||||
- browser.c:
|
- browser.c:
|
||||||
|
|
43
src/global.c
43
src/global.c
|
@ -298,8 +298,9 @@ void shortcut_init(bool unjustify)
|
||||||
const char *regexp_msg = N_("Regexp");
|
const char *regexp_msg = N_("Regexp");
|
||||||
#endif
|
#endif
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
|
const char *prev_history_msg = N_("PrevHstory");
|
||||||
/* TRANSLATORS: Try to keep this and previous strings at most 10 characters. */
|
/* 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
|
#ifdef ENABLE_MULTIBUFFER
|
||||||
/* TRANSLATORS: Try to keep this at most 16 characters. */
|
/* TRANSLATORS: Try to keep this at most 16 characters. */
|
||||||
const char *new_buffer_msg = N_("New Buffer");
|
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");
|
const char *nano_regexp_msg = N_("Use regular expressions");
|
||||||
#endif
|
#endif
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
const char *nano_history_msg =
|
const char *nano_prev_history_msg =
|
||||||
N_("Edit the previous search/replace strings");
|
N_("Edit the previous search/replace string");
|
||||||
|
const char *nano_next_history_msg =
|
||||||
|
N_("Edit the next search/replace string");
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_BROWSER
|
#ifndef DISABLE_BROWSER
|
||||||
const char *nano_tofiles_msg = N_("Go to file browser");
|
const char *nano_tofiles_msg = N_("Go to file browser");
|
||||||
|
@ -779,8 +782,12 @@ void shortcut_init(bool unjustify)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
sc_init_one(&whereis_list, NANO_PREVLINE_KEY, history_msg,
|
sc_init_one(&whereis_list, NANO_PREVLINE_KEY, prev_history_msg,
|
||||||
IFHELP(nano_history_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
|
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);
|
NANO_NO_KEY, VIEW, NULL);
|
||||||
|
|
||||||
sc_init_one(&whereis_list, NANO_CUTTILLEND_KEY, cut_till_end_msg,
|
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,
|
IFHELP(nano_lastline_msg, FALSE), NANO_LASTLINE_ALTKEY,
|
||||||
NANO_LASTLINE_FKEY, NANO_LASTLINE_ALTKEY2, VIEW, do_last_line);
|
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"),
|
sc_init_one(&replace_list, NANO_TOOTHERSEARCH_KEY, N_("No Replace"),
|
||||||
IFHELP(nano_whereis_msg, FALSE), NANO_NO_KEY, NANO_REPLACE_FKEY,
|
IFHELP(nano_whereis_msg, FALSE), NANO_NO_KEY, NANO_REPLACE_FKEY,
|
||||||
NANO_NO_KEY, VIEW, NULL);
|
NANO_NO_KEY, VIEW, NULL);
|
||||||
|
@ -845,8 +852,12 @@ void shortcut_init(bool unjustify)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
sc_init_one(&replace_list, NANO_PREVLINE_KEY, history_msg,
|
sc_init_one(&replace_list, NANO_PREVLINE_KEY, prev_history_msg,
|
||||||
IFHELP(nano_history_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
|
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);
|
NANO_NO_KEY, VIEW, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -876,8 +887,12 @@ void shortcut_init(bool unjustify)
|
||||||
NANO_LASTLINE_FKEY, NANO_LASTLINE_ALTKEY2, VIEW, do_last_line);
|
NANO_LASTLINE_FKEY, NANO_LASTLINE_ALTKEY2, VIEW, do_last_line);
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
sc_init_one(&replace_list_2, NANO_PREVLINE_KEY, history_msg,
|
sc_init_one(&replace_list_2, NANO_PREVLINE_KEY, prev_history_msg,
|
||||||
IFHELP(nano_history_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
|
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);
|
NANO_NO_KEY, VIEW, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1188,8 +1203,12 @@ void shortcut_init(bool unjustify)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
sc_init_one(&whereis_file_list, NANO_PREVLINE_KEY, history_msg,
|
sc_init_one(&whereis_file_list, NANO_PREVLINE_KEY, prev_history_msg,
|
||||||
IFHELP(nano_history_msg, FALSE), NANO_NO_KEY, NANO_NO_KEY,
|
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);
|
NANO_NO_KEY, VIEW, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
static char *help_text = NULL;
|
static char *help_text = NULL;
|
||||||
/* The text displayed in the help window. */
|
/* 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.*/
|
* the function we will call to refresh the edit window.*/
|
||||||
void do_help(void (*refresh_func)(void))
|
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
|
/* Now add our shortcut info. Assume that each shortcut has, at the
|
||||||
* very least, an equivalent control key, an equivalent primary meta
|
* very least, an equivalent control key, an equivalent primary meta
|
||||||
* key sequence, or both. Also assume that the meta key values are
|
* key sequence, or both. Also assume that the meta key values are
|
||||||
* not control characters. We can display a maximum of 3 shortcut
|
* not control characters. We can display a maximum of three
|
||||||
* entries. */
|
* shortcut entries. */
|
||||||
for (s = currshortcut; s != NULL; s = s->next) {
|
for (s = currshortcut; s != NULL; s = s->next) {
|
||||||
int entries = 0;
|
int entries = 0;
|
||||||
|
|
||||||
|
|
11
src/nano.c
11
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
|
/* 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
|
* it's not a shortcut or toggle, throw it out. */
|
||||||
* sequence, throw it out completely, so that we don't end up
|
|
||||||
* inserting its second character as though it were typed. */
|
|
||||||
if (*s_or_t == FALSE) {
|
if (*s_or_t == FALSE) {
|
||||||
if (is_ascii_cntrl_char(input) || *meta_key == TRUE) {
|
if (is_ascii_cntrl_char(input) || *meta_key == TRUE) {
|
||||||
if (*meta_key == TRUE) {
|
|
||||||
*meta_key = FALSE;
|
|
||||||
input = ERR;
|
|
||||||
}
|
|
||||||
statusbar(_("Unknown Command"));
|
statusbar(_("Unknown Command"));
|
||||||
|
if (*meta_key == TRUE)
|
||||||
|
*meta_key = FALSE;
|
||||||
|
input = ERR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
28
src/prompt.c
28
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"
|
/* If we got a shortcut from the current list, or a "universal"
|
||||||
* statusbar prompt shortcut, set have_shortcut to TRUE. */
|
* statusbar prompt shortcut, set have_shortcut to TRUE. */
|
||||||
have_shortcut = (s != NULL || input == NANO_REFRESH_KEY || input ==
|
have_shortcut = (s != NULL || input == NANO_ENTER_KEY || input ==
|
||||||
NANO_HOME_KEY || input == NANO_END_KEY || input ==
|
NANO_REFRESH_KEY || input == NANO_HOME_KEY || input ==
|
||||||
NANO_BACK_KEY || input == NANO_FORWARD_KEY || input ==
|
NANO_END_KEY || input == NANO_BACK_KEY || input ==
|
||||||
NANO_BACKSPACE_KEY || input == NANO_DELETE_KEY || input ==
|
NANO_FORWARD_KEY || input == NANO_BACKSPACE_KEY || input ==
|
||||||
NANO_CUT_KEY ||
|
NANO_DELETE_KEY || input == NANO_CUT_KEY ||
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
input == NANO_NEXTWORD_KEY ||
|
input == NANO_NEXTWORD_KEY ||
|
||||||
#endif
|
#endif
|
||||||
|
@ -100,15 +100,12 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
|
||||||
*s_or_t = have_shortcut;
|
*s_or_t = have_shortcut;
|
||||||
|
|
||||||
/* If we got a non-high-bit control key or a meta key sequence, and
|
/* 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
|
* it's not a shortcut or toggle, throw it out. */
|
||||||
* sequence, throw it out completely, so that we don't end up
|
|
||||||
* inserting its second character as though it were typed. */
|
|
||||||
if (*s_or_t == FALSE) {
|
if (*s_or_t == FALSE) {
|
||||||
if (is_ascii_cntrl_char(input) || *meta_key == TRUE) {
|
if (is_ascii_cntrl_char(input) || *meta_key == TRUE) {
|
||||||
if (*meta_key == TRUE) {
|
if (*meta_key == TRUE)
|
||||||
*meta_key = FALSE;
|
*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) {
|
if (have_shortcut) {
|
||||||
switch (input) {
|
switch (input) {
|
||||||
/* Handle the "universal" statusbar prompt shortcuts. */
|
/* Handle the "universal" statusbar prompt shortcuts. */
|
||||||
|
case NANO_ENTER_KEY:
|
||||||
|
break;
|
||||||
case NANO_REFRESH_KEY:
|
case NANO_REFRESH_KEY:
|
||||||
total_statusbar_refresh(refresh_func);
|
total_statusbar_refresh(refresh_func);
|
||||||
break;
|
break;
|
||||||
|
@ -1062,6 +1061,13 @@ int get_prompt_string(bool allow_tabs,
|
||||||
}
|
}
|
||||||
|
|
||||||
update_statusbar_line(answer, statusbar_x);
|
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;
|
break;
|
||||||
#endif /* !NANO_TINY */
|
#endif /* !NANO_TINY */
|
||||||
|
|
|
@ -536,8 +536,8 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||||
&ignore_seq);
|
&ignore_seq);
|
||||||
|
|
||||||
/* If the escape sequence is unrecognized and
|
/* If the escape sequence is unrecognized and
|
||||||
* not ignored, throw it out completely and
|
* not ignored, throw it out, and indicate this
|
||||||
* indicate this on the statusbar. */
|
* on the statusbar. */
|
||||||
if (retval == ERR && !ignore_seq)
|
if (retval == ERR && !ignore_seq)
|
||||||
statusbar(_("Unknown Command"));
|
statusbar(_("Unknown Command"));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue