diff options
-rw-r--r-- | usr.bin/tmux/cmd-set-option.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/server.c | 17 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 12 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 3 | ||||
-rw-r--r-- | usr.bin/tmux/window.c | 19 |
6 files changed, 48 insertions, 9 deletions
diff --git a/usr.bin/tmux/cmd-set-option.c b/usr.bin/tmux/cmd-set-option.c index 59cb726b3c4..f34dc272415 100644 --- a/usr.bin/tmux/cmd-set-option.c +++ b/usr.bin/tmux/cmd-set-option.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-set-option.c,v 1.21 2009/10/10 09:46:11 nicm Exp $ */ +/* $OpenBSD: cmd-set-option.c,v 1.22 2009/10/10 14:51:16 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -67,6 +67,7 @@ const struct set_option_entry set_option_table[] = { { "message-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL }, { "message-bg", SET_OPTION_COLOUR, 0, 0, NULL }, { "message-fg", SET_OPTION_COLOUR, 0, 0, NULL }, + { "mouse-select-pane", SET_OPTION_FLAG, 0, 0, NULL }, { "prefix", SET_OPTION_KEYS, 0, 0, NULL }, { "repeat-time", SET_OPTION_NUMBER, 0, SHRT_MAX, NULL }, { "set-remain-on-exit", SET_OPTION_FLAG, 0, 0, NULL }, diff --git a/usr.bin/tmux/server.c b/usr.bin/tmux/server.c index d1528532f1c..2d592d2c8ec 100644 --- a/usr.bin/tmux/server.c +++ b/usr.bin/tmux/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.47 2009/10/10 10:02:48 nicm Exp $ */ +/* $OpenBSD: server.c,v 1.48 2009/10/10 14:51:16 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -825,6 +825,7 @@ server_handle_client(struct client *c) struct window *w; struct window_pane *wp; struct screen *s; + struct options *oo; struct timeval tv; struct key_binding *bd; struct keylist *keylist; @@ -849,6 +850,7 @@ server_handle_client(struct client *c) c->session->activity = time(NULL); w = c->session->curw->window; wp = w->active; /* could die */ + oo = &c->session->options; /* Special case: number keys jump to pane in identify mode. */ if (c->flags & CLIENT_IDENTIFY && key >= '0' && key <= '9') { @@ -868,6 +870,10 @@ server_handle_client(struct client *c) /* Check for mouse keys. */ if (key == KEYC_MOUSE) { + if (options_get_number(oo, "mouse-select-pane")) { + window_set_active_at(w, mouse[1], mouse[2]); + wp = w->active; + } window_pane_mouse(wp, c, mouse[0], mouse[1], mouse[2]); continue; } @@ -935,7 +941,9 @@ server_handle_client(struct client *c) } if (c->session == NULL) return; - wp = c->session->curw->window->active; /* could die - do each loop */ + w = c->session->curw->window; + wp = w->active; + oo = &c->session->options; s = wp->screen; /* @@ -948,7 +956,7 @@ server_handle_client(struct client *c) * tty_region/tty_reset/tty_update_mode already take care of not * resetting things that are already in their default state. */ - status = options_get_number(&c->session->options, "status"); + status = options_get_number(oo, "status"); tty_region(&c->tty, 0, c->tty.sy - 1, 0); if (!window_pane_visible(wp) || wp->yoff + s->cy >= c->tty.sy - status) tty_cursor(&c->tty, 0, 0, 0, 0); @@ -956,6 +964,9 @@ server_handle_client(struct client *c) tty_cursor(&c->tty, s->cx, s->cy, wp->xoff, wp->yoff); mode = s->mode; + if (TAILQ_NEXT(TAILQ_FIRST(&w->panes), entry) != NULL && + options_get_number(oo, "mouse-select-pane")) + mode |= MODE_MOUSE; tty_update_mode(&c->tty, mode); tty_reset(&c->tty); } diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 29abd6f113d..78498920e68 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.101 2009/10/10 10:02:48 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.102 2009/10/10 14:51:16 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" @@ -1292,7 +1292,7 @@ with .Op Ic on | off .Xc If this option is -.Ic on +.Ic on (the default), instead of each session locking individually as each has been idle for @@ -1336,6 +1336,14 @@ from the 256-colour palette, or .Ic default . .It Ic message-fg Ar colour Set status line message foreground colour. +.It Xo Ic mouse-select-pane +.Op Ic on | off +.Xc +If on, +.Nm +captures the mouse and when a window is split into multiple panes the mouse may +be used to select the current pane. +The mouse click is also passed through to the application as normal. .It Ic prefix Ar keys Set the keys accepted as a prefix key. .Ar keys diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c index 8172b00291d..a38aa852a29 100644 --- a/usr.bin/tmux/tmux.c +++ b/usr.bin/tmux/tmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.c,v 1.48 2009/10/10 09:46:11 nicm Exp $ */ +/* $OpenBSD: tmux.c,v 1.49 2009/10/10 14:51:16 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -381,6 +381,7 @@ main(int argc, char **argv) options_set_number(so, "message-attr", 0); options_set_number(so, "message-bg", 3); options_set_number(so, "message-fg", 0); + options_set_number(so, "mouse-select-pane", 0); options_set_number(so, "repeat-time", 500); options_set_number(so, "set-remain-on-exit", 0); options_set_number(so, "set-titles", 0); diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 2b6f66297d6..9dfae4c400b 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.124 2009/10/10 10:02:48 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.125 2009/10/10 14:51:16 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -1648,6 +1648,7 @@ struct window *window_create(const char *, const char *, const char *, const char *, struct environ *, struct termios *, u_int, u_int, u_int, char **); void window_destroy(struct window *); +void window_set_active_at(struct window *, u_int, u_int); void window_set_active_pane(struct window *, struct window_pane *); struct window_pane *window_add_pane(struct window *, u_int); void window_resize(struct window *, u_int, u_int); diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c index b80cec3aed3..6aa4dccb9f3 100644 --- a/usr.bin/tmux/window.c +++ b/usr.bin/tmux/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.28 2009/10/10 10:02:48 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.29 2009/10/10 14:51:16 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -304,6 +304,23 @@ window_set_active_pane(struct window *w, struct window_pane *wp) } } +void +window_set_active_at(struct window *w, u_int x, u_int y) +{ + struct window_pane *wp; + + TAILQ_FOREACH(wp, &w->panes, entry) { + if (!window_pane_visible(wp)) + continue; + if (x < wp->xoff || x >= wp->xoff + wp->sx) + continue; + if (y < wp->yoff || y >= wp->yoff + wp->sy) + continue; + window_set_active_pane(w, wp); + break; + } +} + struct window_pane * window_add_pane(struct window *w, u_int hlimit) { |