summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4038038)
raw | patch | inline | side by side (parent: 4038038)
author | Jonas Fonseca <fonseca@diku.dk> | |
Mon, 11 Sep 2006 18:38:20 +0000 (20:38 +0200) | ||
committer | Jonas Fonseca <fonseca@antimatter.localdomain> | |
Mon, 11 Sep 2006 18:51:48 +0000 (20:51 +0200) |
tig.c | patch | blob | history |
index 29f64da9beef80bd28ac28e7135dacb1bc648efd..a6447bf6b45143d5c9a44f6d20d2554a1651c840 100644 (file)
--- a/tig.c
+++ b/tig.c
bool (*enter)(struct view *view, struct line *line);
/* Search for regex in a line. */
bool (*grep)(struct view *view, struct line *line);
+ /* Select line */
+ void (*select)(struct view *view, struct line *line);
};
static struct view_ops pager_ops;
static bool
draw_view_line(struct view *view, unsigned int lineno)
{
+ struct line *line;
+
assert(view_is_displayed(view));
if (view->offset + lineno >= view->lines)
return FALSE;
- return view->ops->draw(view, &view->line[view->offset + lineno], lineno);
+ line = &view->line[view->offset + lineno];
+
+ if (view->offset + lineno == view->lineno)
+ view->ops->select(view, line);
+
+ return view->ops->draw(view, line, lineno);
}
static void
wmove(view->win, lineno, 0);
if (view->offset + lineno == view->lineno) {
- if (type == LINE_COMMIT) {
- string_copy(view->ref, text + 7);
- string_copy(ref_commit, view->ref);
-
- } else if (type == LINE_TREE_DIR || type == LINE_TREE_FILE) {
- string_ncopy(view->ref, text + STRING_SIZE("100644 blob "), 40);
- string_copy(ref_blob, view->ref);
- }
-
type = LINE_CURSOR;
wchgat(view->win, -1, 0, type, NULL);
}
return TRUE;
}
+static void
+pager_select(struct view *view, struct line *line)
+{
+ if (line->type == LINE_COMMIT) {
+ char *text = line->data;
+
+ string_copy(view->ref, text + 7);
+ string_copy(ref_commit, view->ref);
+ }
+}
+
static struct view_ops pager_ops = {
"line",
pager_draw,
pager_read,
pager_enter,
pager_grep,
+ pager_select,
};
return TRUE;
}
+static void
+tree_select(struct view *view, struct line *line)
+{
+ if (line->type == LINE_TREE_DIR || line->type == LINE_TREE_FILE) {
+ char *text = line->data;
+
+ string_ncopy(view->ref, text + STRING_SIZE("100644 blob "), 40);
+ string_copy(ref_blob, view->ref);
+ }
+}
+
static struct view_ops tree_ops = {
"file",
pager_draw,
tree_read,
tree_enter,
pager_grep,
+ tree_select,
};
static bool
blob_read,
pager_enter,
pager_grep,
+ pager_select,
};
wmove(view->win, lineno, col);
if (view->offset + lineno == view->lineno) {
- string_copy(view->ref, commit->id);
- string_copy(ref_commit, view->ref);
type = LINE_CURSOR;
wattrset(view->win, get_line_attr(type));
wchgat(view->win, -1, 0, type, NULL);
return FALSE;
}
+static void
+main_select(struct view *view, struct line *line)
+{
+ struct commit *commit = line->data;
+
+ string_copy(view->ref, commit->id);
+ string_copy(ref_commit, view->ref);
+}
+
static struct view_ops main_ops = {
"commit",
main_draw,
main_read,
main_enter,
main_grep,
+ main_select,
};