mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 05:21:10 +00:00
Rewrite the code for reading and writing files. Now, if the client is
not attached, the server process asks it to open the file, similar to how works for stdin, stdout, stderr. This makes special files like /dev/fd/X work (used by some shells). stdin, stdout and stderr and control mode are now just special cases of the same mechanism. This will also make it easier to use for other commands that read files such as source-file.
This commit is contained in:
27
window.c
27
window.c
@ -1598,31 +1598,28 @@ winlink_shuffle_up(struct session *s, struct winlink *wl)
|
||||
}
|
||||
|
||||
static void
|
||||
window_pane_input_callback(struct client *c, int closed, void *data)
|
||||
window_pane_input_callback(struct client *c, __unused const char *path,
|
||||
int error, int closed, struct evbuffer *buffer, void *data)
|
||||
{
|
||||
struct window_pane_input_data *cdata = data;
|
||||
struct window_pane *wp;
|
||||
struct evbuffer *evb = c->stdin_data;
|
||||
u_char *buf = EVBUFFER_DATA(evb);
|
||||
size_t len = EVBUFFER_LENGTH(evb);
|
||||
u_char *buf = EVBUFFER_DATA(buffer);
|
||||
size_t len = EVBUFFER_LENGTH(buffer);
|
||||
|
||||
wp = window_pane_find_by_id(cdata->wp);
|
||||
if (wp == NULL || closed || c->flags & CLIENT_DEAD) {
|
||||
if (wp == NULL || closed || error != 0 || c->flags & CLIENT_DEAD) {
|
||||
if (wp == NULL)
|
||||
c->flags |= CLIENT_EXIT;
|
||||
evbuffer_drain(evb, len);
|
||||
|
||||
c->stdin_callback = NULL;
|
||||
server_client_unref(c);
|
||||
|
||||
evbuffer_drain(buffer, len);
|
||||
cmdq_continue(cdata->item);
|
||||
free(cdata);
|
||||
|
||||
server_client_unref(c);
|
||||
free(cdata);
|
||||
return;
|
||||
}
|
||||
|
||||
input_parse_buffer(wp, buf, len);
|
||||
evbuffer_drain(evb, len);
|
||||
evbuffer_drain(buffer, len);
|
||||
}
|
||||
|
||||
int
|
||||
@ -1641,6 +1638,8 @@ window_pane_start_input(struct window_pane *wp, struct cmdq_item *item,
|
||||
cdata->item = item;
|
||||
cdata->wp = wp->id;
|
||||
|
||||
return (server_set_stdin_callback(c, window_pane_input_callback, cdata,
|
||||
cause));
|
||||
c->references++;
|
||||
file_read(c, "-", window_pane_input_callback, cdata);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user