summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Viennot <nicolas@viennot.biz>2013-06-26 02:05:13 -0400
committerNicolas Viennot <nicolas@viennot.biz>2013-06-26 02:05:13 -0400
commitc9a6e2560af951ed450732d80844309d8778eaef (patch)
tree6c88a631a7dd80063b4c77148db27c322bdd224e
parent59cab76dd89d96cdcc446567711462eb1c53ca35 (diff)
Synchronize the list binding pane (bind-key + ?)1.8.5
-rw-r--r--cmd-list-keys.c10
-rw-r--r--cmd-queue.c1
-rw-r--r--tmate-encoder.c11
-rw-r--r--tmate.h2
-rw-r--r--window-copy.c10
5 files changed, 33 insertions, 1 deletions
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;