From 06ac4b628dfb581eaad29e8a33859ab9bb07f8bb Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Sun, 10 Feb 2013 18:58:05 +0000 Subject: [PATCH] Add a format client_prefix which is 1 if prefix key has been pressed, used for example #{?client_prefix,X,Y}. Also a few extra server_client_status needed. --- format.c | 2 ++ server-client.c | 7 ++++++- status.c | 4 ++-- tmux.1 | 2 ++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/format.c b/format.c index 1143ced3..abd6808c 100644 --- a/format.c +++ b/format.c @@ -322,6 +322,8 @@ format_client(struct format_tree *ft, struct client *c) *strchr(tim, '\n') = '\0'; format_add(ft, "client_activity_string", "%s", tim); + format_add(ft, "client_prefix", "%d", !!(c->flags & CLIENT_PREFIX)); + if (c->tty.flags & TTY_UTF8) format_add(ft, "client_utf8", "%d", 1); else diff --git a/server-client.c b/server-client.c index 796390f7..e683a206 100644 --- a/server-client.c +++ b/server-client.c @@ -417,6 +417,7 @@ server_client_handle_key(struct client *c, int key) if (!(c->flags & CLIENT_PREFIX)) { if (isprefix) { c->flags |= CLIENT_PREFIX; + server_status_client(c); return; } @@ -431,6 +432,7 @@ server_client_handle_key(struct client *c, int key) /* Prefix key already pressed. Reset prefix and lookup key. */ c->flags &= ~CLIENT_PREFIX; + server_status_client(c); if ((bd = key_bindings_lookup(key | KEYC_PREFIX)) == NULL) { /* If repeating, treat this as a key, else ignore. */ if (c->flags & CLIENT_REPEAT) { @@ -586,8 +588,11 @@ server_client_repeat_timer(unused int fd, unused short events, void *data) { struct client *c = data; - if (c->flags & CLIENT_REPEAT) + if (c->flags & CLIENT_REPEAT) { + if (c->flags & CLIENT_PREFIX) + server_status_client(c); c->flags &= ~(CLIENT_PREFIX|CLIENT_REPEAT); + } } /* Check if client should be exited. */ diff --git a/status.c b/status.c index fa1d44e6..13ea9a53 100644 --- a/status.c +++ b/status.c @@ -437,8 +437,7 @@ status_replace1(struct client *c, struct session *s, struct winlink *wl, case 'P': if (window_pane_index(wp, &idx) != 0) fatalx("index not found"); - xsnprintf( - tmp, sizeof tmp, "%u", idx); + xsnprintf(tmp, sizeof tmp, "%u", idx); ptr = tmp; goto do_replace; case 'S': @@ -539,6 +538,7 @@ status_replace(struct client *c, struct session *s, struct winlink *wl, *optr = '\0'; ft = format_create(); + format_client(ft, c); format_session(ft, s); format_winlink(ft, s, wl); format_window_pane(ft, wp); diff --git a/tmux.1 b/tmux.1 index c360be77..235f3c8e 100644 --- a/tmux.1 +++ b/tmux.1 @@ -2370,6 +2370,7 @@ may contain any of the following special character sequences: .It Li "#S" Ta "Session name" .It Li "#T" Ta "Current pane title" .It Li "#W" Ta "Current window name" +.It Li "'^" Ta "Prefix key if pressed or same length as spaces" .It Li "##" Ta "A literal" Ql # .El .Pp @@ -2939,6 +2940,7 @@ The following variables are available, where appropriate: .It Li "client_created_string" Ta "String time client created" .It Li "client_cwd" Ta "Working directory of client" .It Li "client_height" Ta "Height of client" +.It Li "client_prefix" Ta "1 if prefix key has been pressed" .It Li "client_readonly" Ta "1 if client is readonly" .It Li "client_termname" Ta "Terminal name of client" .It Li "client_tty" Ta "Pseudo terminal of client"