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.)
This commit is contained in:
nicm
2015-11-12 11:05:34 +00:00
parent 7062b0e65d
commit 69e0b8326a
19 changed files with 280 additions and 168 deletions

View File

@ -29,11 +29,11 @@ struct screen *window_choose_init(struct window_pane *);
void window_choose_free(struct window_pane *);
void window_choose_resize(struct window_pane *, u_int, u_int);
void window_choose_key(struct window_pane *, struct client *,
struct session *, int, struct mouse_event *);
struct session *, key_code, struct mouse_event *);
void window_choose_default_callback(struct window_choose_data *);
struct window_choose_mode_item *window_choose_get_item(struct window_pane *,
int, struct mouse_event *);
key_code, struct mouse_event *);
void window_choose_fire_callback(
struct window_pane *, struct window_choose_data *);
@ -86,9 +86,9 @@ struct window_choose_mode_data {
void window_choose_free1(struct window_choose_mode_data *);
int window_choose_key_index(struct window_choose_mode_data *, u_int);
int window_choose_index_key(struct window_choose_mode_data *, int);
int window_choose_index_key(struct window_choose_mode_data *, key_code);
void window_choose_prompt_input(enum window_choose_input_type,
const char *, struct window_pane *, int);
const char *, struct window_pane *, key_code);
void window_choose_reset_top(struct window_pane *, u_int);
void
@ -314,7 +314,7 @@ window_choose_fire_callback(
void
window_choose_prompt_input(enum window_choose_input_type input_type,
const char *prompt, struct window_pane *wp, int key)
const char *prompt, struct window_pane *wp, key_code key)
{
struct window_choose_mode_data *data = wp->modedata;
size_t input_len;
@ -490,7 +490,8 @@ window_choose_expand(struct window_pane *wp, struct session *s, u_int pos)
}
struct window_choose_mode_item *
window_choose_get_item(struct window_pane *wp, int key, struct mouse_event *m)
window_choose_get_item(struct window_pane *wp, key_code key,
struct mouse_event *m)
{
struct window_choose_mode_data *data = wp->modedata;
u_int x, y, idx;
@ -509,7 +510,7 @@ window_choose_get_item(struct window_pane *wp, int key, struct mouse_event *m)
void
window_choose_key(struct window_pane *wp, unused struct client *c,
unused struct session *sess, int key, struct mouse_event *m)
unused struct session *sess, key_code key, struct mouse_event *m)
{
struct window_choose_mode_data *data = wp->modedata;
struct screen *s = &data->screen;
@ -743,8 +744,8 @@ window_choose_key(struct window_pane *wp, unused struct client *c,
}
void
window_choose_write_line(
struct window_pane *wp, struct screen_write_ctx *ctx, u_int py)
window_choose_write_line(struct window_pane *wp, struct screen_write_ctx *ctx,
u_int py)
{
struct window_choose_mode_data *data = wp->modedata;
struct window_choose_mode_item *item;
@ -821,7 +822,7 @@ window_choose_key_index(struct window_choose_mode_data *data, u_int idx)
}
int
window_choose_index_key(struct window_choose_mode_data *data, int key)
window_choose_index_key(struct window_choose_mode_data *data, key_code key)
{
static const char keys[] = "0123456789"
"abcdefghijklmnopqrstuvwxyz"
@ -834,7 +835,7 @@ window_choose_index_key(struct window_choose_mode_data *data, int key)
mkey = mode_key_lookup(&data->mdata, *ptr, NULL);
if (mkey != MODEKEY_NONE && mkey != MODEKEY_OTHER)
continue;
if (key == *ptr)
if (key == (key_code)*ptr)
return (idx);
idx++;
}