summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6bc9f97)
raw | patch | inline | side by side (parent: 6bc9f97)
author | Jonas Fonseca <fonseca@diku.dk> | |
Thu, 3 Apr 2008 19:30:42 +0000 (21:30 +0200) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 6 Apr 2008 12:04:48 +0000 (14:04 +0200) |
Renames the main-date color to date.
tig.c | patch | blob | history |
index 9d694e1f91b4dba6aa1a49080d0d27ded9a4b95f..ee6b6d1e8f7bb9fdbdf1b0af6bd26a57f6c240cb 100644 (file)
--- a/tig.c
+++ b/tig.c
LINE(CURSOR, "", COLOR_WHITE, COLOR_GREEN, A_BOLD), \
LINE(STATUS, "", COLOR_GREEN, COLOR_DEFAULT, 0), \
LINE(DELIMITER, "", COLOR_MAGENTA, COLOR_DEFAULT, 0), \
+LINE(DATE, "", COLOR_BLUE, COLOR_DEFAULT, 0), \
LINE(LINE_NUMBER, "", COLOR_CYAN, COLOR_DEFAULT, 0), \
LINE(TITLE_BLUR, "", COLOR_WHITE, COLOR_BLUE, 0), \
LINE(TITLE_FOCUS, "", COLOR_WHITE, COLOR_BLUE, A_BOLD), \
-LINE(MAIN_DATE, "", COLOR_BLUE, COLOR_DEFAULT, 0), \
LINE(MAIN_AUTHOR, "", COLOR_GREEN, COLOR_DEFAULT, 0), \
LINE(MAIN_COMMIT, "", COLOR_DEFAULT, COLOR_DEFAULT, 0), \
LINE(MAIN_TAG, "", COLOR_MAGENTA, COLOR_DEFAULT, A_BOLD), \
LINE(STAT_STAGED, "", COLOR_MAGENTA, COLOR_DEFAULT, 0), \
LINE(STAT_UNSTAGED,"", COLOR_MAGENTA, COLOR_DEFAULT, 0), \
LINE(STAT_UNTRACKED,"", COLOR_MAGENTA, COLOR_DEFAULT, 0), \
-LINE(BLAME_DATE, "", COLOR_BLUE, COLOR_DEFAULT, 0), \
LINE(BLAME_AUTHOR, "", COLOR_GREEN, COLOR_DEFAULT, 0), \
LINE(BLAME_COMMIT, "", COLOR_DEFAULT, COLOR_DEFAULT, 0), \
LINE(BLAME_ID, "", COLOR_MAGENTA, COLOR_DEFAULT, 0)
if (!string_enum_compare(argv[0], "main-delim", strlen("main-delim"))) {
info = get_line_info("delimiter");
+ } else if (!string_enum_compare(argv[0], "main-date", strlen("main-date"))) {
+ info = get_line_info("date");
+
} else {
config_msg = "Unknown color name";
return ERR;
return col;
}
+static int
+draw_date(struct view *view, struct tm *time, int max, bool selected)
+{
+ char buf[DATE_COLS];
+ int col;
+ int timelen = 0;
+
+ if (max > DATE_COLS)
+ max = DATE_COLS;
+ if (time)
+ timelen = strftime(buf, sizeof(buf), DATE_FORMAT, time);
+ if (!timelen) {
+ memset(buf, ' ', sizeof(buf) - 1);
+ buf[sizeof(buf) - 1] = 0;
+ }
+
+ if (!selected)
+ wattrset(view->win, get_line_attr(LINE_DATE));
+ col = draw_text(view, buf, max, FALSE, selected);
+ if (col < max) {
+ if (!selected)
+ wattrset(view->win, get_line_attr(LINE_DEFAULT));
+ waddch(view->win, ' ');
+ col++;
+ }
+
+ return col;
+}
+
static bool
draw_view_line(struct view *view, unsigned int lineno)
{
@@ -3601,21 +3632,10 @@ blame_draw(struct view *view, struct line *line, unsigned int lineno, bool selec
}
if (opt_date) {
- int n;
-
- if (!selected)
- wattrset(view->win, get_line_attr(LINE_MAIN_DATE));
- if (blame->commit) {
- char buf[DATE_COLS + 1];
- int timelen;
-
- timelen = strftime(buf, sizeof(buf), DATE_FORMAT, &blame->commit->time);
- n = draw_text(view, buf, view->width - col, FALSE, selected);
- draw_text(view, " ", view->width - col - n, FALSE, selected);
- }
+ struct tm *time = blame->commit && *blame->commit->filename
+ ? &blame->commit->time : NULL;
- col += DATE_COLS;
- wmove(view->win, lineno, col);
+ col += draw_date(view, time, view->width, selected);
if (col >= view->width)
return TRUE;
}
static bool
main_draw(struct view *view, struct line *line, unsigned int lineno, bool selected)
{
- char buf[DATE_COLS + 1];
struct commit *commit = line->data;
enum line_type type;
int col = 0;
- size_t timelen;
- int space;
if (!*commit->author)
return FALSE;
- space = view->width;
wmove(view->win, lineno, col);
if (selected) {
@@ -4851,18 +4867,10 @@ main_draw(struct view *view, struct line *line, unsigned int lineno, bool select
wchgat(view->win, -1, 0, type, NULL);
} else {
type = LINE_MAIN_COMMIT;
- wattrset(view->win, get_line_attr(LINE_MAIN_DATE));
}
if (opt_date) {
- int n;
-
- timelen = strftime(buf, sizeof(buf), DATE_FORMAT, &commit->time);
- n = draw_text(view, buf, view->width - col, FALSE, selected);
- draw_text(view, " ", view->width - col - n, FALSE, selected);
-
- col += DATE_COLS;
- wmove(view->win, lineno, col);
+ col += draw_date(view, &commit->time, view->width, selected);
if (col >= view->width)
return TRUE;
}