mirror of
https://github.com/tmux/tmux.git
synced 2025-09-05 08:07:03 +00:00
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:
84
tmux.h
84
tmux.h
@ -95,13 +95,13 @@ struct tmuxproc;
|
||||
#define BELL_OTHER 3
|
||||
|
||||
/* Special key codes. */
|
||||
#define KEYC_NONE 0xfff
|
||||
#define KEYC_BASE 0x1000
|
||||
#define KEYC_NONE 0xffff00000000ULL
|
||||
#define KEYC_BASE 0x100000000000ULL
|
||||
|
||||
/* Key modifier bits. */
|
||||
#define KEYC_ESCAPE 0x2000
|
||||
#define KEYC_CTRL 0x4000
|
||||
#define KEYC_SHIFT 0x8000
|
||||
#define KEYC_ESCAPE 0x200000000000ULL
|
||||
#define KEYC_CTRL 0x400000000000ULL
|
||||
#define KEYC_SHIFT 0x800000000000ULL
|
||||
|
||||
/* Mask to obtain key w/o modifiers. */
|
||||
#define KEYC_MASK_MOD (KEYC_ESCAPE|KEYC_CTRL|KEYC_SHIFT)
|
||||
@ -121,8 +121,14 @@ struct tmuxproc;
|
||||
{ #s "Status", KEYC_ ## name ## _STATUS }, \
|
||||
{ #s "Border", KEYC_ ## name ## _BORDER }
|
||||
|
||||
/*
|
||||
* A single key. This can be ASCII or Unicode or one of the keys starting at
|
||||
* KEYC_BASE.
|
||||
*/
|
||||
typedef uint64_t key_code;
|
||||
|
||||
/* Special key codes. */
|
||||
enum key_code {
|
||||
enum {
|
||||
/* Focus events. */
|
||||
KEYC_FOCUS_IN = KEYC_BASE,
|
||||
KEYC_FOCUS_OUT,
|
||||
@ -570,7 +576,7 @@ struct mode_key_data {
|
||||
|
||||
/* Binding between a key and a command. */
|
||||
struct mode_key_binding {
|
||||
int key;
|
||||
key_code key;
|
||||
|
||||
int mode;
|
||||
enum mode_key_cmd cmd;
|
||||
@ -776,7 +782,7 @@ struct window_mode {
|
||||
void (*free)(struct window_pane *);
|
||||
void (*resize)(struct window_pane *, u_int, u_int);
|
||||
void (*key)(struct window_pane *, struct client *, struct session *,
|
||||
int, struct mouse_event *);
|
||||
key_code, struct mouse_event *);
|
||||
};
|
||||
|
||||
/* Structures for choose mode. */
|
||||
@ -1030,31 +1036,31 @@ RB_HEAD(sessions, session);
|
||||
|
||||
/* Mouse input. */
|
||||
struct mouse_event {
|
||||
int valid;
|
||||
int valid;
|
||||
|
||||
int key;
|
||||
int statusat;
|
||||
key_code key;
|
||||
int statusat;
|
||||
|
||||
u_int x;
|
||||
u_int y;
|
||||
u_int b;
|
||||
u_int x;
|
||||
u_int y;
|
||||
u_int b;
|
||||
|
||||
u_int lx;
|
||||
u_int ly;
|
||||
u_int lb;
|
||||
u_int lx;
|
||||
u_int ly;
|
||||
u_int lb;
|
||||
|
||||
int s;
|
||||
int w;
|
||||
int wp;
|
||||
int s;
|
||||
int w;
|
||||
int wp;
|
||||
|
||||
u_int sgr_type;
|
||||
u_int sgr_b;
|
||||
u_int sgr_type;
|
||||
u_int sgr_b;
|
||||
};
|
||||
|
||||
/* TTY information. */
|
||||
struct tty_key {
|
||||
char ch;
|
||||
int key;
|
||||
key_code key;
|
||||
|
||||
struct tty_key *left;
|
||||
struct tty_key *right;
|
||||
@ -1340,7 +1346,7 @@ struct cmd_entry {
|
||||
|
||||
/* Key binding and key table. */
|
||||
struct key_binding {
|
||||
int key;
|
||||
key_code key;
|
||||
struct cmd_list *cmdlist;
|
||||
int can_repeat;
|
||||
|
||||
@ -1488,7 +1494,8 @@ enum mode_key_cmd mode_key_fromstring(const struct mode_key_cmdstr *,
|
||||
const struct mode_key_table *mode_key_findtable(const char *);
|
||||
void mode_key_init_trees(void);
|
||||
void mode_key_init(struct mode_key_data *, struct mode_key_tree *);
|
||||
enum mode_key_cmd mode_key_lookup(struct mode_key_data *, int, const char **);
|
||||
enum mode_key_cmd mode_key_lookup(struct mode_key_data *, key_code,
|
||||
const char **);
|
||||
|
||||
/* notify.c */
|
||||
void notify_enable(void);
|
||||
@ -1632,9 +1639,9 @@ const char *tty_term_describe(struct tty_term *, enum tty_code_code);
|
||||
const char *tty_acs_get(struct tty *, u_char);
|
||||
|
||||
/* tty-keys.c */
|
||||
void tty_keys_build(struct tty *);
|
||||
void tty_keys_free(struct tty *);
|
||||
int tty_keys_next(struct tty *);
|
||||
void tty_keys_build(struct tty *);
|
||||
void tty_keys_free(struct tty *);
|
||||
key_code tty_keys_next(struct tty *);
|
||||
|
||||
/* arguments.c */
|
||||
int args_cmp(struct args_entry *, struct args_entry *);
|
||||
@ -1720,16 +1727,16 @@ int key_table_cmp(struct key_table *, struct key_table *);
|
||||
int key_bindings_cmp(struct key_binding *, struct key_binding *);
|
||||
struct key_table *key_bindings_get_table(const char *, int);
|
||||
void key_bindings_unref_table(struct key_table *);
|
||||
void key_bindings_add(const char *, int, int, struct cmd_list *);
|
||||
void key_bindings_remove(const char *, int);
|
||||
void key_bindings_add(const char *, key_code, int, struct cmd_list *);
|
||||
void key_bindings_remove(const char *, key_code);
|
||||
void key_bindings_remove_table(const char *);
|
||||
void key_bindings_init(void);
|
||||
void key_bindings_dispatch(struct key_binding *, struct client *,
|
||||
struct mouse_event *);
|
||||
|
||||
/* key-string.c */
|
||||
int key_string_lookup_string(const char *);
|
||||
const char *key_string_lookup_key(int);
|
||||
key_code key_string_lookup_string(const char *);
|
||||
const char *key_string_lookup_key(key_code);
|
||||
|
||||
/* alerts.c */
|
||||
void alerts_reset_all(void);
|
||||
@ -1753,7 +1760,7 @@ void server_add_accept(int);
|
||||
|
||||
/* server-client.c */
|
||||
int server_client_check_nested(struct client *);
|
||||
void server_client_handle_key(struct client *, int);
|
||||
void server_client_handle_key(struct client *, key_code);
|
||||
void server_client_create(int);
|
||||
int server_client_open(struct client *, char **);
|
||||
void server_client_unref(struct client *);
|
||||
@ -1803,7 +1810,7 @@ void status_prompt_set(struct client *, const char *, const char *,
|
||||
int (*)(void *, const char *), void (*)(void *), void *, int);
|
||||
void status_prompt_clear(struct client *);
|
||||
int status_prompt_redraw(struct client *);
|
||||
void status_prompt_key(struct client *, int);
|
||||
void status_prompt_key(struct client *, key_code);
|
||||
void status_prompt_update(struct client *, const char *, const char *);
|
||||
void status_prompt_load_history(void);
|
||||
void status_prompt_save_history(void);
|
||||
@ -1819,11 +1826,11 @@ struct evbuffer *input_pending(struct window_pane *);
|
||||
void input_parse(struct window_pane *);
|
||||
|
||||
/* input-key.c */
|
||||
void input_key(struct window_pane *, int, struct mouse_event *);
|
||||
void input_key(struct window_pane *, key_code, struct mouse_event *);
|
||||
|
||||
/* xterm-keys.c */
|
||||
char *xterm_keys_lookup(int);
|
||||
int xterm_keys_find(const char *, size_t, size_t *, int *);
|
||||
char *xterm_keys_lookup(key_code);
|
||||
int xterm_keys_find(const char *, size_t, size_t *, key_code *);
|
||||
|
||||
/* colour.c */
|
||||
int colour_find_rgb(u_char, u_char, u_char);
|
||||
@ -2020,7 +2027,7 @@ int window_pane_set_mode(
|
||||
struct window_pane *, const struct window_mode *);
|
||||
void window_pane_reset_mode(struct window_pane *);
|
||||
void window_pane_key(struct window_pane *, struct client *,
|
||||
struct session *, int, struct mouse_event *);
|
||||
struct session *, key_code, struct mouse_event *);
|
||||
int window_pane_visible(struct window_pane *);
|
||||
char *window_pane_search(
|
||||
struct window_pane *, const char *, u_int *);
|
||||
@ -2179,6 +2186,7 @@ void utf8_set(struct utf8_data *, u_char);
|
||||
int utf8_open(struct utf8_data *, u_char);
|
||||
int utf8_append(struct utf8_data *, u_char);
|
||||
u_int utf8_combine(const struct utf8_data *);
|
||||
int utf8_split(u_int, struct utf8_data *);
|
||||
u_int utf8_split2(u_int, u_char *);
|
||||
int utf8_strvis(char *, const char *, size_t, int);
|
||||
struct utf8_data *utf8_fromcstr(const char *);
|
||||
|
Reference in New Issue
Block a user