index 6236bf310104280d4c53864d1beb5ed8ec4e305a..b0ce18ff29f103cc89d157630ae8026309de88c6 100644 (file)
--- a/tig.c
+++ b/tig.c
#define SIZEOF_STR 1024 /* Default string size. */
#define SIZEOF_REF 256 /* Size of symbolic or SHA1 ID. */
+#define SIZEOF_REV 41 /* Holds a SHA-1 and an ending NUL */
#define SIZEOF_REVGRAPH 19 /* Size of revision ancestry graphics. */
/* This color name can be used to refer to the default term colors. */
struct ref {
char *name; /* Ref name; tag or head names are shortened. */
- char id[41]; /* Commit SHA1 ID */
+ char id[SIZEOF_REV]; /* Commit SHA1 ID */
unsigned int tag:1; /* Is it a tag? */
unsigned int next:1; /* For ref lists: are there more refs? */
};
{
struct line *line;
bool selected = (view->offset + lineno == view->lineno);
+ bool draw_ok;
assert(view_is_displayed(view));
wclrtoeol(view->win);
}
- return view->ops->draw(view, line, lineno, selected);
+ scrollok(view->win, FALSE);
+ draw_ok = view->ops->draw(view, line, lineno, selected);
+ scrollok(view->win, TRUE);
+
+ return draw_ok;
}
static void
}
static void
-update_display_cursor(void)
+update_display_cursor(struct view *view)
{
- struct view *view = display[current_view];
-
/* Move the cursor to the right-most column of the cursor line.
*
* XXX: This could turn out to be a bit expensive, but it ensures that
* Tree backend
*/
-/* Parse output from git ls-tree:
+/* Parse output from git-ls-tree(1):
*
* 100644 blob fb0e31ea6cc679b7379631188190e975f5789c26 Makefile
* 100644 blob 5304ca4260aaddaee6498f9630e7d471b8591ea6 README
tree_enter(struct view *view, struct line *line)
{
enum open_flags flags = display[0] == view ? OPEN_SPLIT : OPEN_DEFAULT;
- char *data = line->data;
enum request request;
switch (line->type) {
} else {
size_t pathlen = strlen(opt_path);
size_t origlen = pathlen;
+ char *data = line->data;
char *basename = data + SIZEOF_TREE_ATTR;
if (!string_format_from(opt_path, &pathlen, "%s/", basename)) {
* be in sync. */
string_copy(VIEW(REQ_VIEW_BLOB)->ref, ref_blob);
- } else if (line->type == LINE_TREE_DIR) {
- string_ncopy(view->ref, text, 40);
+ } else if (line->type != LINE_TREE_DIR) {
+ return;
}
+
+ string_ncopy(view->ref, text, 40);
}
static struct view_ops tree_ops = {
*/
struct commit {
- char id[41]; /* SHA1 ID. */
+ char id[SIZEOF_REV]; /* SHA1 ID. */
char title[75]; /* First line of the commit message. */
char author[75]; /* Author of the commit. */
struct tm time; /* Date from the author ident. */
}
update_view_title(view);
- update_display_cursor();
+ update_display_cursor(view);
}
/* Controls when nodelay should be in effect when polling user input. */