diff --git a/cmd-confirm-before.c b/cmd-confirm-before.c index 79b67b10..71cbe61c 100644 --- a/cmd-confirm-before.c +++ b/cmd-confirm-before.c @@ -1,4 +1,4 @@ -/* $Id: cmd-confirm-before.c,v 1.1 2009-04-27 13:21:15 tcunha Exp $ */ +/* $Id: cmd-confirm-before.c,v 1.2 2009-04-27 17:27:36 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha @@ -125,7 +125,8 @@ cmd_confirm_before_exec(unused struct cmd *self, struct cmd_ctx *ctx) cdata = xmalloc(sizeof *cdata); cdata->data.cmd = xstrdup(data->cmd); cdata->c = ctx->curclient; - status_prompt_set(cdata->c, buf, cmd_confirm_before_callback, cdata, 0); + status_prompt_set( + cdata->c, buf, cmd_confirm_before_callback, cdata, PROMPT_SINGLE); xfree(buf); return (1); @@ -183,7 +184,7 @@ cmd_confirm_before_callback(void *data, const char *s) struct cmd_ctx ctx; char *cause; - if (s == NULL || (strcasecmp(s, "y") && strcasecmp(s, "yes"))) + if (s == NULL || tolower((u_char) s[0]) != 'y' || s[1] != '\0') goto out; if (cmd_string_parse(cdata->data.cmd, &cmdlist, &cause) != 0) { diff --git a/server-fn.c b/server-fn.c index 5f8b0a45..ca74fd3d 100644 --- a/server-fn.c +++ b/server-fn.c @@ -1,4 +1,4 @@ -/* $Id: server-fn.c,v 1.58 2009-04-02 20:30:20 nicm Exp $ */ +/* $Id: server-fn.c,v 1.59 2009-04-27 17:27:36 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -183,7 +183,8 @@ server_lock(void) continue; status_prompt_clear(c); - status_prompt_set(c, "Password: ", server_lock_callback, c, 1); + status_prompt_set( + c, "Password: ", server_lock_callback, c, PROMPT_HIDDEN); server_redraw_client(c); } server_locked = 1; diff --git a/status.c b/status.c index 39a135ad..1ead7e27 100644 --- a/status.c +++ b/status.c @@ -1,4 +1,4 @@ -/* $Id: status.c,v 1.76 2009-04-27 13:56:51 tcunha Exp $ */ +/* $Id: status.c,v 1.77 2009-04-27 17:27:36 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -563,7 +563,7 @@ status_message_redraw(struct client *c) void status_prompt_set(struct client *c, - const char *msg, int (*fn)(void *, const char *), void *data, int hide) + const char *msg, int (*fn)(void *, const char *), void *data, int flags) { c->prompt_string = xstrdup(msg); @@ -575,7 +575,7 @@ status_prompt_set(struct client *c, c->prompt_hindex = 0; - c->prompt_hidden = hide; + c->prompt_flags = flags; mode_key_init(&c->prompt_mdata, options_get_number(&c->session->options, "status-keys"), @@ -644,7 +644,7 @@ status_prompt_redraw(struct client *c) left--; size = left; } - if (c->prompt_hidden) { + if (c->prompt_flags & PROMPT_HIDDEN) { n = strlen(c->prompt_buffer); if (n > left) n = left; @@ -844,6 +844,12 @@ status_prompt_key(struct client *c, int key) c->prompt_buffer[c->prompt_index++] = key; } + if (c->prompt_flags & PROMPT_SINGLE) { + if (c->prompt_callback( + c->prompt_data, c->prompt_buffer) == 0) + status_prompt_clear(c); + } + c->flags |= CLIENT_STATUS; break; default: diff --git a/tmux.h b/tmux.h index c8cc4ac6..5d2814c0 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.302 2009-04-27 14:51:59 nicm Exp $ */ +/* $Id: tmux.h,v 1.303 2009-04-27 17:27:36 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -857,9 +857,14 @@ struct client { size_t prompt_index; int (*prompt_callback)(void *, const char *); void *prompt_data; - int prompt_hidden; + +#define PROMPT_HIDDEN 0x1 +#define PROMPT_SINGLE 0x2 + int prompt_flags; + u_int prompt_hindex; ARRAY_DECL(, char *) prompt_hdata; + struct mode_key_data prompt_mdata; struct session *session;