Update of /cvsroot/tmux/tmux In directory vz-cvs-2.sog:/tmp/cvs-serv21988 Modified Files: input-keys.c server-client.c tmux.1 tmux.h window-copy.c Log Message: Sync OpenBSD patchset 896:
When mode-mouse is on (it is off by default), automatically enter copy mode when the mouse is dragged or the mouse wheel is used. Also exit copy mode when the mouse wheel is scrolled off the bottom. Discussed with and written by hsim at gmx dot li. Index: input-keys.c =================================================================== RCS file: /cvsroot/tmux/tmux/input-keys.c,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- input-keys.c 7 Jan 2011 14:34:45 -0000 1.48 +++ input-keys.c 25 Apr 2011 20:33:42 -0000 1.49 @@ -219,5 +219,12 @@ buf[len++] = m->y + 33; } bufferevent_write(wp->event, buf, len); + } else if ((m->b & MOUSE_BUTTON) != MOUSE_2) { + if (options_get_number(&wp->window->options, "mode-mouse") && + window_pane_set_mode(wp, &window_copy_mode) == 0) { + window_copy_init_from_pane(wp); + if (wp->mode->mouse != NULL) + wp->mode->mouse(wp, NULL, m); + } } } Index: server-client.c =================================================================== RCS file: /cvsroot/tmux/tmux/server-client.c,v retrieving revision 1.56 retrieving revision 1.57 diff -u -d -r1.56 -r1.57 --- server-client.c 18 Apr 2011 21:07:58 -0000 1.56 +++ server-client.c 25 Apr 2011 20:33:42 -0000 1.57 @@ -313,7 +313,13 @@ if (key == KEYC_MOUSE) { if (c->flags & CLIENT_READONLY) return; - if (options_get_number(oo, "mouse-select-pane")) { + if (options_get_number(oo, "mouse-select-pane") && + ((!(mouse->b & MOUSE_DRAG) && mouse->b != MOUSE_UP) || + wp->mode != &window_copy_mode)) { + /* + * Allow pane switching in copy mode only by mouse down + * (click). + */ window_set_active_at(w, mouse->x, mouse->y); server_redraw_window_borders(w); wp = w->active; @@ -444,6 +450,7 @@ struct window_pane *wp = w->active; struct screen *s = wp->screen; struct options *oo = &c->session->options; + struct options *wo = &w->options; int status, mode; tty_region(&c->tty, 0, c->tty.sy - 1); @@ -459,14 +466,15 @@ * none. */ mode = s->mode; - if (TAILQ_NEXT(TAILQ_FIRST(&w->panes), entry) != NULL && - options_get_number(oo, "mouse-select-pane") && - (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; + if ((mode & ALL_MOUSE_MODES) == 0) { + if (TAILQ_NEXT(TAILQ_FIRST(&w->panes), entry) != NULL && + options_get_number(oo, "mouse-select-pane") == 0) + mode |= MODE_MOUSE_STANDARD; + else if (options_get_number(oo, "mouse-select-window")) + mode |= MODE_MOUSE_STANDARD; + else if (options_get_number(wo, "mode-mouse")) + mode |= MODE_MOUSE_STANDARD; + } /* * Set UTF-8 mouse input if required. If the terminal is UTF-8, the Index: window-copy.c =================================================================== RCS file: /cvsroot/tmux/tmux/window-copy.c,v retrieving revision 1.128 retrieving revision 1.129 diff -u -d -r1.128 -r1.129 --- window-copy.c 6 Apr 2011 22:18:56 -0000 1.128 +++ window-copy.c 25 Apr 2011 20:33:42 -0000 1.129 @@ -760,11 +760,11 @@ /* ARGSUSED */ void window_copy_mouse( - struct window_pane *wp, unused struct session *sess, struct mouse_event *m) + struct window_pane *wp, struct session *sess, struct mouse_event *m) { struct window_copy_mode_data *data = wp->modedata; struct screen *s = &data->screen; - u_int i; + u_int i, old_cy; if (m->x >= screen_size_x(s)) return; @@ -777,8 +777,11 @@ for (i = 0; i < 5; i++) window_copy_cursor_up(wp, 0); } else if ((m->b & MOUSE_BUTTON) == MOUSE_2) { + old_cy = data->cy; for (i = 0; i < 5; i++) window_copy_cursor_down(wp, 0); + if (old_cy == data->cy) + goto reset_mode; } return; } @@ -792,15 +795,9 @@ window_copy_update_cursor(wp, m->x, m->y); if (window_copy_update_selection(wp)) window_copy_redraw_screen(wp); - } else { - s->mode &= ~MODE_MOUSE_ANY; - s->mode |= MODE_MOUSE_STANDARD; - if (sess != NULL) { - window_copy_copy_selection(wp); - window_pane_reset_mode(wp); - } + return; } - return; + goto reset_mode; } /* Otherwise if other buttons pressed, start selection and motion. */ @@ -812,6 +809,16 @@ window_copy_start_selection(wp); window_copy_redraw_screen(wp); } + + return; + +reset_mode: + s->mode &= ~MODE_MOUSE_ANY; + s->mode |= MODE_MOUSE_STANDARD; + if (sess != NULL) { + window_copy_copy_selection(wp); + window_pane_reset_mode(wp); + } } void Index: tmux.h =================================================================== RCS file: /cvsroot/tmux/tmux/tmux.h,v retrieving revision 1.620 retrieving revision 1.621 diff -u -d -r1.620 -r1.621 --- tmux.h 18 Apr 2011 21:07:58 -0000 1.620 +++ tmux.h 25 Apr 2011 20:33:42 -0000 1.621 @@ -1077,6 +1077,7 @@ #define MOUSE_3 2 #define MOUSE_UP 3 #define MOUSE_BUTTON 3 +#define MOUSE_DRAG 32 #define MOUSE_45 64 u_int x; u_int y; @@ -1424,6 +1425,7 @@ void tty_cmd_clearstartofscreen(struct tty *, const struct tty_ctx *); void tty_cmd_deletecharacter(struct tty *, const struct tty_ctx *); void tty_cmd_deleteline(struct tty *, const struct tty_ctx *); +void tty_cmd_erasecharacter(struct tty *, const struct tty_ctx *); void tty_cmd_insertcharacter(struct tty *, const struct tty_ctx *); void tty_cmd_insertline(struct tty *, const struct tty_ctx *); void tty_cmd_linefeed(struct tty *, const struct tty_ctx *); Index: tmux.1 =================================================================== RCS file: /cvsroot/tmux/tmux/tmux.1,v retrieving revision 1.308 retrieving revision 1.309 diff -u -d -r1.308 -r1.309 --- tmux.1 18 Apr 2011 21:07:58 -0000 1.308 +++ tmux.1 25 Apr 2011 20:33:42 -0000 1.309 @@ -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 18 2011 $ +.Dd $Mdocdate: April 19 2011 $ .Dt TMUX 1 .Os .Sh NAME @@ -2314,8 +2314,9 @@ .Op Ic on | off .Xc Mouse state in modes. -If on, the mouse may be used to copy a selection by dragging in copy mode, or -to select an option in choice mode. +If on, the mouse may be used to enter copy mode and copy a selection by +dragging, to enter copy mode and scroll with the mouse wheel, or to select an +option in choice mode. .Pp .It Xo Ic monitor-activity .Op Ic on | off ------------------------------------------------------------------------------ WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd _______________________________________________ tmux-cvs mailing list tmux-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-cvs