mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-27 02:23:15 +01:00
Identical behaviour to select-prompt can now be obtained with
command-prompt, so remove select-prompt and change ' to be bound to command-prompt -p index "select-window -t :%%".
This commit is contained in:
parent
c4a2fdf15b
commit
e0f4697e7c
13
Makefile
13
Makefile
@ -19,16 +19,15 @@ SRCS= attributes.c cfg.c client.c clock.c \
|
||||
cmd-previous-layout.c cmd-previous-window.c cmd-refresh-client.c \
|
||||
cmd-rename-session.c cmd-rename-window.c cmd-resize-pane.c \
|
||||
cmd-respawn-window.c cmd-rotate-window.c cmd-save-buffer.c \
|
||||
cmd-select-layout.c cmd-select-pane.c \
|
||||
cmd-select-prompt.c cmd-select-window.c cmd-send-keys.c \
|
||||
cmd-send-prefix.c cmd-server-info.c cmd-set-buffer.c cmd-set-option.c \
|
||||
cmd-set-window-option.c cmd-show-buffer.c cmd-show-messages.c \
|
||||
cmd-show-options.c cmd-show-window-options.c cmd-source-file.c \
|
||||
cmd-split-window.c cmd-start-server.c cmd-string.c cmd-if-shell.c \
|
||||
cmd-select-layout.c cmd-select-pane.c cmd-select-window.c \
|
||||
cmd-send-keys.c cmd-send-prefix.c cmd-server-info.c cmd-set-buffer.c \
|
||||
cmd-set-option.c cmd-set-window-option.c cmd-show-buffer.c \
|
||||
cmd-show-messages.c cmd-show-options.c cmd-show-window-options.c \
|
||||
cmd-source-file.c cmd-split-window.c cmd-start-server.c cmd-string.c \
|
||||
cmd-run-shell.c cmd-suspend-client.c cmd-swap-pane.c cmd-swap-window.c \
|
||||
cmd-switch-client.c cmd-unbind-key.c cmd-unlink-window.c \
|
||||
cmd-set-environment.c cmd-show-environment.c cmd-choose-client.c \
|
||||
cmd-display-message.c cmd-display-panes.c \
|
||||
cmd-display-message.c cmd-display-panes.c cmd-if-shell.c \
|
||||
cmd-pipe-pane.c cmd-capture-pane.c cmd.c \
|
||||
colour.c environ.c grid-view.c grid-utf8.c grid.c input-keys.c \
|
||||
imsg.c imsg-buffer.c input.c key-bindings.c key-string.c \
|
||||
|
@ -81,6 +81,10 @@ cmd_command_prompt_init(struct cmd *self, int key)
|
||||
case 'f':
|
||||
data->template = xstrdup("find-window '%%'");
|
||||
break;
|
||||
case '\'':
|
||||
data->template = xstrdup("select-window -t ':%%'");
|
||||
data->prompts = xstrdup("index");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,91 +0,0 @@
|
||||
/* $OpenBSD$ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
/*
|
||||
* Prompt for window index and select it.
|
||||
*/
|
||||
|
||||
int cmd_select_prompt_exec(struct cmd *, struct cmd_ctx *);
|
||||
|
||||
int cmd_select_prompt_callback(void *, const char *);
|
||||
|
||||
const struct cmd_entry cmd_select_prompt_entry = {
|
||||
"select-prompt", NULL,
|
||||
CMD_TARGET_CLIENT_USAGE,
|
||||
0, "",
|
||||
cmd_target_init,
|
||||
cmd_target_parse,
|
||||
cmd_select_prompt_exec,
|
||||
cmd_target_free,
|
||||
cmd_target_print
|
||||
};
|
||||
|
||||
int
|
||||
cmd_select_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
{
|
||||
struct cmd_target_data *data = self->data;
|
||||
struct client *c;
|
||||
|
||||
if ((c = cmd_find_client(ctx, data->target)) == NULL)
|
||||
return (-1);
|
||||
|
||||
if (c->prompt_string != NULL)
|
||||
return (0);
|
||||
|
||||
status_prompt_set(c, "index ", cmd_select_prompt_callback, NULL, c, 0);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
cmd_select_prompt_callback(void *data, const char *s)
|
||||
{
|
||||
struct client *c = data;
|
||||
const char *errstr;
|
||||
char msg[128];
|
||||
u_int idx;
|
||||
|
||||
if (s == NULL || *s == '\0')
|
||||
return (0);
|
||||
|
||||
idx = strtonum(s, 0, UINT_MAX, &errstr);
|
||||
if (errstr != NULL) {
|
||||
xsnprintf(msg, sizeof msg, "Index %s: %s", errstr, s);
|
||||
status_message_set(c, "%s", msg);
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (winlink_find_by_index(&c->session->windows, idx) == NULL) {
|
||||
xsnprintf(msg, sizeof msg,
|
||||
"Window not found: %s:%d", c->session->name, idx);
|
||||
status_message_set(c, "%s", msg);
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (session_select(c->session, idx) == 0)
|
||||
server_redraw_session(c->session);
|
||||
recalculate_sizes();
|
||||
|
||||
return (0);
|
||||
}
|
1
cmd.c
1
cmd.c
@ -85,7 +85,6 @@ const struct cmd_entry *cmd_table[] = {
|
||||
&cmd_save_buffer_entry,
|
||||
&cmd_select_layout_entry,
|
||||
&cmd_select_pane_entry,
|
||||
&cmd_select_prompt_entry,
|
||||
&cmd_select_window_entry,
|
||||
&cmd_send_keys_entry,
|
||||
&cmd_send_prefix_entry,
|
||||
|
@ -125,7 +125,7 @@ key_bindings_init(void)
|
||||
{ '?', 0, &cmd_list_keys_entry },
|
||||
{ 'D', 0, &cmd_choose_client_entry },
|
||||
{ '[', 0, &cmd_copy_mode_entry },
|
||||
{ '\'', 0, &cmd_select_prompt_entry },
|
||||
{ '\'', 0, &cmd_command_prompt_entry },
|
||||
{ '\002', /* C-b */ 0, &cmd_send_prefix_entry },
|
||||
{ '\017', /* C-o */ 0, &cmd_rotate_window_entry },
|
||||
{ '\032', /* C-z */ 0, &cmd_suspend_client_entry },
|
||||
|
6
tmux.1
6
tmux.1
@ -1265,7 +1265,7 @@ or
|
||||
keys, quotation marks are necessary, for example:
|
||||
.Bd -literal -offset indent
|
||||
bind-key '"' split-window
|
||||
bind-key "'" select-prompt
|
||||
bind-key "'" new-window
|
||||
.Ed
|
||||
.Pp
|
||||
Commands related to key bindings are as follows:
|
||||
@ -2316,10 +2316,6 @@ The format of
|
||||
is as for
|
||||
.Ic status-left ,
|
||||
with the exception that #() are not handled.
|
||||
.It Ic select-prompt Op Fl t Ar target-client
|
||||
Open a prompt inside
|
||||
.Ar target-client
|
||||
allowing a window index to be entered interactively.
|
||||
.El
|
||||
.Sh BUFFERS
|
||||
.Nm
|
||||
|
1
tmux.h
1
tmux.h
@ -1495,7 +1495,6 @@ extern const struct cmd_entry cmd_run_shell_entry;
|
||||
extern const struct cmd_entry cmd_save_buffer_entry;
|
||||
extern const struct cmd_entry cmd_select_layout_entry;
|
||||
extern const struct cmd_entry cmd_select_pane_entry;
|
||||
extern const struct cmd_entry cmd_select_prompt_entry;
|
||||
extern const struct cmd_entry cmd_select_window_entry;
|
||||
extern const struct cmd_entry cmd_send_keys_entry;
|
||||
extern const struct cmd_entry cmd_send_prefix_entry;
|
||||
|
Loading…
Reference in New Issue
Block a user