Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoscroll in pager #1223

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/tig/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ typedef struct view_column *view_settings;
_(vertical_split, enum vertical_split, VIEW_RESET_DISPLAY | VIEW_DIFF_LIKE) \
_(wrap_lines, bool, VIEW_DIFF_LIKE) \
_(wrap_search, bool, VIEW_NO_FLAGS) \
_(pager_autoscroll, bool, VIEW_NO_FLAGS) \

#define DEFINE_OPTION_EXTERNS(name, type, flags) extern type opt_##name;
OPTION_INFO(DEFINE_OPTION_EXTERNS)
Expand Down
9 changes: 9 additions & 0 deletions src/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ begin_update(struct view *view, const char *dir, const char **argv, enum open_fl
bool
update_view(struct view *view)
{
bool should_autoscroll = false;
/* Clear the view and redraw everything since the tree sorting
* might have rearranged things. */
bool redraw = view->lines == 0;
Expand Down Expand Up @@ -652,11 +653,19 @@ update_view(struct view *view)
return false;
}

if ((view->pos.offset + view->height + 1) == view->lines)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

autoscroll seems like an interesting feature. I don't use the pager view but I can imagine autoscroll being useful.
I think this commit should be submitted in a separate PR, without the highlighting changes.

There seems to be an off-by-one error. When I type :!git log it only scrolls until the last-but-one line; the last line is not visible.

Instead of an option, we could also implement less's F command.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krobelus: I've updated the PR to cover only autoscroll feature and fixed the off by 1 error. I agree that autoscroll is useful, I'm using it all the time.

should_autoscroll = true;

if (!view->ops->read(view, &line, false)) {
report("Allocation failure");
end_update(view, true);
return false;
}

/* Autoscroll is available only in pager */
if (should_autoscroll && opt_pager_autoscroll &&
!strcmp(view->name, "pager"))
do_scroll_view(view, 2);
}

if (io_error(view->pipe)) {
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

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