mirror of
https://github.com/tmux/tmux.git
synced 2026-02-13 09:19:17 +00:00
Add -e flag to command-prompt to close if empty, from Dane Jensen in
GitHub issue 4812.
This commit is contained in:
@@ -42,8 +42,8 @@ const struct cmd_entry cmd_command_prompt_entry = {
|
|||||||
.name = "command-prompt",
|
.name = "command-prompt",
|
||||||
.alias = NULL,
|
.alias = NULL,
|
||||||
|
|
||||||
.args = { "1bFkliI:Np:t:T:", 0, 1, cmd_command_prompt_args_parse },
|
.args = { "1beFiklI:Np:t:T:", 0, 1, cmd_command_prompt_args_parse },
|
||||||
.usage = "[-1bFkliN] [-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE
|
.usage = "[-1beFiklN] [-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE
|
||||||
" [-T prompt-type] [template]",
|
" [-T prompt-type] [template]",
|
||||||
|
|
||||||
.flags = CMD_CLIENT_TFLAG,
|
.flags = CMD_CLIENT_TFLAG,
|
||||||
@@ -163,6 +163,8 @@ cmd_command_prompt_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
cdata->flags |= PROMPT_INCREMENTAL;
|
cdata->flags |= PROMPT_INCREMENTAL;
|
||||||
else if (args_has(args, 'k'))
|
else if (args_has(args, 'k'))
|
||||||
cdata->flags |= PROMPT_KEY;
|
cdata->flags |= PROMPT_KEY;
|
||||||
|
else if (args_has(args, 'e'))
|
||||||
|
cdata->flags |= PROMPT_BSPACE_EXIT;
|
||||||
status_prompt_set(tc, target, cdata->prompts[0].prompt,
|
status_prompt_set(tc, target, cdata->prompts[0].prompt,
|
||||||
cdata->prompts[0].input, cmd_command_prompt_callback,
|
cdata->prompts[0].input, cmd_command_prompt_callback,
|
||||||
cmd_command_prompt_free, cdata, cdata->flags, cdata->prompt_type);
|
cmd_command_prompt_free, cdata, cdata->flags, cdata->prompt_type);
|
||||||
|
|||||||
5
status.c
5
status.c
@@ -1383,6 +1383,11 @@ process_key:
|
|||||||
break;
|
break;
|
||||||
case KEYC_BSPACE:
|
case KEYC_BSPACE:
|
||||||
case 'h'|KEYC_CTRL:
|
case 'h'|KEYC_CTRL:
|
||||||
|
if (c->prompt_flags & PROMPT_BSPACE_EXIT && size == 0) {
|
||||||
|
if (c->prompt_inputcb(c, c->prompt_data, NULL, 1) == 0)
|
||||||
|
status_prompt_clear(c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (c->prompt_index != 0) {
|
if (c->prompt_index != 0) {
|
||||||
if (c->prompt_index == size)
|
if (c->prompt_index == size)
|
||||||
c->prompt_buffer[--c->prompt_index].size = 0;
|
c->prompt_buffer[--c->prompt_index].size = 0;
|
||||||
|
|||||||
6
tmux.1
6
tmux.1
@@ -6716,7 +6716,7 @@ See
|
|||||||
for possible values for
|
for possible values for
|
||||||
.Ar prompt-type .
|
.Ar prompt-type .
|
||||||
.It Xo Ic command-prompt
|
.It Xo Ic command-prompt
|
||||||
.Op Fl 1bFiklN
|
.Op Fl 1beFiklN
|
||||||
.Op Fl I Ar inputs
|
.Op Fl I Ar inputs
|
||||||
.Op Fl p Ar prompts
|
.Op Fl p Ar prompts
|
||||||
.Op Fl t Ar target-client
|
.Op Fl t Ar target-client
|
||||||
@@ -6789,6 +6789,10 @@ makes the prompt only accept numeric key presses.
|
|||||||
.Fl i
|
.Fl i
|
||||||
executes the command every time the prompt input changes instead of when the
|
executes the command every time the prompt input changes instead of when the
|
||||||
user exits the command prompt.
|
user exits the command prompt.
|
||||||
|
.Fl e
|
||||||
|
makes
|
||||||
|
.Em BSpace
|
||||||
|
cancel an empty prompt.
|
||||||
.Pp
|
.Pp
|
||||||
.Fl T
|
.Fl T
|
||||||
tells
|
tells
|
||||||
|
|||||||
1
tmux.h
1
tmux.h
@@ -2054,6 +2054,7 @@ struct client {
|
|||||||
#define PROMPT_KEY 0x10
|
#define PROMPT_KEY 0x10
|
||||||
#define PROMPT_ACCEPT 0x20
|
#define PROMPT_ACCEPT 0x20
|
||||||
#define PROMPT_QUOTENEXT 0x40
|
#define PROMPT_QUOTENEXT 0x40
|
||||||
|
#define PROMPT_BSPACE_EXIT 0x80
|
||||||
int prompt_flags;
|
int prompt_flags;
|
||||||
enum prompt_type prompt_type;
|
enum prompt_type prompt_type;
|
||||||
int prompt_cursor;
|
int prompt_cursor;
|
||||||
|
|||||||
Reference in New Issue
Block a user