tweaks: elide the global variable 'func_key'
There is no need to specially flag a function key or editing key -- the keycode is indication enough in itself: outside of byte range.master
parent
19dfd20a88
commit
cb10b2b908
|
@ -35,8 +35,6 @@ volatile sig_atomic_t sigwinch_counter = 0;
|
||||||
|
|
||||||
bool meta_key;
|
bool meta_key;
|
||||||
/* Whether the current keystroke is a Meta key. */
|
/* Whether the current keystroke is a Meta key. */
|
||||||
bool func_key;
|
|
||||||
/* Whether the current keystroke is an extended keypad value. */
|
|
||||||
bool focusing = TRUE;
|
bool focusing = TRUE;
|
||||||
/* Whether an update of the edit window should center the cursor. */
|
/* Whether an update of the edit window should center the cursor. */
|
||||||
|
|
||||||
|
|
|
@ -1539,7 +1539,7 @@ void terminal_init(void)
|
||||||
/* Say that an unbound key was struck, and if possible which one. */
|
/* Say that an unbound key was struck, and if possible which one. */
|
||||||
void unbound_key(int code)
|
void unbound_key(int code)
|
||||||
{
|
{
|
||||||
if (func_key)
|
if (!is_byte(code))
|
||||||
statusline(ALERT, _("Unbound key"));
|
statusline(ALERT, _("Unbound key"));
|
||||||
else if (meta_key) {
|
else if (meta_key) {
|
||||||
if (code == '[')
|
if (code == '[')
|
||||||
|
@ -1577,7 +1577,7 @@ int do_input(bool allow_funcs)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DISABLE_MOUSE
|
#ifndef DISABLE_MOUSE
|
||||||
if (func_key && input == KEY_MOUSE) {
|
if (input == KEY_MOUSE) {
|
||||||
/* We received a mouse click. */
|
/* We received a mouse click. */
|
||||||
if (do_mouse() == 1)
|
if (do_mouse() == 1)
|
||||||
/* The click was on a shortcut -- read in the character
|
/* The click was on a shortcut -- read in the character
|
||||||
|
@ -1599,10 +1599,9 @@ int do_input(bool allow_funcs)
|
||||||
/* If we got a non-high-bit control key, a meta key sequence, or a
|
/* If we got a non-high-bit control key, a meta key sequence, or a
|
||||||
* function key, and it's not a shortcut or toggle, throw it out. */
|
* function key, and it's not a shortcut or toggle, throw it out. */
|
||||||
if (!have_shortcut) {
|
if (!have_shortcut) {
|
||||||
if (is_ascii_cntrl_char(input) || meta_key || func_key) {
|
if (is_ascii_cntrl_char(input) || meta_key || !is_byte(input)) {
|
||||||
unbound_key(input);
|
unbound_key(input);
|
||||||
meta_key = FALSE;
|
meta_key = FALSE;
|
||||||
func_key = FALSE;
|
|
||||||
input = ERR;
|
input = ERR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,12 +66,11 @@ int do_statusbar_input(bool *ran_func, bool *finished,
|
||||||
#ifndef DISABLE_MOUSE
|
#ifndef DISABLE_MOUSE
|
||||||
/* If we got a mouse click and it was on a shortcut, read in the
|
/* If we got a mouse click and it was on a shortcut, read in the
|
||||||
* shortcut character. */
|
* shortcut character. */
|
||||||
if (func_key && input == KEY_MOUSE) {
|
if (input == KEY_MOUSE) {
|
||||||
if (do_statusbar_mouse() == 1)
|
if (do_statusbar_mouse() == 1)
|
||||||
input = get_kbinput(bottomwin);
|
input = get_kbinput(bottomwin);
|
||||||
else {
|
else {
|
||||||
meta_key = FALSE;
|
meta_key = FALSE;
|
||||||
func_key = FALSE;
|
|
||||||
input = ERR;
|
input = ERR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,10 +86,9 @@ int do_statusbar_input(bool *ran_func, bool *finished,
|
||||||
/* If we got a non-high-bit control key, a meta key sequence, or a
|
/* If we got a non-high-bit control key, a meta key sequence, or a
|
||||||
* function key, and it's not a shortcut or toggle, throw it out. */
|
* function key, and it's not a shortcut or toggle, throw it out. */
|
||||||
if (!have_shortcut) {
|
if (!have_shortcut) {
|
||||||
if (is_ascii_cntrl_char(input) || meta_key || func_key) {
|
if (is_ascii_cntrl_char(input) || meta_key || !is_byte(input)) {
|
||||||
beep();
|
beep();
|
||||||
meta_key = FALSE;
|
meta_key = FALSE;
|
||||||
func_key = FALSE;
|
|
||||||
input = ERR;
|
input = ERR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ extern volatile sig_atomic_t sigwinch_counter;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern bool meta_key;
|
extern bool meta_key;
|
||||||
extern bool func_key;
|
|
||||||
extern bool focusing;
|
extern bool focusing;
|
||||||
|
|
||||||
extern message_type lastmessage;
|
extern message_type lastmessage;
|
||||||
|
|
12
src/winio.c
12
src/winio.c
|
@ -324,8 +324,7 @@ int get_kbinput(WINDOW *win)
|
||||||
|
|
||||||
/* Extract a single keystroke from the input stream. Translate escape
|
/* Extract a single keystroke from the input stream. Translate escape
|
||||||
* sequences and extended keypad codes into their corresponding values.
|
* sequences and extended keypad codes into their corresponding values.
|
||||||
* Set meta_key to TRUE when we get a meta key sequence, and set func_key
|
* Set meta_key to TRUE when appropriate. Supported extended keypad values
|
||||||
* to TRUE when we get a function key. Supported extended keypad values
|
|
||||||
* are: [arrow key], Ctrl-[arrow key], Shift-[arrow key], Enter, Backspace,
|
* are: [arrow key], Ctrl-[arrow key], Shift-[arrow key], Enter, Backspace,
|
||||||
* the editing keypad (Insert, Delete, Home, End, PageUp, and PageDown),
|
* the editing keypad (Insert, Delete, Home, End, PageUp, and PageDown),
|
||||||
* the function keys (F1-F16), and the numeric keypad with NumLock off. */
|
* the function keys (F1-F16), and the numeric keypad with NumLock off. */
|
||||||
|
@ -336,7 +335,6 @@ int parse_kbinput(WINDOW *win)
|
||||||
int *kbinput, keycode, retval = ERR;
|
int *kbinput, keycode, retval = ERR;
|
||||||
|
|
||||||
meta_key = FALSE;
|
meta_key = FALSE;
|
||||||
func_key = FALSE;
|
|
||||||
|
|
||||||
/* Read in a character. */
|
/* Read in a character. */
|
||||||
kbinput = get_input(win, 1);
|
kbinput = get_input(win, 1);
|
||||||
|
@ -633,15 +631,11 @@ int parse_kbinput(WINDOW *win)
|
||||||
else if (retval == controldown)
|
else if (retval == controldown)
|
||||||
retval = sc_seq_or(do_next_block, 0);
|
retval = sc_seq_or(do_next_block, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If our result is an extended keypad value (i.e. a value
|
|
||||||
* outside of byte range), set func_key to TRUE. */
|
|
||||||
if (retval != ERR)
|
|
||||||
func_key = !is_byte(retval);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "parse_kbinput(): kbinput = %d, meta_key = %s, func_key = %s, escapes = %d, byte_digits = %d, retval = %d\n", keycode, meta_key ? "TRUE" : "FALSE", func_key ? "TRUE" : "FALSE", escapes, byte_digits, retval);
|
fprintf(stderr, "parse_kbinput(): kbinput = %d, meta_key = %s, escapes = %d, byte_digits = %d, retval = %d\n",
|
||||||
|
keycode, meta_key ? "TRUE" : "FALSE", escapes, byte_digits, retval);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Return the result. */
|
/* Return the result. */
|
||||||
|
|
Loading…
Reference in New Issue