mirror of
https://github.com/tmux/tmux.git
synced 2026-03-26 13:16:37 +00:00
Add options to new-pane: -k -m message to wait for key before closing a floating pane.
This commit is contained in:
@@ -35,9 +35,9 @@ const struct cmd_entry cmd_new_pane_entry = {
|
|||||||
.name = "new-pane",
|
.name = "new-pane",
|
||||||
.alias = "newp",
|
.alias = "newp",
|
||||||
|
|
||||||
.args = { "bc:de:fF:h:Il:p:Pt:w:x:y:Z", 0, -1, NULL },
|
.args = { "bc:de:fF:h:Iklm:p:Pt:w:x:y:Z", 0, -1, NULL },
|
||||||
.usage = "[-bdefhIPvZ] [-c start-directory] [-e environment] "
|
.usage = "[-bdefhIklPvZ] [-c start-directory] [-e environment] "
|
||||||
"[-F format] [-l size] " CMD_TARGET_PANE_USAGE
|
"[-F format] [-l size] [-m message] " CMD_TARGET_PANE_USAGE
|
||||||
" [shell-command [argument ...]]",
|
" [shell-command [argument ...]]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
@@ -204,6 +204,12 @@ cmd_new_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
environ_free(sc.environ);
|
environ_free(sc.environ);
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
if (args_has(args, 'k') || args_has(args, 'm')) {
|
||||||
|
options_set_number(new_wp->options, "remain-on-exit", 3);
|
||||||
|
if (args_has(args, 'm'))
|
||||||
|
options_set_string(new_wp->options, "remain-on-exit-format",
|
||||||
|
0, "%s", args_get(args, 'm'));
|
||||||
|
}
|
||||||
if (input) {
|
if (input) {
|
||||||
switch (window_pane_start_input(new_wp, item, &cause)) {
|
switch (window_pane_start_input(new_wp, item, &cause)) {
|
||||||
case -1:
|
case -1:
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ static const char *options_table_window_size_list[] = {
|
|||||||
"largest", "smallest", "manual", "latest", NULL
|
"largest", "smallest", "manual", "latest", NULL
|
||||||
};
|
};
|
||||||
static const char *options_table_remain_on_exit_list[] = {
|
static const char *options_table_remain_on_exit_list[] = {
|
||||||
"off", "on", "failed", NULL
|
"off", "on", "failed", "keypress", NULL
|
||||||
};
|
};
|
||||||
static const char *options_table_destroy_unattached_list[] = {
|
static const char *options_table_destroy_unattached_list[] = {
|
||||||
"off", "on", "keep-last", "keep-group", NULL
|
"off", "on", "keep-last", "keep-group", NULL
|
||||||
@@ -1414,7 +1414,7 @@ const struct options_table_entry options_table[] = {
|
|||||||
{ .name = "remain-on-exit-format",
|
{ .name = "remain-on-exit-format",
|
||||||
.type = OPTIONS_TABLE_STRING,
|
.type = OPTIONS_TABLE_STRING,
|
||||||
.scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE,
|
.scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE,
|
||||||
.default_str = "Pane is dead ("
|
.default_str = "Command exited ("
|
||||||
"#{?#{!=:#{pane_dead_status},},"
|
"#{?#{!=:#{pane_dead_status},},"
|
||||||
"status #{pane_dead_status},}"
|
"status #{pane_dead_status},}"
|
||||||
"#{?#{!=:#{pane_dead_signal},},"
|
"#{?#{!=:#{pane_dead_signal},},"
|
||||||
|
|||||||
@@ -2665,6 +2665,14 @@ try_again:
|
|||||||
forward_key:
|
forward_key:
|
||||||
if (c->flags & CLIENT_READONLY)
|
if (c->flags & CLIENT_READONLY)
|
||||||
goto out;
|
goto out;
|
||||||
|
if (wp != NULL &&
|
||||||
|
options_get_number(wp->options, "remain-on-exit") == 3 &&
|
||||||
|
(wp->flags & PANE_EXITED) &&
|
||||||
|
!KEYC_IS_MOUSE(key) && !KEYC_IS_PASTE(key)) {
|
||||||
|
options_set_number(wp->options, "remain-on-exit", 0);
|
||||||
|
server_destroy_pane(wp, 0);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
if (wp != NULL)
|
if (wp != NULL)
|
||||||
window_pane_key(wp, c, s, wl, key, m);
|
window_pane_key(wp, c, s, wl, key, m);
|
||||||
goto out;
|
goto out;
|
||||||
|
|||||||
@@ -339,8 +339,11 @@ server_destroy_pane(struct window_pane *wp, int notify)
|
|||||||
switch (remain_on_exit) {
|
switch (remain_on_exit) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
|
case 3: /* keypress — fall through to draw remain-on-exit-format message */
|
||||||
|
/* FALLTHROUGH */
|
||||||
case 2:
|
case 2:
|
||||||
if (WIFEXITED(wp->status) && WEXITSTATUS(wp->status) == 0)
|
if (remain_on_exit == 2 &&
|
||||||
|
WIFEXITED(wp->status) && WEXITSTATUS(wp->status) == 0)
|
||||||
break;
|
break;
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case 1:
|
case 1:
|
||||||
|
|||||||
Reference in New Issue
Block a user