aboutsummaryrefslogtreecommitdiffstats
path: root/src/custom.c
diff options
context:
space:
mode:
authorLars Henriksen <LarsHenriksen@get2net.dk>2018-03-26 18:44:08 +0200
committerLukas Fleischer <lfleischer@calcurse.org>2018-06-03 11:26:12 +0200
commit7078556f9d055cb46339d436add2a03cc8abbc71 (patch)
tree49cc66196b08fffa061987fbba6490ebda4c2a1f /src/custom.c
parent431e4a00e7792d3421c7122c32ca5df81505caf3 (diff)
downloadcalcurse-7078556f9d055cb46339d436add2a03cc8abbc71.tar.gz
calcurse-7078556f9d055cb46339d436add2a03cc8abbc71.zip
Key bindings for UTF-8 encoded characters
Internally characters (keys) have two representations: integers and key names. Key names are characters strings, usually the name of the character; e.g., the character A has the representations 65 and "A", and the tab character the representations 9 and "TAB". The function keys_int2str() turns the integer representation of a key/character into the key name. For display purposes the key names are usually confined to have display width at most three. Some curses pseudo-keys have longer key names; e.g., the back-tab character is "KEY_BTAB". A long key name makes a character difficult to recognize in the status bar menu. The key name of a multibyte, UTF-8 encoded character is the conventional Unicode name of the code point; e.g., the character ü has key name "U+00FC" because ü is the code point 0xFC. Most of these look alike in the status bar menu. The patch makes the key name of a multibyte character look like that of a singlebyte character: the character itself, i.e. the key name of the character ü is "ü". The main tool is implementation of a utf8_encode() routine. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/custom.c')
-rw-r--r--src/custom.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/custom.c b/src/custom.c
index 246af1d..9443365 100644
--- a/src/custom.c
+++ b/src/custom.c
@@ -908,7 +908,7 @@ print_keys_bindings(WINDOW * win, int selected_row, int selected_elm,
mvwprintw(win, y, pos,
"%s ", key);
noelm++;
- pos += strlen(key) + 1;
+ pos += utf8_strwidth((char *)key) + 1;
}
} else {
mvwaddstr(win, y, KEYPOS,