From 9900e28ba88526eec3ba623ea1ebc94116257c97 Mon Sep 17 00:00:00 2001 From: Tiago Cunha Date: Fri, 14 May 2010 14:33:39 +0000 Subject: Sync OpenBSD patchset 697: 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 :%%". --- cmd-command-prompt.c | 6 +++- cmd-select-prompt.c | 91 ---------------------------------------------------- cmd.c | 3 +- key-bindings.c | 4 +-- tmux.1 | 10 ++---- tmux.h | 3 +- 6 files changed, 12 insertions(+), 105 deletions(-) delete mode 100644 cmd-select-prompt.c diff --git a/cmd-command-prompt.c b/cmd-command-prompt.c index 37814cb9..896923b9 100644 --- a/cmd-command-prompt.c +++ b/cmd-command-prompt.c @@ -1,4 +1,4 @@ -/* $Id: cmd-command-prompt.c,v 1.27 2009-11-14 17:56:39 tcunha Exp $ */ +/* $Id: cmd-command-prompt.c,v 1.28 2010-05-14 14:33:39 tcunha Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -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 3e6b2f51..00000000 --- a/cmd-select-prompt.c +++ /dev/null @@ -1,91 +0,0 @@ -/* $Id: cmd-select-prompt.c,v 1.13 2009-11-14 17:56:39 tcunha Exp $ */ - -/* - * 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 bda30207..079cf5e8 100644 --- a/cmd.c +++ b/cmd.c @@ -1,4 +1,4 @@ -/* $Id: cmd.c,v 1.138 2010-03-15 22:03:38 nicm Exp $ */ +/* $Id: cmd.c,v 1.139 2010-05-14 14:33:39 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -84,7 +84,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 7301a4d9..1a41398c 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -1,4 +1,4 @@ -/* $Id: key-bindings.c,v 1.91 2010-05-14 14:16:37 tcunha Exp $ */ +/* $Id: key-bindings.c,v 1.92 2010-05-14 14:33:39 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -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 08b9f7be..481574f7 100644 --- a/tmux.1 +++ b/tmux.1 @@ -1,4 +1,4 @@ -.\" $Id: tmux.1,v 1.248 2010-05-14 14:19:41 tcunha Exp $ +.\" $Id: tmux.1,v 1.249 2010-05-14 14:33:39 tcunha Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: May 2 2010 $ +.Dd $Mdocdate: May 5 2010 $ .Dt TMUX 1 .Os .Sh NAME @@ -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 70b96532..d8c8faa1 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.556 2010-05-14 14:30:01 tcunha Exp $ */ +/* $Id: tmux.h,v 1.557 2010-05-14 14:33:39 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1494,7 +1494,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; -- cgit v1.2.3