summaryrefslogtreecommitdiffstats
path: root/mode-key.c
diff options
context:
space:
mode:
authornicm <nicm>2015-11-12 11:05:34 +0000
committernicm <nicm>2015-11-12 11:05:34 +0000
commit69e0b8326ad0a983759518b90ed8632146341acf (patch)
tree03f69cf9a96b5e87b760243cc535878940bc7a02 /mode-key.c
parent7062b0e65dcbb94bb190f6c50f4089b2ea6278bb (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.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/mode-key.c b/mode-key.c
index 5ed45bd8..a47cda0b 100644
--- a/mode-key.c
+++ b/mode-key.c
@@ -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;