Skip to content

Commit

Permalink
Fix drawing "outside" the screen in the status and pager views
Browse files Browse the repository at this point in the history
It was causing text to wrap to next line, but with the new function to
draw text with limited width this has become much easier.
  • Loading branch information
jonas committed Mar 19, 2008
1 parent 1c919d6 commit 749cdc9
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions tig.c
Expand Up @@ -2637,7 +2637,6 @@ pager_draw(struct view *view, struct line *line, unsigned int lineno, bool selec
{
char *text = line->data;
enum line_type type = line->type;
int textlen = strlen(text);
int attr;

wmove(view->win, lineno, 0);
Expand Down Expand Up @@ -2690,13 +2689,9 @@ pager_draw(struct view *view, struct line *line, unsigned int lineno, bool selec
}

} else {
int col = 0, pos = 0;
int tilde_attr = get_line_attr(LINE_MAIN_DELIM);

for (; pos < textlen && col < view->width; pos++, col++)
if (text[pos] == '\t')
col += TABSIZE - (col % TABSIZE) - 1;

waddnstr(view->win, text, pos);
draw_text(view, text, view->width, 0, TRUE, tilde_attr);
}

return TRUE;
Expand Down Expand Up @@ -3434,12 +3429,14 @@ static bool
status_draw(struct view *view, struct line *line, unsigned int lineno, bool selected)
{
struct status *status = line->data;
int tilde_attr = get_line_attr(LINE_MAIN_DELIM);

wmove(view->win, lineno, 0);

if (selected) {
wattrset(view->win, get_line_attr(LINE_CURSOR));
wchgat(view->win, -1, 0, LINE_CURSOR, NULL);
tilde_attr = -1;

} else if (!status && line->type != LINE_STAT_NONE) {
wattrset(view->win, get_line_attr(LINE_STAT_SECTION));
Expand Down Expand Up @@ -3473,16 +3470,18 @@ status_draw(struct view *view, struct line *line, unsigned int lineno, bool sele
return FALSE;
}

waddstr(view->win, text);
draw_text(view, text, view->width, 0, TRUE, tilde_attr);
return TRUE;
}

waddch(view->win, status->status);
if (!selected)
wattrset(view->win, A_NORMAL);
wmove(view->win, lineno, 4);
waddstr(view->win, status->new.name);
if (view->width < 5)
return TRUE;

draw_text(view, status->new.name, view->width - 5, 5, TRUE, tilde_attr);
return TRUE;
}

Expand Down Expand Up @@ -4216,20 +4215,23 @@ main_draw(struct view *view, struct line *line, unsigned int lineno, bool select
}

if (opt_rev_graph && commit->graph_size) {
size_t graph_size = view->width - col;
size_t i;

if (type != LINE_CURSOR)
wattrset(view->win, get_line_attr(LINE_MAIN_REVGRAPH));
wmove(view->win, lineno, col);
if (graph_size > commit->graph_size)
graph_size = commit->graph_size;
/* Using waddch() instead of waddnstr() ensures that
* they'll be rendered correctly for the cursor line. */
for (i = 0; i < commit->graph_size; i++)
for (i = 0; i < graph_size; i++)
waddch(view->win, commit->graph[i]);

waddch(view->win, ' ');
col += commit->graph_size + 1;
if (col >= view->width)
return TRUE;
waddch(view->win, ' ');
}
if (type != LINE_CURSOR)
wattrset(view->win, A_NORMAL);
Expand Down Expand Up @@ -4487,6 +4489,9 @@ unicode_width(unsigned long c)
|| (c >= 0x30000 && c <= 0x3fffd)))
return 2;

if (c == '\t')
return opt_tab_size;

return 1;
}

Expand Down

0 comments on commit 749cdc9

Please sign in to comment.