mirror of
https://github.com/tmux/tmux.git
synced 2025-01-05 23:38:48 +00:00
Add a separate mode struct for the active window mode if any.
This commit is contained in:
parent
3c24bc5617
commit
f98c66ece8
@ -199,7 +199,7 @@ cmd_capture_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
size_t len;
|
||||
|
||||
if (self->entry == &cmd_clear_history_entry) {
|
||||
if (wp->mode == &window_copy_mode)
|
||||
if (wp->mode != NULL && wp->mode->mode == &window_copy_mode)
|
||||
window_pane_reset_mode(wp);
|
||||
grid_clear_history(wp->base.grid);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
@ -74,18 +74,18 @@ cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
if (wp->mode != &window_copy_mode) {
|
||||
if (wp->mode == NULL || wp->mode->mode != &window_copy_mode) {
|
||||
flag = window_pane_set_mode(wp, &window_copy_mode, NULL, NULL);
|
||||
if (flag != 0)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
window_copy_init_from_pane(wp, args_has(self->args, 'e'));
|
||||
}
|
||||
if (args_has(args, 'M')) {
|
||||
if (wp->mode != NULL && wp->mode != &window_copy_mode)
|
||||
if (wp->mode != NULL && wp->mode->mode != &window_copy_mode)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
window_copy_start_drag(c, &shared->mouse);
|
||||
}
|
||||
if (wp->mode == &window_copy_mode && args_has(self->args, 'u'))
|
||||
if (args_has(self->args, 'u'))
|
||||
window_copy_pageup(wp, 0);
|
||||
|
||||
return (CMD_RETURN_NORMAL);
|
||||
|
@ -58,19 +58,20 @@ const struct cmd_entry cmd_send_prefix_entry = {
|
||||
static void
|
||||
cmd_send_keys_inject(struct client *c, struct cmdq_item *item, key_code key)
|
||||
{
|
||||
struct window_pane *wp = item->target.wp;
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct key_table *table;
|
||||
struct key_binding *bd;
|
||||
struct window_pane *wp = item->target.wp;
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct window_mode_entry *wme = wp->mode;
|
||||
struct key_table *table;
|
||||
struct key_binding *bd;
|
||||
|
||||
if (wp->mode == NULL || wp->mode->key_table == NULL) {
|
||||
if (wme == NULL || wme->mode->key_table == NULL) {
|
||||
if (options_get_number(wp->window->options, "xterm-keys"))
|
||||
key |= KEYC_XTERM;
|
||||
window_pane_key(wp, NULL, s, wl, key, NULL);
|
||||
return;
|
||||
}
|
||||
table = key_bindings_get_table(wp->mode->key_table(wp), 1);
|
||||
table = key_bindings_get_table(wme->mode->key_table(wme), 1);
|
||||
|
||||
bd = key_bindings_get(table, key & ~KEYC_XTERM);
|
||||
if (bd != NULL) {
|
||||
@ -83,18 +84,19 @@ cmd_send_keys_inject(struct client *c, struct cmdq_item *item, key_code key)
|
||||
static enum cmd_retval
|
||||
cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
|
||||
{
|
||||
struct args *args = self->args;
|
||||
struct client *c = cmd_find_client(item, NULL, 1);
|
||||
struct window_pane *wp = item->target.wp;
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct mouse_event *m = &item->shared->mouse;
|
||||
struct utf8_data *ud, *uc;
|
||||
wchar_t wc;
|
||||
int i, literal;
|
||||
key_code key;
|
||||
u_int np = 1;
|
||||
char *cause = NULL;
|
||||
struct args *args = self->args;
|
||||
struct client *c = cmd_find_client(item, NULL, 1);
|
||||
struct window_pane *wp = item->target.wp;
|
||||
struct session *s = item->target.s;
|
||||
struct winlink *wl = item->target.wl;
|
||||
struct mouse_event *m = &item->shared->mouse;
|
||||
struct window_mode_entry *wme = wp->mode;
|
||||
struct utf8_data *ud, *uc;
|
||||
wchar_t wc;
|
||||
int i, literal;
|
||||
key_code key;
|
||||
u_int np = 1;
|
||||
char *cause = NULL;
|
||||
|
||||
if (args_has(args, 'N')) {
|
||||
np = args_strtonum(args, 'N', 1, UINT_MAX, &cause);
|
||||
@ -103,19 +105,18 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
|
||||
free(cause);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (args_has(args, 'X') || args->argc == 0)
|
||||
wp->modeprefix = np;
|
||||
if (wme != NULL && (args_has(args, 'X') || args->argc == 0))
|
||||
wme->prefix = np;
|
||||
}
|
||||
|
||||
if (args_has(args, 'X')) {
|
||||
if (wp->mode == NULL || wp->mode->command == NULL) {
|
||||
if (wme == NULL || wme->mode->command == NULL) {
|
||||
cmdq_error(item, "not in a mode");
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
if (!m->valid)
|
||||
wp->mode->command(wp, c, s, wl, args, NULL);
|
||||
else
|
||||
wp->mode->command(wp, c, s, wl, args, m);
|
||||
m = NULL;
|
||||
wme->mode->command(wme, c, s, wl, args, m);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
|
6
format.c
6
format.c
@ -1535,7 +1535,7 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp)
|
||||
|
||||
format_add(ft, "pane_in_mode", "%d", wp->screen != &wp->base);
|
||||
if (wp->mode != NULL)
|
||||
format_add(ft, "pane_mode", "%s", wp->mode->name);
|
||||
format_add(ft, "pane_mode", "%s", wp->mode->mode->name);
|
||||
|
||||
format_add(ft, "pane_synchronized", "%d",
|
||||
!!options_get_number(w->options, "synchronize-panes"));
|
||||
@ -1552,8 +1552,8 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp)
|
||||
format_add(ft, "scroll_region_upper", "%u", wp->base.rupper);
|
||||
format_add(ft, "scroll_region_lower", "%u", wp->base.rlower);
|
||||
|
||||
if (wp->mode != NULL && wp->mode->formats != NULL)
|
||||
wp->mode->formats(wp, ft);
|
||||
if (wp->mode != NULL && wp->mode->mode->formats != NULL)
|
||||
wp->mode->mode->formats(wp->mode, ft);
|
||||
|
||||
format_add(ft, "alternate_on", "%d", wp->saved_grid ? 1 : 0);
|
||||
format_add(ft, "alternate_saved_x", "%u", wp->saved_cx);
|
||||
|
@ -928,6 +928,7 @@ server_client_handle_key(struct client *c, key_code key)
|
||||
struct window_pane *wp;
|
||||
struct timeval tv;
|
||||
struct key_table *table, *first;
|
||||
const char *tablename;
|
||||
struct key_binding *bd;
|
||||
int xtimeout, flags;
|
||||
struct cmd_find_state fs;
|
||||
@ -1009,8 +1010,10 @@ server_client_handle_key(struct client *c, key_code key)
|
||||
if (server_client_is_default_key_table(c, c->keytable) &&
|
||||
wp != NULL &&
|
||||
wp->mode != NULL &&
|
||||
wp->mode->key_table != NULL)
|
||||
table = key_bindings_get_table(wp->mode->key_table(wp), 1);
|
||||
wp->mode->mode->key_table != NULL) {
|
||||
tablename = wp->mode->mode->key_table(wp->mode);
|
||||
table = key_bindings_get_table(tablename, 1);
|
||||
}
|
||||
else
|
||||
table = c->keytable;
|
||||
first = table;
|
||||
|
32
tmux.h
32
tmux.h
@ -693,25 +693,37 @@ struct screen_write_ctx {
|
||||
* Window mode. Windows can be in several modes and this is used to call the
|
||||
* right function to handle input and output.
|
||||
*/
|
||||
struct window_mode_entry;
|
||||
struct window_mode {
|
||||
const char *name;
|
||||
|
||||
struct screen *(*init)(struct window_pane *, struct cmd_find_state *,
|
||||
struct args *);
|
||||
void (*free)(struct window_pane *);
|
||||
void (*resize)(struct window_pane *, u_int, u_int);
|
||||
void (*key)(struct window_pane *, struct client *,
|
||||
struct screen *(*init)(struct window_mode_entry *,
|
||||
struct cmd_find_state *, struct args *);
|
||||
void (*free)(struct window_mode_entry *);
|
||||
void (*resize)(struct window_mode_entry *, u_int, u_int);
|
||||
void (*key)(struct window_mode_entry *, struct client *,
|
||||
struct session *, struct winlink *, key_code,
|
||||
struct mouse_event *);
|
||||
|
||||
const char *(*key_table)(struct window_pane *);
|
||||
void (*command)(struct window_pane *, struct client *,
|
||||
const char *(*key_table)(struct window_mode_entry *);
|
||||
void (*command)(struct window_mode_entry *, struct client *,
|
||||
struct session *, struct winlink *, struct args *,
|
||||
struct mouse_event *);
|
||||
void (*formats)(struct window_pane *, struct format_tree *);
|
||||
void (*formats)(struct window_mode_entry *,
|
||||
struct format_tree *);
|
||||
};
|
||||
#define WINDOW_MODE_TIMEOUT 180
|
||||
|
||||
/* Active window mode. */
|
||||
struct window_mode_entry {
|
||||
struct window_pane *wp;
|
||||
|
||||
const struct window_mode *mode;
|
||||
void *data;
|
||||
|
||||
u_int prefix;
|
||||
};
|
||||
|
||||
/* Child window structure. */
|
||||
struct window_pane {
|
||||
u_int id;
|
||||
@ -780,11 +792,9 @@ struct window_pane {
|
||||
struct grid *saved_grid;
|
||||
struct grid_cell saved_cell;
|
||||
|
||||
const struct window_mode *mode;
|
||||
void *modedata;
|
||||
struct window_mode_entry *mode;
|
||||
struct event modetimer;
|
||||
time_t modelast;
|
||||
u_int modeprefix;
|
||||
char *searchstr;
|
||||
|
||||
TAILQ_ENTRY(window_pane) entry;
|
||||
|
@ -25,12 +25,12 @@
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
static struct screen *window_buffer_init(struct window_pane *,
|
||||
static struct screen *window_buffer_init(struct window_mode_entry *,
|
||||
struct cmd_find_state *, struct args *);
|
||||
static void window_buffer_free(struct window_pane *);
|
||||
static void window_buffer_resize(struct window_pane *, u_int,
|
||||
static void window_buffer_free(struct window_mode_entry *);
|
||||
static void window_buffer_resize(struct window_mode_entry *, u_int,
|
||||
u_int);
|
||||
static void window_buffer_key(struct window_pane *,
|
||||
static void window_buffer_key(struct window_mode_entry *,
|
||||
struct client *, struct session *,
|
||||
struct winlink *, key_code, struct mouse_event *);
|
||||
|
||||
@ -253,13 +253,14 @@ window_buffer_search(__unused void *modedata, void *itemdata, const char *ss)
|
||||
}
|
||||
|
||||
static struct screen *
|
||||
window_buffer_init(struct window_pane *wp, __unused struct cmd_find_state *fs,
|
||||
struct args *args)
|
||||
window_buffer_init(struct window_mode_entry *wme,
|
||||
__unused struct cmd_find_state *fs, struct args *args)
|
||||
{
|
||||
struct window_pane *wp = wme->wp;
|
||||
struct window_buffer_modedata *data;
|
||||
struct screen *s;
|
||||
|
||||
wp->modedata = data = xcalloc(1, sizeof *data);
|
||||
wme->data = data = xcalloc(1, sizeof *data);
|
||||
|
||||
if (args == NULL || !args_has(args, 'F'))
|
||||
data->format = xstrdup(WINDOW_BUFFER_DEFAULT_FORMAT);
|
||||
@ -282,9 +283,9 @@ window_buffer_init(struct window_pane *wp, __unused struct cmd_find_state *fs,
|
||||
}
|
||||
|
||||
static void
|
||||
window_buffer_free(struct window_pane *wp)
|
||||
window_buffer_free(struct window_mode_entry *wme)
|
||||
{
|
||||
struct window_buffer_modedata *data = wp->modedata;
|
||||
struct window_buffer_modedata *data = wme->data;
|
||||
u_int i;
|
||||
|
||||
if (data == NULL)
|
||||
@ -303,9 +304,9 @@ window_buffer_free(struct window_pane *wp)
|
||||
}
|
||||
|
||||
static void
|
||||
window_buffer_resize(struct window_pane *wp, u_int sx, u_int sy)
|
||||
window_buffer_resize(struct window_mode_entry *wme, u_int sx, u_int sy)
|
||||
{
|
||||
struct window_buffer_modedata *data = wp->modedata;
|
||||
struct window_buffer_modedata *data = wme->data;
|
||||
|
||||
mode_tree_resize(data->data, sx, sy);
|
||||
}
|
||||
@ -337,11 +338,12 @@ window_buffer_do_paste(void* modedata, void *itemdata, struct client *c,
|
||||
}
|
||||
|
||||
static void
|
||||
window_buffer_key(struct window_pane *wp, struct client *c,
|
||||
window_buffer_key(struct window_mode_entry *wme, struct client *c,
|
||||
__unused struct session *s, __unused struct winlink *wl, key_code key,
|
||||
struct mouse_event *m)
|
||||
{
|
||||
struct window_buffer_modedata *data = wp->modedata;
|
||||
struct window_pane *wp = wme->wp;
|
||||
struct window_buffer_modedata *data = wme->data;
|
||||
struct mode_tree_data *mtd = data->data;
|
||||
struct window_buffer_itemdata *item;
|
||||
int finished;
|
||||
|
@ -25,12 +25,12 @@
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
static struct screen *window_client_init(struct window_pane *,
|
||||
static struct screen *window_client_init(struct window_mode_entry *,
|
||||
struct cmd_find_state *, struct args *);
|
||||
static void window_client_free(struct window_pane *);
|
||||
static void window_client_resize(struct window_pane *, u_int,
|
||||
static void window_client_free(struct window_mode_entry *);
|
||||
static void window_client_resize(struct window_mode_entry *, u_int,
|
||||
u_int);
|
||||
static void window_client_key(struct window_pane *,
|
||||
static void window_client_key(struct window_mode_entry *,
|
||||
struct client *, struct session *,
|
||||
struct winlink *, key_code, struct mouse_event *);
|
||||
|
||||
@ -236,13 +236,14 @@ window_client_draw(__unused void *modedata, void *itemdata,
|
||||
}
|
||||
|
||||
static struct screen *
|
||||
window_client_init(struct window_pane *wp, __unused struct cmd_find_state *fs,
|
||||
struct args *args)
|
||||
window_client_init(struct window_mode_entry *wme,
|
||||
__unused struct cmd_find_state *fs, struct args *args)
|
||||
{
|
||||
struct window_pane *wp = wme->wp;
|
||||
struct window_client_modedata *data;
|
||||
struct screen *s;
|
||||
|
||||
wp->modedata = data = xcalloc(1, sizeof *data);
|
||||
wme->data = data = xcalloc(1, sizeof *data);
|
||||
|
||||
if (args == NULL || !args_has(args, 'F'))
|
||||
data->format = xstrdup(WINDOW_CLIENT_DEFAULT_FORMAT);
|
||||
@ -265,9 +266,9 @@ window_client_init(struct window_pane *wp, __unused struct cmd_find_state *fs,
|
||||
}
|
||||
|
||||
static void
|
||||
window_client_free(struct window_pane *wp)
|
||||
window_client_free(struct window_mode_entry *wme)
|
||||
{
|
||||
struct window_client_modedata *data = wp->modedata;
|
||||
struct window_client_modedata *data = wme->data;
|
||||
u_int i;
|
||||
|
||||
if (data == NULL)
|
||||
@ -286,9 +287,9 @@ window_client_free(struct window_pane *wp)
|
||||
}
|
||||
|
||||
static void
|
||||
window_client_resize(struct window_pane *wp, u_int sx, u_int sy)
|
||||
window_client_resize(struct window_mode_entry *wme, u_int sx, u_int sy)
|
||||
{
|
||||
struct window_client_modedata *data = wp->modedata;
|
||||
struct window_client_modedata *data = wme->data;
|
||||
|
||||
mode_tree_resize(data->data, sx, sy);
|
||||
}
|
||||
@ -311,11 +312,12 @@ window_client_do_detach(void* modedata, void *itemdata,
|
||||
}
|
||||
|
||||
static void
|
||||
window_client_key(struct window_pane *wp, struct client *c,
|
||||
window_client_key(struct window_mode_entry *wme, struct client *c,
|
||||
__unused struct session *s, __unused struct winlink *wl, key_code key,
|
||||
struct mouse_event *m)
|
||||
{
|
||||
struct window_client_modedata *data = wp->modedata;
|
||||
struct window_pane *wp = wme->wp;
|
||||
struct window_client_modedata *data = wme->data;
|
||||
struct mode_tree_data *mtd = data->data;
|
||||
struct window_client_itemdata *item;
|
||||
int finished;
|
||||
|
@ -24,16 +24,16 @@
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
static struct screen *window_clock_init(struct window_pane *,
|
||||
static struct screen *window_clock_init(struct window_mode_entry *,
|
||||
struct cmd_find_state *, struct args *);
|
||||
static void window_clock_free(struct window_pane *);
|
||||
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_free(struct window_mode_entry *);
|
||||
static void window_clock_resize(struct window_mode_entry *, u_int, u_int);
|
||||
static void window_clock_key(struct window_mode_entry *, struct client *,
|
||||
struct session *, struct winlink *, key_code,
|
||||
struct mouse_event *);
|
||||
|
||||
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_mode_entry *);
|
||||
|
||||
const struct window_mode window_clock_mode = {
|
||||
.name = "clock-mode",
|
||||
@ -126,8 +126,9 @@ const char window_clock_table[14][5][5] = {
|
||||
static void
|
||||
window_clock_timer_callback(__unused int fd, __unused short events, void *arg)
|
||||
{
|
||||
struct window_pane *wp = arg;
|
||||
struct window_clock_mode_data *data = wp->modedata;
|
||||
struct window_mode_entry *wme = arg;
|
||||
struct window_pane *wp = wme->wp;
|
||||
struct window_clock_mode_data *data = wme->data;
|
||||
struct tm now, then;
|
||||
time_t t;
|
||||
struct timeval tv = { .tv_sec = 1 };
|
||||
@ -142,37 +143,38 @@ window_clock_timer_callback(__unused int fd, __unused short events, void *arg)
|
||||
return;
|
||||
data->tim = t;
|
||||
|
||||
window_clock_draw_screen(wp);
|
||||
window_clock_draw_screen(wme);
|
||||
server_redraw_window(wp->window);
|
||||
}
|
||||
|
||||
static struct screen *
|
||||
window_clock_init(struct window_pane *wp, __unused struct cmd_find_state *fs,
|
||||
__unused struct args *args)
|
||||
window_clock_init(struct window_mode_entry *wme,
|
||||
__unused struct cmd_find_state *fs, __unused struct args *args)
|
||||
{
|
||||
struct window_pane *wp = wme->wp;
|
||||
struct window_clock_mode_data *data;
|
||||
struct screen *s;
|
||||
struct timeval tv = { .tv_sec = 1 };
|
||||
|
||||
wp->modedata = data = xmalloc(sizeof *data);
|
||||
wme->data = data = xmalloc(sizeof *data);
|
||||
data->tim = time(NULL);
|
||||
|
||||
evtimer_set(&data->timer, window_clock_timer_callback, wp);
|
||||
evtimer_set(&data->timer, window_clock_timer_callback, wme);
|
||||
evtimer_add(&data->timer, &tv);
|
||||
|
||||
s = &data->screen;
|
||||
screen_init(s, screen_size_x(&wp->base), screen_size_y(&wp->base), 0);
|
||||
s->mode &= ~MODE_CURSOR;
|
||||
|
||||
window_clock_draw_screen(wp);
|
||||
window_clock_draw_screen(wme);
|
||||
|
||||
return (s);
|
||||
}
|
||||
|
||||
static void
|
||||
window_clock_free(struct window_pane *wp)
|
||||
window_clock_free(struct window_mode_entry *wme)
|
||||
{
|
||||
struct window_clock_mode_data *data = wp->modedata;
|
||||
struct window_clock_mode_data *data = wme->data;
|
||||
|
||||
evtimer_del(&data->timer);
|
||||
screen_free(&data->screen);
|
||||
@ -180,27 +182,28 @@ window_clock_free(struct window_pane *wp)
|
||||
}
|
||||
|
||||
static void
|
||||
window_clock_resize(struct window_pane *wp, u_int sx, u_int sy)
|
||||
window_clock_resize(struct window_mode_entry *wme, u_int sx, u_int sy)
|
||||
{
|
||||
struct window_clock_mode_data *data = wp->modedata;
|
||||
struct window_clock_mode_data *data = wme->data;
|
||||
struct screen *s = &data->screen;
|
||||
|
||||
screen_resize(s, sx, sy, 0);
|
||||
window_clock_draw_screen(wp);
|
||||
window_clock_draw_screen(wme);
|
||||
}
|
||||
|
||||
static void
|
||||
window_clock_key(struct window_pane *wp, __unused struct client *c,
|
||||
window_clock_key(struct window_mode_entry *wme, __unused struct client *c,
|
||||
__unused struct session *s, __unused struct winlink *wl,
|
||||
__unused key_code key, __unused struct mouse_event *m)
|
||||
{
|
||||
window_pane_reset_mode(wp);
|
||||
window_pane_reset_mode(wme->wp);
|
||||
}
|
||||
|
||||
static void
|
||||
window_clock_draw_screen(struct window_pane *wp)
|
||||
window_clock_draw_screen(struct window_mode_entry *wme)
|
||||
{
|
||||
struct window_clock_mode_data *data = wp->modedata;
|
||||
struct window_pane *wp = wme->wp;
|
||||
struct window_clock_mode_data *data = wme->data;
|
||||
struct screen_write_ctx ctx;
|
||||
int colour, style;
|
||||
struct screen *s = &data->screen;
|
||||
|
936
window-copy.c
936
window-copy.c
File diff suppressed because it is too large
Load Diff
@ -24,11 +24,12 @@
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
static struct screen *window_tree_init(struct window_pane *,
|
||||
static struct screen *window_tree_init(struct window_mode_entry *,
|
||||
struct cmd_find_state *, struct args *);
|
||||
static void window_tree_free(struct window_pane *);
|
||||
static void window_tree_resize(struct window_pane *, u_int, u_int);
|
||||
static void window_tree_key(struct window_pane *,
|
||||
static void window_tree_free(struct window_mode_entry *);
|
||||
static void window_tree_resize(struct window_mode_entry *, u_int,
|
||||
u_int);
|
||||
static void window_tree_key(struct window_mode_entry *,
|
||||
struct client *, struct session *,
|
||||
struct winlink *, key_code, struct mouse_event *);
|
||||
|
||||
@ -810,13 +811,14 @@ window_tree_search(__unused void *modedata, void *itemdata, const char *ss)
|
||||
}
|
||||
|
||||
static struct screen *
|
||||
window_tree_init(struct window_pane *wp, struct cmd_find_state *fs,
|
||||
window_tree_init(struct window_mode_entry *wme, struct cmd_find_state *fs,
|
||||
struct args *args)
|
||||
{
|
||||
struct window_pane *wp = wme->wp;
|
||||
struct window_tree_modedata *data;
|
||||
struct screen *s;
|
||||
|
||||
wp->modedata = data = xcalloc(1, sizeof *data);
|
||||
wme->data = data = xcalloc(1, sizeof *data);
|
||||
|
||||
if (args_has(args, 's'))
|
||||
data->type = WINDOW_TREE_SESSION;
|
||||
@ -871,9 +873,9 @@ window_tree_destroy(struct window_tree_modedata *data)
|
||||
}
|
||||
|
||||
static void
|
||||
window_tree_free(struct window_pane *wp)
|
||||
window_tree_free(struct window_mode_entry *wme)
|
||||
{
|
||||
struct window_tree_modedata *data = wp->modedata;
|
||||
struct window_tree_modedata *data = wme->data;
|
||||
|
||||
if (data == NULL)
|
||||
return;
|
||||
@ -884,9 +886,9 @@ window_tree_free(struct window_pane *wp)
|
||||
}
|
||||
|
||||
static void
|
||||
window_tree_resize(struct window_pane *wp, u_int sx, u_int sy)
|
||||
window_tree_resize(struct window_mode_entry *wme, u_int sx, u_int sy)
|
||||
{
|
||||
struct window_tree_modedata *data = wp->modedata;
|
||||
struct window_tree_modedata *data = wme->data;
|
||||
|
||||
mode_tree_resize(data->data, sx, sy);
|
||||
}
|
||||
@ -1119,11 +1121,12 @@ window_tree_mouse(struct window_tree_modedata *data, key_code key, u_int x,
|
||||
}
|
||||
|
||||
static void
|
||||
window_tree_key(struct window_pane *wp, struct client *c,
|
||||
window_tree_key(struct window_mode_entry *wme, struct client *c,
|
||||
__unused struct session *s, __unused struct winlink *wl, key_code key,
|
||||
struct mouse_event *m)
|
||||
{
|
||||
struct window_tree_modedata *data = wp->modedata;
|
||||
struct window_pane *wp = wme->wp;
|
||||
struct window_tree_modedata *data = wme->data;
|
||||
struct window_tree_itemdata *item, *new_item;
|
||||
char *name, *prompt = NULL;
|
||||
struct cmd_find_state fs;
|
||||
|
26
window.c
26
window.c
@ -811,7 +811,6 @@ window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit)
|
||||
wp->event = NULL;
|
||||
|
||||
wp->mode = NULL;
|
||||
wp->modeprefix = 1;
|
||||
|
||||
wp->layout_cell = NULL;
|
||||
|
||||
@ -1054,8 +1053,8 @@ window_pane_resize(struct window_pane *wp, u_int sx, u_int sy)
|
||||
wp->sy = sy;
|
||||
|
||||
screen_resize(&wp->base, sx, sy, wp->saved_grid == NULL);
|
||||
if (wp->mode != NULL)
|
||||
wp->mode->resize(wp, sx, sy);
|
||||
if (wp->mode != NULL && wp->mode->mode->resize != NULL)
|
||||
wp->mode->mode->resize(wp->mode, sx, sy);
|
||||
|
||||
wp->flags |= PANE_RESIZE;
|
||||
}
|
||||
@ -1222,13 +1221,17 @@ window_pane_set_mode(struct window_pane *wp, const struct window_mode *mode,
|
||||
|
||||
if (wp->mode != NULL)
|
||||
return (1);
|
||||
wp->mode = mode;
|
||||
|
||||
wp->mode = xcalloc(1, sizeof *wp->mode);
|
||||
wp->mode->wp = wp;
|
||||
wp->mode->mode = mode;
|
||||
wp->mode->prefix = 1;
|
||||
|
||||
wp->modelast = time(NULL);
|
||||
evtimer_set(&wp->modetimer, window_pane_mode_timer, wp);
|
||||
evtimer_add(&wp->modetimer, &tv);
|
||||
|
||||
if ((s = wp->mode->init(wp, fs, args)) != NULL)
|
||||
if ((s = wp->mode->mode->init(wp->mode, fs, args)) != NULL)
|
||||
wp->screen = s;
|
||||
wp->flags |= (PANE_REDRAW|PANE_CHANGED);
|
||||
|
||||
@ -1245,9 +1248,9 @@ window_pane_reset_mode(struct window_pane *wp)
|
||||
|
||||
evtimer_del(&wp->modetimer);
|
||||
|
||||
wp->mode->free(wp);
|
||||
wp->mode->mode->free(wp->mode);
|
||||
free(wp->mode);
|
||||
wp->mode = NULL;
|
||||
wp->modeprefix = 1;
|
||||
|
||||
wp->screen = &wp->base;
|
||||
wp->flags |= (PANE_REDRAW|PANE_CHANGED);
|
||||
@ -1260,15 +1263,16 @@ void
|
||||
window_pane_key(struct window_pane *wp, struct client *c, struct session *s,
|
||||
struct winlink *wl, key_code key, struct mouse_event *m)
|
||||
{
|
||||
struct window_pane *wp2;
|
||||
struct window_mode_entry *wme = wp->mode;
|
||||
struct window_pane *wp2;
|
||||
|
||||
if (KEYC_IS_MOUSE(key) && m == NULL)
|
||||
return;
|
||||
|
||||
if (wp->mode != NULL) {
|
||||
if (wme != NULL) {
|
||||
wp->modelast = time(NULL);
|
||||
if (wp->mode->key != NULL)
|
||||
wp->mode->key(wp, c, s, wl, (key & ~KEYC_XTERM), m);
|
||||
if (wme->mode->key != NULL)
|
||||
wme->mode->key(wme, c, s, wl, (key & ~KEYC_XTERM), m);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user