| |   |
| 1553 | 1553 | } |
| 1554 | 1554 | |
| 1555 | 1555 | static int |
| 1556 | draw_graphic(struct view *view, enum line_type type, chtype graphic[], size_t size, size_t max) |
| 1557 | { |
| 1558 | int i; |
| 1559 | int col; |
| 1560 | |
| 1561 | if (max < size) |
| 1562 | size = max; |
| 1563 | |
| 1564 | set_view_attr(view, type); |
| 1565 | /* Using waddch() instead of waddnstr() ensures that |
| 1566 | * they'll be rendered correctly for the cursor line. */ |
| 1567 | for (i = 0; i < size; i++) |
| 1568 | waddch(view->win, graphic[i]); |
| 1569 | |
| 1570 | col = size; |
| 1571 | if (size < max) { |
| 1572 | waddch(view->win, ' '); |
| 1573 | col++; |
| 1574 | } |
| 1575 | |
| 1576 | return col; |
| 1577 | } |
| 1578 | |
| 1579 | static int |
| 1556 | 1580 | draw_date(struct view *view, struct tm *time, int max) |
| 1557 | 1581 | { |
| 1558 | 1582 | char buf[DATE_COLS]; |
| … | … | |
| 4878 | 4878 | col += AUTHOR_COLS; |
| 4879 | 4879 | if (col >= view->width) |
| 4880 | 4880 | return TRUE; |
| 4881 | wmove(view->win, lineno, col); |
| 4881 | 4882 | } |
| 4882 | 4883 | |
| 4883 | 4884 | if (opt_rev_graph && commit->graph_size) { |
| 4884 | | size_t graph_size = view->width - col; |
| 4885 | | size_t i; |
| 4886 | | |
| 4887 | | set_view_attr(view, LINE_MAIN_REVGRAPH); |
| 4888 | | wmove(view->win, lineno, col); |
| 4889 | | if (graph_size > commit->graph_size) |
| 4890 | | graph_size = commit->graph_size; |
| 4891 | | /* Using waddch() instead of waddnstr() ensures that |
| 4892 | | * they'll be rendered correctly for the cursor line. */ |
| 4893 | | for (i = 0; i < graph_size; i++) |
| 4894 | | waddch(view->win, commit->graph[i]); |
| 4895 | | |
| 4896 | | col += commit->graph_size + 1; |
| 4885 | col += draw_graphic(view, LINE_MAIN_REVGRAPH, |
| 4886 | commit->graph, commit->graph_size, |
| 4887 | view->width - col); |
| 4897 | 4888 | if (col >= view->width) |
| 4898 | 4889 | return TRUE; |
| 4899 | | waddch(view->win, ' '); |
| 4900 | 4890 | } |
| 4901 | 4891 | |
| 4902 | | set_view_attr(view, LINE_DEFAULT); |
| 4903 | | wmove(view->win, lineno, col); |
| 4904 | | |
| 4905 | 4892 | if (opt_show_refs && commit->refs) { |
| 4906 | 4893 | size_t i = 0; |
| 4907 | 4894 | |
| toggle raw diff |
--- a/tig.c
+++ b/tig.c
@@ -1553,6 +1553,30 @@ draw_lineno(struct view *view, unsigned int lineno, int max)
}
static int
+draw_graphic(struct view *view, enum line_type type, chtype graphic[], size_t size, size_t max)
+{
+ int i;
+ int col;
+
+ if (max < size)
+ size = max;
+
+ set_view_attr(view, type);
+ /* Using waddch() instead of waddnstr() ensures that
+ * they'll be rendered correctly for the cursor line. */
+ for (i = 0; i < size; i++)
+ waddch(view->win, graphic[i]);
+
+ col = size;
+ if (size < max) {
+ waddch(view->win, ' ');
+ col++;
+ }
+
+ return col;
+}
+
+static int
draw_date(struct view *view, struct tm *time, int max)
{
char buf[DATE_COLS];
@@ -4854,30 +4878,17 @@ main_draw(struct view *view, struct line *line, unsigned int lineno)
col += AUTHOR_COLS;
if (col >= view->width)
return TRUE;
+ wmove(view->win, lineno, col);
}
if (opt_rev_graph && commit->graph_size) {
- size_t graph_size = view->width - col;
- size_t i;
-
- set_view_attr(view, 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 < graph_size; i++)
- waddch(view->win, commit->graph[i]);
-
- col += commit->graph_size + 1;
+ col += draw_graphic(view, LINE_MAIN_REVGRAPH,
+ commit->graph, commit->graph_size,
+ view->width - col);
if (col >= view->width)
return TRUE;
- waddch(view->win, ' ');
}
- set_view_attr(view, LINE_DEFAULT);
- wmove(view->win, lineno, col);
-
if (opt_show_refs && commit->refs) {
size_t i = 0;
|