never mind, this was the latest, i'd just tweaked it. found it in a git
rather than a cvs tree.
i've applied all of this except the emulation-in-cup-mode bit so far
which i'm not entirely convinced about right now
thanks!
On Wed, Apr 02, 2014 at 07:29:06PM +0100, Nicholas Marriott wrote:
> Hi
>
> Did you send me a later version of this? I can't find it :-/.
>
> Cheers
>
>
>
> On Thu, Mar 06, 2014 at 12:46:28PM +0000, Nicholas Marriott wrote:
> > Some changes, notably:
> >
> > - Broke the define changes into separate diffs and applied them.
> >
> > - I don't like it assuming that if m->scroll != 0 the wheel is in use,
> > it is more understandable if it checks the event.
> >
> > - In window-choose.c the return was in the wrong place.
> >
> > Originally the idea of having m->b and m->wheel was to make things
> > simpler but I'm not sure they are actually helping, it might be better
> > if everything just looked at m->xb again :-/. But not now.
> >
> > Not sure this should be on just for mouse-select-pane/window... need to
> > think about it.
> >
> >
> > diff --git a/input-keys.c b/input-keys.c
> > index 7582a63..29de5ea 100644
> > --- a/input-keys.c
> > +++ b/input-keys.c
> > @@ -204,6 +204,22 @@ input_mouse(struct window_pane *wp, struct session *s,
> > struct mouse_event *m)
> > char buf[40];
> > size_t len;
> > struct paste_buffer *pb;
> > + u_int i;
> > +
> > + /*
> > + * Mouse wheel used while alternate screen is active and not mouse
> > + * aware, or shift is pressed.
> > + */
> > + if (((wp->saved_grid != NULL && !(wp->screen->mode & ALL_MOUSE_MODES))
> > ||
> > + m->xb & MOUSE_MASK_SHIFT)) {
> > + for (i = 0; i < m->scroll; i++) {
> > + if (m->wheel == MOUSE_WHEEL_UP)
> > + input_key(wp, KEYC_UP);
> > + else
> > + input_key(wp, KEYC_DOWN);
> > + }
> > + return;
> > + }
> >
> > if (wp->screen->mode & ALL_MOUSE_MODES) {
> > /*
> > @@ -244,7 +260,7 @@ input_mouse(struct window_pane *wp, struct session *s,
> > struct mouse_event *m)
> > paste_send_pane(pb, wp, "\r",
> > wp->screen->mode & MODE_BRACKETPASTE);
> > }
> > - } else if ((m->xb & 3) != 1 &&
> > + } else if (m->button != 1 &&
> > options_get_number(&wp->window->options, "mode-mouse") == 1) {
> > if (window_pane_set_mode(wp, &window_copy_mode) == 0) {
> > window_copy_init_from_pane(wp);
> > diff --git a/tmux.h b/tmux.h
> > index fe6bad2..82c79f0 100644
> > --- a/tmux.h
> > +++ b/tmux.h
> > @@ -1175,6 +1175,7 @@ struct mouse_event {
> >
> > u_int button;
> > u_int clicks;
> > + u_int scroll;
> >
> > int wheel;
> > int event;
> > diff --git a/tty-keys.c b/tty-keys.c
> > index 9dbe450..42f2da4 100644
> > --- a/tty-keys.c
> > +++ b/tty-keys.c
> > @@ -749,6 +749,15 @@ tty_keys_mouse(struct tty *tty, const char *buf,
> > size_t len, size_t *size)
> > m->x = x;
> > m->y = y;
> > if (b & MOUSE_MASK_WHEEL) {
> > + if (b & MOUSE_MASK_SHIFT)
> > + m->scroll = 1;
> > + else
> > + m->scroll = 3;
> > + if (b & MOUSE_MASK_META)
> > + m->scroll *= 3;
> > + if (b & MOUSE_MASK_CTRL)
> > + m->scroll *= 3;
> > +
> > b &= MOUSE_MASK_BUTTONS;
> > if (b == 0)
> > m->wheel = MOUSE_WHEEL_UP;
> > @@ -756,9 +765,9 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t
> > len, size_t *size)
> > m->wheel = MOUSE_WHEEL_DOWN;
> > m->event = MOUSE_EVENT_WHEEL;
> > } else if ((b & MOUSE_MASK_BUTTONS) == 3) {
> > - if (~m->event & MOUSE_EVENT_DRAG && x == m->x && y == m->y) {
> > + if (~m->event & MOUSE_EVENT_DRAG && x == m->x && y == m->y)
> > m->event = MOUSE_EVENT_CLICK;
> > - } else
> > + else
> > m->event = MOUSE_EVENT_DRAG;
> > m->event |= MOUSE_EVENT_UP;
> > } else {
> > diff --git a/window-choose.c b/window-choose.c
> > index e7578fe..e75858e 100644
> > --- a/window-choose.c
> > +++ b/window-choose.c
> > @@ -721,7 +721,17 @@ window_choose_mouse(
> > struct window_choose_mode_data *data = wp->modedata;
> > struct screen *s = &data->screen;
> > struct window_choose_mode_item *item;
> > - u_int idx;
> > + u_int i, idx;
> > +
> > + if (m->event == MOUSE_EVENT_WHEEL) {
> > + for (i = 0; i < m->scroll; i++) {
> > + if (m->wheel == MOUSE_WHEEL_UP)
> > + window_choose_key(wp, sess, KEYC_UP);
> > + else
> > + window_choose_key(wp, sess, KEYC_DOWN);
> > + }
> > + return;
> > + }
> >
> > if (~m->event & MOUSE_EVENT_CLICK)
> > return;
> > diff --git a/window-copy.c b/window-copy.c
> > index e3164f6..9aaf554 100644
> > --- a/window-copy.c
> > +++ b/window-copy.c
> > @@ -871,18 +871,19 @@ window_copy_mouse(
> >
> > /* If mouse wheel (buttons 4 and 5), scroll. */
> > if (m->event == MOUSE_EVENT_WHEEL) {
> > - if (m->wheel == MOUSE_WHEEL_UP) {
> > - for (i = 0; i < 5; i++)
> > + for (i = 0; i < m->scroll; i++) {
> > + if (m->wheel == MOUSE_WHEEL_UP)
> > window_copy_cursor_up(wp, 1);
> > - } else if (m->wheel == MOUSE_WHEEL_DOWN) {
> > - for (i = 0; i < 5; i++)
> > + else {
> > window_copy_cursor_down(wp, 1);
> > - /*
> > - * We reached the bottom, leave copy mode,
> > - * but only if no selection is in progress.
> > - */
> > - if (data->oy == 0 && !s->sel.flag)
> > - goto reset_mode;
> > +
> > + /*
> > + * We reached the bottom, leave copy mode, but
> > + * only if no selection is in progress.
> > + */
> > + if (data->oy == 0 && !s->sel.flag)
> > + goto reset_mode;
> > + }
> > }
> > return;
> > }
> > .
> >
> >
> >
> > On Wed, Mar 05, 2014 at 11:50:09AM +0100, Marcel Partap wrote:
> > > (+ some other changes regarding mouse implementation)
> > > - is u_int for i ok?
> > > - was there a valid reason to use bit shifts for MOUSE_EVENT_*
> > > constants?
> > > - ...
> > > ---
> > > input-keys.c | 18 +++++++++++++++++-
> > > server-fn.c | 1 +
> > > tmux.h | 23 +++++++++++++++++------
> > > tty-keys.c | 27 ++++++++++++++++++---------
> > > window-choose.c | 10 +++++++++-
> > > window-copy.c | 12 +++++-------
> > > 6 files changed, 67 insertions(+), 24 deletions(-)
> > >
> > > diff --git a/input-keys.c b/input-keys.c
> > > index 7582a63..b76dd6c 100644
> > > --- a/input-keys.c
> > > +++ b/input-keys.c
> > > @@ -204,6 +204,22 @@ input_mouse(struct window_pane *wp, struct session
> > > *s, struct mouse_event *m)
> > > char buf[40];
> > > size_t len;
> > > struct paste_buffer *pb;
> > > + u_int i;
> > > +
> > > + /*
> > > + * Mouse wheel used while alternate screen is active and not mouse
> > > + * aware, or shift is pressed.
> > > + */
> > > + if (((wp->saved_grid != NULL && !(wp->screen->mode & ALL_MOUSE_MODES))
> > > ||
> > > + m->xb & MOUSE_SHIFT)) {
> > > + for (i = 0; i < m->scroll; i++) {
> > > + if (m->wheel == MOUSE_WHEEL_UP)
> > > + input_key(wp, KEYC_UP);
> > > + else
> > > + input_key(wp, KEYC_DOWN);
> > > + }
> > > + return;
> > > + }
> > >
> > > if (wp->screen->mode & ALL_MOUSE_MODES) {
> > > /*
> > > @@ -244,7 +260,7 @@ input_mouse(struct window_pane *wp, struct session
> > > *s, struct mouse_event *m)
> > > paste_send_pane(pb, wp, "\r",
> > > wp->screen->mode & MODE_BRACKETPASTE);
> > > }
> > > - } else if ((m->xb & 3) != 1 &&
> > > + } else if (m->button != 1 &&
> > > options_get_number(&wp->window->options, "mode-mouse") == 1) {
> > > if (window_pane_set_mode(wp, &window_copy_mode) == 0) {
> > > window_copy_init_from_pane(wp);
> > > diff --git a/server-fn.c b/server-fn.c
> > > index 3062698..47e1cee 100644
> > > --- a/server-fn.c
> > > +++ b/server-fn.c
> > > @@ -609,3 +609,4 @@ server_unzoom_window(struct window *w)
> > > server_redraw_window(w);
> > > server_status_window(w);
> > > }
> > > +
> > > diff --git a/tmux.h b/tmux.h
> > > index 23b1b46..41be9f8 100644
> > > --- a/tmux.h
> > > +++ b/tmux.h
> > > @@ -1118,19 +1118,29 @@ struct tty_term {
> > > };
> > > LIST_HEAD(tty_terms, tty_term);
> > >
> > > +/* Mouse event masks. */
> > > +#define MOUSE_MASK_BUTTON 3
> > > +#define MOUSE_MASK_DRAG 32
> > > +#define MOUSE_MASK_WHEEL 64
> > > +
> > > +/* Mouse modifier key states. */
> > > +#define MOUSE_SHIFT 4
> > > +#define MOUSE_META 8
> > > +#define MOUSE_CTRL 16
> > > +
> > > /* Mouse wheel states. */
> > > #define MOUSE_WHEEL_UP 0
> > > #define MOUSE_WHEEL_DOWN 1
> > >
> > > /* Mouse events. */
> > > -#define MOUSE_EVENT_DOWN (1 << 0)
> > > -#define MOUSE_EVENT_DRAG (1 << 1)
> > > -#define MOUSE_EVENT_UP (1 << 2)
> > > -#define MOUSE_EVENT_CLICK (1 << 3)
> > > -#define MOUSE_EVENT_WHEEL (1 << 4)
> > > +#define MOUSE_EVENT_DOWN 1
> > > +#define MOUSE_EVENT_DRAG 2
> > > +#define MOUSE_EVENT_UP 4
> > > +#define MOUSE_EVENT_CLICK 8
> > > +#define MOUSE_EVENT_WHEEL 16
> > >
> > > /* Mouse flags. */
> > > -#define MOUSE_RESIZE_PANE (1 << 0)
> > > +#define MOUSE_RESIZE_PANE 1
> > >
> > > /*
> > > * Mouse input. When sent by xterm:
> > > @@ -1160,6 +1170,7 @@ struct mouse_event {
> > >
> > > u_int button;
> > > u_int clicks;
> > > + u_int scroll;
> > >
> > > int wheel;
> > > int event;
> > > diff --git a/tty-keys.c b/tty-keys.c
> > > index 7fb91a8..1a5053a 100644
> > > --- a/tty-keys.c
> > > +++ b/tty-keys.c
> > > @@ -748,21 +748,30 @@ tty_keys_mouse(struct tty *tty, const char *buf,
> > > size_t len, size_t *size)
> > > m->sgr_rel = sgr_rel;
> > > m->x = x;
> > > m->y = y;
> > > - if (b & 64) { /* wheel button */
> > > - b &= 3;
> > > - if (b == 0)
> > > - m->wheel = MOUSE_WHEEL_UP;
> > > - else if (b == 1)
> > > - m->wheel = MOUSE_WHEEL_DOWN;
> > > + m->scroll = 0;
> > > + if (b & MOUSE_MASK_WHEEL) {
> > > m->event = MOUSE_EVENT_WHEEL;
> > > - } else if ((b & 3) == 3) {
> > > + /* Figure out number of lines to scroll, shift is a single
> > > + * line, meta and ctrl multiply exponentially. */
> > > + if (b & MOUSE_SHIFT)
> > > + m->scroll = 1;
> > > + else
> > > + m->scroll = 3;
> > > +
> > > + if (b & MOUSE_META)
> > > + m->scroll *= 3;
> > > + if (b & MOUSE_CTRL)
> > > + m->scroll *= 3;
> > > +
> > > + m->wheel = (b & MOUSE_MASK_BUTTON);
> > > + } else if ((b & MOUSE_MASK_BUTTON) == 3) {
> > > if (~m->event & MOUSE_EVENT_DRAG && x == m->x && y == m->y) {
> > > m->event = MOUSE_EVENT_CLICK;
> > > } else
> > > m->event = MOUSE_EVENT_DRAG;
> > > m->event |= MOUSE_EVENT_UP;
> > > } else {
> > > - if (b & 32) /* drag motion */
> > > + if (b & MOUSE_MASK_DRAG)
> > > m->event = MOUSE_EVENT_DRAG;
> > > else {
> > > if (m->event & MOUSE_EVENT_UP && x == m->x && y == m->y)
> > > @@ -773,7 +782,7 @@ tty_keys_mouse(struct tty *tty, const char *buf,
> > > size_t len, size_t *size)
> > > m->sy = y;
> > > m->event = MOUSE_EVENT_DOWN;
> > > }
> > > - m->button = (b & 3);
> > > + m->button = (b & MOUSE_MASK_BUTTON);
> > > }
> > >
> > > return (0);
> > > diff --git a/window-choose.c b/window-choose.c
> > > index 7b2b32b..9d91994 100644
> > > --- a/window-choose.c
> > > +++ b/window-choose.c
> > > @@ -698,7 +698,15 @@ window_choose_mouse(
> > > struct window_choose_mode_data *data = wp->modedata;
> > > struct screen *s = &data->screen;
> > > struct window_choose_mode_item *item;
> > > - u_int idx;
> > > + u_int i, idx;
> > > +
> > > + for (i = 0; i < m->scroll; i++) {
> > > + if (m->wheel == MOUSE_WHEEL_UP)
> > > + window_choose_key(wp, sess, KEYC_UP);
> > > + else
> > > + window_choose_key(wp, sess, KEYC_DOWN);
> > > + return;
> > > + }
> > >
> > > if (~m->event & MOUSE_EVENT_CLICK)
> > > return;
> > > diff --git a/window-copy.c b/window-copy.c
> > > index 527c95c..7471ef2 100644
> > > --- a/window-copy.c
> > > +++ b/window-copy.c
> > > @@ -862,13 +862,11 @@ window_copy_mouse(
> > > return;
> > >
> > > /* If mouse wheel (buttons 4 and 5), scroll. */
> > > - if (m->event == MOUSE_EVENT_WHEEL) {
> > > - if (m->wheel == MOUSE_WHEEL_UP) {
> > > - for (i = 0; i < 5; i++)
> > > - window_copy_cursor_up(wp, 1);
> > > - } else if (m->wheel == MOUSE_WHEEL_DOWN) {
> > > - for (i = 0; i < 5; i++)
> > > - window_copy_cursor_down(wp, 1);
> > > + for (i = 0; i < m->scroll; i++) {
> > > + if (m->wheel == MOUSE_WHEEL_UP)
> > > + window_copy_cursor_up(wp, 1);
> > > + else {
> > > + window_copy_cursor_down(wp, 1);
> > > /*
> > > * We reached the bottom, leave copy mode,
> > > * but only if no selection is in progress.
> > > --
> > > 1.9.0
> > >
> > >
> > > ------------------------------------------------------------------------------
> > > Subversion Kills Productivity. Get off Subversion & Make the Move to
> > > Perforce.
> > > With Perforce, you get hassle-free workflows. Merge that actually works.
> > > Faster operations. Version large binaries. Built-in WAN optimization and
> > > the
> > > freedom to use Git, Perforce or both. Make the move to Perforce.
> > > http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
> > > _______________________________________________
> > > tmux-users mailing list
> > > [email protected]
> > > https://lists.sourceforge.net/lists/listinfo/tmux-users
------------------------------------------------------------------------------
_______________________________________________
tmux-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-users