aboutsummaryrefslogtreecommitdiffstats
path: root/src/custom.c
diff options
context:
space:
mode:
authorLars Henriksen <LarsHenriksen@get2net.dk>2017-09-27 21:45:33 +0200
committerLukas Fleischer <lfleischer@calcurse.org>2017-10-23 08:39:11 +0200
commitdd5af2f7f407595ab00c02b705c2696e12dbbe36 (patch)
tree2d125d3ed867e027e554d303b22252943d1ba767 /src/custom.c
parentefd76a0d995292e48f5466fccada4901618f7d97 (diff)
downloadcalcurse-dd5af2f7f407595ab00c02b705c2696e12dbbe36.tar.gz
calcurse-dd5af2f7f407595ab00c02b705c2696e12dbbe36.zip
Updates for UTF-8 key bindings
Code point mapping adjusted for multibyte characters to avoid the ncurses range 0-KEY_MAX. This includes three fixes: 1) test sequence in keys_assign_binding(), 2) reassemble multi-byte character in keys_wgetch(), 3) check for already in use in keys_assign_binding(). Rearrangement of code. The introduction of allocated memory in keys_int2str() has as a consequence that check for recognized ncurses pseudo characters now are in two places: keys_str2int() and custom_keys_config(). The latter was moved from keys_wgetch() to improve user information. More informative warning messages in custom_keys_config(). Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/custom.c')
-rw-r--r--src/custom.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/custom.c b/src/custom.c
index 4d02b4f..b8b3553 100644
--- a/src/custom.c
+++ b/src/custom.c
@@ -998,11 +998,14 @@ void custom_keys_config(void)
keys_get_label(selrow), 0);
ch = keys_wgetch(grabwin);
- /* First check if this key would be recognized by calcurse. */
- if (ch < 0) {
+ /* Check if this is a ncurses pseudo key accepted by calcurse. */
+ if (ch >= KEY_MIN && ch <= KEY_MAX && !(
+ ch == KEY_UP || ch == KEY_DOWN ||
+ ch == KEY_LEFT || ch == KEY_RIGHT ||
+ ch == KEY_HOME || ch == KEY_END)) {
not_recognized = 1;
- WARN_MSG(_("This key is not yet recognized by calcurse, "
- "please choose another one."));
+ WARN_MSG(_("The key '%s' is not accepted by calcurse. "
+ "Choose another one."), keyname(ch));
werase(kwin.inner);
nbrowelm =
print_keys_bindings(kwin.inner,
@@ -1026,9 +1029,12 @@ void custom_keys_config(void)
enum key action;
action = keys_get_action(ch);
- WARN_MSG(_("This key is already in use for %s, "
- "please choose another one."),
+ char *keystr = keys_int2str(ch);
+ WARN_MSG(_("The key '%s' is already used for %s. "
+ "Choose another one."),
+ keystr,
keys_get_label(action));
+ mem_free(keystr);
werase(kwin.inner);
nbrowelm =
print_keys_bindings(kwin.inner,