diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/input-keys.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/input.c | 23 | ||||
-rw-r--r-- | usr.bin/tmux/screen-write.c | 21 | ||||
-rw-r--r-- | usr.bin/tmux/server-client.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 16 | ||||
-rw-r--r-- | usr.bin/tmux/tty.c | 26 | ||||
-rw-r--r-- | usr.bin/tmux/window-choose.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/window-copy.c | 14 |
8 files changed, 75 insertions, 37 deletions
diff --git a/usr.bin/tmux/input-keys.c b/usr.bin/tmux/input-keys.c index 5fb032baf03..1780c29e45d 100644 --- a/usr.bin/tmux/input-keys.c +++ b/usr.bin/tmux/input-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input-keys.c,v 1.18 2009/12/03 22:50:10 nicm Exp $ */ +/* $OpenBSD: input-keys.c,v 1.19 2010/12/29 21:49:06 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -204,7 +204,7 @@ input_mouse(struct window_pane *wp, struct mouse_event *m) { char out[8]; - if (wp->screen->mode & MODE_MOUSE) { + if (wp->screen->mode & ALL_MOUSE_MODES) { xsnprintf(out, sizeof out, "\033[M%c%c%c", m->b + 32, m->x + 33, m->y + 33); bufferevent_write(wp->event, out, strlen(out)); diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c index cc3efcf6e2a..874b1eec39c 100644 --- a/usr.bin/tmux/input.c +++ b/usr.bin/tmux/input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input.c,v 1.31 2010/12/23 20:18:39 nicm Exp $ */ +/* $OpenBSD: input.c,v 1.32 2010/12/29 21:49:06 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -953,7 +953,7 @@ input_esc_dispatch(struct input_ctx *ictx) screen_write_insertmode(sctx, 0); screen_write_kcursormode(sctx, 0); screen_write_kkeypadmode(sctx, 0); - screen_write_mousemode(sctx, 0); + screen_write_mousemode_off(sctx); screen_write_clearscreen(sctx); screen_write_cursormove(sctx, 0, 0); @@ -1156,7 +1156,10 @@ input_csi_dispatch(struct input_ctx *ictx) screen_write_cursormode(&ictx->ctx, 0); break; case 1000: - screen_write_mousemode(&ictx->ctx, 0); + case 1001: + case 1002: + case 1003: + screen_write_mousemode_off(&ictx->ctx); break; case 1049: window_pane_alternate_off(wp, &ictx->cell); @@ -1192,7 +1195,19 @@ input_csi_dispatch(struct input_ctx *ictx) screen_write_cursormode(&ictx->ctx, 1); break; case 1000: - screen_write_mousemode(&ictx->ctx, 1); + screen_write_mousemode_on( + &ictx->ctx, MODE_MOUSE_STANDARD); + break; + case 1001: + screen_write_mousemode_on( + &ictx->ctx, MODE_MOUSE_HIGHLIGHT); + break; + case 1002: + screen_write_mousemode_on( + &ictx->ctx, MODE_MOUSE_BUTTON); + break; + case 1003: + screen_write_mousemode_on(&ictx->ctx, MODE_MOUSE_ANY); break; case 1049: window_pane_alternate_on(wp, &ictx->cell); diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c index 9ed21d10cb8..2dec0940d17 100644 --- a/usr.bin/tmux/screen-write.c +++ b/usr.bin/tmux/screen-write.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-write.c,v 1.43 2010/06/21 00:11:12 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.44 2010/12/29 21:49:06 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -829,16 +829,23 @@ screen_write_insertmode(struct screen_write_ctx *ctx, int state) s->mode &= ~MODE_INSERT; } -/* Set mouse mode. */ +/* Set mouse mode off. */ void -screen_write_mousemode(struct screen_write_ctx *ctx, int state) +screen_write_mousemode_off(struct screen_write_ctx *ctx) { struct screen *s = ctx->s; - if (state) - s->mode |= MODE_MOUSE; - else - s->mode &= ~MODE_MOUSE; + s->mode &= ~ALL_MOUSE_MODES; +} + +/* Set mouse mode on. */ +void +screen_write_mousemode_on(struct screen_write_ctx *ctx, int mode) +{ + struct screen *s = ctx->s; + + s->mode &= ~ALL_MOUSE_MODES; + s->mode |= mode; } /* Line feed. */ diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index 0d5a983cbf2..38434adf28b 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.45 2010/12/20 00:17:22 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.46 2010/12/29 21:49:06 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -450,7 +450,7 @@ server_client_reset_state(struct client *c) mode = s->mode; if (TAILQ_NEXT(TAILQ_FIRST(&w->panes), entry) != NULL && options_get_number(oo, "mouse-select-pane")) - mode |= MODE_MOUSE; + mode |= MODE_MOUSE_STANDARD; tty_update_mode(&c->tty, mode); tty_reset(&c->tty); } diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 560749006c4..bd7efdf2c09 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.254 2010/12/21 22:37:59 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.255 2010/12/29 21:49:06 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -545,9 +545,14 @@ struct mode_key_table { #define MODE_INSERT 0x2 #define MODE_KCURSOR 0x4 #define MODE_KKEYPAD 0x8 /* set = application, clear = number */ -#define MODE_MOUSE 0x10 -#define MODE_MOUSEMOTION 0x20 -#define MODE_WRAP 0x40 /* whether lines wrap */ +#define MODE_WRAP 0x10 /* whether lines wrap */ +#define MODE_MOUSE_STANDARD 0x20 +#define MODE_MOUSE_HIGHLIGHT 0x40 +#define MODE_MOUSE_BUTTON 0x80 +#define MODE_MOUSE_ANY 0x100 + +#define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD| \ + MODE_MOUSE_HIGHLIGHT|MODE_MOUSE_BUTTON|MODE_MOUSE_ANY) /* * A single UTF-8 character. @@ -1808,7 +1813,8 @@ void screen_write_cursormode(struct screen_write_ctx *, int); void screen_write_reverseindex(struct screen_write_ctx *); void screen_write_scrollregion(struct screen_write_ctx *, u_int, u_int); void screen_write_insertmode(struct screen_write_ctx *, int); -void screen_write_mousemode(struct screen_write_ctx *, int); +void screen_write_mousemode_on(struct screen_write_ctx *, int); +void screen_write_mousemode_off(struct screen_write_ctx *); void screen_write_linefeed(struct screen_write_ctx *, int); void screen_write_linefeedscreen(struct screen_write_ctx *, int); void screen_write_carriagereturn(struct screen_write_ctx *); diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c index 31dbd4796b2..af567bae45f 100644 --- a/usr.bin/tmux/tty.c +++ b/usr.bin/tmux/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.93 2010/11/22 21:13:13 nicm Exp $ */ +/* $OpenBSD: tty.c,v 1.94 2010/12/29 21:49:06 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -403,17 +403,25 @@ tty_update_mode(struct tty *tty, int mode) else tty_putcode(tty, TTYC_CIVIS); } - if (changed & (MODE_MOUSE|MODE_MOUSEMOTION)) { - if (mode & MODE_MOUSE) { - if (mode & MODE_MOUSEMOTION) - tty_puts(tty, "\033[?1003h"); - else + if (changed & ALL_MOUSE_MODES) { + if (mode & ALL_MOUSE_MODES) { + if (mode & MODE_MOUSE_STANDARD) tty_puts(tty, "\033[?1000h"); + else if (mode & MODE_MOUSE_HIGHLIGHT) + tty_puts(tty, "\033[?1001h"); + else if (mode & MODE_MOUSE_BUTTON) + tty_puts(tty, "\033[?1002h"); + else if (mode & MODE_MOUSE_ANY) + tty_puts(tty, "\033[?1003h"); } else { - if (mode & MODE_MOUSEMOTION) - tty_puts(tty, "\033[?1003l"); - else + if (tty->mode & MODE_MOUSE_STANDARD) tty_puts(tty, "\033[?1000l"); + else if (tty->mode & MODE_MOUSE_HIGHLIGHT) + tty_puts(tty, "\033[?1001l"); + else if (tty->mode & MODE_MOUSE_BUTTON) + tty_puts(tty, "\033[?1002l"); + else if (tty->mode & MODE_MOUSE_ANY) + tty_puts(tty, "\033[?1003l"); } } if (changed & MODE_KKEYPAD) { diff --git a/usr.bin/tmux/window-choose.c b/usr.bin/tmux/window-choose.c index 7749ecfd2dc..35502e04e9b 100644 --- a/usr.bin/tmux/window-choose.c +++ b/usr.bin/tmux/window-choose.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-choose.c,v 1.16 2010/05/23 19:42:19 nicm Exp $ */ +/* $OpenBSD: window-choose.c,v 1.17 2010/12/29 21:49:06 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -127,7 +127,7 @@ window_choose_init(struct window_pane *wp) screen_init(s, screen_size_x(&wp->base), screen_size_y(&wp->base), 0); s->mode &= ~MODE_CURSOR; if (options_get_number(&wp->window->options, "mode-mouse")) - s->mode |= MODE_MOUSE; + s->mode |= MODE_MOUSE_STANDARD; keys = options_get_number(&wp->window->options, "mode-keys"); if (keys == MODEKEY_EMACS) diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index c1f1bbb1a5e..c4f483ed88c 100644 --- a/usr.bin/tmux/window-copy.c +++ b/usr.bin/tmux/window-copy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-copy.c,v 1.64 2010/12/11 17:56:01 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.65 2010/12/29 21:49:06 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -180,7 +180,7 @@ window_copy_init(struct window_pane *wp) s = &data->screen; screen_init(s, screen_size_x(&wp->base), screen_size_y(&wp->base), 0); if (options_get_number(&wp->window->options, "mode-mouse")) - s->mode |= MODE_MOUSE; + s->mode |= MODE_MOUSE_STANDARD; keys = options_get_number(&wp->window->options, "mode-keys"); if (keys == MODEKEY_EMACS) @@ -787,13 +787,14 @@ window_copy_mouse( * If already reading motion, move the cursor while buttons are still * pressed, or stop the selection on their release. */ - if (s->mode & MODE_MOUSEMOTION) { + if (s->mode & MODE_MOUSE_ANY) { if ((m->b & MOUSE_BUTTON) != MOUSE_UP) { window_copy_update_cursor(wp, m->x, m->y); if (window_copy_update_selection(wp)) window_copy_redraw_screen(wp); } else { - s->mode &= ~MODE_MOUSEMOTION; + s->mode &= ~MODE_MOUSE_ANY; + s->mode |= MODE_MOUSE_STANDARD; if (sess != NULL) { window_copy_copy_selection(wp, sess); window_pane_reset_mode(wp); @@ -802,9 +803,10 @@ window_copy_mouse( return; } - /* Otherwise i other buttons pressed, start selection and motion. */ + /* Otherwise if other buttons pressed, start selection and motion. */ if ((m->b & MOUSE_BUTTON) != MOUSE_UP) { - s->mode |= MODE_MOUSEMOTION; + s->mode &= ~MODE_MOUSE_STANDARD; + s->mode |= MODE_MOUSE_ANY; window_copy_update_cursor(wp, m->x, m->y); window_copy_start_selection(wp); |