Skip to content

Commit 713caca

Browse files
author
nicm
committed
Mouse support on the scrollbars, from Michael Grant.
1 parent c26d71d commit 713caca

File tree

7 files changed

+633
-69
lines changed

7 files changed

+633
-69
lines changed

Diff for: cmd-copy-mode.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ const struct cmd_entry cmd_copy_mode_entry = {
3030
.name = "copy-mode",
3131
.alias = NULL,
3232

33-
.args = { "deHMs:t:uq", 0, 0, NULL },
34-
.usage = "[-deHMuq] [-s src-pane] " CMD_TARGET_PANE_USAGE,
33+
.args = { "deHMqSs:t:u", 0, 0, NULL },
34+
.usage = "[-deHMqSu] [-s src-pane] " CMD_TARGET_PANE_USAGE,
3535

3636
.source = { 's', CMD_FIND_PANE, 0 },
3737
.target = { 't', CMD_FIND_PANE, 0 },
@@ -92,7 +92,12 @@ cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item)
9292
if (args_has(args, 'u'))
9393
window_copy_pageup(wp, 0);
9494
if (args_has(args, 'd'))
95-
window_copy_pagedown(wp, 0, args_has(args, 'e'));
95+
window_copy_pagedown(wp, 0, args_has(args, 'e'));
96+
if (args_has(args, 'S')) {
97+
window_copy_scroll(wp, c->tty.mouse_slider_mpos, event->m.y,
98+
args_has(args, 'e'));
99+
return (CMD_RETURN_NORMAL);
100+
}
96101

97102
return (CMD_RETURN_NORMAL);
98103
}

Diff for: key-bindings.c

+5
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,11 @@ key_bindings_init(void)
478478
"bind -n MouseDown3Pane { if -Ft= '#{||:#{mouse_any_flag},#{&&:#{pane_in_mode},#{?#{m/r:(copy|view)-mode,#{pane_mode}},0,1}}}' { select-pane -t=; send -M } { display-menu -t= -xM -yM -T '#[align=centre]#{pane_index} (#{pane_id})' " DEFAULT_PANE_MENU " } }",
479479
"bind -n M-MouseDown3Pane { display-menu -t= -xM -yM -T '#[align=centre]#{pane_index} (#{pane_id})' " DEFAULT_PANE_MENU " }",
480480

481+
/* Mouse on scrollbar. */
482+
"bind -n MouseDown1ScrollbarUp { copy-mode -u }",
483+
"bind -n MouseDown1ScrollbarDown { copy-mode -d }",
484+
"bind -n MouseDrag1ScrollbarSlider { copy-mode -S }",
485+
481486
/* Copy mode (emacs) keys. */
482487
"bind -Tcopy-mode C-Space { send -X begin-selection }",
483488
"bind -Tcopy-mode C-a { send -X start-of-line }",

Diff for: screen-redraw.c

+4
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,10 @@ screen_redraw_draw_pane_scrollbar(struct screen_redraw_ctx *ctx,
10011001

10021002
screen_redraw_draw_scrollbar(ctx, wp, sb_pos, sb_x, sb_y, sb_h,
10031003
slider_h, slider_y);
1004+
1005+
/* Store current position and height of the slider */
1006+
wp->sb_slider_y = slider_y; /* top of slider y pos in scrollbar */
1007+
wp->sb_slider_h = slider_h; /* height of slider */
10041008
}
10051009

10061010
static void

0 commit comments

Comments
 (0)