Merge branch 'obsd-master'

Sync from OpenBSD.
This commit is contained in:
Thomas Adam 2012-09-25 17:05:36 +01:00
commit 48750022c0
5 changed files with 54 additions and 1 deletions

View File

@ -24,6 +24,35 @@
#define CONTROL_SHOULD_NOTIFY_CLIENT(c) \ #define CONTROL_SHOULD_NOTIFY_CLIENT(c) \
((c) != NULL && ((c)->flags & CLIENT_CONTROL)) ((c) != NULL && ((c)->flags & CLIENT_CONTROL))
void
control_notify_input(struct client *c, struct window_pane *wp,
struct evbuffer *input)
{
u_char *buf;
size_t len;
struct evbuffer *message;
u_int i;
if (c->session == NULL)
return;
buf = EVBUFFER_DATA(input);
len = EVBUFFER_LENGTH(input);
/*
* Only write input if the window pane is linked to a window belonging
* to the client's session.
*/
if (winlink_find_by_window(&c->session->windows, wp->window) != NULL) {
message = evbuffer_new();
evbuffer_add_printf(message, "%%output %%%u ", wp->id);
for (i = 0; i < len; i++)
evbuffer_add_printf(message, "%02hhx", buf[i]);
control_write_buffer(c, message);
evbuffer_free(message);
}
}
void void
control_notify_window_layout_changed(struct window *w) control_notify_window_layout_changed(struct window *w)
{ {

View File

@ -752,6 +752,7 @@ input_parse(struct window_pane *wp)
buf = EVBUFFER_DATA(evb); buf = EVBUFFER_DATA(evb);
len = EVBUFFER_LENGTH(evb); len = EVBUFFER_LENGTH(evb);
notify_input(wp, evb);
off = 0; off = 0;
/* Parse the input. */ /* Parse the input. */

View File

@ -131,6 +131,26 @@ notify_drain(void)
} }
} }
void
notify_input(struct window_pane *wp, struct evbuffer *input)
{
struct client *c;
u_int i;
/*
* notify_input() is not queued and only does anything when
* notifications are enabled.
*/
if (!notify_enabled)
return;
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
if (c != NULL && (c->flags & CLIENT_CONTROL))
control_notify_input(c, wp, input);
}
}
void void
notify_window_layout_changed(struct window *w) notify_window_layout_changed(struct window *w)
{ {

3
tmux.h
View File

@ -1527,6 +1527,7 @@ enum mode_key_cmd mode_key_lookup(struct mode_key_data *, int);
/* notify.c */ /* notify.c */
void notify_enable(void); void notify_enable(void);
void notify_disable(void); void notify_disable(void);
void notify_input(struct window_pane *, struct evbuffer *);
void notify_window_layout_changed(struct window *); void notify_window_layout_changed(struct window *);
void notify_window_unlinked(struct session *, struct window *); void notify_window_unlinked(struct session *, struct window *);
void notify_window_linked(struct session *, struct window *); void notify_window_linked(struct session *, struct window *);
@ -2220,6 +2221,8 @@ void printflike2 control_write(struct client *, const char *, ...);
void control_write_buffer(struct client *, struct evbuffer *); void control_write_buffer(struct client *, struct evbuffer *);
/* control-notify.c */ /* control-notify.c */
void control_notify_input(struct client *, struct window_pane *,
struct evbuffer *);
void control_notify_window_layout_changed(struct window *); void control_notify_window_layout_changed(struct window *);
void control_notify_window_unlinked(struct session *, struct window *); void control_notify_window_unlinked(struct session *, struct window *);
void control_notify_window_linked(struct session *, struct window *); void control_notify_window_linked(struct session *, struct window *);

View File

@ -1068,7 +1068,7 @@ window_copy_search_down(struct window_pane *wp, const char *searchstr)
retry: retry:
sgd = ss.grid; sgd = ss.grid;
for (i = fy + 1; i < gd->hsize + gd->sy; i++) { for (i = fy + 1; i < gd->hsize + gd->sy + 1; i++) {
first = 0; first = 0;
if (i == fy + 1) if (i == fy + 1)
first = fx; first = fx;