summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b43e701)
raw | patch | inline | side by side (parent: b43e701)
author | Jonas Fonseca <fonseca@diku.dk> | |
Fri, 13 Feb 2009 13:38:00 +0000 (14:38 +0100) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Fri, 13 Feb 2009 13:41:18 +0000 (14:41 +0100) |
Requested by bill lam.
NEWS | patch | blob | history | |
tig.c | patch | blob | history | |
tigrc.5.txt | patch | blob | history |
index e52130cb340ed738a176dfd289c5ce7674cc1b79..7bd288942eaa18190c09080e604ed0fa1e4e7f6b 100644 (file)
--- a/NEWS
+++ b/NEWS
- Colors for 256-capable terminals can be specified as colorN.
- Entering a number in the prompt will jump to that line number.
- Handle core.worktree by setting GIT_DIR and GIT_WORK_TREE.
+ - Make behavior of horizontal scrolling configurable by setting the
+ 'horizontal-scroll' variable to a number or a percentage. Defaults to
+ scrolling 50% of the view width.
Bug fixes:
index 2b2607bdc9828f6ba4a13db944d78c50e50214c0..705e3ddbe5e96b91eb16b28c5d7848f82b60bfa9 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -109,7 +109,6 @@ static size_t utf8_length(const char **string, size_t col, int *width, size_t ma
/* The default interval between line numbers. */
#define NUMBER_INTERVAL 5
-#define SCROLL_INTERVAL 1
#define TAB_SIZE 8
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 int opt_tab_size = TAB_SIZE;
static int opt_author_cols = AUTHOR_COLS-1;
static char opt_path[SIZEOF_STR] = "";
#define set_attribute(attr, name) map_enum(attr, attr_map, name)
+static int parse_step(double *opt, const char *arg)
+{
+ *opt = atoi(arg);
+ if (!strchr(arg, '%'))
+ return OK;
+
+ /* "Shift down" so 100% and 1 does not conflict. */
+ *opt = (*opt - 1) / 100;
+ if (*opt >= 1.0) {
+ *opt = 0.99;
+ config_msg = "Step value larger than 100%";
+ return ERR;
+ }
+ if (*opt < 0.0) {
+ *opt = 1;
+ config_msg = "Invalid step value";
+ return ERR;
+ }
+ return OK;
+}
+
static int
parse_int(int *opt, const char *arg, int min, int max)
{
if (!strcmp(argv[0], "author-width"))
return parse_int(&opt_author_cols, argv[2], 0, 1024);
+ if (!strcmp(argv[0], "horizontal-scroll"))
+ return parse_step(&opt_hscroll, argv[2]);
+
if (!strcmp(argv[0], "tab-size"))
return parse_int(&opt_tab_size, argv[2], 1, 1024);
@@ -2285,6 +2309,15 @@ 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)
report("Cannot scroll beyond the first column");
return;
}
- if (view->yoffset <= SCROLL_INTERVAL)
+ if (view->yoffset <= apply_step(opt_hscroll, view->width))
view->yoffset = 0;
else
- view->yoffset -= SCROLL_INTERVAL;
+ view->yoffset -= apply_step(opt_hscroll, view->width);
redraw_view_from(view, 0);
report("");
return;
report("Cannot scroll beyond the last column");
return;
}
- view->yoffset += SCROLL_INTERVAL;
+ view->yoffset += apply_step(opt_hscroll, view->width);
+ if (view->yoffset > view->width)
+ view->yoffset = view->width;
redraw_view(view);
report("");
return;
diff --git a/tigrc.5.txt b/tigrc.5.txt
index d0e8c9118cf07251cd71721c59e27911334f0e74..59149acf78bb3cd9e74e538af1eac00ec6678ecd 100644 (file)
--- a/tigrc.5.txt
+++ b/tigrc.5.txt
set show-line-numbers = no # Show line numbers?
set line-number-interval = 5 # Interval between line numbers
set commit-encoding = "UTF-8" # Commit encoding
+set horizontal-scroll = 33% # Scroll 33% of the view width
--------------------------------------------------------------------------
Or in the git configuration files:
tab-size = 8 # Number of spaces per tab
--------------------------------------------------------------------------
-The type of variables are either bool, int, and string.
+The type of variables are either bool, int, string, or mixed.
Valid bool values::
A string of characters. Optionally, use either ' or " as delimiters.
+Valid mixed values::
+
+ These values are composites of the above types. The valid values are
+ specified in the description.
+
Variables
~~~~~~~~~
Number of spaces per tab. The default is 8 spaces.
+'horizontal-scroll' (mixed)::
+
+ Interval to scroll horizontally in each step. Can be specified either
+ as the number of columns, e.g. '5', or as a percentage of the view
+ width, e.g. '33%', where the maximum is 100%. For percentages it is
+ always ensured that at least one column is scrolled. The default is to
+ scroll '50%' of the view width.
+
'commit-encoding' (string)::
The encoding used for commits. The default is UTF-8. Not this option