mirror of
https://github.com/tmux/tmux.git
synced 2025-09-08 12:28:19 +00:00
Merge branch 'obsd-master'
This commit is contained in:
24
cmd-queue.c
24
cmd-queue.c
@@ -66,6 +66,7 @@ cmdq_append(struct client *c, struct cmdq_item *item)
|
|||||||
|
|
||||||
item->queue = queue;
|
item->queue = queue;
|
||||||
TAILQ_INSERT_TAIL(queue, item, entry);
|
TAILQ_INSERT_TAIL(queue, item, entry);
|
||||||
|
log_debug("%s %s: %s", __func__, cmdq_name(c), item->name);
|
||||||
|
|
||||||
item = next;
|
item = next;
|
||||||
} while (item != NULL);
|
} while (item != NULL);
|
||||||
@@ -81,18 +82,17 @@ cmdq_insert_after(struct cmdq_item *after, struct cmdq_item *item)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
next = item->next;
|
next = item->next;
|
||||||
item->next = NULL;
|
item->next = after->next;
|
||||||
|
after->next = item;
|
||||||
|
|
||||||
if (c != NULL)
|
if (c != NULL)
|
||||||
c->references++;
|
c->references++;
|
||||||
item->client = c;
|
item->client = c;
|
||||||
|
|
||||||
item->queue = queue;
|
item->queue = queue;
|
||||||
if (after->next != NULL)
|
TAILQ_INSERT_AFTER(queue, after, item, entry);
|
||||||
TAILQ_INSERT_AFTER(queue, after->next, item, entry);
|
log_debug("%s %s: %s after %s", __func__, cmdq_name(c),
|
||||||
else
|
item->name, after->name);
|
||||||
TAILQ_INSERT_AFTER(queue, after, item, entry);
|
|
||||||
after->next = item;
|
|
||||||
|
|
||||||
item = next;
|
item = next;
|
||||||
} while (item != NULL);
|
} while (item != NULL);
|
||||||
@@ -170,7 +170,7 @@ cmdq_remove(struct cmdq_item *item)
|
|||||||
|
|
||||||
TAILQ_REMOVE(item->queue, item, entry);
|
TAILQ_REMOVE(item->queue, item, entry);
|
||||||
|
|
||||||
free((void *)item->name);
|
free(item->name);
|
||||||
free(item);
|
free(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,7 +206,6 @@ cmdq_get_command(struct cmd_list *cmdlist, struct cmd_find_state *current,
|
|||||||
struct cmdq_item *item, *first = NULL, *last = NULL;
|
struct cmdq_item *item, *first = NULL, *last = NULL;
|
||||||
struct cmd *cmd;
|
struct cmd *cmd;
|
||||||
u_int group = cmdq_next_group();
|
u_int group = cmdq_next_group();
|
||||||
char *tmp;
|
|
||||||
struct cmdq_shared *shared;
|
struct cmdq_shared *shared;
|
||||||
|
|
||||||
shared = xcalloc(1, sizeof *shared);
|
shared = xcalloc(1, sizeof *shared);
|
||||||
@@ -218,10 +217,8 @@ cmdq_get_command(struct cmd_list *cmdlist, struct cmd_find_state *current,
|
|||||||
memcpy(&shared->mouse, m, sizeof shared->mouse);
|
memcpy(&shared->mouse, m, sizeof shared->mouse);
|
||||||
|
|
||||||
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
|
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
|
||||||
xasprintf(&tmp, "command[%s]", cmd->entry->name);
|
|
||||||
|
|
||||||
item = xcalloc(1, sizeof *item);
|
item = xcalloc(1, sizeof *item);
|
||||||
item->name = tmp;
|
xasprintf(&item->name, "[%s/%p]", cmd->entry->name, item);
|
||||||
item->type = CMDQ_COMMAND;
|
item->type = CMDQ_COMMAND;
|
||||||
|
|
||||||
item->group = group;
|
item->group = group;
|
||||||
@@ -316,12 +313,9 @@ struct cmdq_item *
|
|||||||
cmdq_get_callback1(const char *name, cmdq_cb cb, void *data)
|
cmdq_get_callback1(const char *name, cmdq_cb cb, void *data)
|
||||||
{
|
{
|
||||||
struct cmdq_item *item;
|
struct cmdq_item *item;
|
||||||
char *tmp;
|
|
||||||
|
|
||||||
xasprintf(&tmp, "callback[%s]", name);
|
|
||||||
|
|
||||||
item = xcalloc(1, sizeof *item);
|
item = xcalloc(1, sizeof *item);
|
||||||
item->name = tmp;
|
xasprintf(&item->name, "[%s/%p]", name, item);
|
||||||
item->type = CMDQ_CALLBACK;
|
item->type = CMDQ_CALLBACK;
|
||||||
|
|
||||||
item->group = 0;
|
item->group = 0;
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
static void server_client_free(int, short, void *);
|
static void server_client_free(int, short, void *);
|
||||||
static void server_client_check_focus(struct window_pane *);
|
static void server_client_check_focus(struct window_pane *);
|
||||||
static void server_client_check_resize(struct window_pane *);
|
static void server_client_check_resize(struct window_pane *);
|
||||||
static key_code server_client_check_mouse(struct client *);
|
static key_code server_client_check_mouse(struct client *, struct key_event *);
|
||||||
static void server_client_repeat_timer(int, short, void *);
|
static void server_client_repeat_timer(int, short, void *);
|
||||||
static void server_client_click_timer(int, short, void *);
|
static void server_client_click_timer(int, short, void *);
|
||||||
static void server_client_check_exit(struct client *);
|
static void server_client_check_exit(struct client *);
|
||||||
@@ -405,10 +405,10 @@ server_client_exec(struct client *c, const char *cmd)
|
|||||||
|
|
||||||
/* Check for mouse keys. */
|
/* Check for mouse keys. */
|
||||||
static key_code
|
static key_code
|
||||||
server_client_check_mouse(struct client *c)
|
server_client_check_mouse(struct client *c, struct key_event *event)
|
||||||
{
|
{
|
||||||
|
struct mouse_event *m = &event->m;
|
||||||
struct session *s = c->session;
|
struct session *s = c->session;
|
||||||
struct mouse_event *m = &c->tty.mouse;
|
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
u_int x, y, b, sx, sy, px, py;
|
u_int x, y, b, sx, sy, px, py;
|
||||||
@@ -417,7 +417,13 @@ server_client_check_mouse(struct client *c)
|
|||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
struct style_range *sr;
|
struct style_range *sr;
|
||||||
enum { NOTYPE, MOVE, DOWN, UP, DRAG, WHEEL, DOUBLE, TRIPLE } type;
|
enum { NOTYPE, MOVE, DOWN, UP, DRAG, WHEEL, DOUBLE, TRIPLE } type;
|
||||||
enum { NOWHERE, PANE, STATUS, STATUS_LEFT, STATUS_RIGHT, STATUS_DEFAULT, BORDER } where;
|
enum { NOWHERE,
|
||||||
|
PANE,
|
||||||
|
STATUS,
|
||||||
|
STATUS_LEFT,
|
||||||
|
STATUS_RIGHT,
|
||||||
|
STATUS_DEFAULT,
|
||||||
|
BORDER } where;
|
||||||
|
|
||||||
type = NOTYPE;
|
type = NOTYPE;
|
||||||
where = NOWHERE;
|
where = NOWHERE;
|
||||||
@@ -974,11 +980,17 @@ server_client_assume_paste(struct session *s)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle data key input from client. */
|
/*
|
||||||
void
|
* Handle data key input from client. This owns and can modify the key event it
|
||||||
server_client_handle_key(struct client *c, key_code key)
|
* is given and is responsible for freeing it.
|
||||||
|
*/
|
||||||
|
enum cmd_retval
|
||||||
|
server_client_key_callback(struct cmdq_item *item, void *data)
|
||||||
{
|
{
|
||||||
struct mouse_event *m = &c->tty.mouse;
|
struct client *c = item->client;
|
||||||
|
struct key_event *event = data;
|
||||||
|
key_code key = event->key;
|
||||||
|
struct mouse_event *m = &event->m;
|
||||||
struct session *s = c->session;
|
struct session *s = c->session;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct window *w;
|
struct window *w;
|
||||||
@@ -993,7 +1005,7 @@ server_client_handle_key(struct client *c, key_code key)
|
|||||||
|
|
||||||
/* Check the client is good to accept input. */
|
/* Check the client is good to accept input. */
|
||||||
if (s == NULL || (c->flags & (CLIENT_DEAD|CLIENT_SUSPENDED)) != 0)
|
if (s == NULL || (c->flags & (CLIENT_DEAD|CLIENT_SUSPENDED)) != 0)
|
||||||
return;
|
goto out;
|
||||||
wl = s->curw;
|
wl = s->curw;
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
|
||||||
@@ -1005,11 +1017,11 @@ server_client_handle_key(struct client *c, key_code key)
|
|||||||
/* Number keys jump to pane in identify mode. */
|
/* Number keys jump to pane in identify mode. */
|
||||||
if (c->flags & CLIENT_IDENTIFY && key >= '0' && key <= '9') {
|
if (c->flags & CLIENT_IDENTIFY && key >= '0' && key <= '9') {
|
||||||
if (c->flags & CLIENT_READONLY)
|
if (c->flags & CLIENT_READONLY)
|
||||||
return;
|
goto out;
|
||||||
window_unzoom(w);
|
window_unzoom(w);
|
||||||
wp = window_pane_at_index(w, key - '0');
|
wp = window_pane_at_index(w, key - '0');
|
||||||
server_client_clear_identify(c, wp);
|
server_client_clear_identify(c, wp);
|
||||||
return;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle status line. */
|
/* Handle status line. */
|
||||||
@@ -1019,19 +1031,19 @@ server_client_handle_key(struct client *c, key_code key)
|
|||||||
}
|
}
|
||||||
if (c->prompt_string != NULL) {
|
if (c->prompt_string != NULL) {
|
||||||
if (c->flags & CLIENT_READONLY)
|
if (c->flags & CLIENT_READONLY)
|
||||||
return;
|
goto out;
|
||||||
if (status_prompt_key(c, key) == 0)
|
if (status_prompt_key(c, key) == 0)
|
||||||
return;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for mouse keys. */
|
/* Check for mouse keys. */
|
||||||
m->valid = 0;
|
m->valid = 0;
|
||||||
if (key == KEYC_MOUSE) {
|
if (key == KEYC_MOUSE) {
|
||||||
if (c->flags & CLIENT_READONLY)
|
if (c->flags & CLIENT_READONLY)
|
||||||
return;
|
goto out;
|
||||||
key = server_client_check_mouse(c);
|
key = server_client_check_mouse(c, event);
|
||||||
if (key == KEYC_UNKNOWN)
|
if (key == KEYC_UNKNOWN)
|
||||||
return;
|
goto out;
|
||||||
|
|
||||||
m->valid = 1;
|
m->valid = 1;
|
||||||
m->key = key;
|
m->key = key;
|
||||||
@@ -1042,10 +1054,9 @@ server_client_handle_key(struct client *c, key_code key)
|
|||||||
*/
|
*/
|
||||||
if (key == KEYC_DRAGGING) {
|
if (key == KEYC_DRAGGING) {
|
||||||
c->tty.mouse_drag_update(c, m);
|
c->tty.mouse_drag_update(c, m);
|
||||||
return;
|
goto out;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
m->valid = 0;
|
|
||||||
|
|
||||||
/* Find affected pane. */
|
/* Find affected pane. */
|
||||||
if (!KEYC_IS_MOUSE(key) || cmd_find_from_mouse(&fs, m, 0) != 0)
|
if (!KEYC_IS_MOUSE(key) || cmd_find_from_mouse(&fs, m, 0) != 0)
|
||||||
@@ -1084,7 +1095,7 @@ table_changed:
|
|||||||
strcmp(table->name, "prefix") != 0) {
|
strcmp(table->name, "prefix") != 0) {
|
||||||
server_client_set_key_table(c, "prefix");
|
server_client_set_key_table(c, "prefix");
|
||||||
server_status_client(c);
|
server_status_client(c);
|
||||||
return;
|
goto out;
|
||||||
}
|
}
|
||||||
flags = c->flags;
|
flags = c->flags;
|
||||||
|
|
||||||
@@ -1142,9 +1153,9 @@ try_again:
|
|||||||
server_status_client(c);
|
server_status_client(c);
|
||||||
|
|
||||||
/* Execute the key binding. */
|
/* Execute the key binding. */
|
||||||
key_bindings_dispatch(bd, NULL, c, m, &fs);
|
key_bindings_dispatch(bd, item, c, m, &fs);
|
||||||
key_bindings_unref_table(table);
|
key_bindings_unref_table(table);
|
||||||
return;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1179,14 +1190,18 @@ try_again:
|
|||||||
if (first != table && (~flags & CLIENT_REPEAT)) {
|
if (first != table && (~flags & CLIENT_REPEAT)) {
|
||||||
server_client_set_key_table(c, NULL);
|
server_client_set_key_table(c, NULL);
|
||||||
server_status_client(c);
|
server_status_client(c);
|
||||||
return;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
forward_key:
|
forward_key:
|
||||||
if (c->flags & CLIENT_READONLY)
|
if (c->flags & CLIENT_READONLY)
|
||||||
return;
|
goto out;
|
||||||
if (wp != NULL)
|
if (wp != NULL)
|
||||||
window_pane_key(wp, c, s, wl, key, m);
|
window_pane_key(wp, c, s, wl, key, m);
|
||||||
|
|
||||||
|
out:
|
||||||
|
free(event);
|
||||||
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Client functions that need to happen every loop. */
|
/* Client functions that need to happen every loop. */
|
||||||
|
17
status.c
17
status.c
@@ -320,7 +320,7 @@ status_redraw(struct client *c)
|
|||||||
struct session *s = c->session;
|
struct session *s = c->session;
|
||||||
struct screen_write_ctx ctx;
|
struct screen_write_ctx ctx;
|
||||||
struct grid_cell gc;
|
struct grid_cell gc;
|
||||||
u_int lines, i, width = c->tty.sx;
|
u_int lines, i, n, width = c->tty.sx;
|
||||||
int flags, force = 0, changed = 0;
|
int flags, force = 0, changed = 0;
|
||||||
struct options_entry *o;
|
struct options_entry *o;
|
||||||
union options_value *ov;
|
union options_value *ov;
|
||||||
@@ -364,15 +364,17 @@ status_redraw(struct client *c)
|
|||||||
|
|
||||||
/* Write the status lines. */
|
/* Write the status lines. */
|
||||||
o = options_get(s->options, "status-format");
|
o = options_get(s->options, "status-format");
|
||||||
if (o == NULL)
|
if (o == NULL) {
|
||||||
screen_write_clearscreen(&ctx, gc.bg);
|
for (n = 0; n < width * lines; n++)
|
||||||
else {
|
screen_write_putc(&ctx, &gc, ' ');
|
||||||
|
} else {
|
||||||
for (i = 0; i < lines; i++) {
|
for (i = 0; i < lines; i++) {
|
||||||
screen_write_cursormove(&ctx, 0, i, 0);
|
screen_write_cursormove(&ctx, 0, i, 0);
|
||||||
|
|
||||||
ov = options_array_get(o, i);
|
ov = options_array_get(o, i);
|
||||||
if (ov == NULL) {
|
if (ov == NULL) {
|
||||||
screen_write_clearline(&ctx, gc.bg);
|
for (n = 0; n < width; n++)
|
||||||
|
screen_write_putc(&ctx, &gc, ' ');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
sle = &sl->entries[i];
|
sle = &sl->entries[i];
|
||||||
@@ -386,7 +388,10 @@ status_redraw(struct client *c)
|
|||||||
}
|
}
|
||||||
changed = 1;
|
changed = 1;
|
||||||
|
|
||||||
screen_write_clearline(&ctx, gc.bg);
|
for (n = 0; n < width; n++)
|
||||||
|
screen_write_putc(&ctx, &gc, ' ');
|
||||||
|
screen_write_cursormove(&ctx, 0, i, 0);
|
||||||
|
|
||||||
status_free_ranges(&sle->ranges);
|
status_free_ranges(&sle->ranges);
|
||||||
format_draw(&ctx, &gc, width, expanded, &sle->ranges);
|
format_draw(&ctx, &gc, width, expanded, &sle->ranges);
|
||||||
|
|
||||||
|
33
tmux.1
33
tmux.1
@@ -852,7 +852,7 @@ are the name of and shell command to execute in the initial window.
|
|||||||
With
|
With
|
||||||
.Fl d ,
|
.Fl d ,
|
||||||
the initial size comes from the global
|
the initial size comes from the global
|
||||||
.Ar default-size
|
.Ic default-size
|
||||||
option;
|
option;
|
||||||
.Fl x
|
.Fl x
|
||||||
and
|
and
|
||||||
@@ -865,7 +865,7 @@ If
|
|||||||
or
|
or
|
||||||
.Fl y
|
.Fl y
|
||||||
is given, the
|
is given, the
|
||||||
.Ar default-size
|
.Ic default-size
|
||||||
option is set for the session.
|
option is set for the session.
|
||||||
.Pp
|
.Pp
|
||||||
If run from a terminal, any
|
If run from a terminal, any
|
||||||
@@ -2836,9 +2836,15 @@ This option should be configured when
|
|||||||
.Nm
|
.Nm
|
||||||
is used as a login shell.
|
is used as a login shell.
|
||||||
.It Ic default-size Ar XxY
|
.It Ic default-size Ar XxY
|
||||||
Set the default size of windows when the size is not set or the
|
Set the default size of new windows when the
|
||||||
.Ic window-size
|
.Ar window-size
|
||||||
option is manual.
|
option is set to manual or when a session is created with
|
||||||
|
.Ic new-session
|
||||||
|
.Fl d .
|
||||||
|
The value is the width and height separated by an
|
||||||
|
.Ql x
|
||||||
|
character.
|
||||||
|
The default is 80x24.
|
||||||
.It Xo Ic destroy-unattached
|
.It Xo Ic destroy-unattached
|
||||||
.Op Ic on | off
|
.Op Ic on | off
|
||||||
.Xc
|
.Xc
|
||||||
@@ -3421,7 +3427,7 @@ see the
|
|||||||
.Sx STYLES
|
.Sx STYLES
|
||||||
section.
|
section.
|
||||||
.Pp
|
.Pp
|
||||||
.It Xo Ic Ic window-size
|
.It Xo Ic window-size
|
||||||
.Ar largest | Ar smallest | Ar manual
|
.Ar largest | Ar smallest | Ar manual
|
||||||
.Xc
|
.Xc
|
||||||
Configure how
|
Configure how
|
||||||
@@ -3451,21 +3457,6 @@ see the
|
|||||||
.Sx STYLES
|
.Sx STYLES
|
||||||
section.
|
section.
|
||||||
.Pp
|
.Pp
|
||||||
.It Xo Ic window-size
|
|
||||||
.Op Ic smallest | largest | manual
|
|
||||||
.Xc
|
|
||||||
Tell
|
|
||||||
.Nm
|
|
||||||
how to automatically size windows either the size of the smallest session
|
|
||||||
containing the window, the size of the largest, or manual size.
|
|
||||||
See also the
|
|
||||||
.Ic resize-window
|
|
||||||
command and the
|
|
||||||
.Ic default-size
|
|
||||||
and
|
|
||||||
.Ic aggressive-resize
|
|
||||||
options.
|
|
||||||
.Pp
|
|
||||||
.It Xo Ic wrap-search
|
.It Xo Ic wrap-search
|
||||||
.Op Ic on | off
|
.Op Ic on | off
|
||||||
.Xc
|
.Xc
|
||||||
|
15
tmux.h
15
tmux.h
@@ -1054,6 +1054,12 @@ struct mouse_event {
|
|||||||
u_int sgr_b;
|
u_int sgr_b;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Key event. */
|
||||||
|
struct key_event {
|
||||||
|
key_code key;
|
||||||
|
struct mouse_event m;
|
||||||
|
};
|
||||||
|
|
||||||
/* TTY information. */
|
/* TTY information. */
|
||||||
struct tty_key {
|
struct tty_key {
|
||||||
char ch;
|
char ch;
|
||||||
@@ -1145,7 +1151,8 @@ struct tty {
|
|||||||
TTY_UNKNOWN
|
TTY_UNKNOWN
|
||||||
} term_type;
|
} term_type;
|
||||||
|
|
||||||
struct mouse_event mouse;
|
u_int mouse_last_x;
|
||||||
|
u_int mouse_last_y;
|
||||||
int mouse_drag_flag;
|
int mouse_drag_flag;
|
||||||
void (*mouse_drag_update)(struct client *,
|
void (*mouse_drag_update)(struct client *,
|
||||||
struct mouse_event *);
|
struct mouse_event *);
|
||||||
@@ -1286,7 +1293,7 @@ struct cmdq_shared {
|
|||||||
/* Command queue item. */
|
/* Command queue item. */
|
||||||
typedef enum cmd_retval (*cmdq_cb) (struct cmdq_item *, void *);
|
typedef enum cmd_retval (*cmdq_cb) (struct cmdq_item *, void *);
|
||||||
struct cmdq_item {
|
struct cmdq_item {
|
||||||
const char *name;
|
char *name;
|
||||||
struct cmdq_list *queue;
|
struct cmdq_list *queue;
|
||||||
struct cmdq_item *next;
|
struct cmdq_item *next;
|
||||||
|
|
||||||
@@ -1866,7 +1873,7 @@ 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 *);
|
||||||
key_code tty_keys_next(struct tty *);
|
int tty_keys_next(struct tty *);
|
||||||
|
|
||||||
/* arguments.c */
|
/* arguments.c */
|
||||||
void args_set(struct args *, u_char, const char *);
|
void args_set(struct args *, u_char, const char *);
|
||||||
@@ -2004,7 +2011,7 @@ void server_client_set_identify(struct client *, u_int);
|
|||||||
void server_client_set_key_table(struct client *, const char *);
|
void server_client_set_key_table(struct client *, const char *);
|
||||||
const char *server_client_get_key_table(struct client *);
|
const char *server_client_get_key_table(struct client *);
|
||||||
int server_client_check_nested(struct client *);
|
int server_client_check_nested(struct client *);
|
||||||
void server_client_handle_key(struct client *, key_code);
|
enum cmd_retval server_client_key_callback(struct cmdq_item *, void *);
|
||||||
struct client *server_client_create(int);
|
struct client *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 *);
|
||||||
|
60
tty-keys.c
60
tty-keys.c
@@ -46,7 +46,8 @@ static struct tty_key *tty_keys_find(struct tty *, const char *, size_t,
|
|||||||
static int tty_keys_next1(struct tty *, const char *, size_t, key_code *,
|
static int tty_keys_next1(struct tty *, const char *, size_t, key_code *,
|
||||||
size_t *, int);
|
size_t *, int);
|
||||||
static void tty_keys_callback(int, short, void *);
|
static void tty_keys_callback(int, short, void *);
|
||||||
static int tty_keys_mouse(struct tty *, const char *, size_t, size_t *);
|
static int tty_keys_mouse(struct tty *, const char *, size_t, size_t *,
|
||||||
|
struct mouse_event *);
|
||||||
static int tty_keys_clipboard(struct tty *, const char *, size_t,
|
static int tty_keys_clipboard(struct tty *, const char *, size_t,
|
||||||
size_t *);
|
size_t *);
|
||||||
static int tty_keys_device_attributes(struct tty *, const char *, size_t,
|
static int tty_keys_device_attributes(struct tty *, const char *, size_t,
|
||||||
@@ -560,25 +561,26 @@ tty_keys_next1(struct tty *tty, const char *buf, size_t len, key_code *key,
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Process at least one key in the buffer. Return 0 if no keys present. */
|
||||||
* Process at least one key in the buffer and invoke tty->key_callback. Return
|
int
|
||||||
* 0 if there are no further keys, or 1 if there could be more in the buffer.
|
|
||||||
*/
|
|
||||||
key_code
|
|
||||||
tty_keys_next(struct tty *tty)
|
tty_keys_next(struct tty *tty)
|
||||||
{
|
{
|
||||||
struct client *c = tty->client;
|
struct client *c = tty->client;
|
||||||
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 delay, expired = 0, n;
|
int delay, expired = 0, n;
|
||||||
key_code key;
|
key_code key;
|
||||||
|
struct cmdq_item *item;
|
||||||
|
struct mouse_event m = { 0 };
|
||||||
|
struct key_event *event;
|
||||||
|
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
|
||||||
/* Get key buffer. */
|
/* Get key buffer. */
|
||||||
buf = EVBUFFER_DATA(tty->in);
|
buf = EVBUFFER_DATA(tty->in);
|
||||||
len = EVBUFFER_LENGTH(tty->in);
|
len = EVBUFFER_LENGTH(tty->in);
|
||||||
|
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
return (0);
|
return (0);
|
||||||
log_debug("%s: keys are %zu (%.*s)", c->name, len, (int)len, buf);
|
log_debug("%s: keys are %zu (%.*s)", c->name, len, (int)len, buf);
|
||||||
@@ -606,7 +608,7 @@ tty_keys_next(struct tty *tty)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Is this a mouse key press? */
|
/* Is this a mouse key press? */
|
||||||
switch (tty_keys_mouse(tty, buf, len, &size)) {
|
switch (tty_keys_mouse(tty, buf, len, &size, &m)) {
|
||||||
case 0: /* yes */
|
case 0: /* yes */
|
||||||
key = KEYC_MOUSE;
|
key = KEYC_MOUSE;
|
||||||
goto complete_key;
|
goto complete_key;
|
||||||
@@ -725,8 +727,14 @@ complete_key:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Fire the key. */
|
/* Fire the key. */
|
||||||
if (key != KEYC_UNKNOWN)
|
if (key != KEYC_UNKNOWN) {
|
||||||
server_client_handle_key(tty->client, key);
|
event = xmalloc(sizeof *event);
|
||||||
|
event->key = key;
|
||||||
|
memcpy(&event->m, &m, sizeof event->m);
|
||||||
|
|
||||||
|
item = cmdq_get_callback(server_client_key_callback, event);
|
||||||
|
cmdq_append(c, item);
|
||||||
|
}
|
||||||
|
|
||||||
return (1);
|
return (1);
|
||||||
|
|
||||||
@@ -756,12 +764,12 @@ tty_keys_callback(__unused int fd, __unused short events, void *data)
|
|||||||
* (probably a mouse sequence but need more data).
|
* (probably a mouse sequence but need more data).
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size)
|
tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size,
|
||||||
|
struct mouse_event *m)
|
||||||
{
|
{
|
||||||
struct client *c = tty->client;
|
struct client *c = tty->client;
|
||||||
struct mouse_event *m = &tty->mouse;
|
u_int i, x, y, b, sgr_b;
|
||||||
u_int i, x, y, b, sgr_b;
|
u_char sgr_type, ch;
|
||||||
u_char sgr_type, ch;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Standard mouse sequences are \033[M followed by three characters
|
* Standard mouse sequences are \033[M followed by three characters
|
||||||
@@ -882,15 +890,19 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size)
|
|||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
/* Fill mouse event. */
|
/* Fill mouse event. */
|
||||||
m->lx = m->x;
|
m->lx = tty->mouse_last_x;
|
||||||
m->x = x;
|
m->x = x;
|
||||||
m->ly = m->y;
|
m->ly = tty->mouse_last_y;
|
||||||
m->y = y;
|
m->y = y;
|
||||||
m->lb = m->b;
|
m->lb = m->b;
|
||||||
m->b = b;
|
m->b = b;
|
||||||
m->sgr_type = sgr_type;
|
m->sgr_type = sgr_type;
|
||||||
m->sgr_b = sgr_b;
|
m->sgr_b = sgr_b;
|
||||||
|
|
||||||
|
/* Update last mouse state. */
|
||||||
|
tty->mouse_last_x = x;
|
||||||
|
tty->mouse_last_y = y;
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user