summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3694a57)
raw | patch | inline | side by side (parent: 3694a57)
author | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 15 Feb 2009 16:35:34 +0000 (17:35 +0100) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 15 Feb 2009 17:04:19 +0000 (18:04 +0100) |
tig.c | patch | blob | history |
index 6bf13ec179e03be96e1ca9ad20cec3c987dc79b7..148b6b60b1147c130ea7778745011f9cd4646daa 100644 (file)
--- a/tig.c
+++ b/tig.c
LINE_GRAPHIC_VLINE
};
-static int line_graphics[] = {
+static chtype line_graphics[] = {
/* LINE_GRAPHIC_VLINE: */ '|'
};
return col;
}
-static bool
-draw_lineno(struct view *view, unsigned int lineno)
-{
- size_t skip = view->yoffset > view->col ? view->yoffset - view->col : 0;
- char number[10];
- int digits3 = view->digits < 3 ? 3 : view->digits;
- int max_number = MIN(digits3, STRING_SIZE(number));
- int max = view->width - view->col;
- int col;
-
- if (max < max_number)
- max_number = max;
-
- lineno += view->offset + 1;
- if (lineno == 1 || (lineno % opt_num_interval) == 0) {
- static char fmt[] = "%1ld";
-
- if (view->digits <= 9)
- fmt[1] = '0' + digits3;
-
- if (!string_format(number, fmt, lineno))
- number[0] = 0;
- col = draw_chars(view, LINE_LINE_NUMBER, number, max_number, TRUE);
- } else {
- col = draw_space(view, LINE_LINE_NUMBER, max_number, max_number);
- }
-
- if (col < max && skip <= col) {
- set_view_attr(view, LINE_DEFAULT);
- waddch(view->win, line_graphics[LINE_GRAPHIC_VLINE]);
- }
- col++;
-
- view->col += col;
- if (col < max && skip <= col)
- col = draw_space(view, LINE_DEFAULT, max - col, 1);
- view->col++;
-
- return view->width + view->yoffset <= view->col;
-}
-
static bool
draw_text(struct view *view, enum line_type type, const char *string, bool trim)
{
return draw_field(view, LINE_MODE, str, STRING_SIZE("-rw-r--r-- "), FALSE);
}
+static bool
+draw_lineno(struct view *view, unsigned int lineno)
+{
+ char number[10];
+ int digits3 = view->digits < 3 ? 3 : view->digits;
+ int max = MIN(view->width + view->yoffset - view->col, digits3);
+ char *text = NULL;
+
+ lineno += view->offset + 1;
+ if (lineno == 1 || (lineno % opt_num_interval) == 0) {
+ static char fmt[] = "%1ld";
+
+ if (view->digits <= 9)
+ fmt[1] = '0' + digits3;
+
+ if (string_format(number, fmt, lineno))
+ text = number;
+ }
+ if (text)
+ view->col += draw_chars(view, LINE_LINE_NUMBER, text, max, TRUE);
+ else
+ view->col += draw_space(view, LINE_LINE_NUMBER, max, digits3);
+ return draw_graphic(view, LINE_DEFAULT, &line_graphics[LINE_GRAPHIC_VLINE], 1);
+}
+
static bool
draw_view_line(struct view *view, unsigned int lineno)
{