Skip to content

Commit 19448c5

Browse files
committed
Add option to exit copy-mode when scrolling past bottom
1 parent c0cf484 commit 19448c5

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

options-table.c

+5
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,11 @@ const struct options_table_entry window_options_table[] = {
509509
.default_num = 1
510510
},
511511

512+
{ .name = "exit-copy-past-bottom",
513+
.type = OPTIONS_TABLE_FLAG,
514+
.default_num = 0
515+
},
516+
512517
{ .name = "force-height",
513518
.type = OPTIONS_TABLE_NUMBER,
514519
.minimum = 0,

window-copy.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -1848,7 +1848,8 @@ window_copy_cursor_down(struct window_pane *wp, int scroll_only)
18481848
{
18491849
struct window_copy_mode_data *data = wp->modedata;
18501850
struct screen *s = &data->screen;
1851-
u_int ox, oy, px, py;
1851+
u_int scrolled_past_bottom = 0;
1852+
u_int ox, oy, px, py;
18521853

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

18631864
data->cx = data->lastcx;
18641865
if (scroll_only || data->cy == screen_size_y(s) - 1) {
1866+
scrolled_past_bottom = data->oy == 0;
1867+
18651868
window_copy_scroll_up(wp, 1);
18661869
if (scroll_only && data->cy > 0)
18671870
window_copy_redraw_lines(wp, data->cy - 1, 2);
@@ -1883,6 +1886,11 @@ window_copy_cursor_down(struct window_pane *wp, int scroll_only)
18831886
window_copy_cursor_end_of_line(wp);
18841887
else if (s->sel.lineflag == LINE_SEL_RIGHT_LEFT)
18851888
window_copy_cursor_start_of_line(wp);
1889+
1890+
if (scrolled_past_bottom && !s->sel.flag &&
1891+
s->sel.lineflag == LINE_SEL_NONE &&
1892+
options_get_number(&wp->window->options, "exit-copy-past-bottom"))
1893+
window_pane_reset_mode(wp);
18861894
}
18871895

18881896
void

0 commit comments

Comments
 (0)