From bba16f07e6cb778ee551aac985dcc3b74eeb23b2 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 22 Aug 2018 20:06:14 +0000 Subject: [PATCH] Add StatusLeft and StatusRight mouse key modifiers for the left and right parts of the status line. --- usr.bin/tmux/key-string.c | 6 ++- usr.bin/tmux/server-client.c | 102 +++++++++++++++++++++++++++++++---- usr.bin/tmux/status.c | 6 ++- usr.bin/tmux/tmux.1 | 9 ++-- usr.bin/tmux/tmux.h | 21 +++++--- 5 files changed, 122 insertions(+), 22 deletions(-) diff --git a/usr.bin/tmux/key-string.c b/usr.bin/tmux/key-string.c index 21d32e6b5ed..bf10589afd2 100644 --- a/usr.bin/tmux/key-string.c +++ b/usr.bin/tmux/key-string.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key-string.c,v 1.48 2018/07/16 08:48:22 nicm Exp $ */ +/* $OpenBSD: key-string.c,v 1.49 2018/08/22 20:06:14 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -271,6 +271,10 @@ key_string_lookup_key(key_code key) return ("MouseMovePane"); if (key == KEYC_MOUSEMOVE_STATUS) return ("MouseMoveStatus"); + if (key == KEYC_MOUSEMOVE_STATUS_LEFT) + return ("MouseMoveStatusLeft"); + if (key == KEYC_MOUSEMOVE_STATUS_RIGHT) + return ("MouseMoveStatusRight"); if (key == KEYC_MOUSEMOVE_BORDER) return ("MouseMoveBorder"); if (key >= KEYC_USER && key < KEYC_USER + KEYC_NUSER) { diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index 804ed58761d..6c348902167 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.257 2018/08/19 20:13:07 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.258 2018/08/22 20:06:14 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -416,7 +416,7 @@ server_client_check_mouse(struct client *c) key_code key; struct timeval tv; enum { NOTYPE, MOVE, DOWN, UP, DRAG, WHEEL, DOUBLE, TRIPLE } type; - enum { NOWHERE, PANE, STATUS, BORDER } where; + enum { NOWHERE, PANE, STATUS, STATUS_LEFT, STATUS_RIGHT, BORDER } where; type = NOTYPE; where = NOWHERE; @@ -495,19 +495,25 @@ have_event: if (type == NOTYPE) return (KEYC_UNKNOWN); - /* Always save the session. */ + /* Save the session. */ m->s = s->id; + m->w = -1; /* Is this on the status line? */ m->statusat = status_at_line(c); if (m->statusat != -1 && y == (u_int)m->statusat) { - w = status_get_window_at(c, x); - if (w == NULL) - return (KEYC_UNKNOWN); - m->w = w->id; - where = STATUS; - } else - m->w = -1; + if (x < c->status.left_size) + where = STATUS_LEFT; + else if (x > c->tty.sx - c->status.right_size) + where = STATUS_RIGHT; + else { + w = status_get_window_at(c, x); + if (w == NULL) + return (KEYC_UNKNOWN); + m->w = w->id; + where = STATUS; + } + } /* Not on status line. Adjust position and check for border or pane. */ if (where == NOWHERE) { @@ -560,6 +566,10 @@ have_event: key = KEYC_MOUSEDRAGEND1_PANE; if (where == STATUS) key = KEYC_MOUSEDRAGEND1_STATUS; + if (where == STATUS_LEFT) + key = KEYC_MOUSEDRAGEND1_STATUS_LEFT; + if (where == STATUS_RIGHT) + key = KEYC_MOUSEDRAGEND1_STATUS_RIGHT; if (where == BORDER) key = KEYC_MOUSEDRAGEND1_BORDER; break; @@ -568,6 +578,10 @@ have_event: key = KEYC_MOUSEDRAGEND2_PANE; if (where == STATUS) key = KEYC_MOUSEDRAGEND2_STATUS; + if (where == STATUS_LEFT) + key = KEYC_MOUSEDRAGEND2_STATUS_LEFT; + if (where == STATUS_RIGHT) + key = KEYC_MOUSEDRAGEND2_STATUS_RIGHT; if (where == BORDER) key = KEYC_MOUSEDRAGEND2_BORDER; break; @@ -576,6 +590,10 @@ have_event: key = KEYC_MOUSEDRAGEND3_PANE; if (where == STATUS) key = KEYC_MOUSEDRAGEND3_STATUS; + if (where == STATUS_LEFT) + key = KEYC_MOUSEDRAGEND3_STATUS_LEFT; + if (where == STATUS_RIGHT) + key = KEYC_MOUSEDRAGEND3_STATUS_RIGHT; if (where == BORDER) key = KEYC_MOUSEDRAGEND3_BORDER; break; @@ -611,6 +629,10 @@ have_event: key = KEYC_MOUSEDRAG1_PANE; if (where == STATUS) key = KEYC_MOUSEDRAG1_STATUS; + if (where == STATUS_LEFT) + key = KEYC_MOUSEDRAG1_STATUS_LEFT; + if (where == STATUS_RIGHT) + key = KEYC_MOUSEDRAG1_STATUS_RIGHT; if (where == BORDER) key = KEYC_MOUSEDRAG1_BORDER; break; @@ -619,6 +641,10 @@ have_event: key = KEYC_MOUSEDRAG2_PANE; if (where == STATUS) key = KEYC_MOUSEDRAG2_STATUS; + if (where == STATUS_LEFT) + key = KEYC_MOUSEDRAG2_STATUS_LEFT; + if (where == STATUS_RIGHT) + key = KEYC_MOUSEDRAG2_STATUS_RIGHT; if (where == BORDER) key = KEYC_MOUSEDRAG2_BORDER; break; @@ -627,6 +653,10 @@ have_event: key = KEYC_MOUSEDRAG3_PANE; if (where == STATUS) key = KEYC_MOUSEDRAG3_STATUS; + if (where == STATUS_LEFT) + key = KEYC_MOUSEDRAG3_STATUS_LEFT; + if (where == STATUS_RIGHT) + key = KEYC_MOUSEDRAG3_STATUS_RIGHT; if (where == BORDER) key = KEYC_MOUSEDRAG3_BORDER; break; @@ -645,6 +675,10 @@ have_event: key = KEYC_WHEELUP_PANE; if (where == STATUS) key = KEYC_WHEELUP_STATUS; + if (where == STATUS_LEFT) + key = KEYC_WHEELUP_STATUS_LEFT; + if (where == STATUS_RIGHT) + key = KEYC_WHEELUP_STATUS_RIGHT; if (where == BORDER) key = KEYC_WHEELUP_BORDER; } else { @@ -663,6 +697,10 @@ have_event: key = KEYC_MOUSEUP1_PANE; if (where == STATUS) key = KEYC_MOUSEUP1_STATUS; + if (where == STATUS_LEFT) + key = KEYC_MOUSEUP1_STATUS_LEFT; + if (where == STATUS_RIGHT) + key = KEYC_MOUSEUP1_STATUS_RIGHT; if (where == BORDER) key = KEYC_MOUSEUP1_BORDER; break; @@ -671,6 +709,10 @@ have_event: key = KEYC_MOUSEUP2_PANE; if (where == STATUS) key = KEYC_MOUSEUP2_STATUS; + if (where == STATUS_LEFT) + key = KEYC_MOUSEUP2_STATUS_LEFT; + if (where == STATUS_RIGHT) + key = KEYC_MOUSEUP2_STATUS_RIGHT; if (where == BORDER) key = KEYC_MOUSEUP2_BORDER; break; @@ -679,6 +721,10 @@ have_event: key = KEYC_MOUSEUP3_PANE; if (where == STATUS) key = KEYC_MOUSEUP3_STATUS; + if (where == STATUS_LEFT) + key = KEYC_MOUSEUP3_STATUS_LEFT; + if (where == STATUS_RIGHT) + key = KEYC_MOUSEUP3_STATUS_RIGHT; if (where == BORDER) key = KEYC_MOUSEUP3_BORDER; break; @@ -691,6 +737,10 @@ have_event: key = KEYC_MOUSEDOWN1_PANE; if (where == STATUS) key = KEYC_MOUSEDOWN1_STATUS; + if (where == STATUS_LEFT) + key = KEYC_MOUSEDOWN1_STATUS_LEFT; + if (where == STATUS_RIGHT) + key = KEYC_MOUSEDOWN1_STATUS_RIGHT; if (where == BORDER) key = KEYC_MOUSEDOWN1_BORDER; break; @@ -699,6 +749,10 @@ have_event: key = KEYC_MOUSEDOWN2_PANE; if (where == STATUS) key = KEYC_MOUSEDOWN2_STATUS; + if (where == STATUS_LEFT) + key = KEYC_MOUSEDOWN2_STATUS_LEFT; + if (where == STATUS_RIGHT) + key = KEYC_MOUSEDOWN2_STATUS_RIGHT; if (where == BORDER) key = KEYC_MOUSEDOWN2_BORDER; break; @@ -707,6 +761,10 @@ have_event: key = KEYC_MOUSEDOWN3_PANE; if (where == STATUS) key = KEYC_MOUSEDOWN3_STATUS; + if (where == STATUS_LEFT) + key = KEYC_MOUSEDOWN3_STATUS_LEFT; + if (where == STATUS_RIGHT) + key = KEYC_MOUSEDOWN3_STATUS_RIGHT; if (where == BORDER) key = KEYC_MOUSEDOWN3_BORDER; break; @@ -719,6 +777,10 @@ have_event: key = KEYC_DOUBLECLICK1_PANE; if (where == STATUS) key = KEYC_DOUBLECLICK1_STATUS; + if (where == STATUS_LEFT) + key = KEYC_DOUBLECLICK1_STATUS_LEFT; + if (where == STATUS_RIGHT) + key = KEYC_DOUBLECLICK1_STATUS_RIGHT; if (where == BORDER) key = KEYC_DOUBLECLICK1_BORDER; break; @@ -727,6 +789,10 @@ have_event: key = KEYC_DOUBLECLICK2_PANE; if (where == STATUS) key = KEYC_DOUBLECLICK2_STATUS; + if (where == STATUS_LEFT) + key = KEYC_DOUBLECLICK2_STATUS_LEFT; + if (where == STATUS_RIGHT) + key = KEYC_DOUBLECLICK2_STATUS_RIGHT; if (where == BORDER) key = KEYC_DOUBLECLICK2_BORDER; break; @@ -735,6 +801,10 @@ have_event: key = KEYC_DOUBLECLICK3_PANE; if (where == STATUS) key = KEYC_DOUBLECLICK3_STATUS; + if (where == STATUS_LEFT) + key = KEYC_DOUBLECLICK3_STATUS_LEFT; + if (where == STATUS_RIGHT) + key = KEYC_DOUBLECLICK3_STATUS_RIGHT; if (where == BORDER) key = KEYC_DOUBLECLICK3_BORDER; break; @@ -747,6 +817,10 @@ have_event: key = KEYC_TRIPLECLICK1_PANE; if (where == STATUS) key = KEYC_TRIPLECLICK1_STATUS; + if (where == STATUS_LEFT) + key = KEYC_TRIPLECLICK1_STATUS_LEFT; + if (where == STATUS_RIGHT) + key = KEYC_TRIPLECLICK1_STATUS_RIGHT; if (where == BORDER) key = KEYC_TRIPLECLICK1_BORDER; break; @@ -755,6 +829,10 @@ have_event: key = KEYC_TRIPLECLICK2_PANE; if (where == STATUS) key = KEYC_TRIPLECLICK2_STATUS; + if (where == STATUS_LEFT) + key = KEYC_TRIPLECLICK2_STATUS_LEFT; + if (where == STATUS_RIGHT) + key = KEYC_TRIPLECLICK2_STATUS_RIGHT; if (where == BORDER) key = KEYC_TRIPLECLICK2_BORDER; break; @@ -763,6 +841,10 @@ have_event: key = KEYC_TRIPLECLICK3_PANE; if (where == STATUS) key = KEYC_TRIPLECLICK3_STATUS; + if (where == STATUS_LEFT) + key = KEYC_TRIPLECLICK3_STATUS_LEFT; + if (where == STATUS_RIGHT) + key = KEYC_TRIPLECLICK3_STATUS_RIGHT; if (where == BORDER) key = KEYC_TRIPLECLICK3_BORDER; break; diff --git a/usr.bin/tmux/status.c b/usr.bin/tmux/status.c index 01726687a9f..36dfe10e2b2 100644 --- a/usr.bin/tmux/status.c +++ b/usr.bin/tmux/status.c @@ -1,4 +1,4 @@ -/* $OpenBSD: status.c,v 1.178 2018/08/20 20:41:58 nicm Exp $ */ +/* $OpenBSD: status.c,v 1.179 2018/08/22 20:06:14 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -511,6 +511,10 @@ draw: screen_write_fast_copy(&ctx, &window_list, wlstart, 0, wlwidth, 1); screen_free(&window_list); + /* Save left and right size. */ + c->status.left_size = llen; + c->status.right_size = rlen; + screen_write_stop(&ctx); out: diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 8aefa0bf4f9..fb37e3b85bb 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.608 2018/08/20 15:00:42 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.609 2018/08/22 20:06:14 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott .\" @@ -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: August 20 2018 $ +.Dd $Mdocdate: August 22 2018 $ .Dt TMUX 1 .Os .Sh NAME @@ -3504,7 +3504,10 @@ and a location suffix (one of for the contents of a pane, .Ql Border for a pane border or -.Ql Status +.Ql Status , +.Ql StatusLeft , +or +.Ql StatusRight for the status line). The following mouse events are available: .Bl -column "MouseDown1" "MouseDrag1" "WheelDown" -offset indent diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 83989cbceee..939d80e0f5e 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.842 2018/08/20 20:41:58 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.843 2018/08/22 20:06:14 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -116,13 +116,17 @@ struct tmuxproc; #define KEYC_CLICK_TIMEOUT 300 /* Mouse key codes. */ -#define KEYC_MOUSE_KEY(name) \ - KEYC_ ## name ## _PANE, \ - KEYC_ ## name ## _STATUS, \ +#define KEYC_MOUSE_KEY(name) \ + KEYC_ ## name ## _PANE, \ + KEYC_ ## name ## _STATUS, \ + KEYC_ ## name ## _STATUS_LEFT, \ + KEYC_ ## name ## _STATUS_RIGHT, \ KEYC_ ## name ## _BORDER -#define KEYC_MOUSE_STRING(name, s) \ - { #s "Pane", KEYC_ ## name ## _PANE }, \ - { #s "Status", KEYC_ ## name ## _STATUS }, \ +#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 "Border", KEYC_ ## name ## _BORDER } /* @@ -1283,6 +1287,9 @@ struct status_line { struct screen *old_status; int window_list_offset; + + u_int left_size; + u_int right_size; }; /* Client connection. */ -- 2.20.1