Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add option to exit copy-mode when scrolling past bottom
  • Loading branch information
dv committed May 2, 2015
1 parent c0cf484 commit 19448c5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions options-table.c
Expand Up @@ -509,6 +509,11 @@ const struct options_table_entry window_options_table[] = {
.default_num = 1
},

{ .name = "exit-copy-past-bottom",
.type = OPTIONS_TABLE_FLAG,
.default_num = 0
},

{ .name = "force-height",
.type = OPTIONS_TABLE_NUMBER,
.minimum = 0,
Expand Down
10 changes: 9 additions & 1 deletion window-copy.c
Expand Up @@ -1848,7 +1848,8 @@ window_copy_cursor_down(struct window_pane *wp, int scroll_only)
{
struct window_copy_mode_data *data = wp->modedata;
struct screen *s = &data->screen;
u_int ox, oy, px, py;
u_int scrolled_past_bottom = 0;
u_int ox, oy, px, py;

oy = screen_hsize(data->backing) + data->cy - data->oy;
ox = window_copy_find_length(wp, oy);
Expand All @@ -1862,6 +1863,8 @@ window_copy_cursor_down(struct window_pane *wp, int scroll_only)

data->cx = data->lastcx;
if (scroll_only || data->cy == screen_size_y(s) - 1) {
scrolled_past_bottom = data->oy == 0;

window_copy_scroll_up(wp, 1);
if (scroll_only && data->cy > 0)
window_copy_redraw_lines(wp, data->cy - 1, 2);
Expand All @@ -1883,6 +1886,11 @@ window_copy_cursor_down(struct window_pane *wp, int scroll_only)
window_copy_cursor_end_of_line(wp);
else if (s->sel.lineflag == LINE_SEL_RIGHT_LEFT)
window_copy_cursor_start_of_line(wp);

if (scrolled_past_bottom && !s->sel.flag &&
s->sel.lineflag == LINE_SEL_NONE &&
options_get_number(&wp->window->options, "exit-copy-past-bottom"))
window_pane_reset_mode(wp);
}

void
Expand Down

4 comments on commit 19448c5

@stephencelis
Copy link

Choose a reason for hiding this comment

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

Have you opened a PR with this patch?

@reejosamuel
Copy link

Choose a reason for hiding this comment

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

Is your PR merged?

@hongxiaolong
Copy link

Choose a reason for hiding this comment

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

Your PR still not be merged?

And I can not visit your homebrew formula with:

brew install https://raw.githubusercontent.com/dv/dotfiles/master/tmux/tmux.rb

@olehermanse
Copy link

Choose a reason for hiding this comment

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

@dv Any chance you will submit this as a patch to tmux?

Please sign in to comment.