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 :%%".
This commit is contained in:
Tiago Cunha 2010-05-14 14:33:39 +00:00
parent fc69b9ccb7
commit 9900e28ba8
6 changed files with 12 additions and 105 deletions

View File

@ -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 <nicm@users.sourceforge.net> * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -81,6 +81,10 @@ cmd_command_prompt_init(struct cmd *self, int key)
case 'f': case 'f':
data->template = xstrdup("find-window '%%'"); data->template = xstrdup("find-window '%%'");
break; break;
case '\'':
data->template = xstrdup("select-window -t ':%%'");
data->prompts = xstrdup("index");
break;
} }
} }

View File

@ -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 <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);
}

3
cmd.c
View File

@ -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 <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -84,7 +84,6 @@ const struct cmd_entry *cmd_table[] = {
&cmd_save_buffer_entry, &cmd_save_buffer_entry,
&cmd_select_layout_entry, &cmd_select_layout_entry,
&cmd_select_pane_entry, &cmd_select_pane_entry,
&cmd_select_prompt_entry,
&cmd_select_window_entry, &cmd_select_window_entry,
&cmd_send_keys_entry, &cmd_send_keys_entry,
&cmd_send_prefix_entry, &cmd_send_prefix_entry,

View File

@ -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 <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -125,7 +125,7 @@ key_bindings_init(void)
{ '?', 0, &cmd_list_keys_entry }, { '?', 0, &cmd_list_keys_entry },
{ 'D', 0, &cmd_choose_client_entry }, { 'D', 0, &cmd_choose_client_entry },
{ '[', 0, &cmd_copy_mode_entry }, { '[', 0, &cmd_copy_mode_entry },
{ '\'', 0, &cmd_select_prompt_entry }, { '\'', 0, &cmd_command_prompt_entry },
{ '\002', /* C-b */ 0, &cmd_send_prefix_entry }, { '\002', /* C-b */ 0, &cmd_send_prefix_entry },
{ '\017', /* C-o */ 0, &cmd_rotate_window_entry }, { '\017', /* C-o */ 0, &cmd_rotate_window_entry },
{ '\032', /* C-z */ 0, &cmd_suspend_client_entry }, { '\032', /* C-z */ 0, &cmd_suspend_client_entry },

10
tmux.1
View File

@ -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 <nicm@users.sourceforge.net> .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\" .\"
@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" 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 .Dt TMUX 1
.Os .Os
.Sh NAME .Sh NAME
@ -1265,7 +1265,7 @@ or
keys, quotation marks are necessary, for example: keys, quotation marks are necessary, for example:
.Bd -literal -offset indent .Bd -literal -offset indent
bind-key '"' split-window bind-key '"' split-window
bind-key "'" select-prompt bind-key "'" new-window
.Ed .Ed
.Pp .Pp
Commands related to key bindings are as follows: Commands related to key bindings are as follows:
@ -2316,10 +2316,6 @@ The format of
is as for is as for
.Ic status-left , .Ic status-left ,
with the exception that #() are not handled. 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 .El
.Sh BUFFERS .Sh BUFFERS
.Nm .Nm

3
tmux.h
View File

@ -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 <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -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_save_buffer_entry;
extern const struct cmd_entry cmd_select_layout_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_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_select_window_entry;
extern const struct cmd_entry cmd_send_keys_entry; extern const struct cmd_entry cmd_send_keys_entry;
extern const struct cmd_entry cmd_send_prefix_entry; extern const struct cmd_entry cmd_send_prefix_entry;