summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2013-03-21 16:14:10 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2013-03-21 16:14:10 +0000
commit50e19b499c5a6a43a272aae7a62e6c660d574362 (patch)
tree4a8854ba9b2f1e8cbad9134cb835f8d7aaf7c898
parent49f3c5d45c5e0601ddb83ca69cbe5a6cc5dbad8d (diff)
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.
-rw-r--r--usr.bin/tmux/format.c4
-rw-r--r--usr.bin/tmux/server-client.c9
-rw-r--r--usr.bin/tmux/status.c6
-rw-r--r--usr.bin/tmux/tmux.14
4 files changed, 16 insertions, 7 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c
index 7568199ca41..9cd61124891 100644
--- a/usr.bin/tmux/format.c
+++ b/usr.bin/tmux/format.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: format.c,v 1.13 2013/03/21 16:13:24 nicm Exp $ */
+/* $OpenBSD: format.c,v 1.14 2013/03/21 16:14:09 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index 062e08fa447..4e4e2c3825a 100644
--- a/usr.bin/tmux/server-client.c
+++ b/usr.bin/tmux/server-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-client.c,v 1.84 2013/01/30 17:00:17 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.85 2013/03/21 16:14:09 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -418,6 +418,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;
}
@@ -432,6 +433,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) {
@@ -587,8 +589,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/usr.bin/tmux/status.c b/usr.bin/tmux/status.c
index 84bbad89a6c..fde309b2293 100644
--- a/usr.bin/tmux/status.c
+++ b/usr.bin/tmux/status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: status.c,v 1.96 2013/03/21 16:13:24 nicm Exp $ */
+/* $OpenBSD: status.c,v 1.97 2013/03/21 16:14:09 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index fc1d83f6e9c..94121a7cad0 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.314 2013/03/21 16:09:59 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.315 2013/03/21 16:14:09 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -2366,6 +2366,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
@@ -2935,6 +2936,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"