Skip to content

Commit

Permalink
Autoscroll in pager (#1223)
Browse files Browse the repository at this point in the history
Autoscroll the pager view if a new option `pager-autoscroll` is set to `on`.

[tk: tweaked the code and added doc]
  • Loading branch information
psprint authored and koutcher committed Dec 29, 2022
1 parent 05c9b56 commit 4a405bf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doc/tigrc.5.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,11 @@ The following variables can be set:
Mouse support requires that ncurses itself support mouse events and that
you have enabled mouse support in ~/.tigrc with `set mouse = true`.
'pager-autoscroll' (bool)::
Whether to scroll automatically the pager view while loading. Move the
cursor out of the last line to stop scrolling and back in to resume.
'pgrp' (bool)::
Make tig process-group leader when starting and clean all processes
Expand Down
1 change: 1 addition & 0 deletions include/tig/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ typedef struct view_column *view_settings;
_(mouse, bool, VIEW_NO_FLAGS) \
_(mouse_scroll, int, VIEW_NO_FLAGS) \
_(mouse_wheel_cursor, bool, VIEW_NO_FLAGS) \
_(pager_autoscroll, bool, VIEW_NO_FLAGS) \
_(pager_view, view_settings, VIEW_NO_FLAGS) \
_(pgrp, bool, VIEW_NO_FLAGS) \
_(reference_format, struct ref_format **, VIEW_NO_FLAGS) \
Expand Down
3 changes: 3 additions & 0 deletions src/pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ pager_common_read(struct view *view, const char *data, enum line_type type, stru
static bool
pager_read(struct view *view, struct buffer *buf, bool force_stop)
{
if (opt_pager_autoscroll && view->pos.offset + view->height == view->lines - 1)
do_scroll_view(view, 1);

if (!buf) {
if (!diff_done_highlight(view->private)) {
report("Failed run the diff-highlight program: %s", opt_diff_highlight);
Expand Down
1 change: 1 addition & 0 deletions tigrc
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ set mouse = no # Enable mouse support?
set mouse-scroll = 3 # Number of lines to scroll via the mouse
set mouse-wheel-cursor = no # Prefer moving the cursor to scrolling the view?
set pgrp = no # Make tig process-group leader?
set pager-autoscroll = no # Scroll the pager view automatically while loading?

# User-defined commands
# ---------------------
Expand Down

0 comments on commit 4a405bf

Please sign in to comment.