[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nano-devel] [PATCH] input: give more detailed feedback when an unbound
From: |
Benno Schulenberg |
Subject: |
[Nano-devel] [PATCH] input: give more detailed feedback when an unbound key is struck |
Date: |
Wed, 27 Apr 2016 14:44:08 +0200 |
---
src/browser.c | 3 ++-
src/help.c | 3 ++-
src/nano.c | 19 +++++++++++++++++--
src/proto.h | 1 +
4 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/src/browser.c b/src/browser.c
index 31972be..7f16166 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -332,7 +332,8 @@ char *do_browser(char *path, DIR *dir)
} else if (func == do_exit) {
/* Exit from the file browser. */
break;
- }
+ } else
+ unbound_key(kbinput);
}
titlebar(NULL);
edit_refresh();
diff --git a/src/help.c b/src/help.c
index 98066c5..28add5e 100644
--- a/src/help.c
+++ b/src/help.c
@@ -161,7 +161,8 @@ void do_help(void)
} else if (func == do_exit) {
/* Exit from the help viewer. */
break;
- }
+ } else
+ unbound_key(kbinput);
}
if (old_no_help) {
diff --git a/src/nano.c b/src/nano.c
index f7ef4a1..4492061 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -1563,6 +1563,22 @@ void terminal_init(void)
#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
* necessary, and return it.
* 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. */
if (!have_shortcut) {
if (is_ascii_cntrl_char(input) || meta_key || func_key) {
- statusbar(_("Unknown Command"));
- beep();
+ unbound_key(input);
meta_key = FALSE;
func_key = FALSE;
input = ERR;
diff --git a/src/proto.h b/src/proto.h
index 6ad900b..db2cea8 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -498,6 +498,7 @@ void enable_signals(void);
void disable_flow_control(void);
void enable_flow_control(void);
void terminal_init(void);
+void unbound_key(int code);
int do_input(bool allow_funcs);
#ifndef DISABLE_MOUSE
int do_mouse(void);
--
2.8.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Nano-devel] [PATCH] input: give more detailed feedback when an unbound key is struck,
Benno Schulenberg <=