~mdw
/
tig
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Replace screen-update action with noop action named "none"
[tig]
/
tig.c
diff --git
a/tig.c
b/tig.c
index
97e3d0d
..
089a567
100644
(file)
--- a/
tig.c
+++ b/
tig.c
@@
-54,8
+54,8
@@
static size_t utf8_length(const char *string, size_t max_width, int *coloffset,
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#define STRING_SIZE(x) (sizeof(x) - 1)
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#define STRING_SIZE(x) (sizeof(x) - 1)
+#define SIZEOF_STR 1024 /* Default string size. */
#define SIZEOF_REF 256 /* Size of symbolic or SHA1 ID. */
#define SIZEOF_REF 256 /* Size of symbolic or SHA1 ID. */
-#define SIZEOF_CMD 1024 /* Size of command buffer. */
#define SIZEOF_REVGRAPH 19 /* Size of revision ancestry graphics. */
/* This color name can be used to refer to the default term colors. */
#define SIZEOF_REVGRAPH 19 /* Size of revision ancestry graphics. */
/* This color name can be used to refer to the default term colors. */
@@
-224,11
+224,11
@@
string_enum_compare(const char *str1, const char *str2, int len)
*/
static size_t
*/
static size_t
-sq_quote(char buf[SIZEOF_
CMD
], size_t bufsize, const char *src)
+sq_quote(char buf[SIZEOF_
STR
], size_t bufsize, const char *src)
{
char c;
{
char c;
-#define BUFPUT(x) do { if (bufsize < SIZEOF_
CMD
) buf[bufsize++] = (x); } while (0)
+#define BUFPUT(x) do { if (bufsize < SIZEOF_
STR
) buf[bufsize++] = (x); } while (0)
BUFPUT('\'');
while ((c = *src++)) {
BUFPUT('\'');
while ((c = *src++)) {
@@
-283,8
+283,8
@@
sq_quote(char buf[SIZEOF_CMD], size_t bufsize, const char *src)
REQ_(SCROLL_PAGE_DOWN, "Scroll one page down"), \
\
REQ_GROUP("Misc") \
REQ_(SCROLL_PAGE_DOWN, "Scroll one page down"), \
\
REQ_GROUP("Misc") \
+ REQ_(NONE, "Do nothing"), \
REQ_(PROMPT, "Bring up the prompt"), \
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"), \
REQ_(SCREEN_REDRAW, "Redraw the screen"), \
REQ_(SCREEN_RESIZE, "Resize the screen"), \
REQ_(SHOW_VERSION, "Show version information"), \
@@
-366,7
+366,7
@@
static bool opt_rev_graph = TRUE;
static int opt_num_interval = NUMBER_INTERVAL;
static int opt_tab_size = TABSIZE;
static enum request opt_request = REQ_VIEW_MAIN;
static int opt_num_interval = NUMBER_INTERVAL;
static int opt_tab_size = TABSIZE;
static enum request opt_request = REQ_VIEW_MAIN;
-static char opt_cmd[SIZEOF_
CMD
] = "";
+static char opt_cmd[SIZEOF_
STR
] = "";
static FILE *opt_pipe = NULL;
static char opt_encoding[20] = "UTF-8";
static bool opt_utf8 = TRUE;
static FILE *opt_pipe = NULL;
static char opt_encoding[20] = "UTF-8";
static bool opt_utf8 = TRUE;
@@
-691,9
+691,9
@@
static struct keybinding default_keybindings[] = {
{ ':', REQ_PROMPT },
/* wgetch() with nodelay() enabled returns ERR when there's no input. */
{ ':', REQ_PROMPT },
/* wgetch() with nodelay() enabled returns ERR when there's no input. */
- { ERR, REQ_
SCREEN_UPDAT
E },
+ { ERR, REQ_
NON
E },
- /* Us
e
the ncurses SIGWINCH handler. */
+ /* Us
ing
the ncurses SIGWINCH handler. */
{ KEY_RESIZE, REQ_SCREEN_RESIZE },
};
{ KEY_RESIZE, REQ_SCREEN_RESIZE },
};
@@
-1089,7
+1089,7
@@
static int
load_options(void)
{
char *home = getenv("HOME");
load_options(void)
{
char *home = getenv("HOME");
- char buf[
1024
];
+ char buf[
SIZEOF_STR
];
FILE *file;
config_lineno = 0;
FILE *file;
config_lineno = 0;
@@
-1141,7
+1141,7
@@
struct view {
enum keymap keymap; /* What keymap does this view have */
enum keymap keymap; /* What keymap does this view have */
- char cmd[SIZEOF_
CMD
]; /* Command buffer */
+ char cmd[SIZEOF_
STR
]; /* Command buffer */
char ref[SIZEOF_REF]; /* Hovered commit reference */
char vid[SIZEOF_REF]; /* View ID. Set to id member when updating. */
char ref[SIZEOF_REF]; /* Hovered commit reference */
char vid[SIZEOF_REF]; /* View ID. Set to id member when updating. */
@@
-1956,7
+1956,7
@@
view_driver(struct view *view, enum request request)
redraw_display();
break;
redraw_display();
break;
- case REQ_
SCREEN_UPDAT
E:
+ case REQ_
NON
E:
doupdate();
return TRUE;
doupdate();
return TRUE;
@@
-2070,7
+2070,7
@@
pager_draw(struct view *view, struct line *line, unsigned int lineno)
static bool
add_describe_ref(char *buf, int *bufpos, char *commit_id, const char *sep)
{
static bool
add_describe_ref(char *buf, int *bufpos, char *commit_id, const char *sep)
{
- char refbuf[
1024
];
+ char refbuf[
SIZEOF_STR
];
char *ref = NULL;
FILE *pipe;
char *ref = NULL;
FILE *pipe;
@@
-2089,7
+2089,7
@@
add_describe_ref(char *buf, int *bufpos, char *commit_id, const char *sep)
return TRUE;
/* This is the only fatal call, since it can "corrupt" the buffer. */
return TRUE;
/* This is the only fatal call, since it can "corrupt" the buffer. */
- if (!string_nformat(buf,
1024
, bufpos, "%s%s", sep, ref))
+ if (!string_nformat(buf,
SIZEOF_STR
, bufpos, "%s%s", sep, ref))
return FALSE;
return TRUE;
return FALSE;
return TRUE;
@@
-2098,7
+2098,7
@@
add_describe_ref(char *buf, int *bufpos, char *commit_id, const char *sep)
static void
add_pager_refs(struct view *view, struct line *line)
{
static void
add_pager_refs(struct view *view, struct line *line)
{
- char buf[
1024
];
+ char buf[
SIZEOF_STR
];
char *commit_id = line->data + STRING_SIZE("commit ");
struct ref **refs;
int bufpos = 0, refpos = 0;
char *commit_id = line->data + STRING_SIZE("commit ");
struct ref **refs;
int bufpos = 0, refpos = 0;
@@
-2686,11
+2686,11
@@
init_display(void)
wbkgdset(status_win, get_line_attr(LINE_STATUS));
}
wbkgdset(status_win, get_line_attr(LINE_STATUS));
}
-static
int
-read_prompt(
void
)
+static
char *
+read_prompt(
const char *prompt
)
{
enum { READING, STOP, CANCEL } status = READING;
{
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) {
int pos = 0;
while (status == READING) {
@@
-2700,7
+2700,7
@@
read_prompt(void)
foreach_view (view, i)
update_view(view);
foreach_view (view, i)
update_view(view);
- report("
:%.*s"
, pos, buf);
+ report("
%s%.*s", prompt
, pos, buf);
/* Refresh, accept single keystroke of input */
key = wgetch(status_win);
switch (key) {
/* Refresh, accept single keystroke of input */
key = wgetch(status_win);
switch (key) {
@@
-2727,7
+2727,7
@@
read_prompt(void)
default:
if (pos >= sizeof(buf)) {
report("Input string too long");
default:
if (pos >= sizeof(buf)) {
report("Input string too long");
- return
ERR
;
+ return
NULL
;
}
if (isprint(key))
}
if (isprint(key))
@@
-2738,18
+2738,12
@@
read_prompt(void)
if (status == CANCEL) {
/* Clear the status window */
report("");
if (status == CANCEL) {
/* Clear the status window */
report("");
- return
ERR
;
+ return
NULL
;
}
buf[pos++] = 0;
}
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:
* 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;
case REQ_SCREEN_RESIZE:
{
int height, width;