mirror of
https://github.com/tmux/tmux.git
synced 2024-12-13 01:48:47 +00:00
Pass window into mode functions.
This commit is contained in:
parent
4e3d661284
commit
bde0224deb
@ -60,13 +60,14 @@ cmd_send_keys_inject(struct client *c, struct cmdq_item *item, key_code key)
|
|||||||
{
|
{
|
||||||
struct window_pane *wp = item->target.wp;
|
struct window_pane *wp = item->target.wp;
|
||||||
struct session *s = item->target.s;
|
struct session *s = item->target.s;
|
||||||
|
struct winlink *wl = item->target.wl;
|
||||||
struct key_table *table;
|
struct key_table *table;
|
||||||
struct key_binding *bd;
|
struct key_binding *bd;
|
||||||
|
|
||||||
if (wp->mode == NULL || wp->mode->key_table == NULL) {
|
if (wp->mode == NULL || wp->mode->key_table == NULL) {
|
||||||
if (options_get_number(wp->window->options, "xterm-keys"))
|
if (options_get_number(wp->window->options, "xterm-keys"))
|
||||||
key |= KEYC_XTERM;
|
key |= KEYC_XTERM;
|
||||||
window_pane_key(wp, NULL, s, key, NULL);
|
window_pane_key(wp, NULL, s, wl, key, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
table = key_bindings_get_table(wp->mode->key_table(wp), 1);
|
table = key_bindings_get_table(wp->mode->key_table(wp), 1);
|
||||||
@ -86,6 +87,7 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
struct client *c = cmd_find_client(item, NULL, 1);
|
struct client *c = cmd_find_client(item, NULL, 1);
|
||||||
struct window_pane *wp = item->target.wp;
|
struct window_pane *wp = item->target.wp;
|
||||||
struct session *s = item->target.s;
|
struct session *s = item->target.s;
|
||||||
|
struct winlink *wl = item->target.wl;
|
||||||
struct mouse_event *m = &item->shared->mouse;
|
struct mouse_event *m = &item->shared->mouse;
|
||||||
struct utf8_data *ud, *uc;
|
struct utf8_data *ud, *uc;
|
||||||
wchar_t wc;
|
wchar_t wc;
|
||||||
@ -111,9 +113,9 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (!m->valid)
|
if (!m->valid)
|
||||||
wp->mode->command(wp, c, s, args, NULL);
|
wp->mode->command(wp, c, s, wl, args, NULL);
|
||||||
else
|
else
|
||||||
wp->mode->command(wp, c, s, args, m);
|
wp->mode->command(wp, c, s, wl, args, m);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +125,7 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
cmdq_error(item, "no mouse target");
|
cmdq_error(item, "no mouse target");
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
window_pane_key(wp, NULL, s, m->key, m);
|
window_pane_key(wp, NULL, s, wl, m->key, m);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -923,6 +923,7 @@ 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;
|
||||||
|
struct winlink *wl;
|
||||||
struct window *w;
|
struct window *w;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
@ -935,7 +936,8 @@ 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;
|
return;
|
||||||
w = s->curw->window;
|
wl = s->curw;
|
||||||
|
w = wl->window;
|
||||||
|
|
||||||
/* Update the activity timer. */
|
/* Update the activity timer. */
|
||||||
if (gettimeofday(&c->activity_time, NULL) != 0)
|
if (gettimeofday(&c->activity_time, NULL) != 0)
|
||||||
@ -1126,7 +1128,7 @@ forward_key:
|
|||||||
if (c->flags & CLIENT_READONLY)
|
if (c->flags & CLIENT_READONLY)
|
||||||
return;
|
return;
|
||||||
if (wp != NULL)
|
if (wp != NULL)
|
||||||
window_pane_key(wp, c, s, key, m);
|
window_pane_key(wp, c, s, wl, key, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Client functions that need to happen every loop. */
|
/* Client functions that need to happen every loop. */
|
||||||
|
9
tmux.h
9
tmux.h
@ -52,6 +52,7 @@ struct options_entry;
|
|||||||
struct session;
|
struct session;
|
||||||
struct tmuxpeer;
|
struct tmuxpeer;
|
||||||
struct tmuxproc;
|
struct tmuxproc;
|
||||||
|
struct winlink;
|
||||||
|
|
||||||
/* Client-server protocol version. */
|
/* Client-server protocol version. */
|
||||||
#define PROTOCOL_VERSION 8
|
#define PROTOCOL_VERSION 8
|
||||||
@ -699,11 +700,12 @@ 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 *,
|
void (*key)(struct window_pane *, struct client *,
|
||||||
struct session *, key_code, struct mouse_event *);
|
struct session *, struct winlink *, key_code,
|
||||||
|
struct mouse_event *);
|
||||||
|
|
||||||
const char *(*key_table)(struct window_pane *);
|
const char *(*key_table)(struct window_pane *);
|
||||||
void (*command)(struct window_pane *, struct client *,
|
void (*command)(struct window_pane *, struct client *,
|
||||||
struct session *, struct args *,
|
struct session *, struct winlink *, struct args *,
|
||||||
struct mouse_event *);
|
struct mouse_event *);
|
||||||
};
|
};
|
||||||
#define WINDOW_MODE_TIMEOUT 180
|
#define WINDOW_MODE_TIMEOUT 180
|
||||||
@ -2193,7 +2195,8 @@ int window_pane_set_mode(struct window_pane *,
|
|||||||
struct args *);
|
struct args *);
|
||||||
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 *, key_code, struct mouse_event *);
|
struct session *, struct winlink *, key_code,
|
||||||
|
struct mouse_event *);
|
||||||
int window_pane_visible(struct window_pane *);
|
int window_pane_visible(struct window_pane *);
|
||||||
u_int window_pane_search(struct window_pane *, const char *);
|
u_int window_pane_search(struct window_pane *, const char *);
|
||||||
const char *window_printable_flags(struct winlink *);
|
const char *window_printable_flags(struct winlink *);
|
||||||
|
@ -31,8 +31,8 @@ static void window_buffer_free(struct window_pane *);
|
|||||||
static void window_buffer_resize(struct window_pane *, u_int,
|
static void window_buffer_resize(struct window_pane *, u_int,
|
||||||
u_int);
|
u_int);
|
||||||
static void window_buffer_key(struct window_pane *,
|
static void window_buffer_key(struct window_pane *,
|
||||||
struct client *, struct session *, key_code,
|
struct client *, struct session *,
|
||||||
struct mouse_event *);
|
struct winlink *, key_code, struct mouse_event *);
|
||||||
|
|
||||||
#define WINDOW_BUFFER_DEFAULT_COMMAND "paste-buffer -b '%%'"
|
#define WINDOW_BUFFER_DEFAULT_COMMAND "paste-buffer -b '%%'"
|
||||||
|
|
||||||
@ -338,7 +338,8 @@ window_buffer_do_paste(void* modedata, void *itemdata, struct client *c,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
window_buffer_key(struct window_pane *wp, struct client *c,
|
window_buffer_key(struct window_pane *wp, struct client *c,
|
||||||
__unused struct session *s, key_code key, struct mouse_event *m)
|
__unused struct session *s, __unused struct winlink *wl, key_code key,
|
||||||
|
struct mouse_event *m)
|
||||||
{
|
{
|
||||||
struct window_buffer_modedata *data = wp->modedata;
|
struct window_buffer_modedata *data = wp->modedata;
|
||||||
struct mode_tree_data *mtd = data->data;
|
struct mode_tree_data *mtd = data->data;
|
||||||
|
@ -31,8 +31,8 @@ static void window_client_free(struct window_pane *);
|
|||||||
static void window_client_resize(struct window_pane *, u_int,
|
static void window_client_resize(struct window_pane *, u_int,
|
||||||
u_int);
|
u_int);
|
||||||
static void window_client_key(struct window_pane *,
|
static void window_client_key(struct window_pane *,
|
||||||
struct client *, struct session *, key_code,
|
struct client *, struct session *,
|
||||||
struct mouse_event *);
|
struct winlink *, key_code, struct mouse_event *);
|
||||||
|
|
||||||
#define WINDOW_CLIENT_DEFAULT_COMMAND "detach-client -t '%%'"
|
#define WINDOW_CLIENT_DEFAULT_COMMAND "detach-client -t '%%'"
|
||||||
|
|
||||||
@ -312,7 +312,8 @@ window_client_do_detach(void* modedata, void *itemdata,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
window_client_key(struct window_pane *wp, struct client *c,
|
window_client_key(struct window_pane *wp, struct client *c,
|
||||||
__unused struct session *s, key_code key, struct mouse_event *m)
|
__unused struct session *s, __unused struct winlink *wl, key_code key,
|
||||||
|
struct mouse_event *m)
|
||||||
{
|
{
|
||||||
struct window_client_modedata *data = wp->modedata;
|
struct window_client_modedata *data = wp->modedata;
|
||||||
struct mode_tree_data *mtd = data->data;
|
struct mode_tree_data *mtd = data->data;
|
||||||
|
@ -29,7 +29,8 @@ static struct screen *window_clock_init(struct window_pane *,
|
|||||||
static void window_clock_free(struct window_pane *);
|
static void window_clock_free(struct window_pane *);
|
||||||
static void window_clock_resize(struct window_pane *, u_int, u_int);
|
static void window_clock_resize(struct window_pane *, u_int, u_int);
|
||||||
static void window_clock_key(struct window_pane *, struct client *,
|
static void window_clock_key(struct window_pane *, struct client *,
|
||||||
struct session *, key_code, struct mouse_event *);
|
struct session *, struct winlink *, key_code,
|
||||||
|
struct mouse_event *);
|
||||||
|
|
||||||
static void window_clock_timer_callback(int, short, void *);
|
static void window_clock_timer_callback(int, short, void *);
|
||||||
static void window_clock_draw_screen(struct window_pane *);
|
static void window_clock_draw_screen(struct window_pane *);
|
||||||
@ -190,8 +191,8 @@ window_clock_resize(struct window_pane *wp, u_int sx, u_int sy)
|
|||||||
|
|
||||||
static void
|
static 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 key_code key,
|
__unused struct session *s, __unused struct winlink *wl,
|
||||||
__unused struct mouse_event *m)
|
__unused key_code key, __unused struct mouse_event *m)
|
||||||
{
|
{
|
||||||
window_pane_reset_mode(wp);
|
window_pane_reset_mode(wp);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,8 @@
|
|||||||
|
|
||||||
static const char *window_copy_key_table(struct window_pane *);
|
static const char *window_copy_key_table(struct window_pane *);
|
||||||
static void window_copy_command(struct window_pane *, struct client *,
|
static void window_copy_command(struct window_pane *, struct client *,
|
||||||
struct session *, struct args *, struct mouse_event *);
|
struct session *, struct winlink *, struct args *,
|
||||||
|
struct mouse_event *);
|
||||||
static struct screen *window_copy_init(struct window_pane *,
|
static struct screen *window_copy_init(struct window_pane *,
|
||||||
struct cmd_find_state *, struct args *);
|
struct cmd_find_state *, struct args *);
|
||||||
static void window_copy_free(struct window_pane *);
|
static void window_copy_free(struct window_pane *);
|
||||||
@ -514,7 +515,7 @@ window_copy_key_table(struct window_pane *wp)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
window_copy_command(struct window_pane *wp, struct client *c, struct session *s,
|
window_copy_command(struct window_pane *wp, struct client *c, struct session *s,
|
||||||
struct args *args, struct mouse_event *m)
|
__unused struct winlink *wl, struct args *args, struct mouse_event *m)
|
||||||
{
|
{
|
||||||
struct window_copy_mode_data *data = wp->modedata;
|
struct window_copy_mode_data *data = wp->modedata;
|
||||||
struct screen *sn = &data->screen;
|
struct screen *sn = &data->screen;
|
||||||
|
@ -29,8 +29,8 @@ static struct screen *window_tree_init(struct window_pane *,
|
|||||||
static void window_tree_free(struct window_pane *);
|
static void window_tree_free(struct window_pane *);
|
||||||
static void window_tree_resize(struct window_pane *, u_int, u_int);
|
static void window_tree_resize(struct window_pane *, u_int, u_int);
|
||||||
static void window_tree_key(struct window_pane *,
|
static void window_tree_key(struct window_pane *,
|
||||||
struct client *, struct session *, key_code,
|
struct client *, struct session *,
|
||||||
struct mouse_event *);
|
struct winlink *, key_code, struct mouse_event *);
|
||||||
|
|
||||||
#define WINDOW_TREE_DEFAULT_COMMAND "switch-client -t '%%'"
|
#define WINDOW_TREE_DEFAULT_COMMAND "switch-client -t '%%'"
|
||||||
|
|
||||||
@ -1120,7 +1120,8 @@ window_tree_mouse(struct window_tree_modedata *data, key_code key, u_int x,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
window_tree_key(struct window_pane *wp, struct client *c,
|
window_tree_key(struct window_pane *wp, struct client *c,
|
||||||
__unused struct session *s, key_code key, struct mouse_event *m)
|
__unused struct session *s, __unused struct winlink *wl, key_code key,
|
||||||
|
struct mouse_event *m)
|
||||||
{
|
{
|
||||||
struct window_tree_modedata *data = wp->modedata;
|
struct window_tree_modedata *data = wp->modedata;
|
||||||
struct window_tree_itemdata *item, *new_item;
|
struct window_tree_itemdata *item, *new_item;
|
||||||
|
4
window.c
4
window.c
@ -1258,7 +1258,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,
|
||||||
key_code key, struct mouse_event *m)
|
struct winlink *wl, key_code key, struct mouse_event *m)
|
||||||
{
|
{
|
||||||
struct window_pane *wp2;
|
struct window_pane *wp2;
|
||||||
|
|
||||||
@ -1268,7 +1268,7 @@ window_pane_key(struct window_pane *wp, struct client *c, struct session *s,
|
|||||||
if (wp->mode != NULL) {
|
if (wp->mode != NULL) {
|
||||||
wp->modelast = time(NULL);
|
wp->modelast = time(NULL);
|
||||||
if (wp->mode->key != NULL)
|
if (wp->mode->key != NULL)
|
||||||
wp->mode->key(wp, c, s, (key & ~KEYC_XTERM), m);
|
wp->mode->key(wp, c, s, wl, (key & ~KEYC_XTERM), m);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user