From c9a6e2560af951ed450732d80844309d8778eaef Mon Sep 17 00:00:00 2001 From: Nicolas Viennot Date: Wed, 26 Jun 2013 02:05:13 -0400 Subject: Synchronize the list binding pane (bind-key + ?) --- cmd-list-keys.c | 10 ++++++++++ cmd-queue.c | 1 + tmate-encoder.c | 11 ++++++++++- tmate.h | 2 ++ window-copy.c | 10 ++++++++++ 5 files changed, 33 insertions(+), 1 deletion(-) diff --git a/cmd-list-keys.c b/cmd-list-keys.c index 78998b66..f0bcece3 100644 --- a/cmd-list-keys.c +++ b/cmd-list-keys.c @@ -49,6 +49,16 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq) size_t used; int width, keywidth; +#ifdef TMATE + /* XXX TODO Really nasty hack, we really need our own client instance... */ + struct client fake_client; + if (!cmdq->client) { + cmdq->client = &fake_client; + cmdq->client->flags = 0; + cmdq->client->session = RB_MIN(sessions, &sessions); + } +#endif + if (args_has(args, 't')) return (cmd_list_keys_table(self, cmdq)); diff --git a/cmd-queue.c b/cmd-queue.c index 7fe2793a..44602114 100644 --- a/cmd-queue.c +++ b/cmd-queue.c @@ -82,6 +82,7 @@ cmdq_print(struct cmd_q *cmdq, const char *fmt, ...) window_pane_reset_mode(w->active); window_pane_set_mode(w->active, &window_copy_mode); window_copy_init_for_output(w->active); + tmate_sync_copy_mode(w->active); } window_copy_vadd(w->active, fmt, ap); } diff --git a/tmate-encoder.c b/tmate-encoder.c index 3db8e8d7..6ac9a590 100644 --- a/tmate-encoder.c +++ b/tmate-encoder.c @@ -194,7 +194,8 @@ void tmate_sync_copy_mode(struct window_pane *wp) pack(array, 0); return; } - pack(array, 5); + pack(array, 6); + pack(int, data->backing == &wp->base); pack(int, data->oy); pack(int, data->cx); @@ -217,3 +218,11 @@ void tmate_sync_copy_mode(struct window_pane *wp) } else pack(array, 0); } + +void tmate_write_copy_mode(struct window_pane *wp, const char *str) +{ + pack(array, 3); + pack(int, TMATE_WRITE_COPY_MODE); + pack(int, wp->id); + pack(string, str); +} diff --git a/tmate.h b/tmate.h index dea7e56d..f4dcde04 100644 --- a/tmate.h +++ b/tmate.h @@ -27,6 +27,7 @@ enum tmate_commands { TMATE_FAILED_CMD, TMATE_STATUS, TMATE_SYNC_COPY_MODE, + TMATE_WRITE_COPY_MODE, }; struct tmate_encoder { @@ -45,6 +46,7 @@ extern void tmate_exec_cmd(const char *cmd); extern void tmate_failed_cmd(int client_id, const char *cause); extern void tmate_status(const char *left, const char *right); extern void tmate_sync_copy_mode(struct window_pane *wp); +extern void tmate_write_copy_mode(struct window_pane *wp, const char *str); /* tmate-decoder.c */ diff --git a/window-copy.c b/window-copy.c index b19f77b5..d3af1efb 100644 --- a/window-copy.c +++ b/window-copy.c @@ -216,6 +216,9 @@ window_copy_vadd(struct window_pane *wp, const char *fmt, va_list ap) struct grid_cell gc; int utf8flag; u_int old_hsize; +#ifdef TMATE + char *msg; +#endif if (backing == &wp->base) return; @@ -234,7 +237,14 @@ window_copy_vadd(struct window_pane *wp, const char *fmt, va_list ap) screen_write_linefeed(&back_ctx, 0); } else data->backing_written = 1; +#ifdef TMATE + xvasprintf(&msg, fmt, ap); + screen_write_nputs(&back_ctx, 0, &gc, utf8flag, "%s", msg); + tmate_write_copy_mode(wp, msg); + free(msg); +#else screen_write_vnputs(&back_ctx, 0, &gc, utf8flag, fmt, ap); +#endif screen_write_stop(&back_ctx); data->oy += screen_hsize(data->backing) - old_hsize; -- cgit v1.2.3