mirror of
https://github.com/tmux/tmux.git
synced 2025-09-01 20:57:00 +00:00
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@.
This commit is contained in:
17
window.c
17
window.c
@ -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
|
||||
|
Reference in New Issue
Block a user