summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-08-13 23:44:19 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-08-13 23:44:19 +0000
commite817f0af66db5063e74ac083da2966b4da931d6a (patch)
treed4d268f62049ff064fc70b2a5a2c5431b5797d7c /usr.bin/tmux
parent5a290393afd88020d86f0c36a17bcd64a8534586 (diff)
Switch the prompt code to return an empty string when the user enters no
response and reserve NULL for an explicit cancel. Change all callbacks to treat them the same so no functional change. Also add cancel key bindings to emacs mode which were missing.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/cmd-command-prompt.c4
-rw-r--r--usr.bin/tmux/cmd-confirm-before.c6
-rw-r--r--usr.bin/tmux/cmd-select-prompt.c4
-rw-r--r--usr.bin/tmux/mode-key.c4
-rw-r--r--usr.bin/tmux/status.c13
5 files changed, 16 insertions, 15 deletions
diff --git a/usr.bin/tmux/cmd-command-prompt.c b/usr.bin/tmux/cmd-command-prompt.c
index 4019689b702..bbb238e8eed 100644
--- a/usr.bin/tmux/cmd-command-prompt.c
+++ b/usr.bin/tmux/cmd-command-prompt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-command-prompt.c,v 1.6 2009/07/26 12:58:44 nicm Exp $ */
+/* $OpenBSD: cmd-command-prompt.c,v 1.7 2009/08/13 23:44:18 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -112,7 +112,7 @@ cmd_command_prompt_callback(void *data, const char *s)
char *cause, *ptr, *buf, ch;
size_t len, slen;
- if (s == NULL)
+ if (s == NULL || *s == '\0')
return (0);
slen = strlen(s);
diff --git a/usr.bin/tmux/cmd-confirm-before.c b/usr.bin/tmux/cmd-confirm-before.c
index e4fd9e2617a..87ce4c24969 100644
--- a/usr.bin/tmux/cmd-confirm-before.c
+++ b/usr.bin/tmux/cmd-confirm-before.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-confirm-before.c,v 1.6 2009/07/26 12:58:44 nicm Exp $ */
+/* $OpenBSD: cmd-confirm-before.c,v 1.7 2009/08/13 23:44:18 nicm Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -107,7 +107,9 @@ cmd_confirm_before_callback(void *data, const char *s)
struct cmd_ctx ctx;
char *cause;
- if (s == NULL || tolower((u_char) s[0]) != 'y' || s[1] != '\0')
+ if (s == NULL || *s == '\0')
+ return (0);
+ if (tolower((u_char) s[0]) != 'y' || s[1] != '\0')
return (0);
if (cmd_string_parse(cdata->cmd, &cmdlist, &cause) != 0) {
diff --git a/usr.bin/tmux/cmd-select-prompt.c b/usr.bin/tmux/cmd-select-prompt.c
index 5606ea733f0..a1166c5aeee 100644
--- a/usr.bin/tmux/cmd-select-prompt.c
+++ b/usr.bin/tmux/cmd-select-prompt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-select-prompt.c,v 1.5 2009/07/26 12:58:44 nicm Exp $ */
+/* $OpenBSD: cmd-select-prompt.c,v 1.6 2009/08/13 23:44:18 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -66,7 +66,7 @@ cmd_select_prompt_callback(void *data, const char *s)
char msg[128];
u_int idx;
- if (s == NULL)
+ if (s == NULL || *s == '\0')
return (0);
idx = strtonum(s, 0, UINT_MAX, &errstr);
diff --git a/usr.bin/tmux/mode-key.c b/usr.bin/tmux/mode-key.c
index 07f2ed7b21c..a9f3e5dec9c 100644
--- a/usr.bin/tmux/mode-key.c
+++ b/usr.bin/tmux/mode-key.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mode-key.c,v 1.13 2009/08/13 22:32:18 nicm Exp $ */
+/* $OpenBSD: mode-key.c,v 1.14 2009/08/13 23:44:18 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -181,6 +181,7 @@ struct mode_key_tree mode_key_tree_vi_copy;
const struct mode_key_entry mode_key_emacs_edit[] = {
{ '\001' /* C-a */, 0, MODEKEYEDIT_STARTOFLINE },
{ '\002' /* C-p */, 0, MODEKEYEDIT_CURSORLEFT },
+ { '\003' /* C-c */, 0, MODEKEYEDIT_CANCEL },
{ '\004' /* C-d */, 0, MODEKEYEDIT_DELETE },
{ '\005' /* C-e */, 0, MODEKEYEDIT_ENDOFLINE },
{ '\006' /* C-f */, 0, MODEKEYEDIT_CURSORRIGHT },
@@ -190,6 +191,7 @@ const struct mode_key_entry mode_key_emacs_edit[] = {
{ '\016' /* C-n */, 0, MODEKEYEDIT_HISTORYDOWN },
{ '\020' /* C-p */, 0, MODEKEYEDIT_HISTORYUP },
{ '\031' /* C-y */, 0, MODEKEYEDIT_PASTE },
+ { '\033' /* Escape */, 0, MODEKEYEDIT_CANCEL },
{ '\r', 0, MODEKEYEDIT_ENTER },
{ 'm' | KEYC_ESCAPE, 0, MODEKEYEDIT_STARTOFLINE },
{ KEYC_BSPACE, 0, MODEKEYEDIT_BACKSPACE },
diff --git a/usr.bin/tmux/status.c b/usr.bin/tmux/status.c
index b36ad27f96b..3a6b9f62186 100644
--- a/usr.bin/tmux/status.c
+++ b/usr.bin/tmux/status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: status.c,v 1.24 2009/08/08 20:36:42 nicm Exp $ */
+/* $OpenBSD: status.c,v 1.25 2009/08/13 23:44:18 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -920,14 +920,11 @@ status_prompt_key(struct client *c, int key)
c->flags |= CLIENT_STATUS;
break;
case MODEKEYEDIT_ENTER:
- if (*c->prompt_buffer != '\0') {
+ if (*c->prompt_buffer != '\0')
status_prompt_add_history(c);
- if (c->prompt_callbackfn(
- c->prompt_data, c->prompt_buffer) == 0)
- status_prompt_clear(c);
- break;
- }
- /* FALLTHROUGH */
+ if (c->prompt_callbackfn(c->prompt_data, c->prompt_buffer) == 0)
+ status_prompt_clear(c);
+ break;
case MODEKEYEDIT_CANCEL:
if (c->prompt_callbackfn(c->prompt_data, NULL) == 0)
status_prompt_clear(c);