From: Tilo Schwarz Date: Mon, 23 Feb 2009 22:24:03 +0000 (+0100) Subject: Make height of split view configurable X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=39582f2ac584031e7f3eacd09bfb0c4645cb5fe7;p=tig.git Make height of split view configurable Signed-off-by: Tilo Schwarz Signed-off-by: Jonas Fonseca --- diff --git a/NEWS b/NEWS index 15d898b..cf56f49 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,9 @@ Improvements: - Tree view: sort entries by name, date or author. Toggling is bound to 'i' by default, with 'I' controlling whether or not to sort in ascending order. + - Make height of the lower view in a split view configurable by setting + the 'split-view-height' variable to a number or a percentage. + Defaults to 2/3 of the total view height. Bug fixes: diff --git a/tig.c b/tig.c index 58d7bd0..ad77c95 100644 --- a/tig.c +++ b/tig.c @@ -72,6 +72,7 @@ static size_t utf8_length(const char **string, size_t col, int *width, size_t ma #define ABS(x) ((x) >= 0 ? (x) : -(x)) #define MIN(x, y) ((x) < (y) ? (x) : (y)) +#define MAX(x, y) ((x) > (y) ? (x) : (y)) #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) #define STRING_SIZE(x) (sizeof(x) - 1) @@ -111,7 +112,8 @@ static size_t utf8_length(const char **string, size_t col, int *width, size_t ma #define TAB_SIZE 8 -#define SCALE_SPLIT_VIEW(height) ((height) * 2 / 3) +#define SCALE_SPLIT_VIEW (2.0 / 3.0) +#define MIN_VIEW_HEIGHT 4 #define NULL_ID "0000000000000000000000000000000000000000" @@ -913,6 +915,7 @@ static bool opt_rev_graph = FALSE; static bool opt_show_refs = TRUE; static int opt_num_interval = NUMBER_INTERVAL; static double opt_hscroll = 0.50; +static double opt_scale_split_view = SCALE_SPLIT_VIEW; static int opt_tab_size = TAB_SIZE; static int opt_author_cols = AUTHOR_COLS-1; static char opt_path[SIZEOF_STR] = ""; @@ -1594,6 +1597,9 @@ option_set_command(int argc, const char *argv[]) if (!strcmp(argv[0], "horizontal-scroll")) return parse_step(&opt_hscroll, argv[2]); + if (!strcmp(argv[0], "split-view-height")) + return parse_step(&opt_scale_split_view, argv[2]); + if (!strcmp(argv[0], "tab-size")) return parse_int(&opt_tab_size, argv[2], 1, 1024); @@ -2223,6 +2229,15 @@ update_view_title(struct view *view) wnoutrefresh(view->title); } +static int +apply_step(double step, int value) +{ + if (step >= 1) + return (int) step; + value *= step + 0.01; + return value ? value : 1; +} + static void resize_display(void) { @@ -2240,7 +2255,9 @@ resize_display(void) if (view != base) { /* Horizontal split. */ view->width = base->width; - view->height = SCALE_SPLIT_VIEW(base->height); + view->height = apply_step(opt_scale_split_view, base->height); + view->height = MAX(view->height, MIN_VIEW_HEIGHT); + view->height = MIN(view->height, base->height - MIN_VIEW_HEIGHT); base->height -= view->height; /* Make room for the title bar. */ @@ -2353,15 +2370,6 @@ goto_view_line(struct view *view, unsigned long offset, unsigned long lineno) return FALSE; } -static int -apply_step(double step, int value) -{ - if (step >= 1) - return (int) step; - value *= step + 0.01; - return value ? value : 1; -} - /* Scrolling backend */ static void do_scroll_view(struct view *view, int lines) diff --git a/tigrc.5.txt b/tigrc.5.txt index 8b9628f..e5de692 100644 --- a/tigrc.5.txt +++ b/tigrc.5.txt @@ -125,6 +125,14 @@ The following variables can be set: always ensured that at least one column is scrolled. The default is to scroll '50%' of the view width. +'split-view-height' (mixed):: + + Height of the lower view in a split view. Can be specified either as + the number of rows, e.g. '5', or as a percentage of the view height, + e.g. '80%', where the maximum is 100%. It is always ensured that the + smaller of the views is at least four rows high. The default is a view + height of '66%'. + 'commit-encoding' (string):: The encoding used for commits. The default is UTF-8. Not this option