summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cc2d136)
raw | patch | inline | side by side (parent: cc2d136)
author | Jonas Fonseca <fonseca@diku.dk> | |
Wed, 31 May 2006 23:37:30 +0000 (01:37 +0200) | ||
committer | Jonas Fonseca <fonseca@antimatter.localdomain> | |
Wed, 31 May 2006 23:37:30 +0000 (01:37 +0200) |
tig.c | patch | blob | history |
index 1f428a2f40ee0d692b6d2ac163192ce8a685f0ef..5f95896493c21e09a87f1ef3195d914c9e5516e5 100644 (file)
--- a/tig.c
+++ b/tig.c
/* Draw one line; @lineno must be < view->height. */
bool (*draw)(struct view *view, struct line *line, unsigned int lineno);
/* Read one line; updates view->line. */
- bool (*read)(struct view *view, struct line *prev, char *data);
+ bool (*read)(struct view *view, char *data);
/* Depending on view, change display based on current line. */
bool (*enter)(struct view *view, struct line *line);
};
while ((line = fgets(buffer, sizeof(buffer), view->pipe))) {
int linelen = strlen(line);
- struct line *prev = view->lines
- ? &view->line[view->lines - 1]
- : NULL;
-
if (linelen)
line[linelen - 1] = 0;
- if (!view->ops->read(view, prev, line))
+ if (!view->ops->read(view, line))
goto alloc_error;
if (lines-- == 1)
}
static bool
-pager_read(struct view *view, struct line *prev, char *data)
+pager_read(struct view *view, char *data)
{
struct line *line = &view->line[view->lines];
/* Reads git log --pretty=raw output and parses it into the commit struct. */
static bool
-main_read(struct view *view, struct line *prev, char *line)
+main_read(struct view *view, char *line)
{
enum line_type type = get_line_type(line);
- struct commit *commit;
+ struct commit *commit = view->lines
+ ? view->line[view->lines - 1].data : NULL;
switch (type) {
case LINE_COMMIT:
char *ident = line + STRING_SIZE("author ");
char *end = strchr(ident, '<');
- if (!prev)
+ if (!commit)
break;
- commit = prev->data;
-
if (end) {
for (; end > ident && isspace(end[-1]); end--) ;
*end = 0;
break;
}
default:
- if (!prev)
+ if (!commit)
break;
- commit = prev->data;
-
/* Fill in the commit title if it has not already been set. */
if (commit->title[0])
break;
return;
}
- pager_read(view, NULL, "Quick reference for tig keybindings:");
+ pager_read(view, "Quick reference for tig keybindings:");
for (i = 0; i < ARRAY_SIZE(req_info); i++) {
char *key;
if (!req_info[i].request) {
- pager_read(view, NULL, "");
- pager_read(view, NULL, req_info[i].help);
+ pager_read(view, "");
+ pager_read(view, req_info[i].help);
continue;
}
if (string_format(buf, "%-25s %s", key, req_info[i].help))
continue;
- pager_read(view, NULL, buf);
+ pager_read(view, buf);
}
}