summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/window.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2019-05-03 20:44:24 +0000
committernicm <nicm@openbsd.org>2019-05-03 20:44:24 +0000
commitaab3c1a6d3e154659f9c90ea28be7d7e459bf83b (patch)
tree8219414547e526279be9a3931af65e588de387fe /usr.bin/tmux/window.c
parentBring v6_config() into the modern age. Remember (diff)
downloadwireguard-openbsd-aab3c1a6d3e154659f9c90ea28be7d7e459bf83b.tar.xz
wireguard-openbsd-aab3c1a6d3e154659f9c90ea28be7d7e459bf83b.zip
Allow panes to be empty (no command), output can be piped to them with
split-window or display-message -I.
Diffstat (limited to 'usr.bin/tmux/window.c')
-rw-r--r--usr.bin/tmux/window.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index 1a05fe6ba72..00559a93039 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.227 2019/04/26 10:24:26 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.228 2019/05/03 20:44:24 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -72,6 +72,11 @@ const struct window_mode *all_window_modes[] = {
NULL
};
+struct window_pane_input_data {
+ struct cmdq_item *item;
+ u_int wp;
+};
+
static struct window_pane *window_pane_create(struct window *, u_int, u_int,
u_int);
static void window_pane_destroy(struct window_pane *);
@@ -1466,3 +1471,45 @@ winlink_shuffle_up(struct session *s, struct winlink *wl)
return (idx);
}
+
+static void
+window_pane_input_callback(struct client *c, int closed, void *data)
+{
+ struct window_pane_input_data *cdata = data;
+ struct window_pane *wp;
+
+ wp = window_pane_find_by_id(cdata->wp);
+ if (wp == NULL || closed || c->flags & CLIENT_DEAD) {
+ c->stdin_callback = NULL;
+ server_client_unref(c);
+
+ cdata->item->flags &= ~CMDQ_WAITING;
+ free(cdata);
+
+ return;
+ }
+
+ if (evbuffer_add_buffer(wp->event->input, c->stdin_data) != 0)
+ evbuffer_drain(c->stdin_data, EVBUFFER_LENGTH(c->stdin_data));
+ input_parse(wp);
+}
+
+int
+window_pane_start_input(struct window_pane *wp, struct cmdq_item *item,
+ char **cause)
+{
+ struct client *c = item->client;
+ struct window_pane_input_data *cdata;
+
+ if (~wp->flags & PANE_EMPTY) {
+ *cause = xstrdup("pane is not empty");
+ return (-1);
+ }
+
+ cdata = xmalloc(sizeof *cdata);
+ cdata->item = item;
+ cdata->wp = wp->id;
+
+ return (server_set_stdin_callback(c, window_pane_input_callback, cdata,
+ cause));
+}