mirror of
https://github.com/tmate-io/tmate-ssh-server.git
synced 2020-11-18 19:53:51 -08:00
Merge branch 'obsd-master'
This commit is contained in:
commit
5f483499f3
@ -29,7 +29,8 @@
|
|||||||
|
|
||||||
enum cmd_retval cmd_bind_key_exec(struct cmd *, struct cmd_q *);
|
enum cmd_retval cmd_bind_key_exec(struct cmd *, struct cmd_q *);
|
||||||
|
|
||||||
enum cmd_retval cmd_bind_key_mode_table(struct cmd *, struct cmd_q *, int);
|
enum cmd_retval cmd_bind_key_mode_table(struct cmd *, struct cmd_q *,
|
||||||
|
key_code);
|
||||||
|
|
||||||
const struct cmd_entry cmd_bind_key_entry = {
|
const struct cmd_entry cmd_bind_key_entry = {
|
||||||
"bind-key", "bind",
|
"bind-key", "bind",
|
||||||
@ -45,7 +46,7 @@ cmd_bind_key_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
char *cause;
|
char *cause;
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
int key;
|
key_code key;
|
||||||
const char *tablename;
|
const char *tablename;
|
||||||
|
|
||||||
if (args_has(args, 't')) {
|
if (args_has(args, 't')) {
|
||||||
@ -89,7 +90,7 @@ cmd_bind_key_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum cmd_retval
|
enum cmd_retval
|
||||||
cmd_bind_key_mode_table(struct cmd *self, struct cmd_q *cmdq, int key)
|
cmd_bind_key_mode_table(struct cmd *self, struct cmd_q *cmdq, key_code key)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
const char *tablename;
|
const char *tablename;
|
||||||
|
@ -51,7 +51,6 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
char *action, *action_data;
|
char *action, *action_data;
|
||||||
const char *template;
|
const char *template;
|
||||||
u_int idx;
|
u_int idx;
|
||||||
int utf8flag;
|
|
||||||
|
|
||||||
if ((c = cmd_find_client(cmdq, NULL, 1)) == NULL) {
|
if ((c = cmd_find_client(cmdq, NULL, 1)) == NULL) {
|
||||||
cmdq_error(cmdq, "no client available");
|
cmdq_error(cmdq, "no client available");
|
||||||
@ -63,7 +62,6 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
|
|
||||||
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
|
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
utf8flag = options_get_number(wl->window->options, "utf8");
|
|
||||||
|
|
||||||
if (paste_get_top(NULL) == NULL)
|
if (paste_get_top(NULL) == NULL)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
@ -83,7 +81,7 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
cdata->idx = idx;
|
cdata->idx = idx;
|
||||||
|
|
||||||
cdata->ft_template = xstrdup(template);
|
cdata->ft_template = xstrdup(template);
|
||||||
format_defaults_paste_buffer(cdata->ft, pb, utf8flag);
|
format_defaults_paste_buffer(cdata->ft, pb);
|
||||||
|
|
||||||
xasprintf(&action_data, "%s", paste_buffer_name(pb));
|
xasprintf(&action_data, "%s", paste_buffer_name(pb));
|
||||||
cdata->command = cmd_template_replace(action, action_data, 1);
|
cdata->command = cmd_template_replace(action, action_data, 1);
|
||||||
|
@ -55,7 +55,7 @@ cmd_list_buffers_exec(unused struct cmd *self, struct cmd_q *cmdq)
|
|||||||
pb = NULL;
|
pb = NULL;
|
||||||
while ((pb = paste_walk(pb)) != NULL) {
|
while ((pb = paste_walk(pb)) != NULL) {
|
||||||
ft = format_create();
|
ft = format_create();
|
||||||
format_defaults_paste_buffer(ft, pb, 0);
|
format_defaults_paste_buffer(ft, pb);
|
||||||
|
|
||||||
line = format_expand(ft, template);
|
line = format_expand(ft, template);
|
||||||
cmdq_print(cmdq, "%s", line);
|
cmdq_print(cmdq, "%s", line);
|
||||||
|
@ -57,6 +57,7 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
char tmp[BUFSIZ];
|
char tmp[BUFSIZ];
|
||||||
size_t used;
|
size_t used;
|
||||||
int repeat, width, tablewidth, keywidth;
|
int repeat, width, tablewidth, keywidth;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
if (self->entry == &cmd_list_commands_entry)
|
if (self->entry == &cmd_list_commands_entry)
|
||||||
return (cmd_list_keys_commands(self, cmdq));
|
return (cmd_list_keys_commands(self, cmdq));
|
||||||
@ -83,8 +84,8 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
|
|
||||||
width = strlen(table->name);
|
width = strlen(table->name);
|
||||||
if (width > tablewidth)
|
if (width > tablewidth)
|
||||||
tablewidth =width;
|
tablewidth = width;
|
||||||
width = strlen(key);
|
width = utf8_cstrwidth(key);
|
||||||
if (width > keywidth)
|
if (width > keywidth)
|
||||||
keywidth = width;
|
keywidth = width;
|
||||||
}
|
}
|
||||||
@ -102,8 +103,12 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
r = "-r ";
|
r = "-r ";
|
||||||
else
|
else
|
||||||
r = " ";
|
r = " ";
|
||||||
used = xsnprintf(tmp, sizeof tmp, "%s-T %-*s %-*s ", r,
|
used = xsnprintf(tmp, sizeof tmp, "%s-T %-*s %s", r,
|
||||||
(int)tablewidth, table->name, (int)keywidth, key);
|
(int)tablewidth, table->name, key);
|
||||||
|
for (i = 0; i < keywidth - utf8_cstrwidth(key); i++) {
|
||||||
|
if (strlcat(tmp, " ", sizeof tmp) < sizeof tmp)
|
||||||
|
used++;
|
||||||
|
}
|
||||||
if (used < sizeof tmp) {
|
if (used < sizeof tmp) {
|
||||||
cmd_list_print(bd->cmdlist, tmp + used,
|
cmd_list_print(bd->cmdlist, tmp + used,
|
||||||
(sizeof tmp) - used);
|
(sizeof tmp) - used);
|
||||||
|
@ -133,7 +133,7 @@ void
|
|||||||
cmd_load_buffer_callback(struct client *c, int closed, void *data)
|
cmd_load_buffer_callback(struct client *c, int closed, void *data)
|
||||||
{
|
{
|
||||||
const char *bufname = data;
|
const char *bufname = data;
|
||||||
char *pdata, *cause;
|
char *pdata, *cause, *saved;
|
||||||
size_t psize;
|
size_t psize;
|
||||||
|
|
||||||
if (!closed)
|
if (!closed)
|
||||||
@ -154,6 +154,11 @@ cmd_load_buffer_callback(struct client *c, int closed, void *data)
|
|||||||
|
|
||||||
if (paste_set(pdata, psize, bufname, &cause) != 0) {
|
if (paste_set(pdata, psize, bufname, &cause) != 0) {
|
||||||
/* No context so can't use server_client_msg_error. */
|
/* No context so can't use server_client_msg_error. */
|
||||||
|
if (~c->flags & CLIENT_UTF8) {
|
||||||
|
saved = cause;
|
||||||
|
cause = utf8_sanitize(saved);
|
||||||
|
free(saved);
|
||||||
|
}
|
||||||
evbuffer_add_printf(c->stderr_data, "%s", cause);
|
evbuffer_add_printf(c->stderr_data, "%s", cause);
|
||||||
server_push_stderr(c);
|
server_push_stderr(c);
|
||||||
free(pdata);
|
free(pdata);
|
||||||
|
19
cmd-queue.c
19
cmd-queue.c
@ -69,14 +69,21 @@ cmdq_print(struct cmd_q *cmdq, const char *fmt, ...)
|
|||||||
struct client *c = cmdq->client;
|
struct client *c = cmdq->client;
|
||||||
struct window *w;
|
struct window *w;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
char *tmp, *msg;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
|
||||||
if (c == NULL)
|
if (c == NULL)
|
||||||
/* nothing */;
|
/* nothing */;
|
||||||
else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
|
else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
|
||||||
evbuffer_add_vprintf(c->stdout_data, fmt, ap);
|
if (~c->flags & CLIENT_UTF8) {
|
||||||
|
vasprintf(&tmp, fmt, ap);
|
||||||
|
msg = utf8_sanitize(tmp);
|
||||||
|
free(tmp);
|
||||||
|
evbuffer_add(c->stdout_data, msg, strlen(msg));
|
||||||
|
free(msg);
|
||||||
|
} else
|
||||||
|
evbuffer_add_vprintf(c->stdout_data, fmt, ap);
|
||||||
evbuffer_add(c->stdout_data, "\n", 1);
|
evbuffer_add(c->stdout_data, "\n", 1);
|
||||||
server_push_stdout(c);
|
server_push_stdout(c);
|
||||||
} else {
|
} else {
|
||||||
@ -101,6 +108,7 @@ cmdq_error(struct cmd_q *cmdq, const char *fmt, ...)
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
char *msg;
|
char *msg;
|
||||||
size_t msglen;
|
size_t msglen;
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
msglen = xvasprintf(&msg, fmt, ap);
|
msglen = xvasprintf(&msg, fmt, ap);
|
||||||
@ -109,9 +117,14 @@ cmdq_error(struct cmd_q *cmdq, const char *fmt, ...)
|
|||||||
if (c == NULL)
|
if (c == NULL)
|
||||||
cfg_add_cause("%s:%u: %s", cmd->file, cmd->line, msg);
|
cfg_add_cause("%s:%u: %s", cmd->file, cmd->line, msg);
|
||||||
else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
|
else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) {
|
||||||
|
if (~c->flags & CLIENT_UTF8) {
|
||||||
|
tmp = msg;
|
||||||
|
msg = utf8_sanitize(tmp);
|
||||||
|
free(tmp);
|
||||||
|
msglen = strlen(msg);
|
||||||
|
}
|
||||||
evbuffer_add(c->stderr_data, msg, msglen);
|
evbuffer_add(c->stderr_data, msg, msglen);
|
||||||
evbuffer_add(c->stderr_data, "\n", 1);
|
evbuffer_add(c->stderr_data, "\n", 1);
|
||||||
|
|
||||||
server_push_stderr(c);
|
server_push_stderr(c);
|
||||||
c->retval = 1;
|
c->retval = 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -53,7 +53,8 @@ cmd_send_keys_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
const u_char *str;
|
const u_char *str;
|
||||||
int i, key;
|
int i;
|
||||||
|
key_code key;
|
||||||
|
|
||||||
if (args_has(args, 'M')) {
|
if (args_has(args, 'M')) {
|
||||||
wp = cmd_mouse_pane(m, &s, NULL);
|
wp = cmd_mouse_pane(m, &s, NULL);
|
||||||
|
@ -394,7 +394,7 @@ cmd_set_option_key(unused struct cmd *self, struct cmd_q *cmdq,
|
|||||||
const struct options_table_entry *oe, struct options *oo,
|
const struct options_table_entry *oe, struct options *oo,
|
||||||
const char *value)
|
const char *value)
|
||||||
{
|
{
|
||||||
int key;
|
key_code key;
|
||||||
|
|
||||||
if ((key = key_string_lookup_string(value)) == KEYC_NONE) {
|
if ((key = key_string_lookup_string(value)) == KEYC_NONE) {
|
||||||
cmdq_error(cmdq, "bad key: %s", value);
|
cmdq_error(cmdq, "bad key: %s", value);
|
||||||
|
@ -26,8 +26,9 @@
|
|||||||
* Unbind key from command.
|
* Unbind key from command.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum cmd_retval cmd_unbind_key_exec(struct cmd *, struct cmd_q *);
|
enum cmd_retval cmd_unbind_key_exec(struct cmd *, struct cmd_q *);
|
||||||
enum cmd_retval cmd_unbind_key_mode_table(struct cmd *, struct cmd_q *, int);
|
enum cmd_retval cmd_unbind_key_mode_table(struct cmd *, struct cmd_q *,
|
||||||
|
key_code);
|
||||||
|
|
||||||
const struct cmd_entry cmd_unbind_key_entry = {
|
const struct cmd_entry cmd_unbind_key_entry = {
|
||||||
"unbind-key", "unbind",
|
"unbind-key", "unbind",
|
||||||
@ -41,7 +42,7 @@ enum cmd_retval
|
|||||||
cmd_unbind_key_exec(struct cmd *self, struct cmd_q *cmdq)
|
cmd_unbind_key_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
int key;
|
key_code key;
|
||||||
const char *tablename;
|
const char *tablename;
|
||||||
|
|
||||||
if (!args_has(args, 'a')) {
|
if (!args_has(args, 'a')) {
|
||||||
@ -95,7 +96,7 @@ cmd_unbind_key_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum cmd_retval
|
enum cmd_retval
|
||||||
cmd_unbind_key_mode_table(struct cmd *self, struct cmd_q *cmdq, int key)
|
cmd_unbind_key_mode_table(struct cmd *self, struct cmd_q *cmdq, key_code key)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
const char *tablename;
|
const char *tablename;
|
||||||
|
7
format.c
7
format.c
@ -1156,16 +1156,13 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp)
|
|||||||
!!(wp->base.mode & MODE_MOUSE_STANDARD));
|
!!(wp->base.mode & MODE_MOUSE_STANDARD));
|
||||||
format_add(ft, "mouse_button_flag", "%d",
|
format_add(ft, "mouse_button_flag", "%d",
|
||||||
!!(wp->base.mode & MODE_MOUSE_BUTTON));
|
!!(wp->base.mode & MODE_MOUSE_BUTTON));
|
||||||
format_add(ft, "mouse_utf8_flag", "%d",
|
|
||||||
!!(wp->base.mode & MODE_MOUSE_UTF8));
|
|
||||||
|
|
||||||
format_add_cb(ft, "pane_tabs", format_cb_pane_tabs);
|
format_add_cb(ft, "pane_tabs", format_cb_pane_tabs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set default format keys for paste buffer. */
|
/* Set default format keys for paste buffer. */
|
||||||
void
|
void
|
||||||
format_defaults_paste_buffer(struct format_tree *ft, struct paste_buffer *pb,
|
format_defaults_paste_buffer(struct format_tree *ft, struct paste_buffer *pb)
|
||||||
int utf8flag)
|
|
||||||
{
|
{
|
||||||
size_t bufsize;
|
size_t bufsize;
|
||||||
char *s;
|
char *s;
|
||||||
@ -1174,7 +1171,7 @@ format_defaults_paste_buffer(struct format_tree *ft, struct paste_buffer *pb,
|
|||||||
format_add(ft, "buffer_size", "%zu", bufsize);
|
format_add(ft, "buffer_size", "%zu", bufsize);
|
||||||
format_add(ft, "buffer_name", "%s", paste_buffer_name(pb));
|
format_add(ft, "buffer_name", "%s", paste_buffer_name(pb));
|
||||||
|
|
||||||
s = paste_make_sample(pb, utf8flag);
|
s = paste_make_sample(pb);
|
||||||
format_add(ft, "buffer_sample", "%s", s);
|
format_add(ft, "buffer_sample", "%s", s);
|
||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
|
38
input-keys.c
38
input-keys.c
@ -33,7 +33,7 @@
|
|||||||
void input_key_mouse(struct window_pane *, struct mouse_event *);
|
void input_key_mouse(struct window_pane *, struct mouse_event *);
|
||||||
|
|
||||||
struct input_key_ent {
|
struct input_key_ent {
|
||||||
int key;
|
key_code key;
|
||||||
const char *data;
|
const char *data;
|
||||||
|
|
||||||
int flags;
|
int flags;
|
||||||
@ -136,15 +136,16 @@ const struct input_key_ent input_keys[] = {
|
|||||||
|
|
||||||
/* Translate a key code into an output key sequence. */
|
/* Translate a key code into an output key sequence. */
|
||||||
void
|
void
|
||||||
input_key(struct window_pane *wp, int key, struct mouse_event *m)
|
input_key(struct window_pane *wp, key_code key, struct mouse_event *m)
|
||||||
{
|
{
|
||||||
const struct input_key_ent *ike;
|
const struct input_key_ent *ike;
|
||||||
u_int i;
|
u_int i;
|
||||||
size_t dlen;
|
size_t dlen;
|
||||||
char *out;
|
char *out;
|
||||||
u_char ch;
|
key_code justkey;
|
||||||
|
struct utf8_data utf8data;
|
||||||
|
|
||||||
log_debug("writing key 0x%x (%s) to %%%u", key,
|
log_debug("writing key 0x%llx (%s) to %%%u", key,
|
||||||
key_string_lookup_key(key), wp->id);
|
key_string_lookup_key(key), wp->id);
|
||||||
|
|
||||||
/* If this is a mouse key, pass off to mouse function. */
|
/* If this is a mouse key, pass off to mouse function. */
|
||||||
@ -156,13 +157,22 @@ input_key(struct window_pane *wp, int key, struct mouse_event *m)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* If this is a normal 7-bit key, just send it, with a leading escape
|
* If this is a normal 7-bit key, just send it, with a leading escape
|
||||||
* if necessary.
|
* if necessary. If it is a UTF-8 key, split it and send it.
|
||||||
*/
|
*/
|
||||||
if (key != KEYC_NONE && (key & ~KEYC_ESCAPE) < 0x100) {
|
justkey = (key & ~KEYC_ESCAPE);
|
||||||
|
if (key != KEYC_NONE && justkey < 0x7f) {
|
||||||
if (key & KEYC_ESCAPE)
|
if (key & KEYC_ESCAPE)
|
||||||
bufferevent_write(wp->event, "\033", 1);
|
bufferevent_write(wp->event, "\033", 1);
|
||||||
ch = key & ~KEYC_ESCAPE;
|
utf8data.data[0] = justkey;
|
||||||
bufferevent_write(wp->event, &ch, 1);
|
bufferevent_write(wp->event, &utf8data.data[0], 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (key != KEYC_NONE && justkey > 0x7f && justkey < KEYC_BASE) {
|
||||||
|
if (utf8_split(justkey, &utf8data) != 0)
|
||||||
|
return;
|
||||||
|
if (key & KEYC_ESCAPE)
|
||||||
|
bufferevent_write(wp->event, "\033", 1);
|
||||||
|
bufferevent_write(wp->event, utf8data.data, utf8data.size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,11 +205,11 @@ input_key(struct window_pane *wp, int key, struct mouse_event *m)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i == nitems(input_keys)) {
|
if (i == nitems(input_keys)) {
|
||||||
log_debug("key 0x%x missing", key);
|
log_debug("key 0x%llx missing", key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dlen = strlen(ike->data);
|
dlen = strlen(ike->data);
|
||||||
log_debug("found key 0x%x: \"%s\"", key, ike->data);
|
log_debug("found key 0x%llx: \"%s\"", key, ike->data);
|
||||||
|
|
||||||
/* Prefix a \033 for escape. */
|
/* Prefix a \033 for escape. */
|
||||||
if (key & KEYC_ESCAPE)
|
if (key & KEYC_ESCAPE)
|
||||||
|
5
input.c
5
input.c
@ -1921,11 +1921,6 @@ input_exit_rename(struct input_ctx *ictx)
|
|||||||
int
|
int
|
||||||
input_utf8_open(struct input_ctx *ictx)
|
input_utf8_open(struct input_ctx *ictx)
|
||||||
{
|
{
|
||||||
if (!options_get_number(ictx->wp->window->options, "utf8")) {
|
|
||||||
/* Print, and do not switch state. */
|
|
||||||
input_print(ictx);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
log_debug("%s", __func__);
|
log_debug("%s", __func__);
|
||||||
|
|
||||||
utf8_open(&ictx->utf8data, ictx->ch);
|
utf8_open(&ictx->utf8data, ictx->ch);
|
||||||
|
@ -37,7 +37,11 @@ key_table_cmp(struct key_table *e1, struct key_table *e2)
|
|||||||
int
|
int
|
||||||
key_bindings_cmp(struct key_binding *bd1, struct key_binding *bd2)
|
key_bindings_cmp(struct key_binding *bd1, struct key_binding *bd2)
|
||||||
{
|
{
|
||||||
return (bd1->key - bd2->key);
|
if (bd1->key < bd2->key)
|
||||||
|
return (-1);
|
||||||
|
if (bd1->key > bd2->key)
|
||||||
|
return (1);
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct key_table *
|
struct key_table *
|
||||||
@ -80,7 +84,7 @@ key_bindings_unref_table(struct key_table *table)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
key_bindings_add(const char *name, int key, int can_repeat,
|
key_bindings_add(const char *name, key_code key, int can_repeat,
|
||||||
struct cmd_list *cmdlist)
|
struct cmd_list *cmdlist)
|
||||||
{
|
{
|
||||||
struct key_table *table;
|
struct key_table *table;
|
||||||
@ -105,7 +109,7 @@ key_bindings_add(const char *name, int key, int can_repeat,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
key_bindings_remove(const char *name, int key)
|
key_bindings_remove(const char *name, key_code key)
|
||||||
{
|
{
|
||||||
struct key_table *table;
|
struct key_table *table;
|
||||||
struct key_binding bd_find, *bd;
|
struct key_binding bd_find, *bd;
|
||||||
|
63
key-string.c
63
key-string.c
@ -22,12 +22,12 @@
|
|||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
int key_string_search_table(const char *);
|
key_code key_string_search_table(const char *);
|
||||||
int key_string_get_modifiers(const char **);
|
key_code key_string_get_modifiers(const char **);
|
||||||
|
|
||||||
const struct {
|
const struct {
|
||||||
const char *string;
|
const char *string;
|
||||||
int key;
|
key_code key;
|
||||||
} key_string_table[] = {
|
} key_string_table[] = {
|
||||||
/* Function keys. */
|
/* Function keys. */
|
||||||
{ "F1", KEYC_F1 },
|
{ "F1", KEYC_F1 },
|
||||||
@ -98,7 +98,7 @@ const struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Find key string in table. */
|
/* Find key string in table. */
|
||||||
int
|
key_code
|
||||||
key_string_search_table(const char *string)
|
key_string_search_table(const char *string)
|
||||||
{
|
{
|
||||||
u_int i;
|
u_int i;
|
||||||
@ -111,10 +111,10 @@ key_string_search_table(const char *string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Find modifiers. */
|
/* Find modifiers. */
|
||||||
int
|
key_code
|
||||||
key_string_get_modifiers(const char **string)
|
key_string_get_modifiers(const char **string)
|
||||||
{
|
{
|
||||||
int modifiers;
|
key_code modifiers;
|
||||||
|
|
||||||
modifiers = 0;
|
modifiers = 0;
|
||||||
while (((*string)[0] != '\0') && (*string)[1] == '-') {
|
while (((*string)[0] != '\0') && (*string)[1] == '-') {
|
||||||
@ -138,13 +138,16 @@ key_string_get_modifiers(const char **string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Lookup a string and convert to a key value. */
|
/* Lookup a string and convert to a key value. */
|
||||||
int
|
key_code
|
||||||
key_string_lookup_string(const char *string)
|
key_string_lookup_string(const char *string)
|
||||||
{
|
{
|
||||||
static const char *other = "!#()+,-.0123456789:;<=>?'\r\t";
|
static const char *other = "!#()+,-.0123456789:;<=>?'\r\t";
|
||||||
int key, modifiers;
|
key_code key;
|
||||||
u_short u;
|
u_short u;
|
||||||
int size;
|
int size;
|
||||||
|
key_code modifiers;
|
||||||
|
struct utf8_data utf8data;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
/* Is this a hexadecimal value? */
|
/* Is this a hexadecimal value? */
|
||||||
if (string[0] == '0' && string[1] == 'x') {
|
if (string[0] == '0' && string[1] == 'x') {
|
||||||
@ -164,11 +167,21 @@ key_string_lookup_string(const char *string)
|
|||||||
return (KEYC_NONE);
|
return (KEYC_NONE);
|
||||||
|
|
||||||
/* Is this a standard ASCII key? */
|
/* Is this a standard ASCII key? */
|
||||||
if (string[1] == '\0') {
|
if (string[1] == '\0' && (u_char)string[0] <= 127) {
|
||||||
key = (u_char) string[0];
|
key = (u_char)string[0];
|
||||||
if (key < 32 || key == 127 || key > 255)
|
if (key < 32 || key == 127)
|
||||||
return (KEYC_NONE);
|
return (KEYC_NONE);
|
||||||
} else {
|
} else {
|
||||||
|
/* Try as a UTF-8 key. */
|
||||||
|
if (utf8_open(&utf8data, (u_char)*string)) {
|
||||||
|
if (strlen(string) != utf8data.size)
|
||||||
|
return (KEYC_NONE);
|
||||||
|
for (i = 1; i < utf8data.size; i++)
|
||||||
|
utf8_append(&utf8data, (u_char)string[i]);
|
||||||
|
key = utf8_combine(&utf8data);
|
||||||
|
return (key | modifiers);
|
||||||
|
}
|
||||||
|
|
||||||
/* Otherwise look the key up in the table. */
|
/* Otherwise look the key up in the table. */
|
||||||
key = key_string_search_table(string);
|
key = key_string_search_table(string);
|
||||||
if (key == KEYC_NONE)
|
if (key == KEYC_NONE)
|
||||||
@ -195,11 +208,12 @@ key_string_lookup_string(const char *string)
|
|||||||
|
|
||||||
/* Convert a key code into string format, with prefix if necessary. */
|
/* Convert a key code into string format, with prefix if necessary. */
|
||||||
const char *
|
const char *
|
||||||
key_string_lookup_key(int key)
|
key_string_lookup_key(key_code key)
|
||||||
{
|
{
|
||||||
static char out[24];
|
static char out[24];
|
||||||
char tmp[8];
|
char tmp[8];
|
||||||
u_int i;
|
u_int i;
|
||||||
|
struct utf8_data utf8data;
|
||||||
|
|
||||||
*out = '\0';
|
*out = '\0';
|
||||||
|
|
||||||
@ -237,23 +251,32 @@ key_string_lookup_key(int key)
|
|||||||
return (out);
|
return (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Is this a UTF-8 key? */
|
||||||
|
if (key > 127 && key < KEYC_BASE) {
|
||||||
|
if (utf8_split(key, &utf8data) == 0) {
|
||||||
|
memcpy(out, utf8data.data, utf8data.size);
|
||||||
|
out[utf8data.size] = '\0';
|
||||||
|
return (out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Invalid keys are errors. */
|
/* Invalid keys are errors. */
|
||||||
if (key == 127 || key > 255) {
|
if (key == 127 || key > 255) {
|
||||||
snprintf(out, sizeof out, "<INVALID#%04x>", key);
|
snprintf(out, sizeof out, "<INVALID#%llx>", key);
|
||||||
return (out);
|
return (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for standard or control key. */
|
/* Check for standard or control key. */
|
||||||
if (key >= 0 && key <= 32) {
|
if (key <= 32) {
|
||||||
if (key == 0 || key > 26)
|
if (key == 0 || key > 26)
|
||||||
xsnprintf(tmp, sizeof tmp, "C-%c", 64 + key);
|
xsnprintf(tmp, sizeof tmp, "C-%c", (int)(64 + key));
|
||||||
else
|
else
|
||||||
xsnprintf(tmp, sizeof tmp, "C-%c", 96 + key);
|
xsnprintf(tmp, sizeof tmp, "C-%c", (int)(96 + key));
|
||||||
} else if (key >= 32 && key <= 126) {
|
} else if (key >= 32 && key <= 126) {
|
||||||
tmp[0] = key;
|
tmp[0] = key;
|
||||||
tmp[1] = '\0';
|
tmp[1] = '\0';
|
||||||
} else if (key >= 128)
|
} else if (key >= 128)
|
||||||
xsnprintf(tmp, sizeof tmp, "\\%o", key);
|
xsnprintf(tmp, sizeof tmp, "\\%llo", key);
|
||||||
|
|
||||||
strlcat(out, tmp, sizeof out);
|
strlcat(out, tmp, sizeof out);
|
||||||
return (out);
|
return (out);
|
||||||
|
16
mode-key.c
16
mode-key.c
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
/* Entry in the default mode key tables. */
|
/* Entry in the default mode key tables. */
|
||||||
struct mode_key_entry {
|
struct mode_key_entry {
|
||||||
int key;
|
key_code key;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Editing mode for vi: 0 is edit mode, keys not in the table are
|
* 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
|
int
|
||||||
mode_key_cmp(struct mode_key_binding *mbind1, struct mode_key_binding *mbind2)
|
mode_key_cmp(struct mode_key_binding *mbind1, struct mode_key_binding *mbind2)
|
||||||
{
|
{
|
||||||
if (mbind1->mode != mbind2->mode)
|
if (mbind1->mode < mbind2->mode)
|
||||||
return (mbind1->mode - mbind2->mode);
|
return (-1);
|
||||||
return (mbind1->key - mbind2->key);
|
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 *
|
const char *
|
||||||
@ -588,7 +594,7 @@ mode_key_init(struct mode_key_data *mdata, struct mode_key_tree *mtree)
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum mode_key_cmd
|
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;
|
struct mode_key_binding *mbind, mtmp;
|
||||||
|
|
||||||
|
@ -415,11 +415,6 @@ const struct options_table_entry session_options_table[] = {
|
|||||||
.default_str = "bg=green,fg=black"
|
.default_str = "bg=green,fg=black"
|
||||||
},
|
},
|
||||||
|
|
||||||
{ .name = "status-utf8",
|
|
||||||
.type = OPTIONS_TABLE_FLAG,
|
|
||||||
.default_num = 0 /* overridden in main() */
|
|
||||||
},
|
|
||||||
|
|
||||||
{ .name = "update-environment",
|
{ .name = "update-environment",
|
||||||
.type = OPTIONS_TABLE_STRING,
|
.type = OPTIONS_TABLE_STRING,
|
||||||
.default_str = "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID "
|
.default_str = "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID "
|
||||||
@ -623,11 +618,6 @@ const struct options_table_entry window_options_table[] = {
|
|||||||
.default_num = 0
|
.default_num = 0
|
||||||
},
|
},
|
||||||
|
|
||||||
{ .name = "utf8",
|
|
||||||
.type = OPTIONS_TABLE_FLAG,
|
|
||||||
.default_num = 0 /* overridden in main() */
|
|
||||||
},
|
|
||||||
|
|
||||||
{ .name = "window-active-style",
|
{ .name = "window-active-style",
|
||||||
.type = OPTIONS_TABLE_STYLE,
|
.type = OPTIONS_TABLE_STYLE,
|
||||||
.default_str = "default"
|
.default_str = "default"
|
||||||
|
7
paste.c
7
paste.c
@ -274,7 +274,7 @@ paste_set(char *data, size_t size, const char *name, char **cause)
|
|||||||
|
|
||||||
/* Convert start of buffer into a nice string. */
|
/* Convert start of buffer into a nice string. */
|
||||||
char *
|
char *
|
||||||
paste_make_sample(struct paste_buffer *pb, int utf8flag)
|
paste_make_sample(struct paste_buffer *pb)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
size_t len, used;
|
size_t len, used;
|
||||||
@ -286,10 +286,7 @@ paste_make_sample(struct paste_buffer *pb, int utf8flag)
|
|||||||
len = width;
|
len = width;
|
||||||
buf = xreallocarray(NULL, len, 4 + 4);
|
buf = xreallocarray(NULL, len, 4 + 4);
|
||||||
|
|
||||||
if (utf8flag)
|
used = utf8_strvis(buf, pb->data, len, flags);
|
||||||
used = utf8_strvis(buf, pb->data, len, flags);
|
|
||||||
else
|
|
||||||
used = strvisx(buf, pb->data, len, flags);
|
|
||||||
if (pb->size > width || used > width)
|
if (pb->size > width || used > width)
|
||||||
strlcpy(buf + width, "...", 4);
|
strlcpy(buf + width, "...", 4);
|
||||||
return (buf);
|
return (buf);
|
||||||
|
@ -73,7 +73,7 @@ screen_write_putc(struct screen_write_ctx *ctx, struct grid_cell *gc,
|
|||||||
|
|
||||||
/* Calculate string length, with embedded formatting. */
|
/* Calculate string length, with embedded formatting. */
|
||||||
size_t
|
size_t
|
||||||
screen_write_cstrlen(int utf8flag, const char *fmt, ...)
|
screen_write_cstrlen(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *msg, *msg2, *ptr, *ptr2;
|
char *msg, *msg2, *ptr, *ptr2;
|
||||||
@ -98,7 +98,7 @@ screen_write_cstrlen(int utf8flag, const char *fmt, ...)
|
|||||||
}
|
}
|
||||||
*ptr2 = '\0';
|
*ptr2 = '\0';
|
||||||
|
|
||||||
size = screen_write_strlen(utf8flag, "%s", msg2);
|
size = screen_write_strlen("%s", msg2);
|
||||||
|
|
||||||
free(msg);
|
free(msg);
|
||||||
free(msg2);
|
free(msg2);
|
||||||
@ -108,7 +108,7 @@ screen_write_cstrlen(int utf8flag, const char *fmt, ...)
|
|||||||
|
|
||||||
/* Calculate string length. */
|
/* Calculate string length. */
|
||||||
size_t
|
size_t
|
||||||
screen_write_strlen(int utf8flag, const char *fmt, ...)
|
screen_write_strlen(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *msg;
|
char *msg;
|
||||||
@ -122,7 +122,7 @@ screen_write_strlen(int utf8flag, const char *fmt, ...)
|
|||||||
|
|
||||||
ptr = msg;
|
ptr = msg;
|
||||||
while (*ptr != '\0') {
|
while (*ptr != '\0') {
|
||||||
if (utf8flag && *ptr > 0x7f && utf8_open(&utf8data, *ptr)) {
|
if (*ptr > 0x7f && utf8_open(&utf8data, *ptr)) {
|
||||||
ptr++;
|
ptr++;
|
||||||
|
|
||||||
left = strlen(ptr);
|
left = strlen(ptr);
|
||||||
@ -134,7 +134,8 @@ screen_write_strlen(int utf8flag, const char *fmt, ...)
|
|||||||
|
|
||||||
size += utf8data.width;
|
size += utf8data.width;
|
||||||
} else {
|
} else {
|
||||||
size++;
|
if (*ptr > 0x1f && *ptr < 0x7f)
|
||||||
|
size++;
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -151,25 +152,25 @@ screen_write_puts(struct screen_write_ctx *ctx, struct grid_cell *gc,
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
screen_write_vnputs(ctx, -1, gc, 0, fmt, ap);
|
screen_write_vnputs(ctx, -1, gc, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write string with length limit (-1 for unlimited). */
|
/* Write string with length limit (-1 for unlimited). */
|
||||||
void
|
void
|
||||||
screen_write_nputs(struct screen_write_ctx *ctx, ssize_t maxlen,
|
screen_write_nputs(struct screen_write_ctx *ctx, ssize_t maxlen,
|
||||||
struct grid_cell *gc, int utf8flag, const char *fmt, ...)
|
struct grid_cell *gc, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
screen_write_vnputs(ctx, maxlen, gc, utf8flag, fmt, ap);
|
screen_write_vnputs(ctx, maxlen, gc, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
screen_write_vnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
|
screen_write_vnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
|
||||||
struct grid_cell *gc, int utf8flag, const char *fmt, va_list ap)
|
struct grid_cell *gc, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
char *msg;
|
char *msg;
|
||||||
struct utf8_data utf8data;
|
struct utf8_data utf8data;
|
||||||
@ -180,7 +181,7 @@ screen_write_vnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
|
|||||||
|
|
||||||
ptr = msg;
|
ptr = msg;
|
||||||
while (*ptr != '\0') {
|
while (*ptr != '\0') {
|
||||||
if (utf8flag && *ptr > 0x7f && utf8_open(&utf8data, *ptr)) {
|
if (*ptr > 0x7f && utf8_open(&utf8data, *ptr)) {
|
||||||
ptr++;
|
ptr++;
|
||||||
|
|
||||||
left = strlen(ptr);
|
left = strlen(ptr);
|
||||||
@ -208,7 +209,7 @@ screen_write_vnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
|
|||||||
|
|
||||||
if (*ptr == '\001')
|
if (*ptr == '\001')
|
||||||
gc->attr ^= GRID_ATTR_CHARSET;
|
gc->attr ^= GRID_ATTR_CHARSET;
|
||||||
else {
|
else if (*ptr > 0x1f && *ptr < 0x7f) {
|
||||||
size++;
|
size++;
|
||||||
screen_write_putc(ctx, gc, *ptr);
|
screen_write_putc(ctx, gc, *ptr);
|
||||||
}
|
}
|
||||||
@ -221,8 +222,8 @@ screen_write_vnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
|
|||||||
|
|
||||||
/* Write string, similar to nputs, but with embedded formatting (#[]). */
|
/* Write string, similar to nputs, but with embedded formatting (#[]). */
|
||||||
void
|
void
|
||||||
screen_write_cnputs(struct screen_write_ctx *ctx,
|
screen_write_cnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
|
||||||
ssize_t maxlen, struct grid_cell *gc, int utf8flag, const char *fmt, ...)
|
struct grid_cell *gc, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
struct grid_cell lgc;
|
struct grid_cell lgc;
|
||||||
struct utf8_data utf8data;
|
struct utf8_data utf8data;
|
||||||
@ -253,7 +254,7 @@ screen_write_cnputs(struct screen_write_ctx *ctx,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (utf8flag && *ptr > 0x7f && utf8_open(&utf8data, *ptr)) {
|
if (*ptr > 0x7f && utf8_open(&utf8data, *ptr)) {
|
||||||
ptr++;
|
ptr++;
|
||||||
|
|
||||||
left = strlen(ptr);
|
left = strlen(ptr);
|
||||||
@ -279,8 +280,10 @@ screen_write_cnputs(struct screen_write_ctx *ctx,
|
|||||||
if (maxlen > 0 && size + 1 > (size_t) maxlen)
|
if (maxlen > 0 && size + 1 > (size_t) maxlen)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
size++;
|
if (*ptr > 0x1f && *ptr < 0x7f) {
|
||||||
screen_write_putc(ctx, &lgc, *ptr);
|
size++;
|
||||||
|
screen_write_putc(ctx, &lgc, *ptr);
|
||||||
|
}
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,22 +30,22 @@
|
|||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
void server_client_key_table(struct client *, const char *);
|
void server_client_key_table(struct client *, const char *);
|
||||||
void server_client_free(int, short, void *);
|
void server_client_free(int, short, void *);
|
||||||
void server_client_check_focus(struct window_pane *);
|
void server_client_check_focus(struct window_pane *);
|
||||||
void server_client_check_resize(struct window_pane *);
|
void server_client_check_resize(struct window_pane *);
|
||||||
int server_client_check_mouse(struct client *);
|
key_code server_client_check_mouse(struct client *);
|
||||||
void server_client_repeat_timer(int, short, void *);
|
void server_client_repeat_timer(int, short, void *);
|
||||||
void server_client_check_exit(struct client *);
|
void server_client_check_exit(struct client *);
|
||||||
void server_client_check_redraw(struct client *);
|
void server_client_check_redraw(struct client *);
|
||||||
void server_client_set_title(struct client *);
|
void server_client_set_title(struct client *);
|
||||||
void server_client_reset_state(struct client *);
|
void server_client_reset_state(struct client *);
|
||||||
int server_client_assume_paste(struct session *);
|
int server_client_assume_paste(struct session *);
|
||||||
|
|
||||||
void server_client_dispatch(struct imsg *, void *);
|
void server_client_dispatch(struct imsg *, void *);
|
||||||
void server_client_dispatch_command(struct client *, struct imsg *);
|
void server_client_dispatch_command(struct client *, struct imsg *);
|
||||||
void server_client_dispatch_identify(struct client *, struct imsg *);
|
void server_client_dispatch_identify(struct client *, struct imsg *);
|
||||||
void server_client_dispatch_shell(struct client *);
|
void server_client_dispatch_shell(struct client *);
|
||||||
|
|
||||||
/* Check if this client is inside this server. */
|
/* Check if this client is inside this server. */
|
||||||
int
|
int
|
||||||
@ -255,7 +255,7 @@ server_client_free(unused int fd, unused short events, void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check for mouse keys. */
|
/* Check for mouse keys. */
|
||||||
int
|
key_code
|
||||||
server_client_check_mouse(struct client *c)
|
server_client_check_mouse(struct client *c)
|
||||||
{
|
{
|
||||||
struct session *s = c->session;
|
struct session *s = c->session;
|
||||||
@ -265,7 +265,7 @@ server_client_check_mouse(struct client *c)
|
|||||||
enum { NOTYPE, DOWN, UP, DRAG, WHEEL } type = NOTYPE;
|
enum { NOTYPE, DOWN, UP, DRAG, WHEEL } type = NOTYPE;
|
||||||
enum { NOWHERE, PANE, STATUS, BORDER } where = NOWHERE;
|
enum { NOWHERE, PANE, STATUS, BORDER } where = NOWHERE;
|
||||||
u_int x, y, b;
|
u_int x, y, b;
|
||||||
int key;
|
key_code key;
|
||||||
|
|
||||||
log_debug("mouse %02x at %u,%u (last %u,%u) (%d)", m->b, m->x, m->y,
|
log_debug("mouse %02x at %u,%u (last %u,%u) (%d)", m->b, m->x, m->y,
|
||||||
m->lx, m->ly, c->tty.mouse_drag_flag);
|
m->lx, m->ly, c->tty.mouse_drag_flag);
|
||||||
@ -499,7 +499,7 @@ server_client_assume_paste(struct session *s)
|
|||||||
|
|
||||||
/* Handle data key input from client. */
|
/* Handle data key input from client. */
|
||||||
void
|
void
|
||||||
server_client_handle_key(struct client *c, int key)
|
server_client_handle_key(struct client *c, key_code key)
|
||||||
{
|
{
|
||||||
struct mouse_event *m = &c->tty.mouse;
|
struct mouse_event *m = &c->tty.mouse;
|
||||||
struct session *s = c->session;
|
struct session *s = c->session;
|
||||||
@ -633,8 +633,8 @@ retry:
|
|||||||
* No match, but in the root table. Prefix switches to the prefix table
|
* No match, but in the root table. Prefix switches to the prefix table
|
||||||
* and everything else is passed through.
|
* and everything else is passed through.
|
||||||
*/
|
*/
|
||||||
if (key == options_get_number(s->options, "prefix") ||
|
if (key == (key_code)options_get_number(s->options, "prefix") ||
|
||||||
key == options_get_number(s->options, "prefix2")) {
|
key == (key_code)options_get_number(s->options, "prefix2")) {
|
||||||
server_client_key_table(c, "prefix");
|
server_client_key_table(c, "prefix");
|
||||||
server_status_client(c);
|
server_status_client(c);
|
||||||
return;
|
return;
|
||||||
|
66
status.c
66
status.c
@ -29,10 +29,10 @@
|
|||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
char *status_redraw_get_left(struct client *, time_t, int, struct grid_cell *,
|
char *status_redraw_get_left(struct client *, time_t, struct grid_cell *,
|
||||||
|
size_t *);
|
||||||
|
char *status_redraw_get_right(struct client *, time_t, struct grid_cell *,
|
||||||
size_t *);
|
size_t *);
|
||||||
char *status_redraw_get_right(struct client *, time_t, int,
|
|
||||||
struct grid_cell *, size_t *);
|
|
||||||
char *status_print(struct client *, struct winlink *, time_t,
|
char *status_print(struct client *, struct winlink *, time_t,
|
||||||
struct grid_cell *);
|
struct grid_cell *);
|
||||||
char *status_replace(struct client *, struct winlink *, const char *, time_t);
|
char *status_replace(struct client *, struct winlink *, const char *, time_t);
|
||||||
@ -208,8 +208,8 @@ status_at_line(struct client *c)
|
|||||||
|
|
||||||
/* Retrieve options for left string. */
|
/* Retrieve options for left string. */
|
||||||
char *
|
char *
|
||||||
status_redraw_get_left(struct client *c, time_t t, int utf8flag,
|
status_redraw_get_left(struct client *c, time_t t, struct grid_cell *gc,
|
||||||
struct grid_cell *gc, size_t *size)
|
size_t *size)
|
||||||
{
|
{
|
||||||
struct session *s = c->session;
|
struct session *s = c->session;
|
||||||
const char *template;
|
const char *template;
|
||||||
@ -222,7 +222,7 @@ status_redraw_get_left(struct client *c, time_t t, int utf8flag,
|
|||||||
left = status_replace(c, NULL, template, t);
|
left = status_replace(c, NULL, template, t);
|
||||||
|
|
||||||
*size = options_get_number(s->options, "status-left-length");
|
*size = options_get_number(s->options, "status-left-length");
|
||||||
leftlen = screen_write_cstrlen(utf8flag, "%s", left);
|
leftlen = screen_write_cstrlen("%s", left);
|
||||||
if (leftlen < *size)
|
if (leftlen < *size)
|
||||||
*size = leftlen;
|
*size = leftlen;
|
||||||
return (left);
|
return (left);
|
||||||
@ -230,8 +230,8 @@ status_redraw_get_left(struct client *c, time_t t, int utf8flag,
|
|||||||
|
|
||||||
/* Retrieve options for right string. */
|
/* Retrieve options for right string. */
|
||||||
char *
|
char *
|
||||||
status_redraw_get_right(struct client *c, time_t t, int utf8flag,
|
status_redraw_get_right(struct client *c, time_t t, struct grid_cell *gc,
|
||||||
struct grid_cell *gc, size_t *size)
|
size_t *size)
|
||||||
{
|
{
|
||||||
struct session *s = c->session;
|
struct session *s = c->session;
|
||||||
const char *template;
|
const char *template;
|
||||||
@ -244,7 +244,7 @@ status_redraw_get_right(struct client *c, time_t t, int utf8flag,
|
|||||||
right = status_replace(c, NULL, template, t);
|
right = status_replace(c, NULL, template, t);
|
||||||
|
|
||||||
*size = options_get_number(s->options, "status-right-length");
|
*size = options_get_number(s->options, "status-right-length");
|
||||||
rightlen = screen_write_cstrlen(utf8flag, "%s", right);
|
rightlen = screen_write_cstrlen("%s", right);
|
||||||
if (rightlen < *size)
|
if (rightlen < *size)
|
||||||
*size = rightlen;
|
*size = rightlen;
|
||||||
return (right);
|
return (right);
|
||||||
@ -286,7 +286,7 @@ status_redraw(struct client *c)
|
|||||||
u_int offset, needed;
|
u_int offset, needed;
|
||||||
u_int wlstart, wlwidth, wlavailable, wloffset, wlsize;
|
u_int wlstart, wlwidth, wlavailable, wloffset, wlsize;
|
||||||
size_t llen, rlen, seplen;
|
size_t llen, rlen, seplen;
|
||||||
int larrow, rarrow, utf8flag;
|
int larrow, rarrow;
|
||||||
|
|
||||||
/* No status line? */
|
/* No status line? */
|
||||||
if (c->tty.sy == 0 || !options_get_number(s->options, "status"))
|
if (c->tty.sy == 0 || !options_get_number(s->options, "status"))
|
||||||
@ -312,14 +312,11 @@ status_redraw(struct client *c)
|
|||||||
if (c->tty.sy <= 1)
|
if (c->tty.sy <= 1)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* Get UTF-8 flag. */
|
|
||||||
utf8flag = options_get_number(s->options, "status-utf8");
|
|
||||||
|
|
||||||
/* Work out left and right strings. */
|
/* Work out left and right strings. */
|
||||||
memcpy(&lgc, &stdgc, sizeof lgc);
|
memcpy(&lgc, &stdgc, sizeof lgc);
|
||||||
left = status_redraw_get_left(c, t, utf8flag, &lgc, &llen);
|
left = status_redraw_get_left(c, t, &lgc, &llen);
|
||||||
memcpy(&rgc, &stdgc, sizeof rgc);
|
memcpy(&rgc, &stdgc, sizeof rgc);
|
||||||
right = status_redraw_get_right(c, t, utf8flag, &rgc, &rlen);
|
right = status_redraw_get_right(c, t, &rgc, &rlen);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Figure out how much space we have for the window list. If there
|
* Figure out how much space we have for the window list. If there
|
||||||
@ -340,15 +337,14 @@ status_redraw(struct client *c)
|
|||||||
free(wl->status_text);
|
free(wl->status_text);
|
||||||
memcpy(&wl->status_cell, &stdgc, sizeof wl->status_cell);
|
memcpy(&wl->status_cell, &stdgc, sizeof wl->status_cell);
|
||||||
wl->status_text = status_print(c, wl, t, &wl->status_cell);
|
wl->status_text = status_print(c, wl, t, &wl->status_cell);
|
||||||
wl->status_width =
|
wl->status_width = screen_write_cstrlen("%s", wl->status_text);
|
||||||
screen_write_cstrlen(utf8flag, "%s", wl->status_text);
|
|
||||||
|
|
||||||
if (wl == s->curw)
|
if (wl == s->curw)
|
||||||
wloffset = wlwidth;
|
wloffset = wlwidth;
|
||||||
|
|
||||||
oo = wl->window->options;
|
oo = wl->window->options;
|
||||||
sep = options_get_string(oo, "window-status-separator");
|
sep = options_get_string(oo, "window-status-separator");
|
||||||
seplen = screen_write_strlen(utf8flag, "%s", sep);
|
seplen = screen_write_strlen("%s", sep);
|
||||||
wlwidth += wl->status_width + seplen;
|
wlwidth += wl->status_width + seplen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,12 +354,12 @@ status_redraw(struct client *c)
|
|||||||
/* And draw the window list into it. */
|
/* And draw the window list into it. */
|
||||||
screen_write_start(&ctx, NULL, &window_list);
|
screen_write_start(&ctx, NULL, &window_list);
|
||||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
RB_FOREACH(wl, winlinks, &s->windows) {
|
||||||
screen_write_cnputs(&ctx,
|
screen_write_cnputs(&ctx, -1, &wl->status_cell, "%s",
|
||||||
-1, &wl->status_cell, utf8flag, "%s", wl->status_text);
|
wl->status_text);
|
||||||
|
|
||||||
oo = wl->window->options;
|
oo = wl->window->options;
|
||||||
sep = options_get_string(oo, "window-status-separator");
|
sep = options_get_string(oo, "window-status-separator");
|
||||||
screen_write_nputs(&ctx, -1, &stdgc, utf8flag, "%s", sep);
|
screen_write_nputs(&ctx, -1, &stdgc, "%s", sep);
|
||||||
}
|
}
|
||||||
screen_write_stop(&ctx);
|
screen_write_stop(&ctx);
|
||||||
|
|
||||||
@ -435,7 +431,7 @@ draw:
|
|||||||
/* Draw the left string and arrow. */
|
/* Draw the left string and arrow. */
|
||||||
screen_write_cursormove(&ctx, 0, 0);
|
screen_write_cursormove(&ctx, 0, 0);
|
||||||
if (llen != 0)
|
if (llen != 0)
|
||||||
screen_write_cnputs(&ctx, llen, &lgc, utf8flag, "%s", left);
|
screen_write_cnputs(&ctx, llen, &lgc, "%s", left);
|
||||||
if (larrow != 0) {
|
if (larrow != 0) {
|
||||||
memcpy(&gc, &stdgc, sizeof gc);
|
memcpy(&gc, &stdgc, sizeof gc);
|
||||||
if (larrow == -1)
|
if (larrow == -1)
|
||||||
@ -453,7 +449,7 @@ draw:
|
|||||||
} else
|
} else
|
||||||
screen_write_cursormove(&ctx, c->tty.sx - rlen, 0);
|
screen_write_cursormove(&ctx, c->tty.sx - rlen, 0);
|
||||||
if (rlen != 0)
|
if (rlen != 0)
|
||||||
screen_write_cnputs(&ctx, rlen, &rgc, utf8flag, "%s", right);
|
screen_write_cnputs(&ctx, rlen, &rgc, "%s", right);
|
||||||
|
|
||||||
/* Figure out the offset for the window list. */
|
/* Figure out the offset for the window list. */
|
||||||
if (llen != 0)
|
if (llen != 0)
|
||||||
@ -624,16 +620,13 @@ status_message_redraw(struct client *c)
|
|||||||
struct screen old_status;
|
struct screen old_status;
|
||||||
size_t len;
|
size_t len;
|
||||||
struct grid_cell gc;
|
struct grid_cell gc;
|
||||||
int utf8flag;
|
|
||||||
|
|
||||||
if (c->tty.sx == 0 || c->tty.sy == 0)
|
if (c->tty.sx == 0 || c->tty.sy == 0)
|
||||||
return (0);
|
return (0);
|
||||||
memcpy(&old_status, &c->status, sizeof old_status);
|
memcpy(&old_status, &c->status, sizeof old_status);
|
||||||
screen_init(&c->status, c->tty.sx, 1, 0);
|
screen_init(&c->status, c->tty.sx, 1, 0);
|
||||||
|
|
||||||
utf8flag = options_get_number(s->options, "status-utf8");
|
len = screen_write_strlen("%s", c->message_string);
|
||||||
|
|
||||||
len = screen_write_strlen(utf8flag, "%s", c->message_string);
|
|
||||||
if (len > c->tty.sx)
|
if (len > c->tty.sx)
|
||||||
len = c->tty.sx;
|
len = c->tty.sx;
|
||||||
|
|
||||||
@ -642,7 +635,7 @@ status_message_redraw(struct client *c)
|
|||||||
screen_write_start(&ctx, NULL, &c->status);
|
screen_write_start(&ctx, NULL, &c->status);
|
||||||
|
|
||||||
screen_write_cursormove(&ctx, 0, 0);
|
screen_write_cursormove(&ctx, 0, 0);
|
||||||
screen_write_nputs(&ctx, len, &gc, utf8flag, "%s", c->message_string);
|
screen_write_nputs(&ctx, len, &gc, "%s", c->message_string);
|
||||||
for (; len < c->tty.sx; len++)
|
for (; len < c->tty.sx; len++)
|
||||||
screen_write_putc(&ctx, &gc, ' ');
|
screen_write_putc(&ctx, &gc, ' ');
|
||||||
|
|
||||||
@ -754,16 +747,13 @@ status_prompt_redraw(struct client *c)
|
|||||||
struct screen old_status;
|
struct screen old_status;
|
||||||
size_t i, size, left, len, off;
|
size_t i, size, left, len, off;
|
||||||
struct grid_cell gc, *gcp;
|
struct grid_cell gc, *gcp;
|
||||||
int utf8flag;
|
|
||||||
|
|
||||||
if (c->tty.sx == 0 || c->tty.sy == 0)
|
if (c->tty.sx == 0 || c->tty.sy == 0)
|
||||||
return (0);
|
return (0);
|
||||||
memcpy(&old_status, &c->status, sizeof old_status);
|
memcpy(&old_status, &c->status, sizeof old_status);
|
||||||
screen_init(&c->status, c->tty.sx, 1, 0);
|
screen_init(&c->status, c->tty.sx, 1, 0);
|
||||||
|
|
||||||
utf8flag = options_get_number(s->options, "status-utf8");
|
len = screen_write_strlen("%s", c->prompt_string);
|
||||||
|
|
||||||
len = screen_write_strlen(utf8flag, "%s", c->prompt_string);
|
|
||||||
if (len > c->tty.sx)
|
if (len > c->tty.sx)
|
||||||
len = c->tty.sx;
|
len = c->tty.sx;
|
||||||
off = 0;
|
off = 0;
|
||||||
@ -777,19 +767,19 @@ status_prompt_redraw(struct client *c)
|
|||||||
screen_write_start(&ctx, NULL, &c->status);
|
screen_write_start(&ctx, NULL, &c->status);
|
||||||
|
|
||||||
screen_write_cursormove(&ctx, 0, 0);
|
screen_write_cursormove(&ctx, 0, 0);
|
||||||
screen_write_nputs(&ctx, len, &gc, utf8flag, "%s", c->prompt_string);
|
screen_write_nputs(&ctx, len, &gc, "%s", c->prompt_string);
|
||||||
|
|
||||||
left = c->tty.sx - len;
|
left = c->tty.sx - len;
|
||||||
if (left != 0) {
|
if (left != 0) {
|
||||||
size = screen_write_strlen(utf8flag, "%s", c->prompt_buffer);
|
size = screen_write_strlen("%s", c->prompt_buffer);
|
||||||
if (c->prompt_index >= left) {
|
if (c->prompt_index >= left) {
|
||||||
off = c->prompt_index - left + 1;
|
off = c->prompt_index - left + 1;
|
||||||
if (c->prompt_index == size)
|
if (c->prompt_index == size)
|
||||||
left--;
|
left--;
|
||||||
size = left;
|
size = left;
|
||||||
}
|
}
|
||||||
screen_write_nputs(
|
screen_write_nputs(&ctx, left, &gc, "%s", c->prompt_buffer +
|
||||||
&ctx, left, &gc, utf8flag, "%s", c->prompt_buffer + off);
|
off);
|
||||||
|
|
||||||
for (i = len + size; i < c->tty.sx; i++)
|
for (i = len + size; i < c->tty.sx; i++)
|
||||||
screen_write_putc(&ctx, &gc, ' ');
|
screen_write_putc(&ctx, &gc, ' ');
|
||||||
@ -812,7 +802,7 @@ status_prompt_redraw(struct client *c)
|
|||||||
|
|
||||||
/* Handle keys in prompt. */
|
/* Handle keys in prompt. */
|
||||||
void
|
void
|
||||||
status_prompt_key(struct client *c, int key)
|
status_prompt_key(struct client *c, key_code key)
|
||||||
{
|
{
|
||||||
struct session *sess = c->session;
|
struct session *sess = c->session;
|
||||||
struct options *oo = sess->options;
|
struct options *oo = sess->options;
|
||||||
@ -1116,7 +1106,7 @@ status_prompt_key(struct client *c, int key)
|
|||||||
status_prompt_clear(c);
|
status_prompt_clear(c);
|
||||||
break;
|
break;
|
||||||
case MODEKEY_OTHER:
|
case MODEKEY_OTHER:
|
||||||
if ((key & 0xff00) != 0 || key < 32 || key == 127)
|
if (key <= 0x1f || key >= 0x7f)
|
||||||
break;
|
break;
|
||||||
c->prompt_buffer = xrealloc(c->prompt_buffer, size + 2);
|
c->prompt_buffer = xrealloc(c->prompt_buffer, size + 2);
|
||||||
|
|
||||||
|
41
tmux.1
41
tmux.1
@ -190,13 +190,11 @@ flag explicitly informs
|
|||||||
.Nm
|
.Nm
|
||||||
that UTF-8 is supported.
|
that UTF-8 is supported.
|
||||||
.Pp
|
.Pp
|
||||||
If the server is started from a client passed
|
Note that
|
||||||
.Fl u
|
.Nm
|
||||||
or where UTF-8 is detected, the
|
itself always accepts UTF-8, this controls whether it will send UTF-8
|
||||||
.Ic utf8
|
characters to the terminal it is running it (if not, they are replaced by
|
||||||
and
|
.Ql _ ) .
|
||||||
.Ic status-utf8
|
|
||||||
options are enabled in the global window and session options respectively.
|
|
||||||
.It Fl v
|
.It Fl v
|
||||||
Request verbose logging.
|
Request verbose logging.
|
||||||
This option may be specified multiple times for increasing verbosity.
|
This option may be specified multiple times for increasing verbosity.
|
||||||
@ -2774,12 +2772,6 @@ Examples are:
|
|||||||
#[fg=yellow,bold]#(apm -l)%%#[default] [#S]
|
#[fg=yellow,bold]#(apm -l)%%#[default] [#S]
|
||||||
.Ed
|
.Ed
|
||||||
.Pp
|
.Pp
|
||||||
By default, UTF-8 in
|
|
||||||
.Ar string
|
|
||||||
is not interpreted, to enable UTF-8, use the
|
|
||||||
.Ic status-utf8
|
|
||||||
option.
|
|
||||||
.Pp
|
|
||||||
The default is
|
The default is
|
||||||
.Ql "[#S] " .
|
.Ql "[#S] " .
|
||||||
.It Ic status-left-length Ar length
|
.It Ic status-left-length Ar length
|
||||||
@ -2809,9 +2801,7 @@ As with
|
|||||||
.Ar string
|
.Ar string
|
||||||
will be passed to
|
will be passed to
|
||||||
.Xr strftime 3 ,
|
.Xr strftime 3 ,
|
||||||
character pairs are replaced, and UTF-8 is dependent on the
|
character pairs are replaced.
|
||||||
.Ic status-utf8
|
|
||||||
option.
|
|
||||||
.It Ic status-right-length Ar length
|
.It Ic status-right-length Ar length
|
||||||
Set the maximum
|
Set the maximum
|
||||||
.Ar length
|
.Ar length
|
||||||
@ -2831,17 +2821,6 @@ For how to specify
|
|||||||
see the
|
see the
|
||||||
.Ic message-command-style
|
.Ic message-command-style
|
||||||
option.
|
option.
|
||||||
.It Xo Ic status-utf8
|
|
||||||
.Op Ic on | off
|
|
||||||
.Xc
|
|
||||||
Instruct
|
|
||||||
.Nm
|
|
||||||
to treat top-bit-set characters in the
|
|
||||||
.Ic status-left
|
|
||||||
and
|
|
||||||
.Ic status-right
|
|
||||||
strings as UTF-8; notably, this is important for wide characters.
|
|
||||||
This option defaults to off.
|
|
||||||
.It Ic update-environment Ar variables
|
.It Ic update-environment Ar variables
|
||||||
Set a space-separated string containing a list of environment variables to be
|
Set a space-separated string containing a list of environment variables to be
|
||||||
copied into the session environment when a new session is created or an
|
copied into the session environment when a new session is created or an
|
||||||
@ -3088,13 +3067,6 @@ command.
|
|||||||
Duplicate input to any pane to all other panes in the same window (only
|
Duplicate input to any pane to all other panes in the same window (only
|
||||||
for panes that are not in any special mode).
|
for panes that are not in any special mode).
|
||||||
.Pp
|
.Pp
|
||||||
.It Xo Ic utf8
|
|
||||||
.Op Ic on | off
|
|
||||||
.Xc
|
|
||||||
Instructs
|
|
||||||
.Nm
|
|
||||||
to expect UTF-8 sequences to appear in this window.
|
|
||||||
.Pp
|
|
||||||
.It Ic window-active-style Ar style
|
.It Ic window-active-style Ar style
|
||||||
Set the style for the window's active pane.
|
Set the style for the window's active pane.
|
||||||
For how to specify
|
For how to specify
|
||||||
@ -3398,7 +3370,6 @@ The following variables are available, where appropriate:
|
|||||||
.It Li "mouse_any_flag" Ta "" Ta "Pane mouse any flag"
|
.It Li "mouse_any_flag" Ta "" Ta "Pane mouse any flag"
|
||||||
.It Li "mouse_button_flag" Ta "" Ta "Pane mouse button flag"
|
.It Li "mouse_button_flag" Ta "" Ta "Pane mouse button flag"
|
||||||
.It Li "mouse_standard_flag" Ta "" Ta "Pane mouse standard flag"
|
.It Li "mouse_standard_flag" Ta "" Ta "Pane mouse standard flag"
|
||||||
.It Li "mouse_utf8_flag" Ta "" Ta "Pane mouse UTF-8 flag"
|
|
||||||
.It Li "pane_active" Ta "" Ta "1 if active pane"
|
.It Li "pane_active" Ta "" Ta "1 if active pane"
|
||||||
.It Li "pane_bottom" Ta "" Ta "Bottom of pane"
|
.It Li "pane_bottom" Ta "" Ta "Bottom of pane"
|
||||||
.It Li "pane_current_command" Ta "" Ta "Current command if available"
|
.It Li "pane_current_command" Ta "" Ta "Current command if available"
|
||||||
|
44
tmux.c
44
tmux.c
@ -193,8 +193,9 @@ find_home(void)
|
|||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *s, *path, *label, **var, tmp[PATH_MAX];
|
char *path, *label, **var, tmp[PATH_MAX];
|
||||||
int opt, flags, keys;
|
const char *s;
|
||||||
|
int opt, flags, keys;
|
||||||
|
|
||||||
#if defined(DEBUG) && defined(__OpenBSD__)
|
#if defined(DEBUG) && defined(__OpenBSD__)
|
||||||
malloc_options = (char *) "AFGJPX";
|
malloc_options = (char *) "AFGJPX";
|
||||||
@ -265,20 +266,25 @@ main(int argc, char **argv)
|
|||||||
err(1, "pledge");
|
err(1, "pledge");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!(flags & CLIENT_UTF8)) {
|
/*
|
||||||
/*
|
* tmux is a UTF-8 terminal, so if TMUX is set, assume UTF-8.
|
||||||
* If the user has set whichever of LC_ALL, LC_CTYPE or LANG
|
* Otherwise, if the user has set LC_ALL, LC_CTYPE or LANG to contain
|
||||||
* exist (in that order) to contain UTF-8, it is a safe
|
* UTF-8, it is a safe assumption that either they are using a UTF-8
|
||||||
* assumption that either they are using a UTF-8 terminal, or
|
* terminal, or if not they know that output from UTF-8-capable
|
||||||
* if not they know that output from UTF-8-capable programs may
|
* programs may be wrong.
|
||||||
* be wrong.
|
*/
|
||||||
*/
|
if (getenv("TMUX") != NULL)
|
||||||
if ((s = getenv("LC_ALL")) == NULL || *s == '\0') {
|
flags |= CLIENT_UTF8;
|
||||||
if ((s = getenv("LC_CTYPE")) == NULL || *s == '\0')
|
else {
|
||||||
s = getenv("LANG");
|
s = getenv("LC_ALL");
|
||||||
}
|
if (s == NULL || *s == '\0')
|
||||||
if (s != NULL && (strcasestr(s, "UTF-8") != NULL ||
|
s = getenv("LC_CTYPE");
|
||||||
strcasestr(s, "UTF8") != NULL))
|
if (s == NULL || *s == '\0')
|
||||||
|
s = getenv("LANG");
|
||||||
|
if (s == NULL || *s == '\0')
|
||||||
|
s = "";
|
||||||
|
if (strcasestr(s, "UTF-8") != NULL ||
|
||||||
|
strcasestr(s, "UTF8") != NULL)
|
||||||
flags |= CLIENT_UTF8;
|
flags |= CLIENT_UTF8;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,12 +304,6 @@ main(int argc, char **argv)
|
|||||||
global_w_options = options_create(NULL);
|
global_w_options = options_create(NULL);
|
||||||
options_table_populate_tree(window_options_table, global_w_options);
|
options_table_populate_tree(window_options_table, global_w_options);
|
||||||
|
|
||||||
/* Enable UTF-8 if the first client is on UTF-8 terminal. */
|
|
||||||
if (flags & CLIENT_UTF8) {
|
|
||||||
options_set_number(global_s_options, "status-utf8", 1);
|
|
||||||
options_set_number(global_w_options, "utf8", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Override keys to vi if VISUAL or EDITOR are set. */
|
/* Override keys to vi if VISUAL or EDITOR are set. */
|
||||||
if ((s = getenv("VISUAL")) != NULL || (s = getenv("EDITOR")) != NULL) {
|
if ((s = getenv("VISUAL")) != NULL || (s = getenv("EDITOR")) != NULL) {
|
||||||
if (strrchr(s, '/') != NULL)
|
if (strrchr(s, '/') != NULL)
|
||||||
|
117
tmux.h
117
tmux.h
@ -98,13 +98,13 @@ struct tmuxproc;
|
|||||||
#define BELL_OTHER 3
|
#define BELL_OTHER 3
|
||||||
|
|
||||||
/* Special key codes. */
|
/* Special key codes. */
|
||||||
#define KEYC_NONE 0xfff
|
#define KEYC_NONE 0xffff00000000ULL
|
||||||
#define KEYC_BASE 0x1000
|
#define KEYC_BASE 0x100000000000ULL
|
||||||
|
|
||||||
/* Key modifier bits. */
|
/* Key modifier bits. */
|
||||||
#define KEYC_ESCAPE 0x2000
|
#define KEYC_ESCAPE 0x200000000000ULL
|
||||||
#define KEYC_CTRL 0x4000
|
#define KEYC_CTRL 0x400000000000ULL
|
||||||
#define KEYC_SHIFT 0x8000
|
#define KEYC_SHIFT 0x800000000000ULL
|
||||||
|
|
||||||
/* Mask to obtain key w/o modifiers. */
|
/* Mask to obtain key w/o modifiers. */
|
||||||
#define KEYC_MASK_MOD (KEYC_ESCAPE|KEYC_CTRL|KEYC_SHIFT)
|
#define KEYC_MASK_MOD (KEYC_ESCAPE|KEYC_CTRL|KEYC_SHIFT)
|
||||||
@ -124,8 +124,14 @@ struct tmuxproc;
|
|||||||
{ #s "Status", KEYC_ ## name ## _STATUS }, \
|
{ #s "Status", KEYC_ ## name ## _STATUS }, \
|
||||||
{ #s "Border", KEYC_ ## name ## _BORDER }
|
{ #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. */
|
/* Special key codes. */
|
||||||
enum key_code {
|
enum {
|
||||||
/* Focus events. */
|
/* Focus events. */
|
||||||
KEYC_FOCUS_IN = KEYC_BASE,
|
KEYC_FOCUS_IN = KEYC_BASE,
|
||||||
KEYC_FOCUS_OUT,
|
KEYC_FOCUS_OUT,
|
||||||
@ -573,7 +579,7 @@ struct mode_key_data {
|
|||||||
|
|
||||||
/* Binding between a key and a command. */
|
/* Binding between a key and a command. */
|
||||||
struct mode_key_binding {
|
struct mode_key_binding {
|
||||||
int key;
|
key_code key;
|
||||||
|
|
||||||
int mode;
|
int mode;
|
||||||
enum mode_key_cmd cmd;
|
enum mode_key_cmd cmd;
|
||||||
@ -779,7 +785,7 @@ struct window_mode {
|
|||||||
void (*free)(struct window_pane *);
|
void (*free)(struct window_pane *);
|
||||||
void (*resize)(struct window_pane *, u_int, u_int);
|
void (*resize)(struct window_pane *, u_int, u_int);
|
||||||
void (*key)(struct window_pane *, struct client *, struct session *,
|
void (*key)(struct window_pane *, struct client *, struct session *,
|
||||||
int, struct mouse_event *);
|
key_code, struct mouse_event *);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Structures for choose mode. */
|
/* Structures for choose mode. */
|
||||||
@ -1033,31 +1039,31 @@ RB_HEAD(sessions, session);
|
|||||||
|
|
||||||
/* Mouse input. */
|
/* Mouse input. */
|
||||||
struct mouse_event {
|
struct mouse_event {
|
||||||
int valid;
|
int valid;
|
||||||
|
|
||||||
int key;
|
key_code key;
|
||||||
int statusat;
|
int statusat;
|
||||||
|
|
||||||
u_int x;
|
u_int x;
|
||||||
u_int y;
|
u_int y;
|
||||||
u_int b;
|
u_int b;
|
||||||
|
|
||||||
u_int lx;
|
u_int lx;
|
||||||
u_int ly;
|
u_int ly;
|
||||||
u_int lb;
|
u_int lb;
|
||||||
|
|
||||||
int s;
|
int s;
|
||||||
int w;
|
int w;
|
||||||
int wp;
|
int wp;
|
||||||
|
|
||||||
u_int sgr_type;
|
u_int sgr_type;
|
||||||
u_int sgr_b;
|
u_int sgr_b;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* TTY information. */
|
/* TTY information. */
|
||||||
struct tty_key {
|
struct tty_key {
|
||||||
char ch;
|
char ch;
|
||||||
int key;
|
key_code key;
|
||||||
|
|
||||||
struct tty_key *left;
|
struct tty_key *left;
|
||||||
struct tty_key *right;
|
struct tty_key *right;
|
||||||
@ -1343,7 +1349,7 @@ struct cmd_entry {
|
|||||||
|
|
||||||
/* Key binding and key table. */
|
/* Key binding and key table. */
|
||||||
struct key_binding {
|
struct key_binding {
|
||||||
int key;
|
key_code key;
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
int can_repeat;
|
int can_repeat;
|
||||||
|
|
||||||
@ -1453,7 +1459,7 @@ void paste_free(struct paste_buffer *);
|
|||||||
void paste_add(char *, size_t);
|
void paste_add(char *, size_t);
|
||||||
int paste_rename(const char *, const char *, char **);
|
int paste_rename(const char *, const char *, char **);
|
||||||
int paste_set(char *, size_t, const char *, char **);
|
int paste_set(char *, size_t, const char *, char **);
|
||||||
char *paste_make_sample(struct paste_buffer *, int);
|
char *paste_make_sample(struct paste_buffer *);
|
||||||
|
|
||||||
/* format.c */
|
/* format.c */
|
||||||
#define FORMAT_STATUS 0x1
|
#define FORMAT_STATUS 0x1
|
||||||
@ -1472,7 +1478,7 @@ void format_defaults_window(struct format_tree *, struct window *);
|
|||||||
void format_defaults_pane(struct format_tree *,
|
void format_defaults_pane(struct format_tree *,
|
||||||
struct window_pane *);
|
struct window_pane *);
|
||||||
void format_defaults_paste_buffer(struct format_tree *,
|
void format_defaults_paste_buffer(struct format_tree *,
|
||||||
struct paste_buffer *, int);
|
struct paste_buffer *);
|
||||||
|
|
||||||
/* mode-key.c */
|
/* mode-key.c */
|
||||||
extern const struct mode_key_table mode_key_tables[];
|
extern const struct mode_key_table mode_key_tables[];
|
||||||
@ -1491,7 +1497,8 @@ enum mode_key_cmd mode_key_fromstring(const struct mode_key_cmdstr *,
|
|||||||
const struct mode_key_table *mode_key_findtable(const char *);
|
const struct mode_key_table *mode_key_findtable(const char *);
|
||||||
void mode_key_init_trees(void);
|
void mode_key_init_trees(void);
|
||||||
void mode_key_init(struct mode_key_data *, struct mode_key_tree *);
|
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 */
|
/* notify.c */
|
||||||
void notify_enable(void);
|
void notify_enable(void);
|
||||||
@ -1635,9 +1642,9 @@ const char *tty_term_describe(struct tty_term *, enum tty_code_code);
|
|||||||
const char *tty_acs_get(struct tty *, u_char);
|
const char *tty_acs_get(struct tty *, u_char);
|
||||||
|
|
||||||
/* tty-keys.c */
|
/* tty-keys.c */
|
||||||
void tty_keys_build(struct tty *);
|
void tty_keys_build(struct tty *);
|
||||||
void tty_keys_free(struct tty *);
|
void tty_keys_free(struct tty *);
|
||||||
int tty_keys_next(struct tty *);
|
key_code tty_keys_next(struct tty *);
|
||||||
|
|
||||||
/* arguments.c */
|
/* arguments.c */
|
||||||
int args_cmp(struct args_entry *, struct args_entry *);
|
int args_cmp(struct args_entry *, struct args_entry *);
|
||||||
@ -1723,16 +1730,16 @@ int key_table_cmp(struct key_table *, struct key_table *);
|
|||||||
int key_bindings_cmp(struct key_binding *, struct key_binding *);
|
int key_bindings_cmp(struct key_binding *, struct key_binding *);
|
||||||
struct key_table *key_bindings_get_table(const char *, int);
|
struct key_table *key_bindings_get_table(const char *, int);
|
||||||
void key_bindings_unref_table(struct key_table *);
|
void key_bindings_unref_table(struct key_table *);
|
||||||
void key_bindings_add(const char *, int, int, struct cmd_list *);
|
void key_bindings_add(const char *, key_code, int, struct cmd_list *);
|
||||||
void key_bindings_remove(const char *, int);
|
void key_bindings_remove(const char *, key_code);
|
||||||
void key_bindings_remove_table(const char *);
|
void key_bindings_remove_table(const char *);
|
||||||
void key_bindings_init(void);
|
void key_bindings_init(void);
|
||||||
void key_bindings_dispatch(struct key_binding *, struct client *,
|
void key_bindings_dispatch(struct key_binding *, struct client *,
|
||||||
struct mouse_event *);
|
struct mouse_event *);
|
||||||
|
|
||||||
/* key-string.c */
|
/* key-string.c */
|
||||||
int key_string_lookup_string(const char *);
|
key_code key_string_lookup_string(const char *);
|
||||||
const char *key_string_lookup_key(int);
|
const char *key_string_lookup_key(key_code);
|
||||||
|
|
||||||
/* alerts.c */
|
/* alerts.c */
|
||||||
void alerts_reset_all(void);
|
void alerts_reset_all(void);
|
||||||
@ -1756,7 +1763,7 @@ void server_add_accept(int);
|
|||||||
|
|
||||||
/* server-client.c */
|
/* server-client.c */
|
||||||
int server_client_check_nested(struct client *);
|
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);
|
void server_client_create(int);
|
||||||
int server_client_open(struct client *, char **);
|
int server_client_open(struct client *, char **);
|
||||||
void server_client_unref(struct client *);
|
void server_client_unref(struct client *);
|
||||||
@ -1806,7 +1813,7 @@ void status_prompt_set(struct client *, const char *, const char *,
|
|||||||
int (*)(void *, const char *), void (*)(void *), void *, int);
|
int (*)(void *, const char *), void (*)(void *), void *, int);
|
||||||
void status_prompt_clear(struct client *);
|
void status_prompt_clear(struct client *);
|
||||||
int status_prompt_redraw(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_update(struct client *, const char *, const char *);
|
||||||
void status_prompt_load_history(void);
|
void status_prompt_load_history(void);
|
||||||
void status_prompt_save_history(void);
|
void status_prompt_save_history(void);
|
||||||
@ -1822,11 +1829,11 @@ struct evbuffer *input_pending(struct window_pane *);
|
|||||||
void input_parse(struct window_pane *);
|
void input_parse(struct window_pane *);
|
||||||
|
|
||||||
/* input-key.c */
|
/* 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 */
|
/* xterm-keys.c */
|
||||||
char *xterm_keys_lookup(int);
|
char *xterm_keys_lookup(key_code);
|
||||||
int xterm_keys_find(const char *, size_t, size_t *, int *);
|
int xterm_keys_find(const char *, size_t, size_t *, key_code *);
|
||||||
|
|
||||||
/* colour.c */
|
/* colour.c */
|
||||||
int colour_find_rgb(u_char, u_char, u_char);
|
int colour_find_rgb(u_char, u_char, u_char);
|
||||||
@ -1888,24 +1895,24 @@ void grid_view_delete_cells(struct grid *, u_int, u_int, u_int);
|
|||||||
char *grid_view_string_cells(struct grid *, u_int, u_int, u_int);
|
char *grid_view_string_cells(struct grid *, u_int, u_int, u_int);
|
||||||
|
|
||||||
/* screen-write.c */
|
/* screen-write.c */
|
||||||
void screen_write_start(
|
void screen_write_start(struct screen_write_ctx *, struct window_pane *,
|
||||||
struct screen_write_ctx *, struct window_pane *, struct screen *);
|
struct screen *);
|
||||||
void screen_write_stop(struct screen_write_ctx *);
|
void screen_write_stop(struct screen_write_ctx *);
|
||||||
void screen_write_reset(struct screen_write_ctx *);
|
void screen_write_reset(struct screen_write_ctx *);
|
||||||
size_t printflike(2, 3) screen_write_cstrlen(int, const char *, ...);
|
size_t printflike(1, 2) screen_write_cstrlen(const char *, ...);
|
||||||
void printflike(5, 6) screen_write_cnputs(struct screen_write_ctx *,
|
void printflike(4, 5) screen_write_cnputs(struct screen_write_ctx *,
|
||||||
ssize_t, struct grid_cell *, int, const char *, ...);
|
ssize_t, struct grid_cell *, const char *, ...);
|
||||||
size_t printflike(2, 3) screen_write_strlen(int, const char *, ...);
|
size_t printflike(1, 2) screen_write_strlen(const char *, ...);
|
||||||
void printflike(3, 4) screen_write_puts(struct screen_write_ctx *,
|
void printflike(3, 4) screen_write_puts(struct screen_write_ctx *,
|
||||||
struct grid_cell *, const char *, ...);
|
struct grid_cell *, const char *, ...);
|
||||||
void printflike(5, 6) screen_write_nputs(struct screen_write_ctx *,
|
void printflike(4, 5) screen_write_nputs(struct screen_write_ctx *,
|
||||||
ssize_t, struct grid_cell *, int, const char *, ...);
|
ssize_t, struct grid_cell *, const char *, ...);
|
||||||
void screen_write_vnputs(struct screen_write_ctx *,
|
void screen_write_vnputs(struct screen_write_ctx *, ssize_t,
|
||||||
ssize_t, struct grid_cell *, int, const char *, va_list);
|
struct grid_cell *, const char *, va_list);
|
||||||
void screen_write_putc(
|
void screen_write_putc(struct screen_write_ctx *, struct grid_cell *,
|
||||||
struct screen_write_ctx *, struct grid_cell *, u_char);
|
u_char);
|
||||||
void screen_write_copy(struct screen_write_ctx *,
|
void screen_write_copy(struct screen_write_ctx *, struct screen *, u_int,
|
||||||
struct screen *, u_int, u_int, u_int, u_int);
|
u_int, u_int, u_int);
|
||||||
void screen_write_backspace(struct screen_write_ctx *);
|
void screen_write_backspace(struct screen_write_ctx *);
|
||||||
void screen_write_mode_set(struct screen_write_ctx *, int);
|
void screen_write_mode_set(struct screen_write_ctx *, int);
|
||||||
void screen_write_mode_clear(struct screen_write_ctx *, int);
|
void screen_write_mode_clear(struct screen_write_ctx *, int);
|
||||||
@ -2023,7 +2030,7 @@ int window_pane_set_mode(
|
|||||||
struct window_pane *, const struct window_mode *);
|
struct window_pane *, const struct window_mode *);
|
||||||
void window_pane_reset_mode(struct window_pane *);
|
void window_pane_reset_mode(struct window_pane *);
|
||||||
void window_pane_key(struct window_pane *, struct client *,
|
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 *);
|
int window_pane_visible(struct window_pane *);
|
||||||
char *window_pane_search(
|
char *window_pane_search(
|
||||||
struct window_pane *, const char *, u_int *);
|
struct window_pane *, const char *, u_int *);
|
||||||
@ -2182,8 +2189,10 @@ void utf8_set(struct utf8_data *, u_char);
|
|||||||
int utf8_open(struct utf8_data *, u_char);
|
int utf8_open(struct utf8_data *, u_char);
|
||||||
int utf8_append(struct utf8_data *, u_char);
|
int utf8_append(struct utf8_data *, u_char);
|
||||||
u_int utf8_combine(const struct utf8_data *);
|
u_int utf8_combine(const struct utf8_data *);
|
||||||
|
int utf8_split(u_int, struct utf8_data *);
|
||||||
u_int utf8_split2(u_int, u_char *);
|
u_int utf8_split2(u_int, u_char *);
|
||||||
int utf8_strvis(char *, const char *, size_t, int);
|
int utf8_strvis(char *, const char *, size_t, int);
|
||||||
|
char *utf8_sanitize(const char *);
|
||||||
struct utf8_data *utf8_fromcstr(const char *);
|
struct utf8_data *utf8_fromcstr(const char *);
|
||||||
char *utf8_tocstr(struct utf8_data *);
|
char *utf8_tocstr(struct utf8_data *);
|
||||||
u_int utf8_cstrwidth(const char *);
|
u_int utf8_cstrwidth(const char *);
|
||||||
|
62
tty-keys.c
62
tty-keys.c
@ -33,11 +33,11 @@
|
|||||||
* into a ternary tree.
|
* into a ternary tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void tty_keys_add1(struct tty_key **, const char *, int);
|
void tty_keys_add1(struct tty_key **, const char *, key_code);
|
||||||
void tty_keys_add(struct tty *, const char *, int);
|
void tty_keys_add(struct tty *, const char *, key_code);
|
||||||
void tty_keys_free1(struct tty_key *);
|
void tty_keys_free1(struct tty_key *);
|
||||||
struct tty_key *tty_keys_find1(
|
struct tty_key *tty_keys_find1(struct tty_key *, const char *, size_t,
|
||||||
struct tty_key *, const char *, size_t, size_t *);
|
size_t *);
|
||||||
struct tty_key *tty_keys_find(struct tty *, const char *, size_t, size_t *);
|
struct tty_key *tty_keys_find(struct tty *, const char *, size_t, size_t *);
|
||||||
void tty_keys_callback(int, short, void *);
|
void tty_keys_callback(int, short, void *);
|
||||||
int tty_keys_mouse(struct tty *, const char *, size_t, size_t *);
|
int tty_keys_mouse(struct tty *, const char *, size_t, size_t *);
|
||||||
@ -45,7 +45,7 @@ int tty_keys_mouse(struct tty *, const char *, size_t, size_t *);
|
|||||||
/* Default raw keys. */
|
/* Default raw keys. */
|
||||||
struct tty_default_key_raw {
|
struct tty_default_key_raw {
|
||||||
const char *string;
|
const char *string;
|
||||||
int key;
|
key_code key;
|
||||||
};
|
};
|
||||||
const struct tty_default_key_raw tty_default_raw_keys[] = {
|
const struct tty_default_key_raw tty_default_raw_keys[] = {
|
||||||
/*
|
/*
|
||||||
@ -165,7 +165,7 @@ const struct tty_default_key_raw tty_default_raw_keys[] = {
|
|||||||
/* Default terminfo(5) keys. */
|
/* Default terminfo(5) keys. */
|
||||||
struct tty_default_key_code {
|
struct tty_default_key_code {
|
||||||
enum tty_code_code code;
|
enum tty_code_code code;
|
||||||
int key;
|
key_code key;
|
||||||
};
|
};
|
||||||
const struct tty_default_key_code tty_default_code_keys[] = {
|
const struct tty_default_key_code tty_default_code_keys[] = {
|
||||||
/* Function keys. */
|
/* Function keys. */
|
||||||
@ -317,7 +317,7 @@ const struct tty_default_key_code tty_default_code_keys[] = {
|
|||||||
|
|
||||||
/* Add key to tree. */
|
/* Add key to tree. */
|
||||||
void
|
void
|
||||||
tty_keys_add(struct tty *tty, const char *s, int key)
|
tty_keys_add(struct tty *tty, const char *s, key_code key)
|
||||||
{
|
{
|
||||||
struct tty_key *tk;
|
struct tty_key *tk;
|
||||||
size_t size;
|
size_t size;
|
||||||
@ -325,17 +325,17 @@ tty_keys_add(struct tty *tty, const char *s, int key)
|
|||||||
|
|
||||||
keystr = key_string_lookup_key(key);
|
keystr = key_string_lookup_key(key);
|
||||||
if ((tk = tty_keys_find(tty, s, strlen(s), &size)) == NULL) {
|
if ((tk = tty_keys_find(tty, s, strlen(s), &size)) == NULL) {
|
||||||
log_debug("new key %s: 0x%x (%s)", s, key, keystr);
|
log_debug("new key %s: 0x%llx (%s)", s, key, keystr);
|
||||||
tty_keys_add1(&tty->key_tree, s, key);
|
tty_keys_add1(&tty->key_tree, s, key);
|
||||||
} else {
|
} else {
|
||||||
log_debug("replacing key %s: 0x%x (%s)", s, key, keystr);
|
log_debug("replacing key %s: 0x%llx (%s)", s, key, keystr);
|
||||||
tk->key = key;
|
tk->key = key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add next node to the tree. */
|
/* Add next node to the tree. */
|
||||||
void
|
void
|
||||||
tty_keys_add1(struct tty_key **tkp, const char *s, int key)
|
tty_keys_add1(struct tty_key **tkp, const char *s, key_code key)
|
||||||
{
|
{
|
||||||
struct tty_key *tk;
|
struct tty_key *tk;
|
||||||
|
|
||||||
@ -464,15 +464,18 @@ tty_keys_find1(struct tty_key *tk, const char *buf, size_t len, size_t *size)
|
|||||||
* Process at least one key in the buffer and invoke tty->key_callback. Return
|
* Process at least one key in the buffer and invoke tty->key_callback. Return
|
||||||
* 0 if there are no further keys, or 1 if there could be more in the buffer.
|
* 0 if there are no further keys, or 1 if there could be more in the buffer.
|
||||||
*/
|
*/
|
||||||
int
|
key_code
|
||||||
tty_keys_next(struct tty *tty)
|
tty_keys_next(struct tty *tty)
|
||||||
{
|
{
|
||||||
struct tty_key *tk;
|
struct tty_key *tk;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
const char *buf;
|
const char *buf;
|
||||||
size_t len, size;
|
size_t len, size;
|
||||||
cc_t bspace;
|
cc_t bspace;
|
||||||
int key, delay, expired = 0;
|
int delay, expired = 0;
|
||||||
|
key_code key;
|
||||||
|
struct utf8_data utf8data;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
/* Get key buffer. */
|
/* Get key buffer. */
|
||||||
buf = EVBUFFER_DATA(tty->event->input);
|
buf = EVBUFFER_DATA(tty->event->input);
|
||||||
@ -535,8 +538,23 @@ first_key:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Is this valid UTF-8? */
|
||||||
|
if (utf8_open(&utf8data, (u_char)*buf)) {
|
||||||
|
size = utf8data.size;
|
||||||
|
if (len < size) {
|
||||||
|
if (expired)
|
||||||
|
goto discard_key;
|
||||||
|
goto partial_key;
|
||||||
|
}
|
||||||
|
for (i = 1; i < size; i++)
|
||||||
|
utf8_append(&utf8data, (u_char)buf[i]);
|
||||||
|
key = utf8_combine(&utf8data);
|
||||||
|
log_debug("UTF-8 key %.*s %#llx", (int)size, buf, key);
|
||||||
|
goto complete_key;
|
||||||
|
}
|
||||||
|
|
||||||
/* No key found, take first. */
|
/* No key found, take first. */
|
||||||
key = (u_char) *buf;
|
key = (u_char)*buf;
|
||||||
size = 1;
|
size = 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -578,7 +596,7 @@ partial_key:
|
|||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
complete_key:
|
complete_key:
|
||||||
log_debug("complete key %.*s %#x", (int) size, buf, key);
|
log_debug("complete key %.*s %#llx", (int)size, buf, key);
|
||||||
|
|
||||||
/* Remove data from buffer. */
|
/* Remove data from buffer. */
|
||||||
evbuffer_drain(tty->event->input, size);
|
evbuffer_drain(tty->event->input, size);
|
||||||
@ -604,7 +622,7 @@ complete_key:
|
|||||||
return (1);
|
return (1);
|
||||||
|
|
||||||
discard_key:
|
discard_key:
|
||||||
log_debug("discard key %.*s %#x", (int) size, buf, key);
|
log_debug("discard key %.*s %#llx", (int)size, buf, key);
|
||||||
|
|
||||||
/* Remove data from buffer. */
|
/* Remove data from buffer. */
|
||||||
evbuffer_drain(tty->event->input, size);
|
evbuffer_drain(tty->event->input, size);
|
||||||
@ -684,10 +702,10 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size)
|
|||||||
utf8_append(&utf8data, buf[*size]);
|
utf8_append(&utf8data, buf[*size]);
|
||||||
value = utf8_combine(&utf8data);
|
value = utf8_combine(&utf8data);
|
||||||
} else
|
} else
|
||||||
value = (u_char) buf[*size];
|
value = (u_char)buf[*size];
|
||||||
(*size)++;
|
(*size)++;
|
||||||
} else {
|
} else {
|
||||||
value = (u_char) buf[*size];
|
value = (u_char)buf[*size];
|
||||||
(*size)++;
|
(*size)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
78
utf8.c
78
utf8.c
@ -393,6 +393,8 @@ utf8_open(struct utf8_data *utf8data, u_char ch)
|
|||||||
int
|
int
|
||||||
utf8_append(struct utf8_data *utf8data, u_char ch)
|
utf8_append(struct utf8_data *utf8data, u_char ch)
|
||||||
{
|
{
|
||||||
|
/* XXX this should do validity checks too! */
|
||||||
|
|
||||||
if (utf8data->have >= utf8data->size)
|
if (utf8data->have >= utf8data->size)
|
||||||
fatalx("UTF-8 character overflow");
|
fatalx("UTF-8 character overflow");
|
||||||
if (utf8data->size > sizeof utf8data->data)
|
if (utf8data->size > sizeof utf8data->data)
|
||||||
@ -466,18 +468,46 @@ utf8_combine(const struct utf8_data *utf8data)
|
|||||||
case 3:
|
case 3:
|
||||||
value = utf8data->data[2] & 0x3f;
|
value = utf8data->data[2] & 0x3f;
|
||||||
value |= (utf8data->data[1] & 0x3f) << 6;
|
value |= (utf8data->data[1] & 0x3f) << 6;
|
||||||
value |= (utf8data->data[0] & 0x0f) << 12;
|
value |= (utf8data->data[0] & 0xf) << 12;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
value = utf8data->data[3] & 0x3f;
|
value = utf8data->data[3] & 0x3f;
|
||||||
value |= (utf8data->data[2] & 0x3f) << 6;
|
value |= (utf8data->data[2] & 0x3f) << 6;
|
||||||
value |= (utf8data->data[1] & 0x3f) << 12;
|
value |= (utf8data->data[1] & 0x3f) << 12;
|
||||||
value |= (utf8data->data[0] & 0x07) << 18;
|
value |= (utf8data->data[0] & 0x7) << 18;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return (value);
|
return (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Split a UTF-8 character. */
|
||||||
|
int
|
||||||
|
utf8_split(u_int uc, struct utf8_data *utf8data)
|
||||||
|
{
|
||||||
|
if (uc < 0x7f) {
|
||||||
|
utf8data->size = 1;
|
||||||
|
utf8data->data[0] = uc;
|
||||||
|
} else if (uc < 0x7ff) {
|
||||||
|
utf8data->size = 2;
|
||||||
|
utf8data->data[0] = 0xc0 | ((uc >> 6) & 0x1f);
|
||||||
|
utf8data->data[1] = 0x80 | (uc & 0x3f);
|
||||||
|
} else if (uc < 0xffff) {
|
||||||
|
utf8data->size = 3;
|
||||||
|
utf8data->data[0] = 0xe0 | ((uc >> 12) & 0xf);
|
||||||
|
utf8data->data[1] = 0x80 | ((uc >> 6) & 0x3f);
|
||||||
|
utf8data->data[2] = 0x80 | (uc & 0x3f);
|
||||||
|
} else if (uc < 0x1fffff) {
|
||||||
|
utf8data->size = 4;
|
||||||
|
utf8data->data[0] = 0xf0 | ((uc >> 18) & 0x7);
|
||||||
|
utf8data->data[1] = 0x80 | ((uc >> 12) & 0x3f);
|
||||||
|
utf8data->data[2] = 0x80 | ((uc >> 6) & 0x3f);
|
||||||
|
utf8data->data[3] = 0x80 | (uc & 0x3f);
|
||||||
|
} else
|
||||||
|
return (-1);
|
||||||
|
utf8data->width = utf8_width(utf8data);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
/* Split a two-byte UTF-8 character. */
|
/* Split a two-byte UTF-8 character. */
|
||||||
u_int
|
u_int
|
||||||
utf8_split2(u_int uc, u_char *ptr)
|
utf8_split2(u_int uc, u_char *ptr)
|
||||||
@ -554,6 +584,50 @@ utf8_strvis(char *dst, const char *src, size_t len, int flag)
|
|||||||
return (dst - start);
|
return (dst - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sanitize a string, changing any UTF-8 characters to '_'. Caller should free
|
||||||
|
* the returned string. Anything not valid printable ASCII or UTF-8 is
|
||||||
|
* stripped.
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
utf8_sanitize(const char *src)
|
||||||
|
{
|
||||||
|
char *dst;
|
||||||
|
size_t n;
|
||||||
|
int more;
|
||||||
|
struct utf8_data utf8data;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
dst = NULL;
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
while (*src != '\0') {
|
||||||
|
dst = xreallocarray(dst, n + 1, sizeof *dst);
|
||||||
|
if (utf8_open(&utf8data, *src)) {
|
||||||
|
more = 1;
|
||||||
|
while (*++src != '\0' && more)
|
||||||
|
more = utf8_append(&utf8data, *src);
|
||||||
|
if (!more) {
|
||||||
|
dst = xreallocarray(dst, n + utf8data.width,
|
||||||
|
sizeof *dst);
|
||||||
|
for (i = 0; i < utf8data.width; i++)
|
||||||
|
dst[n++] = '_';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
src -= utf8data.have;
|
||||||
|
}
|
||||||
|
if (*src > 0x1f && *src < 0x7f)
|
||||||
|
dst[n] = *src;
|
||||||
|
src++;
|
||||||
|
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
|
||||||
|
dst = xreallocarray(dst, n + 1, sizeof *dst);
|
||||||
|
dst[n] = '\0';
|
||||||
|
return (dst);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert a string into a buffer of UTF-8 characters. Terminated by size == 0.
|
* Convert a string into a buffer of UTF-8 characters. Terminated by size == 0.
|
||||||
* Caller frees.
|
* Caller frees.
|
||||||
|
@ -29,11 +29,11 @@ struct screen *window_choose_init(struct window_pane *);
|
|||||||
void window_choose_free(struct window_pane *);
|
void window_choose_free(struct window_pane *);
|
||||||
void window_choose_resize(struct window_pane *, u_int, u_int);
|
void window_choose_resize(struct window_pane *, u_int, u_int);
|
||||||
void window_choose_key(struct window_pane *, struct client *,
|
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 *);
|
void window_choose_default_callback(struct window_choose_data *);
|
||||||
struct window_choose_mode_item *window_choose_get_item(struct window_pane *,
|
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(
|
void window_choose_fire_callback(
|
||||||
struct window_pane *, struct window_choose_data *);
|
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 *);
|
void window_choose_free1(struct window_choose_mode_data *);
|
||||||
int window_choose_key_index(struct window_choose_mode_data *, u_int);
|
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,
|
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 window_choose_reset_top(struct window_pane *, u_int);
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -314,7 +314,7 @@ window_choose_fire_callback(
|
|||||||
|
|
||||||
void
|
void
|
||||||
window_choose_prompt_input(enum window_choose_input_type input_type,
|
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;
|
struct window_choose_mode_data *data = wp->modedata;
|
||||||
size_t input_len;
|
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 *
|
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;
|
struct window_choose_mode_data *data = wp->modedata;
|
||||||
u_int x, y, idx;
|
u_int x, y, idx;
|
||||||
@ -509,7 +510,7 @@ window_choose_get_item(struct window_pane *wp, int key, struct mouse_event *m)
|
|||||||
|
|
||||||
void
|
void
|
||||||
window_choose_key(struct window_pane *wp, unused struct client *c,
|
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 window_choose_mode_data *data = wp->modedata;
|
||||||
struct screen *s = &data->screen;
|
struct screen *s = &data->screen;
|
||||||
@ -743,8 +744,8 @@ window_choose_key(struct window_pane *wp, unused struct client *c,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
window_choose_write_line(
|
window_choose_write_line(struct window_pane *wp, struct screen_write_ctx *ctx,
|
||||||
struct window_pane *wp, struct screen_write_ctx *ctx, u_int py)
|
u_int py)
|
||||||
{
|
{
|
||||||
struct window_choose_mode_data *data = wp->modedata;
|
struct window_choose_mode_data *data = wp->modedata;
|
||||||
struct window_choose_mode_item *item;
|
struct window_choose_mode_item *item;
|
||||||
@ -753,13 +754,12 @@ window_choose_write_line(
|
|||||||
struct grid_cell gc;
|
struct grid_cell gc;
|
||||||
size_t last, xoff = 0;
|
size_t last, xoff = 0;
|
||||||
char hdr[32], label[32];
|
char hdr[32], label[32];
|
||||||
int utf8flag, key;
|
int key;
|
||||||
|
|
||||||
if (data->callbackfn == NULL)
|
if (data->callbackfn == NULL)
|
||||||
fatalx("called before callback assigned");
|
fatalx("called before callback assigned");
|
||||||
|
|
||||||
last = screen_size_y(s) - 1;
|
last = screen_size_y(s) - 1;
|
||||||
utf8flag = options_get_number(wp->window->options, "utf8");
|
|
||||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
memcpy(&gc, &grid_default_cell, sizeof gc);
|
||||||
if (data->selected == data->top + py)
|
if (data->selected == data->top + py)
|
||||||
style_apply(&gc, oo, "mode-style");
|
style_apply(&gc, oo, "mode-style");
|
||||||
@ -776,7 +776,7 @@ window_choose_write_line(
|
|||||||
xsnprintf(label, sizeof label, "(%c)", key);
|
xsnprintf(label, sizeof label, "(%c)", key);
|
||||||
else
|
else
|
||||||
xsnprintf(label, sizeof label, "(%d)", item->pos);
|
xsnprintf(label, sizeof label, "(%d)", item->pos);
|
||||||
screen_write_nputs(ctx, screen_size_x(s) - 1, &gc, utf8flag,
|
screen_write_nputs(ctx, screen_size_x(s) - 1, &gc,
|
||||||
"%*s %s %s", data->width + 2, label,
|
"%*s %s %s", data->width + 2, label,
|
||||||
/*
|
/*
|
||||||
* Add indication to tree if necessary about whether it's
|
* Add indication to tree if necessary about whether it's
|
||||||
@ -821,7 +821,7 @@ window_choose_key_index(struct window_choose_mode_data *data, u_int idx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
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"
|
static const char keys[] = "0123456789"
|
||||||
"abcdefghijklmnopqrstuvwxyz"
|
"abcdefghijklmnopqrstuvwxyz"
|
||||||
@ -834,7 +834,7 @@ window_choose_index_key(struct window_choose_mode_data *data, int key)
|
|||||||
mkey = mode_key_lookup(&data->mdata, *ptr, NULL);
|
mkey = mode_key_lookup(&data->mdata, *ptr, NULL);
|
||||||
if (mkey != MODEKEY_NONE && mkey != MODEKEY_OTHER)
|
if (mkey != MODEKEY_NONE && mkey != MODEKEY_OTHER)
|
||||||
continue;
|
continue;
|
||||||
if (key == *ptr)
|
if (key == (key_code)*ptr)
|
||||||
return (idx);
|
return (idx);
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ struct screen *window_clock_init(struct window_pane *);
|
|||||||
void window_clock_free(struct window_pane *);
|
void window_clock_free(struct window_pane *);
|
||||||
void window_clock_resize(struct window_pane *, u_int, u_int);
|
void window_clock_resize(struct window_pane *, u_int, u_int);
|
||||||
void window_clock_key(struct window_pane *, struct client *,
|
void window_clock_key(struct window_pane *, struct client *,
|
||||||
struct session *, int, struct mouse_event *);
|
struct session *, key_code, struct mouse_event *);
|
||||||
|
|
||||||
void window_clock_timer_callback(int, short, void *);
|
void window_clock_timer_callback(int, short, void *);
|
||||||
void window_clock_draw_screen(struct window_pane *);
|
void window_clock_draw_screen(struct window_pane *);
|
||||||
@ -186,7 +186,8 @@ window_clock_resize(struct window_pane *wp, u_int sx, u_int sy)
|
|||||||
|
|
||||||
void
|
void
|
||||||
window_clock_key(struct window_pane *wp, unused struct client *c,
|
window_clock_key(struct window_pane *wp, unused struct client *c,
|
||||||
unused struct session *sess, unused int key, unused struct mouse_event *m)
|
unused struct session *sess, unused key_code key,
|
||||||
|
unused struct mouse_event *m)
|
||||||
{
|
{
|
||||||
window_pane_reset_mode(wp);
|
window_pane_reset_mode(wp);
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,9 @@ struct screen *window_copy_init(struct window_pane *);
|
|||||||
void window_copy_free(struct window_pane *);
|
void window_copy_free(struct window_pane *);
|
||||||
void window_copy_resize(struct window_pane *, u_int, u_int);
|
void window_copy_resize(struct window_pane *, u_int, u_int);
|
||||||
void window_copy_key(struct window_pane *, struct client *, struct session *,
|
void window_copy_key(struct window_pane *, struct client *, struct session *,
|
||||||
int, struct mouse_event *);
|
key_code, struct mouse_event *);
|
||||||
int window_copy_key_input(struct window_pane *, int);
|
int window_copy_key_input(struct window_pane *, key_code);
|
||||||
int window_copy_key_numeric_prefix(struct window_pane *, int);
|
int window_copy_key_numeric_prefix(struct window_pane *, key_code);
|
||||||
|
|
||||||
void window_copy_redraw_selection(struct window_pane *, u_int);
|
void window_copy_redraw_selection(struct window_pane *, u_int);
|
||||||
void window_copy_redraw_lines(struct window_pane *, u_int, u_int);
|
void window_copy_redraw_lines(struct window_pane *, u_int, u_int);
|
||||||
@ -280,13 +280,11 @@ window_copy_vadd(struct window_pane *wp, const char *fmt, va_list ap)
|
|||||||
struct screen *backing = data->backing;
|
struct screen *backing = data->backing;
|
||||||
struct screen_write_ctx back_ctx, ctx;
|
struct screen_write_ctx back_ctx, ctx;
|
||||||
struct grid_cell gc;
|
struct grid_cell gc;
|
||||||
int utf8flag;
|
|
||||||
u_int old_hsize, old_cy;
|
u_int old_hsize, old_cy;
|
||||||
|
|
||||||
if (backing == &wp->base)
|
if (backing == &wp->base)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
utf8flag = options_get_number(wp->window->options, "utf8");
|
|
||||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
memcpy(&gc, &grid_default_cell, sizeof gc);
|
||||||
|
|
||||||
old_hsize = screen_hsize(data->backing);
|
old_hsize = screen_hsize(data->backing);
|
||||||
@ -301,7 +299,7 @@ window_copy_vadd(struct window_pane *wp, const char *fmt, va_list ap)
|
|||||||
} else
|
} else
|
||||||
data->backing_written = 1;
|
data->backing_written = 1;
|
||||||
old_cy = backing->cy;
|
old_cy = backing->cy;
|
||||||
screen_write_vnputs(&back_ctx, 0, &gc, utf8flag, fmt, ap);
|
screen_write_vnputs(&back_ctx, 0, &gc, fmt, ap);
|
||||||
screen_write_stop(&back_ctx);
|
screen_write_stop(&back_ctx);
|
||||||
|
|
||||||
data->oy += screen_hsize(data->backing) - old_hsize;
|
data->oy += screen_hsize(data->backing) - old_hsize;
|
||||||
@ -368,7 +366,7 @@ window_copy_resize(struct window_pane *wp, u_int sx, u_int sy)
|
|||||||
|
|
||||||
void
|
void
|
||||||
window_copy_key(struct window_pane *wp, struct client *c, struct session *sess,
|
window_copy_key(struct window_pane *wp, struct client *c, struct session *sess,
|
||||||
int key, struct mouse_event *m)
|
key_code key, struct mouse_event *m)
|
||||||
{
|
{
|
||||||
const char *word_separators;
|
const char *word_separators;
|
||||||
struct window_copy_mode_data *data = wp->modedata;
|
struct window_copy_mode_data *data = wp->modedata;
|
||||||
@ -800,7 +798,7 @@ input_off:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
window_copy_key_input(struct window_pane *wp, int key)
|
window_copy_key_input(struct window_pane *wp, key_code key)
|
||||||
{
|
{
|
||||||
struct window_copy_mode_data *data = wp->modedata;
|
struct window_copy_mode_data *data = wp->modedata;
|
||||||
struct screen *s = &data->screen;
|
struct screen *s = &data->screen;
|
||||||
@ -897,7 +895,7 @@ window_copy_key_input(struct window_pane *wp, int key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
window_copy_key_numeric_prefix(struct window_pane *wp, int key)
|
window_copy_key_numeric_prefix(struct window_pane *wp, key_code key)
|
||||||
{
|
{
|
||||||
struct window_copy_mode_data *data = wp->modedata;
|
struct window_copy_mode_data *data = wp->modedata;
|
||||||
struct screen *s = &data->screen;
|
struct screen *s = &data->screen;
|
||||||
@ -1021,19 +1019,18 @@ window_copy_search_up(struct window_pane *wp, const char *searchstr)
|
|||||||
struct grid_cell gc;
|
struct grid_cell gc;
|
||||||
size_t searchlen;
|
size_t searchlen;
|
||||||
u_int i, last, fx, fy, px;
|
u_int i, last, fx, fy, px;
|
||||||
int utf8flag, n, wrapped, wrapflag, cis;
|
int n, wrapped, wrapflag, cis;
|
||||||
const char *ptr;
|
const char *ptr;
|
||||||
|
|
||||||
if (*searchstr == '\0')
|
if (*searchstr == '\0')
|
||||||
return;
|
return;
|
||||||
utf8flag = options_get_number(wp->window->options, "utf8");
|
|
||||||
wrapflag = options_get_number(wp->window->options, "wrap-search");
|
wrapflag = options_get_number(wp->window->options, "wrap-search");
|
||||||
searchlen = screen_write_strlen(utf8flag, "%s", searchstr);
|
searchlen = screen_write_strlen("%s", searchstr);
|
||||||
|
|
||||||
screen_init(&ss, searchlen, 1, 0);
|
screen_init(&ss, searchlen, 1, 0);
|
||||||
screen_write_start(&ctx, NULL, &ss);
|
screen_write_start(&ctx, NULL, &ss);
|
||||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
memcpy(&gc, &grid_default_cell, sizeof gc);
|
||||||
screen_write_nputs(&ctx, -1, &gc, utf8flag, "%s", searchstr);
|
screen_write_nputs(&ctx, -1, &gc, "%s", searchstr);
|
||||||
screen_write_stop(&ctx);
|
screen_write_stop(&ctx);
|
||||||
|
|
||||||
fx = data->cx;
|
fx = data->cx;
|
||||||
@ -1088,19 +1085,18 @@ window_copy_search_down(struct window_pane *wp, const char *searchstr)
|
|||||||
struct grid_cell gc;
|
struct grid_cell gc;
|
||||||
size_t searchlen;
|
size_t searchlen;
|
||||||
u_int i, first, fx, fy, px;
|
u_int i, first, fx, fy, px;
|
||||||
int utf8flag, n, wrapped, wrapflag, cis;
|
int n, wrapped, wrapflag, cis;
|
||||||
const char *ptr;
|
const char *ptr;
|
||||||
|
|
||||||
if (*searchstr == '\0')
|
if (*searchstr == '\0')
|
||||||
return;
|
return;
|
||||||
utf8flag = options_get_number(wp->window->options, "utf8");
|
|
||||||
wrapflag = options_get_number(wp->window->options, "wrap-search");
|
wrapflag = options_get_number(wp->window->options, "wrap-search");
|
||||||
searchlen = screen_write_strlen(utf8flag, "%s", searchstr);
|
searchlen = screen_write_strlen("%s", searchstr);
|
||||||
|
|
||||||
screen_init(&ss, searchlen, 1, 0);
|
screen_init(&ss, searchlen, 1, 0);
|
||||||
screen_write_start(&ctx, NULL, &ss);
|
screen_write_start(&ctx, NULL, &ss);
|
||||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
memcpy(&gc, &grid_default_cell, sizeof gc);
|
||||||
screen_write_nputs(&ctx, -1, &gc, utf8flag, "%s", searchstr);
|
screen_write_nputs(&ctx, -1, &gc, "%s", searchstr);
|
||||||
screen_write_stop(&ctx);
|
screen_write_stop(&ctx);
|
||||||
|
|
||||||
fx = data->cx;
|
fx = data->cx;
|
||||||
|
2
window.c
2
window.c
@ -1116,7 +1116,7 @@ window_pane_reset_mode(struct window_pane *wp)
|
|||||||
|
|
||||||
void
|
void
|
||||||
window_pane_key(struct window_pane *wp, struct client *c, struct session *s,
|
window_pane_key(struct window_pane *wp, struct client *c, struct session *s,
|
||||||
int key, struct mouse_event *m)
|
key_code key, struct mouse_event *m)
|
||||||
{
|
{
|
||||||
struct window_pane *wp2;
|
struct window_pane *wp2;
|
||||||
|
|
||||||
|
21
xterm-keys.c
21
xterm-keys.c
@ -40,11 +40,12 @@
|
|||||||
* We accept any but always output the latter (it comes first in the table).
|
* We accept any but always output the latter (it comes first in the table).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int xterm_keys_match(const char *, const char *, size_t, size_t *, u_int *);
|
int xterm_keys_match(const char *, const char *, size_t, size_t *,
|
||||||
int xterm_keys_modifiers(const char *, size_t, size_t *, u_int *);
|
key_code *);
|
||||||
|
int xterm_keys_modifiers(const char *, size_t, size_t *, key_code *);
|
||||||
|
|
||||||
struct xterm_keys_entry {
|
struct xterm_keys_entry {
|
||||||
int key;
|
key_code key;
|
||||||
const char *template;
|
const char *template;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -115,7 +116,7 @@ const struct xterm_keys_entry xterm_keys_table[] = {
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xterm_keys_match(const char *template, const char *buf, size_t len,
|
xterm_keys_match(const char *template, const char *buf, size_t len,
|
||||||
size_t *size, u_int *modifiers)
|
size_t *size, key_code *modifiers)
|
||||||
{
|
{
|
||||||
size_t pos;
|
size_t pos;
|
||||||
int retval;
|
int retval;
|
||||||
@ -148,7 +149,8 @@ xterm_keys_match(const char *template, const char *buf, size_t len,
|
|||||||
|
|
||||||
/* Find modifiers from buffer. */
|
/* Find modifiers from buffer. */
|
||||||
int
|
int
|
||||||
xterm_keys_modifiers(const char *buf, size_t len, size_t *pos, u_int *modifiers)
|
xterm_keys_modifiers(const char *buf, size_t len, size_t *pos,
|
||||||
|
key_code *modifiers)
|
||||||
{
|
{
|
||||||
u_int flags;
|
u_int flags;
|
||||||
|
|
||||||
@ -179,11 +181,12 @@ xterm_keys_modifiers(const char *buf, size_t len, size_t *pos, u_int *modifiers)
|
|||||||
* key), -1 for not found, 1 for partial match.
|
* key), -1 for not found, 1 for partial match.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xterm_keys_find(const char *buf, size_t len, size_t *size, int *key)
|
xterm_keys_find(const char *buf, size_t len, size_t *size, key_code *key)
|
||||||
{
|
{
|
||||||
const struct xterm_keys_entry *entry;
|
const struct xterm_keys_entry *entry;
|
||||||
u_int i, modifiers;
|
u_int i;
|
||||||
int matched;
|
int matched;
|
||||||
|
key_code modifiers;
|
||||||
|
|
||||||
for (i = 0; i < nitems(xterm_keys_table); i++) {
|
for (i = 0; i < nitems(xterm_keys_table); i++) {
|
||||||
entry = &xterm_keys_table[i];
|
entry = &xterm_keys_table[i];
|
||||||
@ -201,11 +204,11 @@ xterm_keys_find(const char *buf, size_t len, size_t *size, int *key)
|
|||||||
|
|
||||||
/* Lookup a key number from the table. */
|
/* Lookup a key number from the table. */
|
||||||
char *
|
char *
|
||||||
xterm_keys_lookup(int key)
|
xterm_keys_lookup(key_code key)
|
||||||
{
|
{
|
||||||
const struct xterm_keys_entry *entry;
|
const struct xterm_keys_entry *entry;
|
||||||
u_int i;
|
u_int i;
|
||||||
int modifiers;
|
key_code modifiers;
|
||||||
char *out;
|
char *out;
|
||||||
|
|
||||||
modifiers = 1;
|
modifiers = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user