diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-10-11 10:04:28 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-10-11 10:04:28 +0000 |
commit | c7964be422d4499e887e9ad8540ee7187b27f1f6 (patch) | |
tree | 0da41d52352fc467485f5ce439d9cc385be327d7 /usr.bin/tmux/window.c | |
parent | 8a3e3e2520cb0b0b448c05fbfd1d8e11ea2d492e (diff) |
Add a pipe-pane command to allow a pane to be piped to a shell command, for
example:
pipe-pane 'cat >~/out'
No arguments stops outputing and closes the pipe; the -o flag toggles a pipe
and on and off (useful for key bindings).
Suggested by espie@.
Diffstat (limited to 'usr.bin/tmux/window.c')
-rw-r--r-- | usr.bin/tmux/window.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c index f77e7cd758c..2dbc0673324 100644 --- a/usr.bin/tmux/window.c +++ b/usr.bin/tmux/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.31 2009/10/11 07:01:10 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.32 2009/10/11 10:04:27 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -425,6 +425,10 @@ window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit) wp->sx = sx; wp->sy = sy; + wp->pipe_fd = -1; + wp->pipe_buf = NULL; + wp->pipe_off = 0; + wp->saved_grid = NULL; screen_init(&wp->base, sx, sy, hlimit); @@ -448,6 +452,11 @@ window_pane_destroy(struct window_pane *wp) if (wp->saved_grid != NULL) grid_destroy(wp->saved_grid); + if (wp->pipe_fd != -1) { + buffer_destroy(wp->pipe_buf); + close(wp->pipe_fd); + } + buffer_destroy(wp->in); buffer_destroy(wp->out); @@ -621,7 +630,15 @@ window_pane_reset_mode(struct window_pane *wp) void window_pane_parse(struct window_pane *wp) { + size_t new_size; + + new_size = BUFFER_USED(wp->in) - wp->pipe_off; + if (wp->pipe_fd != -1 && new_size > 0) + buffer_write(wp->pipe_buf, BUFFER_OUT(wp->in), new_size); + input_parse(wp); + + wp->pipe_off = BUFFER_USED(wp->in); } void |