summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2017-08-16 12:12:54 +0000
committernicm <nicm@openbsd.org>2017-08-16 12:12:54 +0000
commit3b2d01c064a55b6a704d663d8090ab4e1c456d54 (patch)
tree51ad3305bc3ac070ab93a8192acab096d0b83de8
parentRename BELL_* values to ALERT_* now they are used by more than bells, (diff)
downloadwireguard-openbsd-3b2d01c064a55b6a704d663d8090ab4e1c456d54.tar.xz
wireguard-openbsd-3b2d01c064a55b6a704d663d8090ab4e1c456d54.zip
Add -d flag to display-panes to specify timeout, and make 0 mean no
timeout. From Laurens Post.
-rw-r--r--usr.bin/tmux/cmd-display-panes.c21
-rw-r--r--usr.bin/tmux/server-client.c9
-rw-r--r--usr.bin/tmux/tmux.117
-rw-r--r--usr.bin/tmux/tmux.h4
4 files changed, 36 insertions, 15 deletions
diff --git a/usr.bin/tmux/cmd-display-panes.c b/usr.bin/tmux/cmd-display-panes.c
index d40a1a0366c..17ee70cf544 100644
--- a/usr.bin/tmux/cmd-display-panes.c
+++ b/usr.bin/tmux/cmd-display-panes.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-display-panes.c,v 1.19 2017/04/22 10:22:39 nicm Exp $ */
+/* $OpenBSD: cmd-display-panes.c,v 1.20 2017/08/16 12:12:54 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -37,8 +37,8 @@ const struct cmd_entry cmd_display_panes_entry = {
.name = "display-panes",
.alias = "displayp",
- .args = { "t:", 0, 1 },
- .usage = CMD_TARGET_CLIENT_USAGE,
+ .args = { "d:t:", 0, 1 },
+ .usage = "[-d duration] " CMD_TARGET_CLIENT_USAGE,
.flags = CMD_AFTERHOOK,
.exec = cmd_display_panes_exec
@@ -49,6 +49,9 @@ cmd_display_panes_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = self->args;
struct client *c;
+ struct session *s;
+ u_int delay;
+ char *cause;
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
return (CMD_RETURN_ERROR);
@@ -61,8 +64,18 @@ cmd_display_panes_exec(struct cmd *self, struct cmdq_item *item)
c->identify_callback_data = xstrdup(args->argv[0]);
else
c->identify_callback_data = xstrdup("select-pane -t '%%'");
+ s = c->session;
- server_client_set_identify(c);
+ if (args_has(args, 'd')) {
+ delay = args_strtonum(args, 'd', 0, UINT_MAX, &cause);
+ if (cause != NULL) {
+ cmdq_error(item, "delay %s", cause);
+ free(cause);
+ return (CMD_RETURN_ERROR);
+ }
+ } else
+ delay = options_get_number(s->options, "display-panes-time");
+ server_client_set_identify(c, delay);
return (CMD_RETURN_NORMAL);
}
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index 337f8b82e8c..10ce7534c83 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.241 2017/07/14 08:04:23 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.242 2017/08/16 12:12:54 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -74,19 +74,18 @@ server_client_callback_identify(__unused int fd, __unused short events,
/* Set identify mode on client. */
void
-server_client_set_identify(struct client *c)
+server_client_set_identify(struct client *c, u_int delay)
{
struct timeval tv;
- int delay;
- delay = options_get_number(c->session->options, "display-panes-time");
tv.tv_sec = delay / 1000;
tv.tv_usec = (delay % 1000) * 1000L;
if (event_initialized(&c->identify_timer))
evtimer_del(&c->identify_timer);
evtimer_set(&c->identify_timer, server_client_callback_identify, c);
- evtimer_add(&c->identify_timer, &tv);
+ if (delay != 0)
+ evtimer_add(&c->identify_timer, &tv);
c->flags |= CLIENT_IDENTIFY;
c->tty.flags |= (TTY_FREEZE|TTY_NOCURSOR);
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 46f34406cec..3819575d6c4 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.572 2017/08/09 11:43:45 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.573 2017/08/16 12:12:54 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: August 9 2017 $
+.Dd $Mdocdate: August 16 2017 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -1461,6 +1461,7 @@ specifies the format for each item in the tree.
This command works only if at least one client is attached.
.It Xo
.Ic display-panes
+.Op Fl d Ar duration
.Op Fl t Ar target-client
.Op Ar template
.Xc
@@ -1468,11 +1469,19 @@ This command works only if at least one client is attached.
Display a visible indicator of each pane shown by
.Ar target-client .
See the
-.Ic display-panes-time ,
-.Ic display-panes-colour ,
+.Ic display-panes-colour
and
.Ic display-panes-active-colour
session options.
+The indicator is closed when a key is pressed or
+.Ar duration
+milliseconds have passed.
+If
+.Fl d
+is not given,
+.Ic display-panes-time
+is used.
+A duration of zero means the indicator stays until a key is pressed.
While the indicator is on screen, a pane may be chosen with the
.Ql 0
to
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index ac1f9557c4d..c8ad282a046 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.799 2017/08/16 11:46:08 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.800 2017/08/16 12:12:54 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1870,7 +1870,7 @@ void server_add_accept(int);
/* server-client.c */
u_int server_client_how_many(void);
-void server_client_set_identify(struct client *);
+void server_client_set_identify(struct client *, u_int);
void server_client_clear_identify(struct client *, struct window_pane *);
void server_client_set_key_table(struct client *, const char *);
const char *server_client_get_key_table(struct client *);