diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-03-25 18:59:56 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-03-25 18:59:56 +0000 |
commit | f504c5799b10266a9d6a41525112113687723065 (patch) | |
tree | 017cfe924a5ba2c813b85c8fe28b3cbc2e4c14de /usr.bin | |
parent | a0609559123abf99b9d87e3d84d1800d013d444d (diff) |
Add StatusDefault binding for the mouse on any otherwise unassigned
parts of the status line, from Avi Halachmi.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/server-client.c | 90 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 22 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 4 |
3 files changed, 85 insertions, 31 deletions
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index 42ec9c45981..a043d7788d7 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.273 2019/03/25 09:22:09 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.274 2019/03/25 18:59:55 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -419,7 +419,7 @@ server_client_check_mouse(struct client *c) struct timeval tv; struct style_range *sr; enum { NOTYPE, MOVE, DOWN, UP, DRAG, WHEEL, DOUBLE, TRIPLE } type; - enum { NOWHERE, PANE, STATUS, STATUS_LEFT, STATUS_RIGHT, BORDER } where; + enum { NOWHERE, PANE, STATUS, STATUS_LEFT, STATUS_RIGHT, STATUS_DEFAULT, BORDER } where; type = NOTYPE; where = NOWHERE; @@ -508,25 +508,27 @@ have_event: y >= (u_int)m->statusat && y < m->statusat + status_line_size(c)) { sr = status_get_range(c, x, y - m->statusat); - if (sr == NULL) - return (KEYC_UNKNOWN); - switch (sr->type) { - case STYLE_RANGE_NONE: - return (KEYC_UNKNOWN); - case STYLE_RANGE_LEFT: - where = STATUS_LEFT; - break; - case STYLE_RANGE_RIGHT: - where = STATUS_RIGHT; - break; - case STYLE_RANGE_WINDOW: - wl = winlink_find_by_index(&s->windows, sr->argument); - if (wl == NULL) + if (sr == NULL) { + where = STATUS_DEFAULT; + } else { + switch (sr->type) { + case STYLE_RANGE_NONE: return (KEYC_UNKNOWN); - m->w = wl->window->id; + case STYLE_RANGE_LEFT: + where = STATUS_LEFT; + break; + case STYLE_RANGE_RIGHT: + where = STATUS_RIGHT; + break; + case STYLE_RANGE_WINDOW: + wl = winlink_find_by_index(&s->windows, sr->argument); + if (wl == NULL) + return (KEYC_UNKNOWN); + m->w = wl->window->id; - where = STATUS; - break; + where = STATUS; + break; + } } } @@ -605,6 +607,8 @@ have_event: key = KEYC_MOUSEDRAGEND1_STATUS_LEFT; if (where == STATUS_RIGHT) key = KEYC_MOUSEDRAGEND1_STATUS_RIGHT; + if (where == STATUS_DEFAULT) + key = KEYC_MOUSEDRAGEND1_STATUS_DEFAULT; if (where == BORDER) key = KEYC_MOUSEDRAGEND1_BORDER; break; @@ -617,6 +621,8 @@ have_event: key = KEYC_MOUSEDRAGEND2_STATUS_LEFT; if (where == STATUS_RIGHT) key = KEYC_MOUSEDRAGEND2_STATUS_RIGHT; + if (where == STATUS_DEFAULT) + key = KEYC_MOUSEDRAGEND2_STATUS_DEFAULT; if (where == BORDER) key = KEYC_MOUSEDRAGEND2_BORDER; break; @@ -629,6 +635,8 @@ have_event: key = KEYC_MOUSEDRAGEND3_STATUS_LEFT; if (where == STATUS_RIGHT) key = KEYC_MOUSEDRAGEND3_STATUS_RIGHT; + if (where == STATUS_DEFAULT) + key = KEYC_MOUSEDRAGEND3_STATUS_DEFAULT; if (where == BORDER) key = KEYC_MOUSEDRAGEND3_BORDER; break; @@ -651,6 +659,12 @@ have_event: key = KEYC_MOUSEMOVE_PANE; if (where == STATUS) key = KEYC_MOUSEMOVE_STATUS; + if (where == STATUS_LEFT) + key = KEYC_MOUSEMOVE_STATUS_LEFT; + if (where == STATUS_RIGHT) + key = KEYC_MOUSEMOVE_STATUS_RIGHT; + if (where == STATUS_DEFAULT) + key = KEYC_MOUSEMOVE_STATUS_DEFAULT; if (where == BORDER) key = KEYC_MOUSEMOVE_BORDER; break; @@ -668,6 +682,8 @@ have_event: key = KEYC_MOUSEDRAG1_STATUS_LEFT; if (where == STATUS_RIGHT) key = KEYC_MOUSEDRAG1_STATUS_RIGHT; + if (where == STATUS_DEFAULT) + key = KEYC_MOUSEDRAG1_STATUS_DEFAULT; if (where == BORDER) key = KEYC_MOUSEDRAG1_BORDER; break; @@ -680,6 +696,8 @@ have_event: key = KEYC_MOUSEDRAG2_STATUS_LEFT; if (where == STATUS_RIGHT) key = KEYC_MOUSEDRAG2_STATUS_RIGHT; + if (where == STATUS_DEFAULT) + key = KEYC_MOUSEDRAG2_STATUS_DEFAULT; if (where == BORDER) key = KEYC_MOUSEDRAG2_BORDER; break; @@ -692,6 +710,8 @@ have_event: key = KEYC_MOUSEDRAG3_STATUS_LEFT; if (where == STATUS_RIGHT) key = KEYC_MOUSEDRAG3_STATUS_RIGHT; + if (where == STATUS_DEFAULT) + key = KEYC_MOUSEDRAG3_STATUS_DEFAULT; if (where == BORDER) key = KEYC_MOUSEDRAG3_BORDER; break; @@ -714,6 +734,8 @@ have_event: key = KEYC_WHEELUP_STATUS_LEFT; if (where == STATUS_RIGHT) key = KEYC_WHEELUP_STATUS_RIGHT; + if (where == STATUS_DEFAULT) + key = KEYC_WHEELUP_STATUS_DEFAULT; if (where == BORDER) key = KEYC_WHEELUP_BORDER; } else { @@ -721,6 +743,12 @@ have_event: key = KEYC_WHEELDOWN_PANE; if (where == STATUS) key = KEYC_WHEELDOWN_STATUS; + if (where == STATUS_LEFT) + key = KEYC_WHEELDOWN_STATUS_LEFT; + if (where == STATUS_RIGHT) + key = KEYC_WHEELDOWN_STATUS_RIGHT; + if (where == STATUS_DEFAULT) + key = KEYC_WHEELDOWN_STATUS_DEFAULT; if (where == BORDER) key = KEYC_WHEELDOWN_BORDER; } @@ -736,6 +764,8 @@ have_event: key = KEYC_MOUSEUP1_STATUS_LEFT; if (where == STATUS_RIGHT) key = KEYC_MOUSEUP1_STATUS_RIGHT; + if (where == STATUS_DEFAULT) + key = KEYC_MOUSEUP1_STATUS_DEFAULT; if (where == BORDER) key = KEYC_MOUSEUP1_BORDER; break; @@ -748,6 +778,8 @@ have_event: key = KEYC_MOUSEUP2_STATUS_LEFT; if (where == STATUS_RIGHT) key = KEYC_MOUSEUP2_STATUS_RIGHT; + if (where == STATUS_DEFAULT) + key = KEYC_MOUSEUP2_STATUS_DEFAULT; if (where == BORDER) key = KEYC_MOUSEUP2_BORDER; break; @@ -760,6 +792,8 @@ have_event: key = KEYC_MOUSEUP3_STATUS_LEFT; if (where == STATUS_RIGHT) key = KEYC_MOUSEUP3_STATUS_RIGHT; + if (where == STATUS_DEFAULT) + key = KEYC_MOUSEUP3_STATUS_DEFAULT; if (where == BORDER) key = KEYC_MOUSEUP3_BORDER; break; @@ -776,6 +810,8 @@ have_event: key = KEYC_MOUSEDOWN1_STATUS_LEFT; if (where == STATUS_RIGHT) key = KEYC_MOUSEDOWN1_STATUS_RIGHT; + if (where == STATUS_DEFAULT) + key = KEYC_MOUSEDOWN1_STATUS_DEFAULT; if (where == BORDER) key = KEYC_MOUSEDOWN1_BORDER; break; @@ -788,6 +824,8 @@ have_event: key = KEYC_MOUSEDOWN2_STATUS_LEFT; if (where == STATUS_RIGHT) key = KEYC_MOUSEDOWN2_STATUS_RIGHT; + if (where == STATUS_DEFAULT) + key = KEYC_MOUSEDOWN2_STATUS_DEFAULT; if (where == BORDER) key = KEYC_MOUSEDOWN2_BORDER; break; @@ -800,6 +838,8 @@ have_event: key = KEYC_MOUSEDOWN3_STATUS_LEFT; if (where == STATUS_RIGHT) key = KEYC_MOUSEDOWN3_STATUS_RIGHT; + if (where == STATUS_DEFAULT) + key = KEYC_MOUSEDOWN3_STATUS_DEFAULT; if (where == BORDER) key = KEYC_MOUSEDOWN3_BORDER; break; @@ -816,6 +856,8 @@ have_event: key = KEYC_DOUBLECLICK1_STATUS_LEFT; if (where == STATUS_RIGHT) key = KEYC_DOUBLECLICK1_STATUS_RIGHT; + if (where == STATUS_DEFAULT) + key = KEYC_DOUBLECLICK1_STATUS_DEFAULT; if (where == BORDER) key = KEYC_DOUBLECLICK1_BORDER; break; @@ -828,6 +870,8 @@ have_event: key = KEYC_DOUBLECLICK2_STATUS_LEFT; if (where == STATUS_RIGHT) key = KEYC_DOUBLECLICK2_STATUS_RIGHT; + if (where == STATUS_DEFAULT) + key = KEYC_DOUBLECLICK2_STATUS_DEFAULT; if (where == BORDER) key = KEYC_DOUBLECLICK2_BORDER; break; @@ -840,6 +884,8 @@ have_event: key = KEYC_DOUBLECLICK3_STATUS_LEFT; if (where == STATUS_RIGHT) key = KEYC_DOUBLECLICK3_STATUS_RIGHT; + if (where == STATUS_DEFAULT) + key = KEYC_DOUBLECLICK3_STATUS_DEFAULT; if (where == BORDER) key = KEYC_DOUBLECLICK3_BORDER; break; @@ -856,6 +902,8 @@ have_event: key = KEYC_TRIPLECLICK1_STATUS_LEFT; if (where == STATUS_RIGHT) key = KEYC_TRIPLECLICK1_STATUS_RIGHT; + if (where == STATUS_DEFAULT) + key = KEYC_TRIPLECLICK1_STATUS_DEFAULT; if (where == BORDER) key = KEYC_TRIPLECLICK1_BORDER; break; @@ -868,6 +916,8 @@ have_event: key = KEYC_TRIPLECLICK2_STATUS_LEFT; if (where == STATUS_RIGHT) key = KEYC_TRIPLECLICK2_STATUS_RIGHT; + if (where == STATUS_DEFAULT) + key = KEYC_TRIPLECLICK2_STATUS_DEFAULT; if (where == BORDER) key = KEYC_TRIPLECLICK2_BORDER; break; @@ -880,6 +930,8 @@ have_event: key = KEYC_TRIPLECLICK3_STATUS_LEFT; if (where == STATUS_RIGHT) key = KEYC_TRIPLECLICK3_STATUS_RIGHT; + if (where == STATUS_DEFAULT) + key = KEYC_TRIPLECLICK3_STATUS_DEFAULT; if (where == BORDER) key = KEYC_TRIPLECLICK3_BORDER; break; diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index d6ae5cff54b..bf9734ac43a 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.631 2019/03/25 14:29:36 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.632 2019/03/25 18:59:55 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> .\" @@ -3519,16 +3519,16 @@ option is on (the default is off), allows mouse events to be bound as keys. The name of each key is made up of a mouse event (such as .Ql MouseUp1 ) -and a location suffix (one of -.Ql Pane -for the contents of a pane, -.Ql Border -for a pane border or -.Ql Status , -.Ql StatusLeft , -or -.Ql StatusRight -for the status line). +and a location suffix, one of the following: +.Bl -column "XXXXXXXXXXXXX" -offset indent +.It Li "Pane" Ta "the contents of a pane" +.It Li "Border" Ta "a pane border" +.It Li "Status" Ta "the status line window list" +.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" +.El +.Pp The following mouse events are available: .Bl -column "MouseDown1" "MouseDrag1" "WheelDown" -offset indent .It Li "WheelUp" Ta "WheelDown" Ta "" diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 944ab89aeaf..86f5a58b8f6 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.876 2019/03/20 19:19:11 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.877 2019/03/25 18:59:55 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -128,12 +128,14 @@ struct winlink; KEYC_ ## name ## _STATUS, \ KEYC_ ## name ## _STATUS_LEFT, \ KEYC_ ## name ## _STATUS_RIGHT, \ + KEYC_ ## name ## _STATUS_DEFAULT, \ 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 }, \ { #s "Border", KEYC_ ## name ## _BORDER } /* |