diff options
author | nicm <nicm> | 2015-11-12 11:05:34 +0000 |
---|---|---|
committer | nicm <nicm> | 2015-11-12 11:05:34 +0000 |
commit | 69e0b8326ad0a983759518b90ed8632146341acf (patch) | |
tree | 03f69cf9a96b5e87b760243cc535878940bc7a02 /mode-key.c | |
parent | 7062b0e65dcbb94bb190f6c50f4089b2ea6278bb (diff) |
Support UTF-8 key bindings by expanding the key type from int to
uint64_t and converting UTF-8 to Unicode on input and the reverse on
output. (This allows key bindings, there are still omissions - the
largest being that the various prompts do not accept UTF-8.)
Diffstat (limited to 'mode-key.c')
-rw-r--r-- | mode-key.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -40,7 +40,7 @@ /* Entry in the default mode key tables. */ struct mode_key_entry { - int key; + key_code key; /* * Editing mode for vi: 0 is edit mode, keys not in the table are @@ -523,9 +523,15 @@ RB_GENERATE(mode_key_tree, mode_key_binding, entry, mode_key_cmp); int mode_key_cmp(struct mode_key_binding *mbind1, struct mode_key_binding *mbind2) { - if (mbind1->mode != mbind2->mode) - return (mbind1->mode - mbind2->mode); - return (mbind1->key - mbind2->key); + if (mbind1->mode < mbind2->mode) + return (-1); + if (mbind1->mode > mbind2->mode) + return (1); + if (mbind1->key < mbind2->key) + return (-1); + if (mbind1->key > mbind2->key) + return (1); + return (0); } const char * @@ -588,7 +594,7 @@ mode_key_init(struct mode_key_data *mdata, struct mode_key_tree *mtree) } enum mode_key_cmd -mode_key_lookup(struct mode_key_data *mdata, int key, const char **arg) +mode_key_lookup(struct mode_key_data *mdata, key_code key, const char **arg) { struct mode_key_binding *mbind, mtmp; |