X-Git-Url: https://git.distorted.org.uk/~mdw/tig/blobdiff_plain/cb9e48c17bd6ab31a03b73951cb74383d7f9d572..1d754561072b1e73f82098cf0265159a7fce495e:/tig.c diff --git a/tig.c b/tig.c index b84c561..089a567 100644 --- a/tig.c +++ b/tig.c @@ -283,8 +283,8 @@ sq_quote(char buf[SIZEOF_STR], size_t bufsize, const char *src) REQ_(SCROLL_PAGE_DOWN, "Scroll one page down"), \ \ REQ_GROUP("Misc") \ + REQ_(NONE, "Do nothing"), \ REQ_(PROMPT, "Bring up the prompt"), \ - REQ_(SCREEN_UPDATE, "Update the screen"), \ REQ_(SCREEN_REDRAW, "Redraw the screen"), \ REQ_(SCREEN_RESIZE, "Resize the screen"), \ REQ_(SHOW_VERSION, "Show version information"), \ @@ -691,9 +691,9 @@ static struct keybinding default_keybindings[] = { { ':', REQ_PROMPT }, /* wgetch() with nodelay() enabled returns ERR when there's no input. */ - { ERR, REQ_SCREEN_UPDATE }, + { ERR, REQ_NONE }, - /* Use the ncurses SIGWINCH handler. */ + /* Using the ncurses SIGWINCH handler. */ { KEY_RESIZE, REQ_SCREEN_RESIZE }, }; @@ -1956,7 +1956,7 @@ view_driver(struct view *view, enum request request) redraw_display(); break; - case REQ_SCREEN_UPDATE: + case REQ_NONE: doupdate(); return TRUE; @@ -2686,11 +2686,11 @@ init_display(void) wbkgdset(status_win, get_line_attr(LINE_STATUS)); } -static int +static char * read_prompt(const char *prompt) { enum { READING, STOP, CANCEL } status = READING; - char buf[sizeof(opt_cmd) - STRING_SIZE("git \0")]; + static char buf[sizeof(opt_cmd) - STRING_SIZE("git \0")]; int pos = 0; while (status == READING) { @@ -2727,7 +2727,7 @@ read_prompt(const char *prompt) default: if (pos >= sizeof(buf)) { report("Input string too long"); - return ERR; + return NULL; } if (isprint(key)) @@ -2738,18 +2738,12 @@ read_prompt(const char *prompt) if (status == CANCEL) { /* Clear the status window */ report(""); - return ERR; + return NULL; } buf[pos++] = 0; - if (!string_format(opt_cmd, "git %s", buf)) - return ERR; - if (strncmp(buf, "show", 4) && isspace(buf[4])) - opt_request = REQ_VIEW_DIFF; - else - opt_request = REQ_VIEW_PAGER; - return OK; + return buf; } /* @@ -3010,10 +3004,21 @@ main(int argc, char *argv[]) * status_win restricted. */ switch (request) { case REQ_PROMPT: - if (read_prompt(":") == ERR) - request = REQ_SCREEN_UPDATE; - break; + { + char *cmd = read_prompt(":"); + + if (cmd && string_format(opt_cmd, "git %s", cmd)) { + if (strncmp(cmd, "show", 4) && isspace(cmd[4])) { + opt_request = REQ_VIEW_DIFF; + } else { + opt_request = REQ_VIEW_PAGER; + } + break; + } + request = REQ_NONE; + break; + } case REQ_SCREEN_RESIZE: { int height, width;