The branch, master has been updated via 06ac4b628dfb581eaad29e8a33859ab9bb07f8bb (commit) via 6c53a1ed684e0e149679e7df3365d8d6f41d4cdc (commit) from 6ad2c5c40fb1532b2eeae9f01327752708c6a510 (commit)
- Log ----------------------------------------------------------------- commit 06ac4b628dfb581eaad29e8a33859ab9bb07f8bb Author: Nicholas Marriott <nicholas.marri...@gmail.com> Commit: Nicholas Marriott <nicholas.marri...@gmail.com> 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 1143ced..abd6808 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 796390f..e683a20 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 fa1d44e..13ea9a5 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 c360be7..235f3c8 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" commit 6c53a1ed684e0e149679e7df3365d8d6f41d4cdc Author: Nicholas Marriott <nicholas.marri...@gmail.com> Commit: Nicholas Marriott <nicholas.marri...@gmail.com> Allow formats in status options. --- format.c | 3 ++- status.c | 30 +++++++++++++++++++----------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/format.c b/format.c index 5f57c72..1143ced 100644 --- a/format.c +++ b/format.c @@ -251,10 +251,11 @@ format_expand(struct format_tree *ft, const char *fmt) continue; } } - while (len - off < 2) { + while (len - off < 3) { buf = xrealloc(buf, 2, len); len *= 2; } + buf[off++] = '#'; buf[off++] = ch; continue; } diff --git a/status.c b/status.c index 88ab68d..fa1d44e 100644 --- a/status.c +++ b/status.c @@ -393,13 +393,6 @@ status_replace1(struct client *c, struct session *s, struct winlink *wl, long limit; u_int idx; - if (s == NULL) - s = c->session; - if (wl == NULL) - wl = s->curw; - if (wp == NULL) - wp = wl->window->active; - errno = 0; limit = strtol(*iptr, &endptr, 10); if ((limit == 0 && errno != EINVAL) || @@ -468,6 +461,9 @@ status_replace1(struct client *c, struct session *s, struct winlink *wl, */ ch = ']'; goto skip_to; + case '{': + ptr = (char *) "#{"; + goto do_replace; case '#': *(*optr)++ = '#'; break; @@ -507,13 +503,21 @@ char * status_replace(struct client *c, struct session *s, struct winlink *wl, struct window_pane *wp, const char *fmt, time_t t, int jobsflag) { - static char out[BUFSIZ]; - char in[BUFSIZ], ch, *iptr, *optr; - size_t len; + static char out[BUFSIZ]; + char in[BUFSIZ], ch, *iptr, *optr; + size_t len; + struct format_tree *ft; if (fmt == NULL) return (xstrdup("")); + if (s == NULL) + s = c->session; + if (wl == NULL) + wl = s->curw; + if (wp == NULL) + wp = wl->window->active; + len = strftime(in, sizeof in, fmt, localtime(&t)); in[len] = '\0'; @@ -534,7 +538,11 @@ status_replace(struct client *c, struct session *s, struct winlink *wl, } *optr = '\0'; - return (xstrdup(out)); + ft = format_create(); + format_session(ft, s); + format_winlink(ft, s, wl); + format_window_pane(ft, wp); + return (format_expand(ft, out)); } /* Figure out job name and get its result, starting it off if necessary. */ ----------------------------------------------------------------------- Summary of changes: format.c | 5 ++++- server-client.c | 7 ++++++- status.c | 34 +++++++++++++++++++++------------- tmux.1 | 2 ++ 4 files changed, 33 insertions(+), 15 deletions(-) hooks/post-receive -- tmux ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb _______________________________________________ tmux-cvs mailing list tmux-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-cvs