summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d720de4)
raw | patch | inline | side by side (parent: d720de4)
author | Jonas Fonseca <fonseca@diku.dk> | |
Mon, 11 Sep 2006 19:44:03 +0000 (21:44 +0200) | ||
committer | Jonas Fonseca <fonseca@antimatter.localdomain> | |
Mon, 11 Sep 2006 19:44:03 +0000 (21:44 +0200) |
tig.c | patch | blob | history |
index a6447bf6b45143d5c9a44f6d20d2554a1651c840..fb7a9a69cb756c8638786c65b8ef97fe80cdc95d 100644 (file)
--- a/tig.c
+++ b/tig.c
/* What type of content being displayed. Used in the title bar. */
const char *type;
/* Draw one line; @lineno must be < view->height. */
- bool (*draw)(struct view *view, struct line *line, unsigned int lineno);
+ bool (*draw)(struct view *view, struct line *line, unsigned int lineno, bool selected);
/* Read one line; updates view->line. */
bool (*read)(struct view *view, char *data);
/* Depending on view, change display based on current line. */
draw_view_line(struct view *view, unsigned int lineno)
{
struct line *line;
+ bool selected = (view->offset + lineno == view->lineno);
assert(view_is_displayed(view));
line = &view->line[view->offset + lineno];
- if (view->offset + lineno == view->lineno)
+ if (selected)
view->ops->select(view, line);
- return view->ops->draw(view, line, lineno);
+ return view->ops->draw(view, line, lineno, selected);
}
static void
*/
static bool
-pager_draw(struct view *view, struct line *line, unsigned int lineno)
+pager_draw(struct view *view, struct line *line, unsigned int lineno, bool selected)
{
char *text = line->data;
enum line_type type = line->type;
wmove(view->win, lineno, 0);
- if (view->offset + lineno == view->lineno) {
+ if (selected) {
type = LINE_CURSOR;
wchgat(view->win, -1, 0, type, NULL);
}
if (line->type == LINE_COMMIT) {
char *text = line->data;
- string_copy(view->ref, text + 7);
+ string_copy(view->ref, text + STRING_SIZE("commit "));
string_copy(ref_commit, view->ref);
}
}
};
static bool
-main_draw(struct view *view, struct line *line, unsigned int lineno)
+main_draw(struct view *view, struct line *line, unsigned int lineno, bool selected)
{
char buf[DATE_COLS + 1];
struct commit *commit = line->data;
wmove(view->win, lineno, col);
- if (view->offset + lineno == view->lineno) {
+ if (selected) {
type = LINE_CURSOR;
wattrset(view->win, get_line_attr(type));
wchgat(view->win, -1, 0, type, NULL);