summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cb9e48c)
raw | patch | inline | side by side (parent: cb9e48c)
author | Jonas Fonseca <fonseca@diku.dk> | |
Fri, 8 Sep 2006 16:41:56 +0000 (18:41 +0200) | ||
committer | Jonas Fonseca <fonseca@antimatter.localdomain> | |
Fri, 8 Sep 2006 16:41:56 +0000 (18:41 +0200) |
tig.c | patch | blob | history |
index b84c561f95235a5a58e22df2bafea5253d49cd08..7b8fc7dd84e6107f90ab3257eed5587c098e601d 100644 (file)
--- a/tig.c
+++ b/tig.c
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) {
default:
if (pos >= sizeof(buf)) {
report("Input string too long");
- return ERR;
+ return NULL;
}
if (isprint(key))
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;
}
/*
* 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_SCREEN_UPDATE;
+ break;
+ }
case REQ_SCREEN_RESIZE:
{
int height, width;