From e0f4697e7cfd1a09d6332eae607fd3a9a1181234 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 5 May 2010 23:24:23 +0000 Subject: [PATCH] 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 :%%". --- Makefile | 13 +++---- cmd-command-prompt.c | 4 ++ cmd-select-prompt.c | 91 -------------------------------------------- cmd.c | 1 - key-bindings.c | 2 +- tmux.1 | 6 +-- tmux.h | 1 - 7 files changed, 12 insertions(+), 106 deletions(-) delete mode 100644 cmd-select-prompt.c diff --git a/Makefile b/Makefile index 189ea52f..6907a68b 100644 --- a/Makefile +++ b/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 \ diff --git a/cmd-command-prompt.c b/cmd-command-prompt.c index e3774256..b76ea8d1 100644 --- a/cmd-command-prompt.c +++ b/cmd-command-prompt.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; } } diff --git a/cmd-select-prompt.c b/cmd-select-prompt.c deleted file mode 100644 index 12fe711d..00000000 --- a/cmd-select-prompt.c +++ /dev/null @@ -1,91 +0,0 @@ -/* $OpenBSD$ */ - -/* - * Copyright (c) 2008 Nicholas Marriott - * - * 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 - -#include - -#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); -} diff --git a/cmd.c b/cmd.c index 09b58adf..d82a765e 100644 --- a/cmd.c +++ b/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, diff --git a/key-bindings.c b/key-bindings.c index 9a2fcc12..44132202 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -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 }, diff --git a/tmux.1 b/tmux.1 index 49816e24..26966cb6 100644 --- a/tmux.1 +++ b/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 diff --git a/tmux.h b/tmux.h index ec6ab3d4..d07a6517 100644 --- a/tmux.h +++ b/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;