summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7ea608c)
raw | patch | inline | side by side (parent: 7ea608c)
author | Jonas Fonseca <fonseca@diku.dk> | |
Tue, 15 Dec 2009 03:01:59 +0000 (22:01 -0500) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Tue, 15 Dec 2009 03:01:59 +0000 (22:01 -0500) |
NEWS | patch | blob | history | |
manual.txt | patch | blob | history | |
tig.c | patch | blob | history | |
tigrc.5.txt | patch | blob | history |
index e80e847eed2fdd947c3aa5ad7f45dc72bdcb00b7..17d3925bb8557223476fdacbef76b17680a10d6a 100644 (file)
--- a/NEWS
+++ b/NEWS
%(file) works as expected.
- Branch view: add entry to browse all branches (uses git-log's --all
flag).
+ - Abbreviation of author names can now be configured and toggled.
Bug fixes:
diff --git a/manual.txt b/manual.txt
index cc8cb795aca192f3808f8f7d4944bb7babb4fe26..475cf5a746ad54dc18004e0b5e18f4dd45a3d94a 100644 (file)
--- a/manual.txt
+++ b/manual.txt
|v |Show version.
|o |Open option menu
|. |Toggle line numbers on/off.
-|D |Toggle date display on/off.
-|A |Toggle author display on/off.
+|D |Toggle date display on/off/relative.
+|A |Toggle author display on/off/abbreviated.
|g |Toggle revision graph visualization on/off.
|F |Toggle reference display on/off (tag and branch names).
|: |Open prompt. This allows you to specify what git command
index d2dff15fd17bcd60c6a56209a420f33c9fc37a5a..b668cf002a7e66c6ed3ff4fd36cda7f11f5635c7 100644 (file)
--- a/tig.c
+++ b/tig.c
}
+#define AUTHOR_VALUES \
+ AUTHOR_(NO), \
+ AUTHOR_(FULL), \
+ AUTHOR_(ABBREVIATED)
+
+enum author {
+#define AUTHOR_(name) AUTHOR_##name
+ AUTHOR_VALUES,
+#undef AUTHOR_
+ AUTHOR_DEFAULT = AUTHOR_FULL
+};
+
+static const struct enum_map author_map[] = {
+#define AUTHOR_(name) ENUM_MAP(#name, AUTHOR_##name)
+ AUTHOR_VALUES
+#undef AUTHOR_
+};
+
+static const char *
+get_author_initials(const char *author, size_t max_columns)
+{
+ static char initials[10];
+ size_t pos;
+
+#define is_initial_sep(c) (isspace(c) || ispunct(c) || (c) == '@')
+
+ memset(initials, 0, sizeof(initials));
+ for (pos = 0; *author && pos < max_columns - 1; author++, pos++) {
+ while (is_initial_sep(*author))
+ author++;
+ strncpy(&initials[pos], author, sizeof(initials) - 1 - pos);
+ while (*author && !is_initial_sep(author[1]))
+ author++;
+ }
+
+ return initials;
+}
+
+
static bool
argv_from_string(const char *argv[SIZEOF_ARG], int *argc, char *cmd)
{
/* Option and state variables. */
static enum date opt_date = DATE_DEFAULT;
-static bool opt_author = TRUE;
+static enum author opt_author = AUTHOR_DEFAULT;
static bool opt_line_number = FALSE;
static bool opt_line_graphics = TRUE;
static bool opt_rev_graph = FALSE;
}
if (!strcmp(argv[0], "show-author"))
- return parse_bool(&opt_author, argv[2]);
+ return parse_enum(&opt_author, argv[2], author_map);
if (!strcmp(argv[0], "show-date"))
return parse_enum(&opt_date, argv[2], date_map);
static bool
draw_author(struct view *view, const char *author)
{
- bool trim = opt_author_cols == 0 || opt_author_cols > 5 || !author;
-
- if (!trim) {
- static char initials[10];
- size_t pos;
+ bool trim = opt_author_cols == 0 || opt_author_cols > 5;
+ bool abbreviate = opt_author == AUTHOR_ABBREVIATED || !trim;
-#define is_initial_sep(c) (isspace(c) || ispunct(c) || (c) == '@')
-
- memset(initials, 0, sizeof(initials));
- for (pos = 0; *author && pos < opt_author_cols - 1; author++, pos++) {
- while (is_initial_sep(*author))
- author++;
- strncpy(&initials[pos], author, sizeof(initials) - 1 - pos);
- while (*author && !is_initial_sep(author[1]))
- author++;
- }
-
- author = initials;
- }
+ if (abbreviate && author)
+ author = get_author_initials(author, opt_author_cols);
return draw_field(view, LINE_AUTHOR, author, opt_author_cols, trim);
}
toggle_enum_option_do(opt, help, map, ARRAY_SIZE(map))
#define toggle_date() toggle_enum_option(&opt_date, "dates", date_map)
+#define toggle_author() toggle_enum_option(&opt_author, "author names", author_map)
static void
toggle_view_option(bool *option, const char *help)
if (prompt_menu("Toggle option", menu, &selected)) {
if (menu[selected].data == &opt_date)
toggle_date();
+ else if (menu[selected].data == &opt_author)
+ toggle_author();
else
toggle_view_option(menu[selected].data, menu[selected].text);
}
break;
case REQ_TOGGLE_AUTHOR:
- toggle_view_option(&opt_author, "author display");
+ toggle_author();
break;
case REQ_TOGGLE_REV_GRAPH:
diff --git a/tigrc.5.txt b/tigrc.5.txt
index be9bf8dbf8f008428a04338d23b1bb6e42ac9f2f..e3276ca5f04599699373c4dbd8e8c0b2f4c984b6 100644 (file)
--- a/tigrc.5.txt
+++ b/tigrc.5.txt
Examples:
--------------------------------------------------------------------------
-set show-author = yes # Show author?
+set show-author = abbreviated # Show abbreviated author names.
set show-date = relative # Show relative commit date.
set show-rev-graph = yes # Show revision graph?
set show-refs = yes # Show references?
The following variables can be set:
-'show-author' (bool)::
'show-rev-graph' (bool)::
'show-refs' (bool)::
- Whether to show author, revision graph, and references
- (branches, tags, and remotes) in the main view on start-up. Can all be
- toggled.
+ Whether to show revision graph, and references (branches, tags, and
+ remotes) in the main view on start-up. Can all be toggled.
-'show-date' (bool or "relative" or "short")::
+'show-author' (mixed) ["abbreviated" | "default" | bool]::
+
+ How to display author names. If set to "abbreviated" author initials
+ will be shown. Can be toggled.
+
+'show-date' (mixed) ["relative" | "short" | "default" | bool]::
Whether and how to show date. If set to "relative" a relative date will be
used, e.g. "2 minutes ago". If set to "short" no time information is