diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2011-04-18 21:07:58 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2011-04-18 21:07:58 +0000 |
commit | dc6bd984259dc94376ebf1dc2315a4567dfececb (patch) | |
tree | b3c63d3d32cc2ce61223022bcbe47be17192fc15 | |
parent | 34a331aa9928619dc095b4daacdeed379e73ffbe (diff) | |
download | rtmux-dc6bd984259dc94376ebf1dc2315a4567dfececb.tar.gz rtmux-dc6bd984259dc94376ebf1dc2315a4567dfececb.tar.bz2 rtmux-dc6bd984259dc94376ebf1dc2315a4567dfececb.zip |
|PatchSet 893
|Date: 2011/04/18 20:49:05
|Author: nicm
|Branch: HEAD
|Tag: (none)
|Log:
|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-- | options-table.c | 7 | ||||
-rw-r--r-- | server-client.c | 12 | ||||
-rw-r--r-- | status.c | 20 | ||||
-rw-r--r-- | tmux.1 | 2 | ||||
-rw-r--r-- | tmux.h | 5 |
5 files changed, 41 insertions, 5 deletions
diff --git a/options-table.c b/options-table.c index 7c5e1031..037ae2f8 100644 --- a/options-table.c +++ b/options-table.c @@ -1,4 +1,4 @@ -/* $Id: options-table.c,v 1.6 2011-04-18 21:03:42 nicm Exp $ */ +/* $Id: options-table.c,v 1.7 2011-04-18 21:07:58 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott <nicm@users.sourceforge.net> @@ -197,6 +197,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/server-client.c b/server-client.c index 54dcb62d..f29dd314 100644 --- a/server-client.c +++ b/server-client.c @@ -1,4 +1,4 @@ -/* $Id: server-client.c,v 1.55 2011-04-06 22:21:02 nicm Exp $ */ +/* $Id: server-client.c,v 1.56 2011-04-18 21:07:58 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -318,6 +318,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; } @@ -458,6 +464,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 @@ -1,4 +1,4 @@ -/* $Id: status.c,v 1.157 2011-04-06 22:21:02 nicm Exp $ */ +/* $Id: status.c,v 1.158 2011-04-18 21:07:58 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); @@ -1,4 +1,4 @@ -.\" $Id: tmux.1,v 1.307 2011-04-18 21:07:12 nicm Exp $ +.\" $Id: tmux.1,v 1.308 2011-04-18 21:07:58 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.619 2011-04-09 07:48:58 nicm Exp $ */ +/* $Id: tmux.h,v 1.620 2011-04-18 21:07:58 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -953,6 +953,8 @@ struct session { struct environ environ; + int wlmouse; + int references; TAILQ_ENTRY(session) gentry; @@ -1662,6 +1664,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); |