summaryrefslogtreecommitdiffstats
path: root/server-client.c
diff options
context:
space:
mode:
authornicm <nicm>2023-08-17 14:10:28 +0000
committernicm <nicm>2023-08-17 14:10:28 +0000
commit8636848e6348bb0e38cd6aaaadbe61e15181bc8f (patch)
treee9967f79f8a2060093ab0a1ca0a3ce6e3fe744f7 /server-client.c
parentd9942c769eb059e2cadfb63f2050fad8d0357d19 (diff)
Add a session, pane and user mouse range types for the status line and
add format variables for mouse_status_line and mouse_status_range so they can be associated with different commands in the key bindings. GitHub issue 3652.
Diffstat (limited to 'server-client.c')
-rw-r--r--server-client.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/server-client.c b/server-client.c
index 1c927bb5..0f26ad37 100644
--- a/server-client.c
+++ b/server-client.c
@@ -564,9 +564,9 @@ static key_code
server_client_check_mouse(struct client *c, struct key_event *event)
{
struct mouse_event *m = &event->m;
- struct session *s = c->session;
- struct winlink *wl;
- struct window_pane *wp;
+ struct session *s = c->session, *fs;
+ struct winlink *fwl;
+ struct window_pane *wp, *fwp;
u_int x, y, b, sx, sy, px, py;
int ignore = 0;
key_code key;
@@ -672,6 +672,7 @@ have_event:
/* Save the session. */
m->s = s->id;
m->w = -1;
+ m->wp = -1;
m->ignore = ignore;
/* Is this on the status line? */
@@ -688,18 +689,42 @@ have_event:
case STYLE_RANGE_NONE:
return (KEYC_UNKNOWN);
case STYLE_RANGE_LEFT:
+ log_debug("mouse range: left");
where = STATUS_LEFT;
break;
case STYLE_RANGE_RIGHT:
+ log_debug("mouse range: right");
where = STATUS_RIGHT;
break;
+ case STYLE_RANGE_PANE:
+ fwp = window_pane_find_by_id(sr->argument);
+ if (fwp == NULL)
+ return (KEYC_UNKNOWN);
+ m->wp = sr->argument;
+
+ log_debug("mouse range: pane %%%u", m->wp);
+ where = STATUS;
+ break;
case STYLE_RANGE_WINDOW:
- wl = winlink_find_by_index(&s->windows,
+ fwl = winlink_find_by_index(&s->windows,
sr->argument);
- if (wl == NULL)
+ if (fwl == NULL)
return (KEYC_UNKNOWN);
- m->w = wl->window->id;
+ m->w = fwl->window->id;
+ log_debug("mouse range: window @%u", m->w);
+ where = STATUS;
+ break;
+ case STYLE_RANGE_SESSION:
+ fs = session_find_by_id(sr->argument);
+ if (fs == NULL)
+ return (KEYC_UNKNOWN);
+ m->s = sr->argument;
+
+ log_debug("mouse range: session $%u", m->s);
+ where = STATUS;
+ break;
+ case STYLE_RANGE_USER:
where = STATUS;
break;
}