{"thread":{"id":"17979","subject":"[tig PATCH 0/1] Make height of split view configurable","startedAt":"2009-02-23T22:24:02Z","lastAt":"2009-02-25T22:17:25Z","messageCount":3,"participants":["tilo@tilo-schwarz.de","Jonas Fonseca"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"105937","messageId":"cover.1235338009.git.tilo@tilo-schwarz.de","threadId":"17979","inReplyTo":null,"subject":"[tig PATCH 0/1] Make height of split view configurable","fromName":"","fromEmail":"tilo@tilo-schwarz.de","sentAt":"2009-02-23T22:24:02Z","receivedAt":"2009-02-23T22:24:02Z","isPatch":true,"sender":{"key":"tilo@tilo-schwarz.de","avatar":null},"body":"Rationale: On a large display with many rows it would be nice to be\nable to configure the heights of the views in the split view. For\nexample, I like to have the lower diff view be 90% of the total\nview height.\n\nAs it is, the patch lets the height of the lower view be configurable.\nIs it may be better to configure the height of the upper view? \n\nAny input on variable nameing, code style etc. of course welcome.\n\n\nTilo Schwarz (1):\n  Make height of split view configurable\n\n NEWS        |    3 +++\n tig.c       |   30 +++++++++++++++++++-----------\n tigrc.5.txt |    8 ++++++++\n 3 files changed, 30 insertions(+), 11 deletions(-)\n"},{"id":"105938","messageId":"25c05f03ae71d23eb40e60f49037590939eb352d.1235338009.git.tilo@tilo-schwarz.de","threadId":"17979","inReplyTo":"cover.1235338009.git.tilo@tilo-schwarz.de","subject":"[PATCH 1/1] Make height of split view configurable","fromName":"","fromEmail":"tilo@tilo-schwarz.de","sentAt":"2009-02-23T22:24:03Z","receivedAt":"2009-02-23T22:24:03Z","isPatch":true,"sender":{"key":"tilo@tilo-schwarz.de","avatar":null},"body":"\nSigned-off-by: Tilo Schwarz <tilo@tilo-schwarz.de>\n---\n NEWS        |    3 +++\n tig.c       |   30 +++++++++++++++++++-----------\n tigrc.5.txt |    8 ++++++++\n 3 files changed, 30 insertions(+), 11 deletions(-)\n\ndiff --git a/NEWS b/NEWS\nindex 15d898b..a48ed16 100644\n--- a/NEWS\n+++ b/NEWS\n@@ -11,6 +11,9 @@ Improvements:\n  - Tree view: sort entries by name, date or author. Toggling is bound to\n    'i' by default, with 'I' controlling whether or not to sort in\n    ascending order.\n+ - Make height of the lower view in a split view configurable by setting the\n+   'split-view-height' variable to a number or a percentage. Defaults to 66% of\n+   the total view height.\n \n Bug fixes:\n \ndiff --git a/tig.c b/tig.c\nindex 58d7bd0..ad77c95 100644\n--- a/tig.c\n+++ b/tig.c\n@@ -72,6 +72,7 @@ static size_t utf8_length(const char **string, size_t col, int *width, size_t ma\n \n #define ABS(x)\t\t((x) >= 0  ? (x) : -(x))\n #define MIN(x, y)\t((x) < (y) ? (x) :  (y))\n+#define MAX(x, y)\t((x) > (y) ? (x) :  (y))\n \n #define ARRAY_SIZE(x)\t(sizeof(x) / sizeof(x[0]))\n #define STRING_SIZE(x)\t(sizeof(x) - 1)\n@@ -111,7 +112,8 @@ static size_t utf8_length(const char **string, size_t col, int *width, size_t ma\n \n #define TAB_SIZE\t8\n \n-#define\tSCALE_SPLIT_VIEW(height)\t((height) * 2 / 3)\n+#define\tSCALE_SPLIT_VIEW (2.0 / 3.0)\n+#define MIN_VIEW_HEIGHT 4\n \n #define NULL_ID\t\t\"0000000000000000000000000000000000000000\"\n \n@@ -913,6 +915,7 @@ static bool opt_rev_graph\t\t= FALSE;\n static bool opt_show_refs\t\t= TRUE;\n static int opt_num_interval\t\t= NUMBER_INTERVAL;\n static double opt_hscroll\t\t= 0.50;\n+static double opt_scale_split_view\t= SCALE_SPLIT_VIEW;\n static int opt_tab_size\t\t\t= TAB_SIZE;\n static int opt_author_cols\t\t= AUTHOR_COLS-1;\n static char opt_path[SIZEOF_STR]\t= \"\";\n@@ -1594,6 +1597,9 @@ option_set_command(int argc, const char *argv[])\n \tif (!strcmp(argv[0], \"horizontal-scroll\"))\n \t\treturn parse_step(&opt_hscroll, argv[2]);\n \n+\tif (!strcmp(argv[0], \"split-view-height\"))\n+\t\treturn parse_step(&opt_scale_split_view, argv[2]);\n+\n \tif (!strcmp(argv[0], \"tab-size\"))\n \t\treturn parse_int(&opt_tab_size, argv[2], 1, 1024);\n \n@@ -2223,6 +2229,15 @@ update_view_title(struct view *view)\n \twnoutrefresh(view->title);\n }\n \n+static int\n+apply_step(double step, int value)\n+{\n+\tif (step >= 1)\n+\t\treturn (int) step;\n+\tvalue *= step + 0.01;\n+\treturn value ? value : 1;\n+}\n+\n static void\n resize_display(void)\n {\n@@ -2240,7 +2255,9 @@ resize_display(void)\n \tif (view != base) {\n \t\t/* Horizontal split. */\n \t\tview->width   = base->width;\n-\t\tview->height  = SCALE_SPLIT_VIEW(base->height);\n+\t\tview->height  = apply_step(opt_scale_split_view, base->height);\n+\t\tview->height  = MAX(view->height, MIN_VIEW_HEIGHT);\n+\t\tview->height  = MIN(view->height, base->height - MIN_VIEW_HEIGHT);\n \t\tbase->height -= view->height;\n \n \t\t/* Make room for the title bar. */\n@@ -2353,15 +2370,6 @@ goto_view_line(struct view *view, unsigned long offset, unsigned long lineno)\n \treturn FALSE;\n }\n \n-static int\n-apply_step(double step, int value)\n-{\n-\tif (step >= 1)\n-\t\treturn (int) step;\n-\tvalue *= step + 0.01;\n-\treturn value ? value : 1;\n-}\n-\n /* Scrolling backend */\n static void\n do_scroll_view(struct view *view, int lines)\ndiff --git a/tigrc.5.txt b/tigrc.5.txt\nindex 8b9628f..e5de692 100644\n--- a/tigrc.5.txt\n+++ b/tigrc.5.txt\n@@ -125,6 +125,14 @@ The following variables can be set:\n \talways ensured that at least one column is scrolled. The default is to\n \tscroll '50%' of the view width.\n \n+'split-view-height' (mixed)::\n+\n+\tHeight of the lower view in a split view. Can be specified either as\n+\tthe number of rows, e.g. '5', or as a percentage of the view height,\n+\te.g. '80%', where the maximum is 100%. It is always ensured that the\n+\tsmaller of the views is at least four rows high. The default is a view\n+\theight of '66%'.\n+\n 'commit-encoding' (string)::\n \n \tThe encoding used for commits. The default is UTF-8. Not this option\n-- \n1.5.6.5\n"},{"id":"106268","messageId":"2c6b72b30902251417s2f166910w4a47a2d1a43aef93@mail.gmail.com","threadId":"17979","inReplyTo":"cover.1235338009.git.tilo@tilo-schwarz.de","subject":"Re: [tig PATCH 0/1] Make height of split view configurable","fromName":"Jonas Fonseca","fromEmail":"jonas.fonseca@gmail.com","sentAt":"2009-02-25T22:17:25Z","receivedAt":"2009-02-25T22:17:25Z","isPatch":true,"sender":{"key":"jonas.fonseca@gmail.com","avatar":"https://gravatar.com/avatar/9b7fa23cce50269e5d164312b6ac5ae818a180f837b38f28f3bdf689dd7f96cd?d=mp&s=160"},"body":"On Mon, Feb 23, 2009 at 23:24,  <tilo@tilo-schwarz.de> wrote:\n> Rationale: On a large display with many rows it would be nice to be\n> able to configure the heights of the views in the split view. For\n> example, I like to have the lower diff view be 90% of the total\n> view height.\n>\n> As it is, the patch lets the height of the lower view be configurable.\n> Is it may be better to configure the height of the upper view?\n\nI don't know, the way you have done it seems reasonable.\n\n> Any input on variable nameing, code style etc. of course welcome.\n\nVery, very clean and nicely done with the reusing of the parse/apply\nstep code. Thanks.\n\n-- \nJonas Fonseca\n"}]}