Support key bindings for all escape keys

All key names for ordinary ASCII keys as well as for escape keys (pseudo
keys) are cached in a lookup-table, keynames[], at startup. Mapping
between key names (strings) and key codes (integers) in keys_str2int and
keys_int2str) is performed through this table.

The key names used are those returned by the keyname() function of
ncurses. But to accommodate some of the names to the three-letter space
available in the status menu, four ordinary keys and the most common
escape keys have calcurse abbreviated names: ESC, TAB, RET, SPC and LFT,
HOM, PgU, INS, F1, etc.

All keys known by ncurses can be bound. Thus the check for not
recognized keys in the key configuration menu becomes superfluous. The
only keys that cannot be bound, are those escape keys not known to
ncurses, i.e. not described by the terminfo database for the terminal
type in use.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lars Henriksen
2017-10-22 10:01:16 +02:00
committed by Lukas Fleischer
parent dd5af2f7f4
commit 61e577bf8a
2 changed files with 95 additions and 84 deletions

View File

@@ -153,11 +153,12 @@
#define CALHEIGHT 8
/* Key definitions. */
#define CTRLVAL 0x1F
#define CTRL(x) ((x) & CTRLVAL)
#define ESCAPE 27
#define TAB 9
#define SPACE 32
#define CTRLVAL 0x1F
#define CTRL(x) ((x) & CTRLVAL)
#define ESCAPE 27
#define TAB 9
#define RETURN 10
#define SPACE 32
#define KEYS_KEYLEN 3 /* length of each keybinding */
#define KEYS_LABELEN 8 /* length of command description */