They cause copy selection to exclude to the left (or right) of the
column when they're set.  These are screen's version of block copy and I
think they do better than tmux's for copying e.g.  the paths out of `git
status`:

> $ git status
> ...
> #
> # some/file
> # some/much/much/much/longer/file
> # some/shorter/file

With screen I'd navigate to the "s" in "some/file" then " " (start
copy), "c" (prune "# "), "jj" or similar (navigate to bottom line), "$"
(end of line), " " (complete copy).

With tmux's block mode I could not figure out a good way to move the
right and bottom sides far enough.  One way or another I had to do a
painful navigation to one of the extremes (either wail on "l" at the
bottom row to get to the rightest column or use "$" on the longest row
then wail on "j" to navigate to the bottom row).

Keith

Thus spake Nicholas Marriott, at Wed, May 14, 2014 at 07:25:03AM +0100:
> Date: Wed, 14 May 2014 07:25:03 +0100
> From: Nicholas Marriott <nicholas.marri...@gmail.com>
> To: Keith Amling <aml...@palantir.com>
> CC: tmux-users@lists.sourceforge.net
> Subject: Re: [PATCH 2/3] Copy mode commands left-prune and right-prune to
>  match screen's c and C.
> 
> 
> What do these do?
> 
> 
> 
> 
> On Tue, May 13, 2014 at 08:54:49PM -0700, Keith Amling wrote:
> > This is mostly straight-forward although it feels like there are a lot
> > of layers to push it through.  Also, I have no idea what's appropriate
> > [if anything] to bind this to in emacs copy mode.
> > 
> > Keith
> > 
> > ---
> >  mode-key.c    |  4 ++++
> >  screen.c      | 12 ++++++++++-
> >  tmux.h        |  7 ++++++-
> >  window-copy.c | 64 
> > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
> >  4 files changed, 83 insertions(+), 4 deletions(-)
> > 
> > diff --git a/mode-key.c b/mode-key.c
> > index 57be2d8164b9..eb97d3f8a385 100644
> > --- a/mode-key.c
> > +++ b/mode-key.c
> > @@ -146,6 +146,8 @@ const struct mode_key_cmdstr mode_key_cmdstr_copy[] = {
> >     { MODEKEYCOPY_STARTSELECTION, "begin-selection" },
> >     { MODEKEYCOPY_TOPLINE, "top-line" },
> >     { MODEKEYCOPY_UP, "cursor-up" },
> > +   { MODEKEYCOPY_LEFTPRUNE, "left-prune" },
> > +   { MODEKEYCOPY_RIGHTPRUNE, "right-prune" },
> >  
> >     { 0, NULL }
> >  };
> > @@ -275,6 +277,7 @@ const struct mode_key_entry mode_key_vi_copy[] = {
> >     { '?',                      0, MODEKEYCOPY_SEARCHUP },
> >     { 'A',                      0, MODEKEYCOPY_APPENDSELECTION },
> >     { 'B',                      0, MODEKEYCOPY_PREVIOUSSPACE },
> > +   { 'C',                      0, MODEKEYCOPY_RIGHTPRUNE },
> >     { 'D',                      0, MODEKEYCOPY_COPYENDOFLINE },
> >     { 'E',                      0, MODEKEYCOPY_NEXTSPACEEND },
> >     { 'F',                      0, MODEKEYCOPY_JUMPBACK },
> > @@ -300,6 +303,7 @@ const struct mode_key_entry mode_key_vi_copy[] = {
> >     { '\r',                     0, MODEKEYCOPY_COPYSELECTION },
> >     { '^',                      0, MODEKEYCOPY_BACKTOINDENTATION },
> >     { 'b',                      0, MODEKEYCOPY_PREVIOUSWORD },
> > +   { 'c',                      0, MODEKEYCOPY_LEFTPRUNE },
> >     { 'e',                      0, MODEKEYCOPY_NEXTWORDEND },
> >     { 'f',                      0, MODEKEYCOPY_JUMP },
> >     { 'g',                      0, MODEKEYCOPY_HISTORYTOP },
> > diff --git a/screen.c b/screen.c
> > index 7bfc01543a01..f41cbb2d9cb8 100644
> > --- a/screen.c
> > +++ b/screen.c
> > @@ -251,7 +251,8 @@ screen_resize_y(struct screen *s, u_int sy)
> >  /* Set selection. */
> >  void
> >  screen_set_selection(struct screen *s, u_int sx, u_int sy,
> > -    u_int ex, u_int ey, u_int rectflag, struct grid_cell *gc)
> > +    u_int ex, u_int ey, u_int rectflag, u_int leftprunex, u_int 
> > rightprunex,
> > +    struct grid_cell *gc)
> >  {
> >     struct screen_sel       *sel = &s->sel;
> >  
> > @@ -261,6 +262,9 @@ screen_set_selection(struct screen *s, u_int sx, u_int 
> > sy,
> >  
> >     sel->sx = sx; sel->sy = sy;
> >     sel->ex = ex; sel->ey = ey;
> > +
> > +   sel->leftprunex = leftprunex;
> > +   sel->rightprunex = rightprunex;
> >  }
> >  
> >  /* Clear selection. */
> > @@ -281,6 +285,12 @@ screen_check_selection(struct screen *s, u_int px, 
> > u_int py)
> >     if (!sel->flag)
> >             return (0);
> >  
> > +   if (px < sel->leftprunex)
> > +           return (0);
> > +
> > +   if (px > sel->rightprunex)
> > +           return (0);
> > +
> >     if (sel->rectflag) {
> >             if (sel->sy < sel->ey) {
> >                     /* start line < end line -- downward selection. */
> > diff --git a/tmux.h b/tmux.h
> > index fde94afc47b3..aa01b17ee0e3 100644
> > --- a/tmux.h
> > +++ b/tmux.h
> > @@ -584,6 +584,8 @@ enum mode_key_cmd {
> >     MODEKEYCOPY_STARTSELECTION,
> >     MODEKEYCOPY_TOPLINE,
> >     MODEKEYCOPY_UP,
> > +   MODEKEYCOPY_LEFTPRUNE,
> > +   MODEKEYCOPY_RIGHTPRUNE,
> >  };
> >  
> >  /* Entry in the default mode key tables. */
> > @@ -761,6 +763,9 @@ struct screen_sel {
> >     u_int            ex;
> >     u_int            ey;
> >  
> > +   u_int leftprunex;
> > +   u_int rightprunex;
> > +
> >     struct grid_cell cell;
> >  };
> >  
> > @@ -2093,7 +2098,7 @@ void   screen_set_cursor_colour(struct screen *, 
> > const char *);
> >  void        screen_set_title(struct screen *, const char *);
> >  void        screen_resize(struct screen *, u_int, u_int, int);
> >  void        screen_set_selection(struct screen *,
> > -        u_int, u_int, u_int, u_int, u_int, struct grid_cell *);
> > +        u_int, u_int, u_int, u_int, u_int, u_int, u_int, struct grid_cell 
> > *);
> >  void        screen_clear_selection(struct screen *);
> >  int         screen_check_selection(struct screen *, u_int, u_int);
> >  void        screen_reflow(struct screen *, u_int);
> > diff --git a/window-copy.c b/window-copy.c
> > index 69a3e13b8bbd..6d2edda8c567 100644
> > --- a/window-copy.c
> > +++ b/window-copy.c
> > @@ -82,6 +82,8 @@ void      window_copy_cursor_previous_word(struct 
> > window_pane *, const char *);
> >  void       window_copy_scroll_up(struct window_pane *, u_int);
> >  void       window_copy_scroll_down(struct window_pane *, u_int);
> >  void       window_copy_rectangle_toggle(struct window_pane *);
> > +void       window_copy_left_prune(struct window_pane *);
> > +void       window_copy_right_prune(struct window_pane *);
> >  
> >  const struct window_mode window_copy_mode = {
> >     window_copy_init,
> > @@ -141,6 +143,11 @@ struct window_copy_mode_data {
> >     u_int           lastcx; /* position in last line with content */
> >     u_int           lastsx; /* size of last line with content */
> >  
> > +   int             leftprunex_set;
> > +   u_int           leftprunex;
> > +   int             rightprunex_set;
> > +   u_int           rightprunex;
> > +
> >     enum window_copy_input_type inputtype;
> >     const char     *inputprompt;
> >     char           *inputstr;
> > @@ -169,6 +176,9 @@ window_copy_init(struct window_pane *wp)
> >     data->lastcx = 0;
> >     data->lastsx = 0;
> >  
> > +   data->leftprunex_set = 0;
> > +   data->rightprunex_set = 0;
> > +
> >     data->backing_written = 0;
> >  
> >     data->rectflag = 0;
> > @@ -723,6 +733,12 @@ window_copy_key(struct window_pane *wp, struct session 
> > *sess, int key)
> >     case MODEKEYCOPY_RECTANGLETOGGLE:
> >             window_copy_rectangle_toggle(wp);
> >             break;
> > +   case MODEKEYCOPY_LEFTPRUNE:
> > +           window_copy_left_prune(wp);
> > +           break;
> > +   case MODEKEYCOPY_RIGHTPRUNE:
> > +           window_copy_right_prune(wp);
> > +           break;
> >     default:
> >             break;
> >     }
> > @@ -1295,7 +1311,7 @@ window_copy_update_selection(struct window_pane *wp, 
> > int may_redraw)
> >     struct screen                   *s = &data->screen;
> >     struct options                  *oo = &wp->window->options;
> >     struct grid_cell                 gc;
> > -   u_int                            sx, sy, ty, cy;
> > +   u_int                            sx, sy, ty, cy, leftprunex, 
> > rightprunex;
> >  
> >     if (!s->sel.flag)
> >             return (0);
> > @@ -1320,9 +1336,12 @@ window_copy_update_selection(struct window_pane *wp, 
> > int may_redraw)
> >     } else
> >             sy -= ty;
> >     sy = screen_hsize(s) + sy;
> > +   leftprunex = data->leftprunex_set ? data->leftprunex : 0;
> > +   rightprunex = data->rightprunex_set ? data->rightprunex : 
> > (screen_size_x(s) - 1);
> >  
> >     screen_set_selection(s,
> > -       sx, sy, data->cx, screen_hsize(s) + data->cy, data->rectflag, &gc);
> > +       sx, sy, data->cx, screen_hsize(s) + data->cy, data->rectflag,
> > +       leftprunex, rightprunex, &gc);
> >  
> >     if (data->rectflag && may_redraw) {
> >             /*
> > @@ -1428,6 +1447,23 @@ window_copy_get_selection(struct window_pane *wp, 
> > size_t *len)
> >             restsx = 0;
> >     }
> >  
> > +   if (data->leftprunex_set) {
> > +           if (firstsx < data->leftprunex) {
> > +                   firstsx = data->leftprunex;
> > +           }
> > +           if (restsx < data->leftprunex) {
> > +                   restsx = data->leftprunex;
> > +           }
> > +   }
> > +   if (data->rightprunex_set) {
> > +           if (restex > data->rightprunex + 1) {
> > +                   restex = data->rightprunex + 1;
> > +           }
> > +           if (lastex > data->rightprunex + 1) {
> > +                   lastex = data->rightprunex + 1;
> > +           }
> > +   }
> > +
> >     /* Copy the lines. */
> >     for (i = sy; i <= ey; i++)
> >             window_copy_copy_line(wp, &buf, &off, i,
> > @@ -2190,3 +2226,27 @@ window_copy_rectangle_toggle(struct window_pane *wp)
> >     window_copy_update_selection(wp, 1);
> >     window_copy_redraw_screen(wp);
> >  }
> > +
> > +void
> > +window_copy_left_prune(struct window_pane *wp)
> > +{
> > +   struct window_copy_mode_data    *data = wp->modedata;
> > +   if (!data->rightprunex_set || data->cx <= data->rightprunex) {
> > +           data->leftprunex = data->cx;
> > +           data->leftprunex_set = 1;
> > +           window_copy_update_selection(wp, 1);
> > +           window_copy_redraw_screen(wp);
> > +   }
> > +}
> > +
> > +void
> > +window_copy_right_prune(struct window_pane *wp)
> > +{
> > +   struct window_copy_mode_data    *data = wp->modedata;
> > +   if (!data->leftprunex_set || data->cx >= data->leftprunex) {
> > +           data->rightprunex = data->cx;
> > +           data->rightprunex_set = 1;
> > +           window_copy_update_selection(wp, 1);
> > +           window_copy_redraw_screen(wp);
> > +   }
> > +}
> > -- 
> > 1.9.1
> > 
> > 
> > ------------------------------------------------------------------------------
> > "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
> > Instantly run your Selenium tests across 300+ browser/OS combos.
> > Get unparalleled scalability from the best Selenium testing platform 
> > available
> > Simple to use. Nothing to install. Get started now for free."
> > https://urldefense.proofpoint.com/v1/url?u=http://p.sf.net/sfu/SauceLabs&k=fDZpZZQMmYwf27OU23GmAQ%3D%3D%0A&r=BTdtcPIZXD8V7r6BhVE1Cy1S1ITG2lF8LZPYHbBpv%2B0%3D%0A&m=WeRze7PcCSBhNaBLkmFaSCbn%2F2f2bjjPKqnn0V7YBc8%3D%0A&s=b21e920c1772cb37c8ecb2c8f9a60a94253711e3de0a602d79944543f9f0c2ef
> > _______________________________________________
> > tmux-users mailing list
> > tmux-users@lists.sourceforge.net
> > https://urldefense.proofpoint.com/v1/url?u=https://lists.sourceforge.net/lists/listinfo/tmux-users&k=fDZpZZQMmYwf27OU23GmAQ%3D%3D%0A&r=BTdtcPIZXD8V7r6BhVE1Cy1S1ITG2lF8LZPYHbBpv%2B0%3D%0A&m=WeRze7PcCSBhNaBLkmFaSCbn%2F2f2bjjPKqnn0V7YBc8%3D%0A&s=82f244c2db8317ccc52403d4bc774b880618e056a80142da4f1fd333a51d22d8

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to