diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2024-11-12 09:32:57 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2024-11-12 09:32:57 +0000 |
commit | cf04b5f312f8388fad56b135ec2b30167a54284a (patch) | |
tree | 57dbbb5760eb93f0dc62d00cc3f95ed65ab1db48 /usr.bin | |
parent | d9ccba3f05a1bc7c5fc3d9b7d70dd24849bc38b7 (diff) |
Mouse support on the scrollbars, from Michael Grant.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/cmd-copy-mode.c | 13 | ||||
-rw-r--r-- | usr.bin/tmux/key-bindings.c | 7 | ||||
-rw-r--r-- | usr.bin/tmux/screen-redraw.c | 6 | ||||
-rw-r--r-- | usr.bin/tmux/server-client.c | 514 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 28 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 39 | ||||
-rw-r--r-- | usr.bin/tmux/window-copy.c | 111 |
7 files changed, 641 insertions, 77 deletions
diff --git a/usr.bin/tmux/cmd-copy-mode.c b/usr.bin/tmux/cmd-copy-mode.c index a9110cf87cb..b173d613597 100644 --- a/usr.bin/tmux/cmd-copy-mode.c +++ b/usr.bin/tmux/cmd-copy-mode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-copy-mode.c,v 1.48 2024/08/26 07:09:34 nicm Exp $ */ +/* $OpenBSD: cmd-copy-mode.c,v 1.49 2024/11/12 09:32:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -30,8 +30,8 @@ const struct cmd_entry cmd_copy_mode_entry = { .name = "copy-mode", .alias = NULL, - .args = { "deHMs:t:uq", 0, 0, NULL }, - .usage = "[-deHMuq] [-s src-pane] " CMD_TARGET_PANE_USAGE, + .args = { "deHMqSs:t:u", 0, 0, NULL }, + .usage = "[-deHMqSu] [-s src-pane] " CMD_TARGET_PANE_USAGE, .source = { 's', CMD_FIND_PANE, 0 }, .target = { 't', CMD_FIND_PANE, 0 }, @@ -92,7 +92,12 @@ cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item) if (args_has(args, 'u')) window_copy_pageup(wp, 0); if (args_has(args, 'd')) - window_copy_pagedown(wp, 0, args_has(args, 'e')); + window_copy_pagedown(wp, 0, args_has(args, 'e')); + if (args_has(args, 'S')) { + window_copy_scroll(wp, c->tty.mouse_slider_mpos, event->m.y, + args_has(args, 'e')); + return (CMD_RETURN_NORMAL); + } return (CMD_RETURN_NORMAL); } diff --git a/usr.bin/tmux/key-bindings.c b/usr.bin/tmux/key-bindings.c index 5f14aa3748f..c248003bd8b 100644 --- a/usr.bin/tmux/key-bindings.c +++ b/usr.bin/tmux/key-bindings.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key-bindings.c,v 1.150 2024/10/04 07:03:08 nicm Exp $ */ +/* $OpenBSD: key-bindings.c,v 1.151 2024/11/12 09:32:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -478,6 +478,11 @@ key_bindings_init(void) "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 " } }", "bind -n M-MouseDown3Pane { display-menu -t= -xM -yM -T '#[align=centre]#{pane_index} (#{pane_id})' " DEFAULT_PANE_MENU " }", + /* Mouse on scrollbar. */ + "bind -n MouseDown1ScrollbarUp { copy-mode -u }", + "bind -n MouseDown1ScrollbarDown { copy-mode -d }", + "bind -n MouseDrag1ScrollbarSlider { copy-mode -S }", + /* Copy mode (emacs) keys. */ "bind -Tcopy-mode C-Space { send -X begin-selection }", "bind -Tcopy-mode C-a { send -X start-of-line }", diff --git a/usr.bin/tmux/screen-redraw.c b/usr.bin/tmux/screen-redraw.c index cbda4a6954d..0326775baf1 100644 --- a/usr.bin/tmux/screen-redraw.c +++ b/usr.bin/tmux/screen-redraw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-redraw.c,v 1.100 2024/11/05 09:41:17 nicm Exp $ */ +/* $OpenBSD: screen-redraw.c,v 1.101 2024/11/12 09:32:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1001,6 +1001,10 @@ screen_redraw_draw_pane_scrollbar(struct screen_redraw_ctx *ctx, screen_redraw_draw_scrollbar(ctx, wp, sb_pos, sb_x, sb_y, sb_h, slider_h, slider_y); + + /* Store current position and height of the slider */ + wp->sb_slider_y = slider_y; /* top of slider y pos in scrollbar */ + wp->sb_slider_h = slider_h; /* height of slider */ } static void diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index 1493b6726a5..9af2a290382 100644 --- a/usr.bin/tmux/server-client.c +++ b/usr.bin/tmux/server-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-client.c,v 1.415 2024/11/05 09:41:17 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.416 2024/11/12 09:32:56 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -576,10 +576,12 @@ server_client_check_mouse(struct client *c, struct key_event *event) { struct mouse_event *m = &event->m; struct session *s = c->session, *fs; + struct options *wo = s->curw->window->options; struct winlink *fwl; struct window_pane *wp, *fwp; - u_int x, y, b, sx, sy, px, py; - int ignore = 0; + u_int x, y, b, sx, sy, px, py, line = 0, sb_pos; + u_int sl_top, sl_bottom, sl_mpos = 0; + int ignore = 0, sb, sb_w, pane_status; key_code key; struct timeval tv; struct style_range *sr; @@ -598,7 +600,10 @@ server_client_check_mouse(struct client *c, struct key_event *event) STATUS_LEFT, STATUS_RIGHT, STATUS_DEFAULT, - BORDER } where = NOWHERE; + BORDER, + SCROLLBAR_UP, + SCROLLBAR_SLIDER, + SCROLLBAR_DOWN } where = NOWHERE; log_debug("%s mouse %02x at %u,%u (last %u,%u) (%d)", c->name, m->b, m->x, m->y, m->lx, m->ly, c->tty.mouse_drag_flag); @@ -747,54 +752,114 @@ have_event: } } - /* Not on status line. Adjust position and check for border or pane. */ + /* + * Not on status line. Adjust position and check for border, pane, or + * scrollbar. + */ if (where == NOWHERE) { - px = x; - if (m->statusat == 0 && y >= m->statuslines) - py = y - m->statuslines; - else if (m->statusat > 0 && y >= (u_int)m->statusat) - py = m->statusat - 1; - else - py = y; - - tty_window_offset(&c->tty, &m->ox, &m->oy, &sx, &sy); - log_debug("mouse window @%u at %u,%u (%ux%u)", - s->curw->window->id, m->ox, m->oy, sx, sy); - if (px > sx || py > sy) - return (KEYC_UNKNOWN); - px = px + m->ox; - py = py + m->oy; - - /* Try the pane borders if not zoomed. */ - if (~s->curw->window->flags & WINDOW_ZOOMED) { - TAILQ_FOREACH(wp, &s->curw->window->panes, entry) { - if ((wp->xoff + wp->sx == px && - wp->yoff <= 1 + py && - wp->yoff + wp->sy >= py) || - (wp->yoff + wp->sy == py && - wp->xoff <= 1 + px && - wp->xoff + wp->sx >= px)) - break; - } - if (wp != NULL) - where = BORDER; - } + if (c->tty.mouse_scrolling_flag) + where = SCROLLBAR_SLIDER; + else { + px = x; + if (m->statusat == 0 && y >= m->statuslines) + py = y - m->statuslines; + else if (m->statusat > 0 && y >= (u_int)m->statusat) + py = m->statusat - 1; + else + py = y; + + tty_window_offset(&c->tty, &m->ox, &m->oy, &sx, &sy); + log_debug("mouse window @%u at %u,%u (%ux%u)", + s->curw->window->id, m->ox, m->oy, sx, sy); + if (px > sx || py > sy) + return (KEYC_UNKNOWN); + px = px + m->ox; + py = py + m->oy; - /* Otherwise try inside the pane. */ - if (where == NOWHERE) { + /* Try inside the pane. */ wp = window_get_active_at(s->curw->window, px, py); - if (wp != NULL) - where = PANE; - else + if (wp == NULL) return (KEYC_UNKNOWN); + + /* Try the scrollbar next to a pane. */ + sb = options_get_number(wo, "pane-scrollbars"); + sb_pos = options_get_number(wo, + "pane-scrollbars-position"); + if (sb == PANE_SCROLLBARS_ALWAYS || + (sb == PANE_SCROLLBARS_MODAL && + window_pane_mode(wp) != WINDOW_PANE_NO_MODE)) + sb_w = PANE_SCROLLBARS_WIDTH; + else + sb_w = 0; + pane_status = options_get_number(wo, + "pane-border-status"); + if (pane_status == PANE_STATUS_TOP) + line = wp->yoff - 1; + else if (pane_status == PANE_STATUS_BOTTOM) + line = wp->yoff + wp->sy; + + /* + * Check if py could lie within a scrollbar. If the + * pane is at the top, then py is 0; if not then the + * top, then yoff to yoff + sy. + */ + if ((pane_status != PANE_STATUS_OFF && py != line) || + (wp->yoff == 0 && py < wp->sy) || + (py >= wp->yoff && py < wp->yoff + wp->sy)) { + if ((sb_pos == PANE_SCROLLBARS_RIGHT && + (px >= wp->xoff + wp->sx && + px < wp->xoff + wp->sx + sb_w)) || + (sb_pos == PANE_SCROLLBARS_LEFT && + (px >= wp->xoff - sb_w && + px < wp->xoff))) { + sl_top = wp->yoff + wp->sb_slider_y; + sl_bottom = (wp->yoff + + wp->sb_slider_y + + wp->sb_slider_h - 1); + if (py < sl_top) + where = SCROLLBAR_UP; + else if (py >= sl_top && + py <= sl_bottom) { + where = SCROLLBAR_SLIDER; + sl_mpos = (py - + wp->sb_slider_y - wp->yoff); + } else /* py > sl_bottom */ + where = SCROLLBAR_DOWN; + } else + where = PANE; + } else { + /* Try the pane borders if not zoomed. */ + if (~s->curw->window->flags & WINDOW_ZOOMED) { + TAILQ_FOREACH(wp, + &s->curw->window->panes, entry) { + if ((wp->xoff + wp->sx == px && + wp->yoff <= 1 + py && + wp->yoff + wp->sy >= py) || + (wp->yoff + wp->sy == py && + wp->xoff <= 1 + px && + wp->xoff + wp->sx >= px)) + break; + } + if (wp != NULL) + where = BORDER; + } + } + if (where == PANE) { + log_debug("mouse %u,%u on pane %%%u", x, y, + wp->id); + } else if (where == BORDER) + log_debug("mouse on pane %%%u border", wp->id); + else if (where == SCROLLBAR_UP || + where == SCROLLBAR_SLIDER || + where == SCROLLBAR_DOWN) { + log_debug("mouse on pane %%%u scrollbar", + wp->id); + } + m->wp = wp->id; + m->w = wp->window->id; } - if (where == PANE) - log_debug("mouse %u,%u on pane %%%u", x, y, wp->id); - else if (where == BORDER) - log_debug("mouse on pane %%%u border", wp->id); - m->wp = wp->id; - m->w = wp->window->id; - } + } else + m->wp = -1; /* Stop dragging if needed. */ if (type != DRAG && type != WHEEL && c->tty.mouse_drag_flag != 0) { @@ -803,6 +868,7 @@ have_event: c->tty.mouse_drag_update = NULL; c->tty.mouse_drag_release = NULL; + c->tty.mouse_scrolling_flag = 0; /* * End a mouse drag by passing a MouseDragEnd key corresponding @@ -820,6 +886,8 @@ have_event: key = KEYC_MOUSEDRAGEND1_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDRAGEND1_STATUS_DEFAULT; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDRAGEND1_SCROLLBAR_SLIDER; if (where == BORDER) key = KEYC_MOUSEDRAGEND1_BORDER; break; @@ -834,6 +902,8 @@ have_event: key = KEYC_MOUSEDRAGEND2_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDRAGEND2_STATUS_DEFAULT; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDRAGEND2_SCROLLBAR_SLIDER; if (where == BORDER) key = KEYC_MOUSEDRAGEND2_BORDER; break; @@ -848,6 +918,8 @@ have_event: key = KEYC_MOUSEDRAGEND3_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDRAGEND3_STATUS_DEFAULT; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDRAGEND3_SCROLLBAR_SLIDER; if (where == BORDER) key = KEYC_MOUSEDRAGEND3_BORDER; break; @@ -862,6 +934,8 @@ have_event: key = KEYC_MOUSEDRAGEND6_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDRAGEND6_STATUS_DEFAULT; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDRAGEND6_SCROLLBAR_SLIDER; if (where == BORDER) key = KEYC_MOUSEDRAGEND6_BORDER; break; @@ -876,6 +950,8 @@ have_event: key = KEYC_MOUSEDRAGEND7_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDRAGEND7_STATUS_DEFAULT; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDRAGEND7_SCROLLBAR_SLIDER; if (where == BORDER) key = KEYC_MOUSEDRAGEND7_BORDER; break; @@ -890,6 +966,8 @@ have_event: key = KEYC_MOUSEDRAGEND8_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDRAGEND8_STATUS_DEFAULT; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDRAGEND8_SCROLLBAR_SLIDER; if (where == BORDER) key = KEYC_MOUSEDRAGEND8_BORDER; break; @@ -904,6 +982,8 @@ have_event: key = KEYC_MOUSEDRAGEND9_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDRAGEND9_STATUS_DEFAULT; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDRAGEND9_SCROLLBAR_SLIDER; if (where == BORDER) key = KEYC_MOUSEDRAGEND9_BORDER; break; @@ -918,6 +998,8 @@ have_event: key = KEYC_MOUSEDRAGEND10_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDRAGEND10_STATUS_DEFAULT; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDRAGEND10_SCROLLBAR_SLIDER; if (where == BORDER) key = KEYC_MOUSEDRAGEND10_BORDER; break; @@ -932,6 +1014,8 @@ have_event: key = KEYC_MOUSEDRAGEND11_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDRAGEND11_STATUS_DEFAULT; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDRAGEND11_SCROLLBAR_SLIDER; if (where == BORDER) key = KEYC_MOUSEDRAGEND11_BORDER; break; @@ -940,6 +1024,7 @@ have_event: break; } c->tty.mouse_drag_flag = 0; + c->tty.mouse_slider_mpos = -1; goto out; } @@ -978,6 +1063,12 @@ have_event: key = KEYC_MOUSEDRAG1_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDRAG1_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEDRAG1_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDRAG1_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEDRAG1_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEDRAG1_BORDER; break; @@ -992,6 +1083,12 @@ have_event: key = KEYC_MOUSEDRAG2_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDRAG2_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEDRAG2_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDRAG2_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEDRAG2_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEDRAG2_BORDER; break; @@ -1006,6 +1103,12 @@ have_event: key = KEYC_MOUSEDRAG3_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDRAG3_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEDRAG3_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDRAG3_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEDRAG3_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEDRAG3_BORDER; break; @@ -1020,6 +1123,12 @@ have_event: key = KEYC_MOUSEDRAG6_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDRAG6_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEDRAG6_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDRAG6_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEDRAG6_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEDRAG6_BORDER; break; @@ -1034,6 +1143,12 @@ have_event: key = KEYC_MOUSEDRAG7_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDRAG7_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEDRAG7_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDRAG7_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEDRAG7_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEDRAG7_BORDER; break; @@ -1048,6 +1163,12 @@ have_event: key = KEYC_MOUSEDRAG8_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDRAG8_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEDRAG8_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDRAG8_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEDRAG8_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEDRAG8_BORDER; break; @@ -1062,6 +1183,12 @@ have_event: key = KEYC_MOUSEDRAG9_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDRAG9_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEDRAG9_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDRAG9_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEDRAG9_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEDRAG9_BORDER; break; @@ -1076,6 +1203,12 @@ have_event: key = KEYC_MOUSEDRAG10_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDRAG10_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEDRAG10_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDRAG10_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEDRAG10_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEDRAG10_BORDER; break; @@ -1090,6 +1223,12 @@ have_event: key = KEYC_MOUSEDRAG11_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDRAG11_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEDRAG11_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDRAG11_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEDRAG11_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEDRAG11_BORDER; break; @@ -1098,9 +1237,16 @@ have_event: /* * Begin a drag by setting the flag to a non-zero value that - * corresponds to the mouse button in use. + * corresponds to the mouse button in use. If starting to drag + * the scrollbar, store the relative position in the slider + * where the user grabbed. */ c->tty.mouse_drag_flag = MOUSE_BUTTONS(b) + 1; + if (c->tty.mouse_scrolling_flag == 0 && + where == SCROLLBAR_SLIDER) { + c->tty.mouse_scrolling_flag = 1; + c->tty.mouse_slider_mpos = sl_mpos; + } break; case WHEEL: if (MOUSE_BUTTONS(b) == MOUSE_WHEEL_UP) { @@ -1144,6 +1290,12 @@ have_event: key = KEYC_MOUSEUP1_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEUP1_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEUP1_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEUP1_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEUP1_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEUP1_BORDER; break; @@ -1158,6 +1310,12 @@ have_event: key = KEYC_MOUSEUP2_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEUP2_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEUP2_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEUP2_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEUP2_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEUP2_BORDER; break; @@ -1172,6 +1330,12 @@ have_event: key = KEYC_MOUSEUP3_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEUP3_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEUP3_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEUP3_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEUP3_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEUP3_BORDER; break; @@ -1186,6 +1350,12 @@ have_event: key = KEYC_MOUSEUP6_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEUP6_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEUP6_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEUP6_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEUP6_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEUP6_BORDER; break; @@ -1200,6 +1370,12 @@ have_event: key = KEYC_MOUSEUP7_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEUP7_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEUP7_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEUP7_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEUP7_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEUP7_BORDER; break; @@ -1214,6 +1390,12 @@ have_event: key = KEYC_MOUSEUP8_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEUP8_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEUP8_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEUP8_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEUP8_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEUP8_BORDER; break; @@ -1228,6 +1410,12 @@ have_event: key = KEYC_MOUSEUP9_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEUP9_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEUP9_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEUP9_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEUP9_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEUP9_BORDER; break; @@ -1241,7 +1429,13 @@ have_event: if (where == STATUS_RIGHT) key = KEYC_MOUSEUP1_STATUS_RIGHT; if (where == STATUS_DEFAULT) - key = KEYC_MOUSEUP1_STATUS_DEFAULT; + key = KEYC_MOUSEUP10_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEUP10_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEUP10_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEUP1_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEUP1_BORDER; break; @@ -1256,6 +1450,12 @@ have_event: key = KEYC_MOUSEUP11_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEUP11_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEUP11_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEUP11_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEUP11_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEUP11_BORDER; break; @@ -1274,6 +1474,12 @@ have_event: key = KEYC_MOUSEDOWN1_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDOWN1_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEDOWN1_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDOWN1_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEDOWN1_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEDOWN1_BORDER; break; @@ -1288,6 +1494,12 @@ have_event: key = KEYC_MOUSEDOWN2_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDOWN2_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEDOWN2_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDOWN2_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEDOWN2_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEDOWN2_BORDER; break; @@ -1302,6 +1514,12 @@ have_event: key = KEYC_MOUSEDOWN3_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDOWN3_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEDOWN3_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDOWN3_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEDOWN3_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEDOWN3_BORDER; break; @@ -1316,6 +1534,12 @@ have_event: key = KEYC_MOUSEDOWN6_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDOWN6_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEDOWN6_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDOWN6_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEDOWN6_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEDOWN6_BORDER; break; @@ -1330,6 +1554,12 @@ have_event: key = KEYC_MOUSEDOWN7_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDOWN7_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEDOWN7_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDOWN7_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEDOWN7_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEDOWN7_BORDER; break; @@ -1344,6 +1574,12 @@ have_event: key = KEYC_MOUSEDOWN8_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDOWN8_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEDOWN8_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDOWN8_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEDOWN8_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEDOWN8_BORDER; break; @@ -1358,6 +1594,12 @@ have_event: key = KEYC_MOUSEDOWN9_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDOWN9_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEDOWN9_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDOWN9_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEDOWN9_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEDOWN9_BORDER; break; @@ -1372,6 +1614,12 @@ have_event: key = KEYC_MOUSEDOWN10_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDOWN10_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEDOWN10_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDOWN10_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEDOWN10_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEDOWN10_BORDER; break; @@ -1386,6 +1634,12 @@ have_event: key = KEYC_MOUSEDOWN11_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_MOUSEDOWN11_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_MOUSEDOWN11_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_MOUSEDOWN11_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_MOUSEDOWN11_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_MOUSEDOWN11_BORDER; break; @@ -1404,6 +1658,12 @@ have_event: key = KEYC_SECONDCLICK1_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_SECONDCLICK1_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_SECONDCLICK1_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_SECONDCLICK1_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_SECONDCLICK1_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_SECONDCLICK1_BORDER; break; @@ -1418,6 +1678,12 @@ have_event: key = KEYC_SECONDCLICK2_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_SECONDCLICK2_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_SECONDCLICK2_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_SECONDCLICK2_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_SECONDCLICK2_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_SECONDCLICK2_BORDER; break; @@ -1432,6 +1698,12 @@ have_event: key = KEYC_SECONDCLICK3_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_SECONDCLICK3_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_SECONDCLICK3_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_SECONDCLICK3_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_SECONDCLICK3_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_SECONDCLICK3_BORDER; break; @@ -1446,6 +1718,12 @@ have_event: key = KEYC_SECONDCLICK6_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_SECONDCLICK6_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_SECONDCLICK6_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_SECONDCLICK6_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_SECONDCLICK6_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_SECONDCLICK6_BORDER; break; @@ -1460,6 +1738,12 @@ have_event: key = KEYC_SECONDCLICK7_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_SECONDCLICK7_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_SECONDCLICK7_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_SECONDCLICK7_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_SECONDCLICK7_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_SECONDCLICK7_BORDER; break; @@ -1474,6 +1758,12 @@ have_event: key = KEYC_SECONDCLICK8_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_SECONDCLICK8_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_SECONDCLICK8_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_SECONDCLICK8_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_SECONDCLICK8_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_SECONDCLICK8_BORDER; break; @@ -1488,6 +1778,12 @@ have_event: key = KEYC_SECONDCLICK9_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_SECONDCLICK9_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_SECONDCLICK9_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_SECONDCLICK9_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_SECONDCLICK9_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_SECONDCLICK9_BORDER; break; @@ -1502,6 +1798,12 @@ have_event: key = KEYC_SECONDCLICK10_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_SECONDCLICK10_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_SECONDCLICK10_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_SECONDCLICK10_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_SECONDCLICK10_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_SECONDCLICK10_BORDER; break; @@ -1516,6 +1818,12 @@ have_event: key = KEYC_SECONDCLICK11_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_SECONDCLICK11_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_SECONDCLICK11_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_SECONDCLICK11_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_SECONDCLICK11_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_SECONDCLICK11_BORDER; break; @@ -1534,6 +1842,12 @@ have_event: key = KEYC_DOUBLECLICK1_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_DOUBLECLICK1_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_DOUBLECLICK1_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_DOUBLECLICK1_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_DOUBLECLICK1_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_DOUBLECLICK1_BORDER; break; @@ -1548,6 +1862,12 @@ have_event: key = KEYC_DOUBLECLICK2_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_DOUBLECLICK2_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_DOUBLECLICK2_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_DOUBLECLICK2_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_DOUBLECLICK2_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_DOUBLECLICK2_BORDER; break; @@ -1562,6 +1882,12 @@ have_event: key = KEYC_DOUBLECLICK3_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_DOUBLECLICK3_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_DOUBLECLICK3_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_DOUBLECLICK3_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_DOUBLECLICK3_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_DOUBLECLICK3_BORDER; break; @@ -1576,6 +1902,12 @@ have_event: key = KEYC_DOUBLECLICK6_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_DOUBLECLICK6_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_DOUBLECLICK6_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_DOUBLECLICK6_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_DOUBLECLICK6_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_DOUBLECLICK6_BORDER; break; @@ -1590,6 +1922,12 @@ have_event: key = KEYC_DOUBLECLICK7_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_DOUBLECLICK7_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_DOUBLECLICK7_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_DOUBLECLICK7_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_DOUBLECLICK7_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_DOUBLECLICK7_BORDER; break; @@ -1604,6 +1942,12 @@ have_event: key = KEYC_DOUBLECLICK8_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_DOUBLECLICK8_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_DOUBLECLICK8_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_DOUBLECLICK8_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_DOUBLECLICK8_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_DOUBLECLICK8_BORDER; break; @@ -1618,6 +1962,12 @@ have_event: key = KEYC_DOUBLECLICK9_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_DOUBLECLICK9_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_DOUBLECLICK9_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_DOUBLECLICK9_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_DOUBLECLICK9_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_DOUBLECLICK9_BORDER; break; @@ -1632,6 +1982,12 @@ have_event: key = KEYC_DOUBLECLICK10_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_DOUBLECLICK10_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_DOUBLECLICK10_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_DOUBLECLICK10_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_DOUBLECLICK10_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_DOUBLECLICK10_BORDER; break; @@ -1646,6 +2002,12 @@ have_event: key = KEYC_DOUBLECLICK11_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_DOUBLECLICK11_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_DOUBLECLICK11_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_DOUBLECLICK11_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_DOUBLECLICK11_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_DOUBLECLICK11_BORDER; break; @@ -1664,6 +2026,12 @@ have_event: key = KEYC_TRIPLECLICK1_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_TRIPLECLICK1_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_TRIPLECLICK1_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_TRIPLECLICK1_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_TRIPLECLICK1_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_TRIPLECLICK1_BORDER; break; @@ -1678,6 +2046,12 @@ have_event: key = KEYC_TRIPLECLICK2_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_TRIPLECLICK2_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_TRIPLECLICK2_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_TRIPLECLICK2_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_TRIPLECLICK2_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_TRIPLECLICK2_BORDER; break; @@ -1692,6 +2066,12 @@ have_event: key = KEYC_TRIPLECLICK3_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_TRIPLECLICK3_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_TRIPLECLICK3_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_TRIPLECLICK3_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_TRIPLECLICK3_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_TRIPLECLICK3_BORDER; break; @@ -1706,6 +2086,12 @@ have_event: key = KEYC_TRIPLECLICK6_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_TRIPLECLICK6_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_TRIPLECLICK6_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_TRIPLECLICK6_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_TRIPLECLICK6_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_TRIPLECLICK6_BORDER; break; @@ -1720,6 +2106,12 @@ have_event: key = KEYC_TRIPLECLICK7_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_TRIPLECLICK7_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_TRIPLECLICK7_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_TRIPLECLICK7_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_TRIPLECLICK7_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_TRIPLECLICK7_BORDER; break; @@ -1734,6 +2126,12 @@ have_event: key = KEYC_TRIPLECLICK8_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_TRIPLECLICK8_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_TRIPLECLICK8_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_TRIPLECLICK8_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_TRIPLECLICK8_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_TRIPLECLICK8_BORDER; break; @@ -1748,6 +2146,12 @@ have_event: key = KEYC_TRIPLECLICK9_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_TRIPLECLICK9_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_TRIPLECLICK9_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_TRIPLECLICK9_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_TRIPLECLICK9_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_TRIPLECLICK9_BORDER; break; @@ -1762,6 +2166,12 @@ have_event: key = KEYC_TRIPLECLICK10_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_TRIPLECLICK10_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_TRIPLECLICK10_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_TRIPLECLICK10_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_TRIPLECLICK10_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_TRIPLECLICK10_BORDER; break; @@ -1776,6 +2186,12 @@ have_event: key = KEYC_TRIPLECLICK11_STATUS_RIGHT; if (where == STATUS_DEFAULT) key = KEYC_TRIPLECLICK11_STATUS_DEFAULT; + if (where == SCROLLBAR_UP) + key = KEYC_TRIPLECLICK11_SCROLLBAR_UP; + if (where == SCROLLBAR_SLIDER) + key = KEYC_TRIPLECLICK11_SCROLLBAR_SLIDER; + if (where == SCROLLBAR_DOWN) + key = KEYC_TRIPLECLICK11_SCROLLBAR_DOWN; if (where == BORDER) key = KEYC_TRIPLECLICK11_BORDER; break; diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 612798cef93..664454095ef 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.970 2024/11/11 08:41:05 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.971 2024/11/12 09:32:56 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: November 11 2024 $ +.Dd $Mdocdate: November 12 2024 $ .Dt TMUX 1 .Os .Sh NAME @@ -2400,22 +2400,31 @@ The synopsis for the command is: .Bl -tag -width Ds .It Xo Ic copy-mode -.Op Fl deHMqu +.Op Fl deHMqSu .Op Fl s Ar src-pane .Op Fl t Ar target-pane .Xc Enter copy mode. +.Pp .Fl u -also scrolls one page up after entering and +enters copy mode and scrolls one page up and .Fl d -one page down if already in copy mode. -.Fl M -begins a mouse drag (only valid if bound to a mouse key binding, see -.Sx MOUSE SUPPORT ) . +one page down. .Fl H hides the position indicator in the top right. .Fl q cancels copy mode and any other modes. +.Pp +.Fl M +begins a mouse drag (only valid if bound to a mouse key binding, see +.Sx MOUSE SUPPORT ) . +.Fl S +scrolls when bound to a mouse drag event; for example, +.Ic copy-mode -Se +is bound to +.Ar MouseDrag1ScrollbarSlider +by default. +.Pp .Fl s copies from .Ar src-pane @@ -5441,6 +5450,9 @@ and a location suffix, one of the following: .It Li "StatusLeft" Ta "the left part of the status line" .It Li "StatusRight" Ta "the right part of the status line" .It Li "StatusDefault" Ta "any other part of the status line" +.It Li "ScrollbarSlider" Ta "the scrollbar slider" +.It Li "ScrollbarUp" Ta "above the scrollbar slider" +.It Li "ScrollbarDown" Ta "below the scrollbar slider" .El .Pp The following mouse events are available: diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index a46ba92b4f2..f098f452293 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.1239 2024/11/11 08:41:05 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.1240 2024/11/12 09:32:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -169,19 +169,25 @@ struct winlink; #define KEYC_CLICK_TIMEOUT 300 /* Mouse key codes. */ -#define KEYC_MOUSE_KEY(name) \ - KEYC_ ## name ## _PANE, \ - KEYC_ ## name ## _STATUS, \ - KEYC_ ## name ## _STATUS_LEFT, \ - KEYC_ ## name ## _STATUS_RIGHT, \ - KEYC_ ## name ## _STATUS_DEFAULT, \ +#define KEYC_MOUSE_KEY(name) \ + KEYC_ ## name ## _PANE, \ + KEYC_ ## name ## _STATUS, \ + KEYC_ ## name ## _STATUS_LEFT, \ + KEYC_ ## name ## _STATUS_RIGHT, \ + KEYC_ ## name ## _STATUS_DEFAULT, \ + KEYC_ ## name ## _SCROLLBAR_UP, \ + KEYC_ ## name ## _SCROLLBAR_SLIDER, \ + KEYC_ ## name ## _SCROLLBAR_DOWN, \ KEYC_ ## name ## _BORDER -#define KEYC_MOUSE_STRING(name, s) \ - { #s "Pane", KEYC_ ## name ## _PANE }, \ - { #s "Status", KEYC_ ## name ## _STATUS }, \ - { #s "StatusLeft", KEYC_ ## name ## _STATUS_LEFT }, \ - { #s "StatusRight", KEYC_ ## name ## _STATUS_RIGHT }, \ - { #s "StatusDefault", KEYC_ ## name ## _STATUS_DEFAULT }, \ +#define KEYC_MOUSE_STRING(name, s) \ + { #s "Pane", KEYC_ ## name ## _PANE }, \ + { #s "Status", KEYC_ ## name ## _STATUS }, \ + { #s "StatusLeft", KEYC_ ## name ## _STATUS_LEFT }, \ + { #s "StatusRight", KEYC_ ## name ## _STATUS_RIGHT }, \ + { #s "StatusDefault", KEYC_ ## name ## _STATUS_DEFAULT }, \ + { #s "ScrollbarUp", KEYC_ ## name ## _SCROLLBAR_UP }, \ + { #s "ScrollbarSlider", KEYC_ ## name ## _SCROLLBAR_SLIDER }, \ + { #s "ScrollbarDown", KEYC_ ## name ## _SCROLLBAR_DOWN }, \ { #s "Border", KEYC_ ## name ## _BORDER } /* @@ -1109,6 +1115,9 @@ struct window_pane { #define PANE_UNSEENCHANGES 0x2000 #define PANE_REDRAWSCROLLBAR 0x4000 + u_int sb_slider_y; + u_int sb_slider_h; + int argc; char **argv; char *shell; @@ -1509,6 +1518,9 @@ struct tty { u_int mouse_last_y; u_int mouse_last_b; int mouse_drag_flag; + int mouse_scrolling_flag; + int mouse_slider_mpos; + void (*mouse_drag_update)(struct client *, struct mouse_event *); void (*mouse_drag_release)(struct client *, @@ -3266,6 +3278,7 @@ void printflike(3, 4) window_copy_add(struct window_pane *, int, const char *, ...); void printflike(3, 0) window_copy_vadd(struct window_pane *, int, const char *, va_list); +void window_copy_scroll(struct window_pane *, int, u_int, int); void window_copy_pageup(struct window_pane *, int); void window_copy_pagedown(struct window_pane *, int, int); void window_copy_start_drag(struct client *, struct mouse_event *); diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index 1a6c6690705..19484ad0cd3 100644 --- a/usr.bin/tmux/window-copy.c +++ b/usr.bin/tmux/window-copy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-copy.c,v 1.364 2024/11/08 08:51:36 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.365 2024/11/12 09:32:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -40,6 +40,8 @@ static void window_copy_free(struct window_mode_entry *); static void window_copy_resize(struct window_mode_entry *, u_int, u_int); static void window_copy_formats(struct window_mode_entry *, struct format_tree *); +static void window_copy_scroll1(struct window_mode_entry *, + struct window_pane *wp, int, u_int, int); static void window_copy_pageup1(struct window_mode_entry *, int); static int window_copy_pagedown1(struct window_mode_entry *, int, int); static void window_copy_next_paragraph(struct window_mode_entry *); @@ -599,6 +601,113 @@ window_copy_vadd(struct window_pane *wp, int parse, const char *fmt, va_list ap) } void +window_copy_scroll(struct window_pane *wp, int sl_mpos, u_int my, + int scroll_exit) +{ + struct window_mode_entry *wme = TAILQ_FIRST(&wp->modes); + + if (wme != NULL) { + window_set_active_pane(wp->window, wp, 0); + window_copy_scroll1(wme, wp, sl_mpos, my, scroll_exit); + } +} + +static void +window_copy_scroll1(struct window_mode_entry *wme, struct window_pane *wp, + int sl_mpos, u_int my, int scroll_exit) +{ + struct window_copy_mode_data *data = wme->data; + u_int ox, oy, px, py, n, offset, size; + u_int new_offset, slider_y = wp->sb_slider_y; + u_int slider_height = wp->sb_slider_h; + u_int sb_height = wp->sy, sb_top = wp->yoff; + u_int sy = screen_size_y(data->backing); + int new_slider_y, delta; + + /* + * sl_mpos is where in the slider the user is dragging, mouse is + * dragging this y point relative to top of slider. + */ + if (my <= sb_top + sl_mpos) { + /* Slider banged into top. */ + new_slider_y = sb_top - wp->yoff; + } else if (my - sl_mpos > sb_top + sb_height - slider_height) { + /* Slider banged into bottom. */ + new_slider_y = sb_top - wp->yoff + (sb_height - slider_height); + } else { + /* Slider is somewhere in the middle. */ + new_slider_y = my - wp->yoff - sl_mpos + 1; + } + + if (TAILQ_FIRST(&wp->modes) == NULL || + window_copy_get_current_offset(wp, &offset, &size) == 0) + return; + + /* + * See screen_redraw_draw_pane_scrollbar - this is the inverse of the + * formula used there. + */ + new_offset = new_slider_y * ((float)(size + sb_height) / sb_height); + delta = (int)offset - new_offset; + + /* + * Move pane view around based on delta relative to the cursor, + * maintaining the selection. + */ + oy = screen_hsize(data->backing) + data->cy - data->oy; + ox = window_copy_find_length(wme, oy); + + if (data->cx != ox) { + data->lastcx = data->cx; + data->lastsx = ox; + } + data->cx = data->lastcx; + + if (delta >= 0) { + n = (u_int)delta; + if (data->oy + n > screen_hsize(data->backing)) { + data->oy = screen_hsize(data->backing); + if (data->cy < n) + data->cy = 0; + else + data->cy -= n; + } else + data->oy += n; + } else { + n = (u_int)-delta; + if (data->oy < n) { + data->oy = 0; + if (data->cy + (n - data->oy) >= sy) + data->cy = sy - 1; + else + data->cy += n - data->oy; + } else + data->oy -= n; + } + + /* Don't also drag tail when dragging a scrollbar, it looks weird. */ + data->cursordrag = CURSORDRAG_NONE; + + if (data->screen.sel == NULL || !data->rectflag) { + py = screen_hsize(data->backing) + data->cy - data->oy; + px = window_copy_find_length(wme, py); + if ((data->cx >= data->lastsx && data->cx != px) || + data->cx > px) + window_copy_cursor_end_of_line(wme); + } + + if (scroll_exit && data->oy == 0) { + window_pane_reset_mode(wp); + return; + } + + if (data->searchmark != NULL && !data->timeout) + window_copy_search_marks(wme, NULL, data->searchregex, 1); + window_copy_update_selection(wme, 1, 0); + window_copy_redraw_screen(wme); +} + +void window_copy_pageup(struct window_pane *wp, int half_page) { window_copy_pageup1(TAILQ_FIRST(&wp->modes), half_page); |