mirror of
https://github.com/tmate-io/tmate.git
synced 2024-12-24 15:48:58 +01:00
Sync OpenBSD patchset 261:
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.
This commit is contained in:
parent
6f9a2ee50a
commit
646d6a929c
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-command-prompt.c,v 1.21 2009-07-28 22:12:16 tcunha Exp $ */
|
||||
/* $Id: cmd-command-prompt.c,v 1.22 2009-08-16 19:29:24 tcunha 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);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-confirm-before.c,v 1.9 2009-07-28 22:12:16 tcunha Exp $ */
|
||||
/* $Id: cmd-confirm-before.c,v 1.10 2009-08-16 19:29:24 tcunha 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) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-select-prompt.c,v 1.11 2009-07-28 22:12:16 tcunha Exp $ */
|
||||
/* $Id: cmd-select-prompt.c,v 1.12 2009-08-16 19:29:24 tcunha 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);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: mode-key.c,v 1.24 2009-08-16 19:26:49 tcunha Exp $ */
|
||||
/* $Id: mode-key.c,v 1.25 2009-08-16 19:29:24 tcunha 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 },
|
||||
|
13
status.c
13
status.c
@ -1,4 +1,4 @@
|
||||
/* $Id: status.c,v 1.109 2009-08-09 17:40:17 tcunha Exp $ */
|
||||
/* $Id: status.c,v 1.110 2009-08-16 19:29:24 tcunha 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);
|
||||
|
Loading…
Reference in New Issue
Block a user