From f2d95af83227cea265bcce5e8604eccc6d3fd849 Mon Sep 17 00:00:00 2001 From: Samuel Bronson Date: Wed, 12 Aug 2009 18:11:55 -0400 Subject: [PATCH] Add an option (and toggle) for shortening the date column by skipping the time. Signed-off-by: Samuel Bronson --- tig.c | 14 +++++++++++++- tigrc.5.txt | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tig.c b/tig.c index e52185e..55e0224 100644 --- a/tig.c +++ b/tig.c @@ -103,6 +103,7 @@ static size_t utf8_length(const char **string, size_t col, int *width, size_t ma /* The format and size of the date column in the main view. */ #define DATE_FORMAT "%Y-%m-%d %H:%M" #define DATE_COLS STRING_SIZE("2006-04-29 14:21 ") +#define DATE_SHORT_COLS STRING_SIZE("2006-04-29 ") #define ID_COLS 8 @@ -837,6 +838,7 @@ run_io_load(const char **argv, const char *separators, REQ_(OPTIONS, "Open option menu"), \ REQ_(TOGGLE_LINENO, "Toggle line numbers"), \ REQ_(TOGGLE_DATE, "Toggle date display"), \ + REQ_(TOGGLE_DATE_SHORT, "Toggle short (date-only) dates"), \ REQ_(TOGGLE_AUTHOR, "Toggle author display"), \ REQ_(TOGGLE_REV_GRAPH, "Toggle revision graph visualization"), \ REQ_(TOGGLE_REFS, "Toggle reference display (tags/branches)"), \ @@ -901,6 +903,7 @@ get_request(const char *name) /* Option and state variables. */ static bool opt_date = TRUE; +static bool opt_date_short = FALSE; static bool opt_author = TRUE; static bool opt_line_number = FALSE; static bool opt_line_graphics = TRUE; @@ -1154,6 +1157,7 @@ static const struct keybinding default_keybindings[] = { { 'o', REQ_OPTIONS }, { '.', REQ_TOGGLE_LINENO }, { 'D', REQ_TOGGLE_DATE }, + { 'T', REQ_TOGGLE_DATE_SHORT }, { 'A', REQ_TOGGLE_AUTHOR }, { 'g', REQ_TOGGLE_REV_GRAPH }, { 'F', REQ_TOGGLE_REFS }, @@ -1575,6 +1579,9 @@ option_set_command(int argc, const char *argv[]) if (!strcmp(argv[0], "show-date")) return parse_bool(&opt_date, argv[2]); + if (!strcmp(argv[0], "date-short")) + return parse_bool(&opt_date_short, argv[2]); + if (!strcmp(argv[0], "show-rev-graph")) return parse_bool(&opt_rev_graph, argv[2]); @@ -2026,8 +2033,9 @@ static bool draw_date(struct view *view, time_t *time) { const char *date = mkdate(time); + int cols = opt_date_short ? DATE_SHORT_COLS : DATE_COLS; - return draw_field(view, LINE_DATE, date, DATE_COLS, FALSE); + return draw_field(view, LINE_DATE, date, cols, FALSE); } static bool @@ -3322,6 +3330,10 @@ view_driver(struct view *view, enum request request) toggle_view_option(&opt_date, "date display"); break; + case REQ_TOGGLE_DATE_SHORT: + toggle_view_option(&opt_date_short, "date shortening"); + break; + case REQ_TOGGLE_AUTHOR: toggle_view_option(&opt_author, "author display"); break; diff --git a/tigrc.5.txt b/tigrc.5.txt index 1376232..618761d 100644 --- a/tigrc.5.txt +++ b/tigrc.5.txt @@ -94,6 +94,11 @@ The following variables can be set: (branches, tags, and remotes) in the main view on start-up. Can all be toggled. +'date-short' (bool):: + + Whether to shorten the date column in the main view to just the date + on startup. Can be toggled. + 'author-width' (int):: Width of the author column. When set to 5 or below, the author name @@ -340,6 +345,7 @@ stop-loading Stop all loading views options Open options menu toggle-lineno Toggle line numbers toggle-date Toggle date display +toggle-date-short Toggle short (date-only) dates toggle-author Toggle author display toggle-rev-graph Toggle revision graph visualization toggle-refs Toggle reference display -- 2.30.2