mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-26 14:51:36 +03:00
tweaks: return quicker from the key parsing routine
This commit is contained in:
parent
b9e83fe9f8
commit
1af1f5c9f4
67
src/winio.c
67
src/winio.c
@ -369,6 +369,9 @@ int parse_kbinput(WINDOW *win)
|
|||||||
keycode, escapes, byte_digits);
|
keycode, escapes, byte_digits);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (keycode == ERR)
|
||||||
|
return ERR;
|
||||||
|
|
||||||
if (keycode == NANO_CONTROL_3) {
|
if (keycode == NANO_CONTROL_3) {
|
||||||
/* Increment the escape counter. */
|
/* Increment the escape counter. */
|
||||||
escapes++;
|
escapes++;
|
||||||
@ -376,7 +379,9 @@ int parse_kbinput(WINDOW *win)
|
|||||||
if (escapes > 3)
|
if (escapes > 3)
|
||||||
escapes = 1;
|
escapes = 1;
|
||||||
solitary = (escapes == 1 && get_key_buffer_len() == 0);
|
solitary = (escapes == 1 && get_key_buffer_len() == 0);
|
||||||
} else if (keycode != ERR) {
|
return ERR;
|
||||||
|
}
|
||||||
|
|
||||||
switch (escapes) {
|
switch (escapes) {
|
||||||
case 0:
|
case 0:
|
||||||
/* One non-escape: normal input mode. */
|
/* One non-escape: normal input mode. */
|
||||||
@ -507,38 +512,35 @@ int parse_kbinput(WINDOW *win)
|
|||||||
parse_escape_sequence(win, keycode));
|
parse_escape_sequence(win, keycode));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (retval != ERR) {
|
if (retval == ERR)
|
||||||
|
return ERR;
|
||||||
|
|
||||||
switch (retval) {
|
switch (retval) {
|
||||||
#ifdef KEY_SLEFT
|
#ifdef KEY_SLEFT
|
||||||
/* Slang doesn't support KEY_SLEFT. */
|
/* Slang doesn't support KEY_SLEFT. */
|
||||||
case KEY_SLEFT:
|
case KEY_SLEFT:
|
||||||
#endif
|
#endif
|
||||||
case KEY_LEFT:
|
case KEY_LEFT:
|
||||||
retval = sc_seq_or(do_left, keycode);
|
return sc_seq_or(do_left, keycode);
|
||||||
break;
|
|
||||||
#ifdef KEY_SRIGHT
|
#ifdef KEY_SRIGHT
|
||||||
/* Slang doesn't support KEY_SRIGHT. */
|
/* Slang doesn't support KEY_SRIGHT. */
|
||||||
case KEY_SRIGHT:
|
case KEY_SRIGHT:
|
||||||
#endif
|
#endif
|
||||||
case KEY_RIGHT:
|
case KEY_RIGHT:
|
||||||
retval = sc_seq_or(do_right, keycode);
|
return sc_seq_or(do_right, keycode);
|
||||||
break;
|
|
||||||
#ifdef KEY_SUP
|
#ifdef KEY_SUP
|
||||||
/* ncurses and Slang don't support KEY_SUP. */
|
/* ncurses and Slang don't support KEY_SUP. */
|
||||||
case KEY_SUP:
|
case KEY_SUP:
|
||||||
#endif
|
#endif
|
||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
retval = sc_seq_or(do_up_void, keycode);
|
return sc_seq_or(do_up_void, keycode);
|
||||||
break;
|
|
||||||
#ifdef KEY_SDOWN
|
#ifdef KEY_SDOWN
|
||||||
/* ncurses and Slang don't support KEY_SDOWN. */
|
/* ncurses and Slang don't support KEY_SDOWN. */
|
||||||
case KEY_SDOWN:
|
case KEY_SDOWN:
|
||||||
#endif
|
#endif
|
||||||
case KEY_DOWN:
|
case KEY_DOWN:
|
||||||
retval = sc_seq_or(do_down_void, keycode);
|
return sc_seq_or(do_down_void, keycode);
|
||||||
break;
|
|
||||||
#ifdef KEY_SHOME
|
#ifdef KEY_SHOME
|
||||||
/* HP-UX 10-11 and Slang don't support KEY_SHOME. */
|
/* HP-UX 10-11 and Slang don't support KEY_SHOME. */
|
||||||
case KEY_SHOME:
|
case KEY_SHOME:
|
||||||
@ -547,8 +549,7 @@ int parse_kbinput(WINDOW *win)
|
|||||||
case KEY_HOME:
|
case KEY_HOME:
|
||||||
#endif
|
#endif
|
||||||
case KEY_A1: /* Home (7) on keypad with NumLock off. */
|
case KEY_A1: /* Home (7) on keypad with NumLock off. */
|
||||||
retval = sc_seq_or(do_home, keycode);
|
return sc_seq_or(do_home, keycode);
|
||||||
break;
|
|
||||||
#ifdef KEY_SEND
|
#ifdef KEY_SEND
|
||||||
/* HP-UX 10-11 and Slang don't support KEY_SEND. */
|
/* HP-UX 10-11 and Slang don't support KEY_SEND. */
|
||||||
case KEY_SEND:
|
case KEY_SEND:
|
||||||
@ -557,38 +558,31 @@ int parse_kbinput(WINDOW *win)
|
|||||||
case KEY_END:
|
case KEY_END:
|
||||||
#endif
|
#endif
|
||||||
case KEY_C1: /* End (1) on keypad with NumLock off. */
|
case KEY_C1: /* End (1) on keypad with NumLock off. */
|
||||||
retval = sc_seq_or(do_end, keycode);
|
return sc_seq_or(do_end, keycode);
|
||||||
break;
|
|
||||||
case KEY_PPAGE:
|
case KEY_PPAGE:
|
||||||
case KEY_A3: /* PageUp (9) on keypad with NumLock off. */
|
case KEY_A3: /* PageUp (9) on keypad with NumLock off. */
|
||||||
retval = sc_seq_or(do_page_up, keycode);
|
return sc_seq_or(do_page_up, keycode);
|
||||||
break;
|
|
||||||
case KEY_NPAGE:
|
case KEY_NPAGE:
|
||||||
case KEY_C3: /* PageDown (3) on keypad with NumLock off. */
|
case KEY_C3: /* PageDown (3) on keypad with NumLock off. */
|
||||||
retval = sc_seq_or(do_page_down, keycode);
|
return sc_seq_or(do_page_down, keycode);
|
||||||
break;
|
|
||||||
|
|
||||||
case KEY_ENTER:
|
case KEY_ENTER:
|
||||||
retval = sc_seq_or(do_enter, keycode);
|
return sc_seq_or(do_enter, keycode);
|
||||||
break;
|
|
||||||
case KEY_BACKSPACE:
|
case KEY_BACKSPACE:
|
||||||
retval = sc_seq_or(do_backspace, keycode);
|
return sc_seq_or(do_backspace, keycode);
|
||||||
break;
|
|
||||||
#ifdef KEY_SDC
|
#ifdef KEY_SDC
|
||||||
/* Slang doesn't support KEY_SDC. */
|
/* Slang doesn't support KEY_SDC. */
|
||||||
case KEY_SDC:
|
case KEY_SDC:
|
||||||
#endif
|
#endif
|
||||||
case NANO_CONTROL_8:
|
case NANO_CONTROL_8:
|
||||||
if (ISSET(REBIND_DELETE))
|
if (ISSET(REBIND_DELETE))
|
||||||
retval = sc_seq_or(do_delete, keycode);
|
return sc_seq_or(do_delete, keycode);
|
||||||
else
|
else
|
||||||
retval = sc_seq_or(do_backspace, keycode);
|
return sc_seq_or(do_backspace, keycode);
|
||||||
break;
|
|
||||||
#ifdef KEY_SIC
|
#ifdef KEY_SIC
|
||||||
/* Slang doesn't support KEY_SIC. */
|
/* Slang doesn't support KEY_SIC. */
|
||||||
case KEY_SIC:
|
case KEY_SIC:
|
||||||
retval = sc_seq_or(do_insertfile_void, keycode);
|
return sc_seq_or(do_insertfile_void, keycode);
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef KEY_SBEG
|
#ifdef KEY_SBEG
|
||||||
/* Slang doesn't support KEY_SBEG. */
|
/* Slang doesn't support KEY_SBEG. */
|
||||||
@ -599,8 +593,7 @@ int parse_kbinput(WINDOW *win)
|
|||||||
case KEY_BEG:
|
case KEY_BEG:
|
||||||
#endif
|
#endif
|
||||||
case KEY_B2: /* Center (5) on keypad with NumLock off. */
|
case KEY_B2: /* Center (5) on keypad with NumLock off. */
|
||||||
retval = ERR;
|
return ERR;
|
||||||
break;
|
|
||||||
#ifdef KEY_CANCEL
|
#ifdef KEY_CANCEL
|
||||||
#ifdef KEY_SCANCEL
|
#ifdef KEY_SCANCEL
|
||||||
/* Slang doesn't support KEY_SCANCEL. */
|
/* Slang doesn't support KEY_SCANCEL. */
|
||||||
@ -608,8 +601,7 @@ int parse_kbinput(WINDOW *win)
|
|||||||
#endif
|
#endif
|
||||||
/* Slang doesn't support KEY_CANCEL. */
|
/* Slang doesn't support KEY_CANCEL. */
|
||||||
case KEY_CANCEL:
|
case KEY_CANCEL:
|
||||||
retval = first_sc_for(currmenu, do_cancel)->keycode;
|
return first_sc_for(currmenu, do_cancel)->keycode;
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef KEY_SUSPEND
|
#ifdef KEY_SUSPEND
|
||||||
#ifdef KEY_SSUSPEND
|
#ifdef KEY_SSUSPEND
|
||||||
@ -618,8 +610,7 @@ int parse_kbinput(WINDOW *win)
|
|||||||
#endif
|
#endif
|
||||||
/* Slang doesn't support KEY_SUSPEND. */
|
/* Slang doesn't support KEY_SUSPEND. */
|
||||||
case KEY_SUSPEND:
|
case KEY_SUSPEND:
|
||||||
retval = sc_seq_or(do_suspend_void, 0);
|
return sc_seq_or(do_suspend_void, 0);
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef PDCURSES
|
#ifdef PDCURSES
|
||||||
case KEY_SHIFT_L:
|
case KEY_SHIFT_L:
|
||||||
@ -628,8 +619,7 @@ int parse_kbinput(WINDOW *win)
|
|||||||
case KEY_CONTROL_R:
|
case KEY_CONTROL_R:
|
||||||
case KEY_ALT_L:
|
case KEY_ALT_L:
|
||||||
case KEY_ALT_R:
|
case KEY_ALT_R:
|
||||||
retval = ERR;
|
return ERR;
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
#if !defined(NANO_TINY) && defined(KEY_RESIZE)
|
#if !defined(NANO_TINY) && defined(KEY_RESIZE)
|
||||||
/* Since we don't change the default SIGWINCH handler when
|
/* Since we don't change the default SIGWINCH handler when
|
||||||
@ -637,13 +627,10 @@ int parse_kbinput(WINDOW *win)
|
|||||||
* Also, Slang and SunOS 5.7-5.9 don't support
|
* Also, Slang and SunOS 5.7-5.9 don't support
|
||||||
* KEY_RESIZE. */
|
* KEY_RESIZE. */
|
||||||
case KEY_RESIZE:
|
case KEY_RESIZE:
|
||||||
retval = ERR;
|
return ERR;
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Return the result. */
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user