summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2020-03-28 09:51:13 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2020-03-28 09:51:13 +0000
commit92994531665ee55ac49c741fa9cfcd8a73502b7d (patch)
tree01f78143dc877f9efa96e2c05e306ae83af71134 /usr.bin/tmux
parent8b552de51b522a5cd7c41b4b79f609711e14c33a (diff)
Make two -E only close popup automatically if the command exited with 0.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/cmd-display-menu.c6
-rw-r--r--usr.bin/tmux/popup.c7
-rw-r--r--usr.bin/tmux/tmux.17
-rw-r--r--usr.bin/tmux/tmux.h3
4 files changed, 17 insertions, 6 deletions
diff --git a/usr.bin/tmux/cmd-display-menu.c b/usr.bin/tmux/cmd-display-menu.c
index ad8bff823c9..c4e6b3c56b0 100644
--- a/usr.bin/tmux/cmd-display-menu.c
+++ b/usr.bin/tmux/cmd-display-menu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-display-menu.c,v 1.8 2020/03/28 09:39:44 nicm Exp $ */
+/* $OpenBSD: cmd-display-menu.c,v 1.9 2020/03/28 09:51:12 nicm Exp $ */
/*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -280,7 +280,9 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
if (args_has(args, 'K'))
flags |= POPUP_WRITEKEYS;
- if (args_has(args, 'E'))
+ if (args_has(args, 'E') > 1)
+ flags |= POPUP_CLOSEEXITZERO;
+ else if (args_has(args, 'E'))
flags |= POPUP_CLOSEEXIT;
if (popup_display(flags, item, px, py, w, h, nlines, lines, shellcmd,
cmd, cwd, c, fs) != 0)
diff --git a/usr.bin/tmux/popup.c b/usr.bin/tmux/popup.c
index c3424674c39..32d4d5df6f7 100644
--- a/usr.bin/tmux/popup.c
+++ b/usr.bin/tmux/popup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: popup.c,v 1.2 2020/03/28 09:39:44 nicm Exp $ */
+/* $OpenBSD: popup.c,v 1.3 2020/03/28 09:51:12 nicm Exp $ */
/*
* Copyright (c) 2020 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -260,7 +260,8 @@ popup_key_cb(struct client *c, struct key_event *event)
if (pd->ictx != NULL && (pd->flags & POPUP_WRITEKEYS)) {
if (KEYC_IS_MOUSE(event->key))
return (0);
- if ((~pd->flags & POPUP_CLOSEEXIT) &&
+ if (((pd->flags & (POPUP_CLOSEEXIT|POPUP_CLOSEEXITZERO)) == 0 ||
+ pd->job == NULL) &&
(event->key == '\033' || event->key == '\003'))
return (1);
if (pd->job == NULL)
@@ -347,6 +348,8 @@ popup_job_complete_cb(struct job *job)
if (pd->flags & POPUP_CLOSEEXIT)
server_client_clear_overlay(pd->c);
+ if ((pd->flags & POPUP_CLOSEEXITZERO) && pd->status == 0)
+ server_client_clear_overlay(pd->c);
}
u_int
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 65c480c3a13..cc2db2e9ed7 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.722 2020/03/28 09:39:27 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.723 2020/03/28 09:51:12 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
@@ -5032,6 +5032,11 @@ shell command.
closes the popup automatically when
.Ar shell-command
exits.
+Two
+.Fl E
+closes the popup only if
+.Ar shell-command
+exited with success.
With
.Fl K ,
.Ql Escape
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 6fff7c8fe14..43227313398 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.965 2020/03/28 09:39:44 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.966 2020/03/28 09:51:12 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -2761,6 +2761,7 @@ int menu_display(struct menu *, int, struct cmdq_item *, u_int,
/* popup.c */
#define POPUP_WRITEKEYS 0x1
#define POPUP_CLOSEEXIT 0x2
+#define POPUP_CLOSEEXITZERO 0x4
u_int popup_width(struct cmdq_item *, u_int, const char **,
struct client *, struct cmd_find_state *);
u_int popup_height(u_int, const char **);