summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2011-04-18 19:49:06 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2011-04-18 19:49:06 +0000
commitc2cc1692ef366e56bac88dcb73ae5e1f5793f96f (patch)
treea167c29aa1897f97835129c635244ad87e5d4b41
parent35bb11f41141ac829e82402f997915ccc3ca7b4f (diff)
Add an option (mouse-select-window) which allows the mouse to be used by
clicking on the status line, written by hsim at gmx dot li.
-rw-r--r--usr.bin/tmux/options-table.c7
-rw-r--r--usr.bin/tmux/server-client.c12
-rw-r--r--usr.bin/tmux/status.c20
-rw-r--r--usr.bin/tmux/tmux.19
-rw-r--r--usr.bin/tmux/tmux.h5
5 files changed, 47 insertions, 6 deletions
diff --git a/usr.bin/tmux/options-table.c b/usr.bin/tmux/options-table.c
index 2cebb0b5dc2..509cca04b74 100644
--- a/usr.bin/tmux/options-table.c
+++ b/usr.bin/tmux/options-table.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options-table.c,v 1.4 2011/04/09 20:00:29 nicm Exp $ */
+/* $OpenBSD: options-table.c,v 1.5 2011/04/18 19:49:05 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -198,6 +198,11 @@ const struct options_table_entry session_options_table[] = {
.default_num = 0
},
+ { .name = "mouse-select-window",
+ .type = OPTIONS_TABLE_FLAG,
+ .default_num = 0
+ },
+
{ .name = "mouse-utf8",
.type = OPTIONS_TABLE_FLAG,
.default_num = 0
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index 4b0b2d0a02c..782c5e29fba 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.52 2011/03/29 19:30:16 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.53 2011/04/18 19:49:05 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -319,6 +319,12 @@ server_client_handle_key(int key, struct mouse_event *mouse, void *data)
server_redraw_window_borders(w);
wp = w->active;
}
+ if (mouse->y + 1 == c->tty.sy && mouse->b == MOUSE_UP &&
+ options_get_number(oo, "mouse-select-window") &&
+ options_get_number(oo, "status")) {
+ status_set_window_at(c, mouse->x);
+ return;
+ }
window_pane_mouse(wp, c->session, mouse);
return;
}
@@ -459,6 +465,10 @@ server_client_reset_state(struct client *c)
(mode & ALL_MOUSE_MODES) == 0)
mode |= MODE_MOUSE_STANDARD;
+ if (options_get_number(oo, "mouse-select-window") &&
+ (mode & ALL_MOUSE_MODES) == 0)
+ mode |= MODE_MOUSE_STANDARD;
+
/*
* Set UTF-8 mouse input if required. If the terminal is UTF-8, the
* user has set mouse-utf8 and any mouse mode is in effect, turn on
diff --git a/usr.bin/tmux/status.c b/usr.bin/tmux/status.c
index 6448949cfa0..92cd897e8c7 100644
--- a/usr.bin/tmux/status.c
+++ b/usr.bin/tmux/status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: status.c,v 1.72 2011/03/29 19:30:16 nicm Exp $ */
+/* $OpenBSD: status.c,v 1.73 2011/04/18 19:49:05 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -120,6 +120,23 @@ status_redraw_get_right(struct client *c,
return (right);
}
+/* Set window at window list position. */
+void
+status_set_window_at(struct client *c, u_int x)
+{
+ struct session *s = c->session;
+ struct winlink *wl;
+
+ x += s->wlmouse;
+ RB_FOREACH(wl, winlinks, &s->windows) {
+ if (x < wl->status_width &&
+ session_select(s, wl->idx) == 0) {
+ server_redraw_session(s);
+ }
+ x -= wl->status_width + 1;
+ }
+}
+
/* Draw status for client on the last lines of given context. */
int
status_redraw(struct client *c)
@@ -325,6 +342,7 @@ draw:
wloffset++;
/* Copy the window list. */
+ s->wlmouse = -wloffset + wlstart;
screen_write_cursormove(&ctx, wloffset, 0);
screen_write_copy(&ctx, &window_list, wlstart, 0, wlwidth, 1);
screen_free(&window_list);
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 499ae9edb1d..368d762eb2a 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.221 2011/04/17 20:39:44 jmc Exp $
+.\" $OpenBSD: tmux.1,v 1.222 2011/04/18 19:49:05 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -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: April 17 2011 $
+.Dd $Mdocdate: April 18 2011 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -1896,6 +1896,11 @@ If on,
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 Xo Ic mouse-select-window
+.Op Ic on | off
+.Xc
+If on, clicking the mouse on a window name in the status line will select that
+window.
.It Ic pane-active-border-bg Ar colour
.It Ic pane-active-border-fg Ar colour
Set the pane border colour for the currently active pane.
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index daa5dab9bc2..f5f901a496a 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.280 2011/04/09 07:48:08 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.281 2011/04/18 19:49:05 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -957,6 +957,8 @@ struct session {
struct environ environ;
+ int wlmouse;
+
int references;
TAILQ_ENTRY(session) gentry;
@@ -1666,6 +1668,7 @@ int status_out_cmp(struct status_out *, struct status_out *);
RB_PROTOTYPE(status_out_tree, status_out, entry, status_out_cmp);
void status_free_jobs(struct status_out_tree *);
void status_update_jobs(struct client *);
+void status_set_window_at(struct client *, u_int);
int status_redraw(struct client *);
char *status_replace(struct client *, struct session *,
struct winlink *, struct window_pane *, const char *, time_t, int);