summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2020-03-31 06:35:39 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2020-03-31 06:35:39 +0000
commitcfd4a050f5a94ffebcf7d436f6a13b095be61d40 (patch)
treee668954f6093cf99004895a8f6de6908fbd96b7e /usr.bin/tmux
parentff6e3d97e1558a78dfa14c07472fbc7983533e94 (diff)
Detach reply escape sequences from the pane so they work in popups.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/input.c28
-rw-r--r--usr.bin/tmux/popup.c5
-rw-r--r--usr.bin/tmux/spawn.c4
-rw-r--r--usr.bin/tmux/tmux.h5
-rw-r--r--usr.bin/tmux/window.c9
5 files changed, 24 insertions, 27 deletions
diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c
index 77ce62afc78..fe94e34418f 100644
--- a/usr.bin/tmux/input.c
+++ b/usr.bin/tmux/input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: input.c,v 1.171 2020/03/19 14:03:48 nicm Exp $ */
+/* $OpenBSD: input.c,v 1.172 2020/03/31 06:35:38 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -75,6 +75,7 @@ struct input_param {
/* Input parser context. */
struct input_ctx {
struct window_pane *wp;
+ struct bufferevent *event;
struct screen_write_ctx ctx;
struct input_cell cell;
@@ -788,12 +789,13 @@ input_restore_state(struct input_ctx *ictx)
/* Initialise input parser. */
struct input_ctx *
-input_init(struct window_pane *wp)
+input_init(struct window_pane *wp, struct bufferevent *bev)
{
struct input_ctx *ictx;
ictx = xcalloc(1, sizeof *ictx);
ictx->wp = wp;
+ ictx->event = bev;
ictx->input_space = INPUT_BUF_START;
ictx->input_buf = xmalloc(INPUT_BUF_START);
@@ -1058,18 +1060,15 @@ input_get(struct input_ctx *ictx, u_int validx, int minval, int defval)
static void
input_reply(struct input_ctx *ictx, const char *fmt, ...)
{
- struct window_pane *wp = ictx->wp;
+ struct bufferevent *bev = ictx->event;
va_list ap;
char *reply;
- if (wp == NULL)
- return;
-
va_start(ap, fmt);
xvasprintf(&reply, fmt, ap);
va_end(ap);
- bufferevent_write(wp->event, reply, strlen(reply));
+ bufferevent_write(bev, reply, strlen(reply));
free(reply);
}
@@ -1801,7 +1800,9 @@ static void
input_csi_dispatch_winops(struct input_ctx *ictx)
{
struct screen_write_ctx *sctx = &ictx->ctx;
+ struct screen *s = sctx->s;
struct window_pane *wp = ictx->wp;
+ u_int x = screen_size_x(s), y = screen_size_y(s);
int n, m;
m = 0;
@@ -1858,10 +1859,7 @@ input_csi_dispatch_winops(struct input_ctx *ictx)
}
break;
case 18:
- if (wp != NULL) {
- input_reply(ictx, "\033[8;%u;%ut", wp->sy,
- wp->sx);
- }
+ input_reply(ictx, "\033[8;%u;%ut", x, y);
break;
default:
log_debug("%s: unknown '%c'", __func__, ictx->ch);
@@ -2565,13 +2563,13 @@ input_osc_52(struct input_ctx *ictx, const char *p)
outlen = 0;
out = NULL;
}
- bufferevent_write(wp->event, "\033]52;;", 6);
+ bufferevent_write(ictx->event, "\033]52;;", 6);
if (outlen != 0)
- bufferevent_write(wp->event, out, outlen);
+ bufferevent_write(ictx->event, out, outlen);
if (ictx->input_end == INPUT_END_BEL)
- bufferevent_write(wp->event, "\007", 1);
+ bufferevent_write(ictx->event, "\007", 1);
else
- bufferevent_write(wp->event, "\033\\", 2);
+ bufferevent_write(ictx->event, "\033\\", 2);
free(out);
return;
}
diff --git a/usr.bin/tmux/popup.c b/usr.bin/tmux/popup.c
index 50f547e7fc2..71cc853d9bc 100644
--- a/usr.bin/tmux/popup.c
+++ b/usr.bin/tmux/popup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: popup.c,v 1.4 2020/03/30 07:42:44 nicm Exp $ */
+/* $OpenBSD: popup.c,v 1.5 2020/03/31 06:35:38 nicm Exp $ */
/*
* Copyright (c) 2020 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -443,8 +443,6 @@ popup_display(int flags, struct cmdq_item *item, u_int px, u_int py, u_int sx,
popup_write_screen(c, pd);
if (shellcmd != NULL) {
- pd->ictx = input_init(NULL);
-
if (fs != NULL)
s = fs->s;
else
@@ -455,6 +453,7 @@ popup_display(int flags, struct cmdq_item *item, u_int px, u_int py, u_int sx,
pd->job = job_run(shellcmd, s, cwd, popup_job_update_cb,
popup_job_complete_cb, NULL, pd, jobflags, pd->sx - 2,
pd->sy - 2);
+ pd->ictx = input_init(NULL, job_get_event(pd->job));
}
server_client_set_overlay(c, 0, popup_check_cb, popup_mode_cb,
diff --git a/usr.bin/tmux/spawn.c b/usr.bin/tmux/spawn.c
index c3b8566987d..f6d3f7e07a4 100644
--- a/usr.bin/tmux/spawn.c
+++ b/usr.bin/tmux/spawn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spawn.c,v 1.17 2020/03/19 14:03:49 nicm Exp $ */
+/* $OpenBSD: spawn.c,v 1.18 2020/03/31 06:35:38 nicm Exp $ */
/*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -256,7 +256,7 @@ spawn_pane(struct spawn_context *sc, char **cause)
window_pane_reset_mode_all(sc->wp0);
screen_reinit(&sc->wp0->base);
input_free(sc->wp0->ictx);
- sc->wp0->ictx = input_init(sc->wp0);
+ sc->wp0->ictx = NULL;
new_wp = sc->wp0;
new_wp->flags &= ~(PANE_STATUSREADY|PANE_STATUSDRAWN);
} else if (sc->lc == NULL) {
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 6e20cfa3d85..fd7d74f16b6 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.967 2020/03/30 16:16:48 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.968 2020/03/31 06:35:38 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -2296,7 +2296,7 @@ void recalculate_size(struct window *);
void recalculate_sizes(void);
/* input.c */
-struct input_ctx *input_init(struct window_pane *);
+struct input_ctx *input_init(struct window_pane *, struct bufferevent *);
void input_free(struct input_ctx *);
void input_reset(struct input_ctx *, int);
struct evbuffer *input_pending(struct input_ctx *);
@@ -2334,6 +2334,7 @@ struct grid *grid_create(u_int, u_int, u_int);
void grid_destroy(struct grid *);
int grid_compare(struct grid *, struct grid *);
void grid_collect_history(struct grid *);
+void grid_remove_history(struct grid *, u_int );
void grid_scroll_history(struct grid *, u_int);
void grid_scroll_history_region(struct grid *, u_int, u_int, u_int);
void grid_clear_history(struct grid *);
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index 0b21dd1057b..f93696b92f8 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.250 2020/03/19 14:03:49 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.251 2020/03/31 06:35:38 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -891,8 +891,6 @@ window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit)
if (gethostname(host, sizeof host) == 0)
screen_set_title(&wp->base, host);
- wp->ictx = input_init(wp);
-
return (wp);
}
@@ -906,8 +904,8 @@ window_pane_destroy(struct window_pane *wp)
bufferevent_free(wp->event);
close(wp->fd);
}
-
- input_free(wp->ictx);
+ if (wp->ictx != NULL)
+ input_free(wp->ictx);
screen_free(&wp->status_screen);
@@ -974,6 +972,7 @@ window_pane_set_event(struct window_pane *wp)
wp->event = bufferevent_new(wp->fd, window_pane_read_callback,
NULL, window_pane_error_callback, wp);
+ wp->ictx = input_init(wp, wp->event);
bufferevent_setwatermark(wp->event, EV_READ, 0, READ_SIZE);
bufferevent_enable(wp->event, EV_READ|EV_WRITE);