diff --git a/CHANGES b/CHANGES index b9ed5a2c..6ba8968c 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,7 @@ 27 November 2007 +* Enable/disable mouse when asked, if terminal claims to support it. Mouse + sequences are just passed through unaltered for the moment. * Big internal reorganisation. Rather than leaving control of the tty solely in the client and piping all data through a socket to it, change so that the server opens the tty again and reads and writes to it directly. This avoids @@ -283,4 +285,4 @@ (including mutt, emacs). No status bar yet and no key remapping or other customisation. -$Id: CHANGES,v 1.87 2007-11-27 19:23:32 nicm Exp $ +$Id: CHANGES,v 1.88 2007-11-27 23:28:51 nicm Exp $ diff --git a/TODO b/TODO index e9a52a23..3cc55e58 100644 --- a/TODO +++ b/TODO @@ -65,3 +65,26 @@ - anything which uses cmd_{send,recv}_string will break if the string is split. string length should be part of the command size - echo \\033[35\;46m\\033[2J last line quirk (with C-b r) + +-------- +kmous -- \E[M + +mouse init: putp("\033[?1000h"); +mouse deinit: putp("\033[?1000l"); + +\e[M CbCxCy + * On button press or release, xterm sends ESC [ M CbCxCy. + * The low two bits of Cb encode button information: 0=MB1 + * pressed, 1=MB2 pressed, 2=MB3 pressed, 3=release. The + * upper bits encode what modifiers were down when the + * button was pressed and are added together. 4=Shift, + * 8=Meta, 16=Control. Cx and Cy are the x and y coordinates + * of the mouse event. The upper left corner is (1,1). + + + get_mouse getm Gm Curses should get + button events + key_mouse kmous Km Mouse event has + occurred + mouse_info minfo Mi Mouse status + information diff --git a/input.c b/input.c index 90d41785..9406a45d 100644 --- a/input.c +++ b/input.c @@ -1,4 +1,4 @@ -/* $Id: input.c,v 1.41 2007-11-27 23:01:27 nicm Exp $ */ +/* $Id: input.c,v 1.42 2007-11-27 23:28:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -913,6 +913,10 @@ input_handle_sequence_sm(struct input_ctx *ictx) s->mode |= MODE_CURSOR; input_write(ictx, TTY_CURSORON); break; + case 1000: + s->mode |= MODE_MOUSE; + input_write(ictx, TTY_MOUSEON); + break; default: log_debug("unknown SM [%hhu]: %u", ictx->private, n); break; @@ -954,6 +958,10 @@ input_handle_sequence_rm(struct input_ctx *ictx) s->mode &= ~MODE_CURSOR; input_write(ictx, TTY_CURSOROFF); break; + case 1000: + s->mode &= ~MODE_MOUSE; + input_write(ictx, TTY_MOUSEOFF); + break; default: log_debug("unknown RM [%hhu]: %u", ictx->private, n); break; diff --git a/tmux.h b/tmux.h index 0c77c392..bc11c6a7 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.105 2007-11-27 23:01:27 nicm Exp $ */ +/* $Id: tmux.h,v 1.106 2007-11-27 23:28:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -282,6 +282,8 @@ struct buffer { #define TTY_KKEYPADOFF 22 #define TTY_KKEYPADON 23 #define TTY_TITLE 24 +#define TTY_MOUSEON 25 +#define TTY_MOUSEOFF 26 /* XXX merge allon/off into 1 arg? */ /* Message codes. */ enum hdrtype { @@ -343,6 +345,7 @@ struct msg_resize_data { #define MODE_HIDDEN 0x020 #define MODE_BACKGROUND 0x040 #define MODE_BGCURSOR 0x080 +#define MODE_MOUSE 0x100 /* * Virtual screen. This is stored as three blocks of 8-bit values, one for @@ -558,7 +561,7 @@ struct client { #define CLIENT_TERMINAL 0x1 #define CLIENT_PREFIX 0x2 -#define CLIENT_ATTACHED 0x4 +#define CLIENT_MOUSE 0x4 int flags; struct session *session; diff --git a/tty.c b/tty.c index c3e8850e..e0f0249e 100644 --- a/tty.c +++ b/tty.c @@ -1,4 +1,4 @@ -/* $Id: tty.c,v 1.6 2007-11-27 23:01:27 nicm Exp $ */ +/* $Id: tty.c,v 1.7 2007-11-27 23:28:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -324,7 +324,15 @@ tty_vwrite(struct tty *tty, int cmd, va_list ap) case TTY_KKEYPADON: if (keypad_xmit != NULL) tty_puts(tty, keypad_xmit); + break; #endif + case TTY_MOUSEOFF: + if (key_mouse != NULL) + tty_puts(tty, "\e[?1000l"); + break; + case TTY_MOUSEON: + if (key_mouse != NULL) + tty_puts(tty, "\e[?1000h"); break; case TTY_TITLE: break;