diff options
author | 2019-03-12 11:16:49 +0000 | |
---|---|---|
committer | 2019-03-12 11:16:49 +0000 | |
commit | 2c8678f77a1ff1cce3579aa4c6553911c9f4dde2 (patch) | |
tree | a58e089f82315aac5e2eef457bff6c90afac2435 /usr.bin/tmux/cmd-send-keys.c | |
parent | Almost all terminals now support hardware tabs so default to OXTABS (diff) | |
download | wireguard-openbsd-2c8678f77a1ff1cce3579aa4c6553911c9f4dde2.tar.xz wireguard-openbsd-2c8678f77a1ff1cce3579aa4c6553911c9f4dde2.zip |
Allow multiple modes to be open in a pane. A stack of open modes is kept
and the previous restored when the top is exited. If a mode that is
already on the stack is entered, the existing instance is moved to the
top as the active mode rather than being opened new.
Diffstat (limited to 'usr.bin/tmux/cmd-send-keys.c')
-rw-r--r-- | usr.bin/tmux/cmd-send-keys.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/usr.bin/tmux/cmd-send-keys.c b/usr.bin/tmux/cmd-send-keys.c index 9465278b496..5ebc9ceff8f 100644 --- a/usr.bin/tmux/cmd-send-keys.c +++ b/usr.bin/tmux/cmd-send-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-send-keys.c,v 1.45 2019/03/07 20:24:21 nicm Exp $ */ +/* $OpenBSD: cmd-send-keys.c,v 1.46 2019/03/12 11:16:50 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -61,10 +61,11 @@ 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 window_mode_entry *wme = wp->mode; + struct window_mode_entry *wme; struct key_table *table; struct key_binding *bd; + wme = TAILQ_FIRST(&wp->modes); if (wme == NULL || wme->mode->key_table == NULL) { if (options_get_number(wp->window->options, "xterm-keys")) key |= KEYC_XTERM; @@ -90,7 +91,7 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item) 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 window_mode_entry *wme = TAILQ_FIRST(&wp->modes); struct utf8_data *ud, *uc; wchar_t wc; int i, literal; @@ -105,8 +106,13 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item) free(cause); return (CMD_RETURN_ERROR); } - if (wme != NULL && (args_has(args, 'X') || args->argc == 0)) + if (wme != NULL && (args_has(args, 'X') || args->argc == 0)) { + if (wme == NULL || wme->mode->command == NULL) { + cmdq_error(item, "not in a mode"); + return (CMD_RETURN_ERROR); + } wme->prefix = np; + } } if (args_has(args, 'X')) { |