How about this instead (not tested)?

Index: cmd-paste-buffer.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/cmd-paste-buffer.c,v
retrieving revision 1.25
diff -u -p -r1.25 cmd-paste-buffer.c
--- cmd-paste-buffer.c  13 May 2014 07:34:35 -0000      1.25
+++ cmd-paste-buffer.c  23 Jun 2014 10:09:15 -0000
@@ -50,7 +50,6 @@ cmd_paste_buffer_exec(struct cmd *self, 
        struct session          *s;
        struct paste_buffer     *pb;
        const char              *sepstr, *bufname;
-       int                      pflag;
 
        if (cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp) == NULL)
                return (CMD_RETURN_ERROR);
@@ -77,8 +76,7 @@ cmd_paste_buffer_exec(struct cmd *self, 
                        else
                                sepstr = "\r";
                }
-               pflag = (wp->screen->mode & MODE_BRACKETPASTE);
-               paste_send_pane(pb, wp, sepstr, args_has(args, 'p') && pflag);
+               paste_send_pane(pb, wp, sepstr, args_has(args, 'p'));
        }
 
        /* Delete the buffer if -d. */
Index: input-keys.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/input-keys.c,v
retrieving revision 1.37
diff -u -p -r1.37 input-keys.c
--- input-keys.c        8 May 2014 07:59:16 -0000       1.37
+++ input-keys.c        23 Jun 2014 10:11:10 -0000
@@ -206,6 +206,7 @@ input_mouse(struct window_pane *wp, stru
        size_t                   len;
        struct paste_buffer     *pb;
        u_int                    i;
+       int                      event;
 
        /*
         * If the alternate screen is active and hasn't enabled the mouse, send
@@ -253,15 +254,14 @@ input_mouse(struct window_pane *wp, stru
                return;
        }
 
-       if (m->button == 1 && (m->event & MOUSE_EVENT_CLICK) &&
-           options_get_number(&wp->window->options, "mode-mouse") == 1) {
+       if (options_get_number(&wp->window->options, "mode-mouse") != 1)
+               return;
+       event = m->event & (MOUSE_EVENT_CLICK|MOUSE_EVENT_WHEEL);
+       if (wp->mode == NULL && m->button == 1 && event == MOUSE_EVENT_CLICK) {
                pb = paste_get_top();
-               if (pb != NULL) {
-                       paste_send_pane(pb, wp, "\r",
-                           wp->screen->mode & MODE_BRACKETPASTE);
-               }
-       } else if (m->button != 1 &&
-           options_get_number(&wp->window->options, "mode-mouse") == 1) {
+               if (pb == NULL)
+                       paste_send_pane(pb, wp, "\r", 1);
+       } else {
                if (window_pane_set_mode(wp, &window_copy_mode) == 0) {
                        window_copy_init_from_pane(wp);
                        if (wp->mode->mouse != NULL)
Index: paste.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/paste.c,v
retrieving revision 1.21
diff -u -p -r1.21 paste.c
--- paste.c     20 Jun 2014 11:00:19 -0000      1.21
+++ paste.c     23 Jun 2014 10:12:03 -0000
@@ -298,7 +298,7 @@ paste_send_pane(struct paste_buffer *pb,
        const char      *data = pb->data, *end = data + pb->size, *lf;
        size_t           seplen;
 
-       if (bracket)
+       if (bracket && (wp->screen->mode & MODE_BRACKETPASTE))
                bufferevent_write(wp->event, "\033[200~", 6);
 
        seplen = strlen(sep);
@@ -312,6 +312,6 @@ paste_send_pane(struct paste_buffer *pb,
        if (end != data)
                bufferevent_write(wp->event, data, end - data);
 
-       if (bracket)
+       if (bracket && (wp->screen->mode & MODE_BRACKETPASTE))
                bufferevent_write(wp->event, "\033[201~", 6);
 }



On Sat, Jun 21, 2014 at 04:30:18PM +0100, Balazs Kezes wrote:
> From 9d161e63f44910fbd0294310bd03bcf39f147726 Mon Sep 17 00:00:00 2001
> From: Balazs Kezes <rlblas...@gmail.com>
> Date: Sat, 21 Jun 2014 13:13:16 +0100
> Subject: [PATCH 2/5] Refactor input_mouse()
> 
> Move "options_get_number(...)" out of the two conditions so that there's only
> one call to it. Also add some cosmetic changes.
> ---
>  input-keys.c | 22 ++++++++++++++--------
>  1 file changed, 14 insertions(+), 8 deletions(-)
> 
> diff --git a/input-keys.c b/input-keys.c
> index 7531f22..840104f 100644
> --- a/input-keys.c
> +++ b/input-keys.c
> @@ -205,6 +205,7 @@ input_mouse(struct window_pane *wp, struct session *s, 
> struct mouse_event *m)
>       size_t                   len;
>       struct paste_buffer     *pb;
>       u_int                    i;
> +     int                      wheel;
>  
>       /*
>        * If the alternate screen is active and hasn't enabled the mouse, send
> @@ -252,15 +253,20 @@ input_mouse(struct window_pane *wp, struct session *s, 
> struct mouse_event *m)
>               return;
>       }
>  
> -     if (m->button == 1 && (m->event & MOUSE_EVENT_CLICK) &&
> -         options_get_number(&wp->window->options, "mode-mouse") == 1) {
> -             pb = paste_get_top();
> -             if (pb != NULL) {
> -                     paste_send_pane(pb, wp, "\r",
> -                         wp->screen->mode & MODE_BRACKETPASTE);
> +     if (options_get_number(&wp->window->options, "mode-mouse") != 1)
> +             return;
> +
> +     /* We don't care about m->button in case of wheel events. */
> +     wheel = (m->event & MOUSE_EVENT_WHEEL);
> +     if (wp->mode == NULL && !wheel && m->button == 1) {
> +             if (m->event & MOUSE_EVENT_CLICK) {
> +                     pb = paste_get_top();
> +                     if (pb != NULL) {
> +                             paste_send_pane(pb, wp, "\r",
> +                                     wp->screen->mode & MODE_BRACKETPASTE);
> +                     }
>               }
> -     } else if (m->button != 1 &&
> -         options_get_number(&wp->window->options, "mode-mouse") == 1) {
> +     } else {
>               if (window_pane_set_mode(wp, &window_copy_mode) == 0) {
>                       window_copy_init_from_pane(wp);
>                       if (wp->mode->mouse != NULL)
> -- 
> 2.0.0.526.g5318336
> 


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to