input: give more detailed feedback when an unbound key is struck

master
Benno Schulenberg 2016-04-27 14:37:31 +02:00
parent eb871e72f5
commit e0c4f9c5fe
4 changed files with 22 additions and 4 deletions

View File

@ -332,7 +332,8 @@ char *do_browser(char *path, DIR *dir)
} else if (func == do_exit) { } else if (func == do_exit) {
/* Exit from the file browser. */ /* Exit from the file browser. */
break; break;
} } else
unbound_key(kbinput);
} }
titlebar(NULL); titlebar(NULL);
edit_refresh(); edit_refresh();

View File

@ -161,7 +161,8 @@ void do_help(void)
} else if (func == do_exit) { } else if (func == do_exit) {
/* Exit from the help viewer. */ /* Exit from the help viewer. */
break; break;
} } else
unbound_key(kbinput);
} }
if (old_no_help) { if (old_no_help) {

View File

@ -1563,6 +1563,22 @@ void terminal_init(void)
#endif #endif
} }
/* Say that an unbound key was struck, and if possible which one. */
void unbound_key(int code)
{
if (func_key)
statusbar(_("Unbound key"));
else if (meta_key) {
if (0x60 < code && code < 0x7B)
code -= 0x20;
statusbar(_("Unbound key: M-%c"), code);
} else if (code < 0x20)
statusbar(_("Unbound key: ^%c"), code + 0x40);
else
statusbar(_("Unbound key: %c"), code);
beep();
}
/* Read in a character, interpret it as a shortcut or toggle if /* Read in a character, interpret it as a shortcut or toggle if
* necessary, and return it. * necessary, and return it.
* If allow_funcs is FALSE, don't actually run any functions associated * If allow_funcs is FALSE, don't actually run any functions associated
@ -1612,8 +1628,7 @@ int do_input(bool allow_funcs)
* 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 || func_key) {
statusbar(_("Unknown Command")); unbound_key(input);
beep();
meta_key = FALSE; meta_key = FALSE;
func_key = FALSE; func_key = FALSE;
input = ERR; input = ERR;

View File

@ -498,6 +498,7 @@ void enable_signals(void);
void disable_flow_control(void); void disable_flow_control(void);
void enable_flow_control(void); void enable_flow_control(void);
void terminal_init(void); void terminal_init(void);
void unbound_key(int code);
int do_input(bool allow_funcs); int do_input(bool allow_funcs);
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
int do_mouse(void); int do_mouse(void);