summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/format.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2021-10-05 17:23:14 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2021-10-05 17:23:14 +0000
commitd4d7dad4df8021858ccae2ce95abfaa358d528dd (patch)
tree161d386b26b9f2afe473c07110f35dec06c16829 /usr.bin/tmux/format.c
parent2e3a78d101d9f7357fbe5a931a58d0af055acdfc (diff)
Set mouse_x and mouse_y on the status line, GitHub issue 2913.
Diffstat (limited to 'usr.bin/tmux/format.c')
-rw-r--r--usr.bin/tmux/format.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c
index 74ed8b09779..30e5e0a2277 100644
--- a/usr.bin/tmux/format.c
+++ b/usr.bin/tmux/format.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: format.c,v 1.295 2021/10/05 12:45:02 nicm Exp $ */
+/* $OpenBSD: format.c,v 1.296 2021/10/05 17:23:13 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1614,11 +1614,16 @@ format_cb_mouse_x(struct format_tree *ft)
struct window_pane *wp;
u_int x, y;
- if (ft->m.valid) {
- wp = cmd_mouse_pane(&ft->m, NULL, NULL);
- if (wp != NULL && cmd_mouse_at(wp, &ft->m, &x, &y, 0) == 0)
- return (format_printf("%u", x));
+ if (!ft->m.valid)
return (NULL);
+ wp = cmd_mouse_pane(&ft->m, NULL, NULL);
+ if (wp != NULL && cmd_mouse_at(wp, &ft->m, &x, &y, 0) == 0)
+ return (format_printf("%u", x));
+ if (ft->c != NULL && (ft->c->tty.flags & TTY_STARTED)) {
+ if (ft->m.statusat == 0 && ft->m.y < ft->m.statuslines)
+ return (format_printf("%u", ft->m.x));
+ if (ft->m.statusat > 0 && ft->m.y >= ft->m.statusat)
+ return (format_printf("%u", ft->m.x));
}
return (NULL);
}
@@ -1628,13 +1633,18 @@ static void *
format_cb_mouse_y(struct format_tree *ft)
{
struct window_pane *wp;
- u_int x, y;
+ u_int x, y, top;
- if (ft->m.valid) {
- wp = cmd_mouse_pane(&ft->m, NULL, NULL);
- if (wp != NULL && cmd_mouse_at(wp, &ft->m, &x, &y, 0) == 0)
- return (format_printf("%u", y));
+ if (!ft->m.valid)
return (NULL);
+ wp = cmd_mouse_pane(&ft->m, NULL, NULL);
+ if (wp != NULL && cmd_mouse_at(wp, &ft->m, &x, &y, 0) == 0)
+ return (format_printf("%u", y));
+ if (ft->c != NULL && (ft->c->tty.flags & TTY_STARTED)) {
+ if (ft->m.statusat == 0 && ft->m.y < ft->m.statuslines)
+ return (format_printf("%u", ft->m.y));
+ if (ft->m.statusat > 0 && ft->m.y >= ft->m.statusat)
+ return (format_printf("%u", ft->m.y - ft->m.statusat));
}
return (NULL);
}