summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d4d5d59)
raw | patch | inline | side by side (parent: d4d5d59)
author | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 10 Apr 2011 03:39:01 +0000 (23:39 -0400) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 10 Apr 2011 03:39:01 +0000 (23:39 -0400) |
tig.c | patch | blob | history |
index 65973d2bcb4ea659170d73ee25f9782b6082953d..7de7f8603f510cb4e487be33b1c09abbc92c3ff8 100644 (file)
--- a/tig.c
+++ b/tig.c
return initials;
}
+#define author_trim(cols) (cols == 0 || cols > 5)
+
+static const char *
+mkauthor(const char *text, int cols, enum author author)
+{
+ bool trim = author_trim(cols);
+ bool abbreviate = author == AUTHOR_ABBREVIATED || !trim;
+
+ if (!author)
+ return "";
+ if (abbreviate && text)
+ return get_author_initials(text);
+ return text;
+}
/*
* User requests
static bool
draw_author(struct view *view, const char *author)
{
- bool trim = opt_author_cols == 0 || opt_author_cols > 5;
- bool abbreviate = opt_author == AUTHOR_ABBREVIATED || !trim;
-
- if (opt_author == AUTHOR_NO)
- return FALSE;
-
- if (abbreviate && author)
- author = get_author_initials(author);
+ bool trim = author_trim(opt_author_cols);
+ const char *text = mkauthor(author, opt_author_cols, opt_author);
- return draw_field(view, LINE_AUTHOR, author, opt_author_cols, trim);
+ return draw_field(view, LINE_AUTHOR, text, opt_author_cols, trim);
}
static bool