Yeah I thought about this again and I think it is fine. Applied to
OpenBSD, will be in SF later, thanks.



On Fri, Apr 15, 2011 at 12:15:06PM -0300, Tiago Resende wrote:
> On Friday, 2011-04-15, at 08:31:26 +0200, Hannes von Haugwitz wrote:
> > > Since there is already a means of altering a user's key binding
> > > preference using the mode-keys option, I thought it would be a nice if
> > > tmux would adjust the selection behavior based on that value as well.
> > 
> > I second this feature request.
> 
> Possible patch attached. As far as I tested, it only behaves differently
> from vim when ending the selection at a line break (tmux will consume
> that last break, vim will not). I didn't want to mess with
> window_copy_copy_line() just to correct that small detail, though.
> 
> Could you guys test this and see if it's correct? Could you also test it
> in emacs mode, if it isn't too much trouble?

> diff -Ndur tmux-orig//window-copy.c tmux/window-copy.c
> --- tmux-orig//window-copy.c  2011-04-06 19:18:56.000000000 -0300
> +++ tmux/window-copy.c        2011-04-15 10:46:48.199849693 -0300
> @@ -1218,6 +1218,7 @@
>       size_t                           off;
>       u_int                            i, xx, yy, sx, sy, ex, ey, limit;
>       u_int                            firstsx, lastex, restex, restsx;
> +     int                              keys;
>  
>       if (!s->sel.flag)
>               return;
> @@ -1254,6 +1255,13 @@
>        * end (restex) of all other lines.
>        */
>       xx = screen_size_x(s);
> +     /*
> +      * Behave according to mode-keys. If it is emacs, copy like emacs,
> +      * keeping the top-left-most character, and dropping the
> +      * bottom-right-most, regardless of copy direction. If it is vi, also
> +      * keep bottom-right-most character.
> +      */
> +     keys = options_get_number(&wp->window->options, "mode-keys");
>       if (data->rectflag) {
>               /*
>                * Need to ignore the column with the cursor in it, which for
> @@ -1261,8 +1269,14 @@
>                */
>               if (data->selx < data->cx) {
>                       /* Selection start is on the left. */
> -                     lastex = data->cx;
> -                     restex = data->cx;
> +                     if (keys == MODEKEY_EMACS) {
> +                             lastex = data->cx;
> +                             restex = data->cx;
> +                     }
> +                     else {
> +                             lastex = data->cx + 1;
> +                             restex = data->cx + 1;
> +                     }
>                       firstsx = data->selx;
>                       restsx = data->selx;
>               } else {
> @@ -1273,11 +1287,10 @@
>                       restsx = data->cx;
>               }
>       } else {
> -             /*
> -              * Like emacs, keep the top-left-most character, and drop the
> -              * bottom-right-most, regardless of copy direction.
> -              */
> -             lastex = ex;
> +             if (keys == MODEKEY_EMACS)
> +                     lastex = ex;
> +             else    
> +                     lastex = ex + 1;
>               restex = xx;
>               firstsx = sx;
>               restsx = 0;

> ------------------------------------------------------------------------------
> Benefiting from Server Virtualization: Beyond Initial Workload 
> Consolidation -- Increasing the use of server virtualization is a top
> priority.Virtualization can reduce costs, simplify management, and improve 
> application availability and disaster protection. Learn more about boosting 
> the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev

> _______________________________________________
> tmux-users mailing list
> tmux-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tmux-users


------------------------------------------------------------------------------
Fulfilling the Lean Software Promise
Lean software platforms are now widely adopted and the benefits have been 
demonstrated beyond question. Learn why your peers are replacing JEE 
containers with lightweight application servers - and what you can gain 
from the move. http://p.sf.net/sfu/vmware-sfemails
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to