Hi Thanks for updated diff,
Comments inline. > Index: mode-key.c > =================================================================== > RCS file: /cvsroot/tmux/tmux/mode-key.c,v > retrieving revision 1.36 > diff -u -r1.36 mode-key.c > --- mode-key.c 4 Dec 2009 22:14:47 -0000 1.36 > +++ mode-key.c 21 Jan 2010 07:42:17 -0000 > @@ -85,6 +85,9 @@ > { MODEKEYCOPY_ENDOFLINE, "end-of-line" }, > { MODEKEYCOPY_GOTOLINE, "goto-line" }, > { MODEKEYCOPY_LEFT, "cursor-left" }, > + { MODEKEYCOPY_MARGIN_LEFT, "left-margin" }, > + { MODEKEYCOPY_MARGIN_RIGHT, "right-margin" }, > + { MODEKEYCOPY_MARGIN_TOGGLE, "square-copy-toggle" }, Why are left-margin/right-margin commands necessary? Can't the selection start position and the cursor positon determine the rectangle? This would seem to be much more intuitive to use. I think square-copy-toggle should be rectangle-toggle. > { MODEKEYCOPY_MIDDLELINE, "middle-line" }, > { MODEKEYCOPY_NEXTPAGE, "page-down" }, > { MODEKEYCOPY_NEXTWORD, "next-word" }, > @@ -186,6 +189,9 @@ > { 'n', 0, MODEKEYCOPY_SEARCHAGAIN }, > { 'q', 0, MODEKEYCOPY_CANCEL }, > { 'w', 0, MODEKEYCOPY_NEXTWORD }, > + { 'c', 0, MODEKEYCOPY_MARGIN_LEFT }, > + { 'C', 0, MODEKEYCOPY_MARGIN_RIGHT }, > + { 'v', 0, MODEKEYCOPY_MARGIN_TOGGLE }, > { KEYC_BSPACE, 0, MODEKEYCOPY_LEFT }, > { KEYC_DOWN | KEYC_CTRL,0, MODEKEYCOPY_SCROLLDOWN }, > { KEYC_DOWN, 0, MODEKEYCOPY_DOWN }, > @@ -276,6 +282,9 @@ > { 'R' | KEYC_ESCAPE, 0, MODEKEYCOPY_TOPLINE }, > { 'v' | KEYC_ESCAPE, 0, MODEKEYCOPY_PREVIOUSPAGE }, > { 'w' | KEYC_ESCAPE, 0, MODEKEYCOPY_COPYSELECTION }, > + { 'c' | KEYC_ESCAPE, 0, MODEKEYCOPY_MARGIN_LEFT }, > + { 'C' | KEYC_ESCAPE, 0, MODEKEYCOPY_MARGIN_RIGHT }, > + { 'V' | KEYC_ESCAPE, 0, MODEKEYCOPY_MARGIN_TOGGLE }, > { KEYC_DOWN | KEYC_CTRL,0, MODEKEYCOPY_SCROLLDOWN }, > { KEYC_DOWN | KEYC_ESCAPE, 0, MODEKEYCOPY_HALFPAGEDOWN }, > { KEYC_DOWN, 0, MODEKEYCOPY_DOWN }, > Index: screen.c > =================================================================== > RCS file: /cvsroot/tmux/tmux/screen.c,v > retrieving revision 1.98 > diff -u -r1.98 screen.c > --- screen.c 5 Jan 2010 23:54:53 -0000 1.98 > +++ screen.c 21 Jan 2010 07:42:17 -0000 > @@ -228,13 +228,18 @@ > /* Set selection. */ > void > screen_set_selection(struct screen *s, > - u_int sx, u_int sy, u_int ex, u_int ey, struct grid_cell *gc) > + u_int sx, u_int sy, u_int ex, u_int ey, u_int block_mode, > + u_int marginl, u_int marginr, struct grid_cell *gc) > { > struct screen_sel *sel = &s->sel; > > memcpy(&sel->cell, gc, sizeof sel->cell); > sel->flag = 1; > > + sel->block_mode = block_mode; This should be called marginflag. I think it might be better if all the variables used rect rather than margin, although it isn't too important. But see comment above, if you use the existing sx, sy, ex and ey to determine the extent of the rectangle there is no need for these. > + sel->marginl = marginl; > + sel->marginr = marginr; > + > /* starting line < ending line -- downward selection. */ > if (sy < ey) { > sel->sx = sx; sel->sy = sy; > @@ -282,6 +287,12 @@ > if (!sel->flag || py < sel->sy || py > sel->ey) > return (0); > > + if (sel->block_mode && px < sel->marginl) > + return (0); > + > + if (sel->block_mode && px > sel->marginr - 1) > + return (0); marginr can never be 0? > + > if (py == sel->sy && py == sel->ey) { > if (px < sel->sx || px > sel->ex) > return (0); > Index: tmux.h > =================================================================== > RCS file: /cvsroot/tmux/tmux/tmux.h,v > retrieving revision 1.536 > diff -u -r1.536 tmux.h > --- tmux.h 8 Jan 2010 16:31:35 -0000 1.536 > +++ tmux.h 21 Jan 2010 07:42:18 -0000 > @@ -455,6 +455,9 @@ > MODEKEYCOPY_HALFPAGEDOWN, > MODEKEYCOPY_HALFPAGEUP, > MODEKEYCOPY_LEFT, > + MODEKEYCOPY_MARGIN_LEFT, > + MODEKEYCOPY_MARGIN_RIGHT, > + MODEKEYCOPY_MARGIN_TOGGLE, > MODEKEYCOPY_MIDDLELINE, > MODEKEYCOPY_NEXTPAGE, > MODEKEYCOPY_NEXTWORD, > @@ -672,6 +675,10 @@ > u_int ex; > u_int ey; > > + u_int block_mode; > + u_int marginl; > + u_int marginr; > + > struct grid_cell cell; > }; > > @@ -1762,7 +1769,8 @@ > void screen_set_title(struct screen *, const char *); > void screen_resize(struct screen *, u_int, u_int); > void screen_set_selection( > - struct screen *, u_int, u_int, u_int, u_int, struct grid_cell *); > + struct screen *, 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); > > Index: window-copy.c > =================================================================== > RCS file: /cvsroot/tmux/tmux/window-copy.c,v > retrieving revision 1.94 > diff -u -r1.94 window-copy.c > --- window-copy.c 4 Dec 2009 22:14:47 -0000 1.94 > +++ window-copy.c 21 Jan 2010 07:42:19 -0000 > @@ -67,6 +67,9 @@ > void window_copy_cursor_previous_word(struct window_pane *); > void window_copy_scroll_up(struct window_pane *, u_int); > void window_copy_scroll_down(struct window_pane *, u_int); > +void window_copy_margin_left(struct window_pane *); > +void window_copy_margin_right(struct window_pane *); > +void window_copy_margin_toggle(struct window_pane *); > > const struct window_mode window_copy_mode = { > window_copy_init, > @@ -94,6 +97,10 @@ > u_int selx; > u_int sely; > > + u_int block_mode; /* are we in block mode? */ > + u_int marginl; /* left margin for block copying */ > + u_int marginr; /* right margin for block copying */ > + > u_int cx; > u_int cy; > > @@ -125,6 +132,10 @@ > data->lastcx = 0; > data->lastsx = 0; > > + data->block_mode = 0; > + data->marginl = 0; > + data->marginr = 0; > + > data->inputtype = WINDOW_COPY_OFF; > data->inputprompt = NULL; > data->inputstr = xstrdup(""); > @@ -351,6 +362,15 @@ > data->inputprompt = "Goto Line"; > *data->inputstr = '\0'; > goto input_on; > + case MODEKEYCOPY_MARGIN_LEFT: > + window_copy_margin_left(wp); > + return; > + case MODEKEYCOPY_MARGIN_RIGHT: > + window_copy_margin_right(wp); > + return; > + case MODEKEYCOPY_MARGIN_TOGGLE: > + window_copy_margin_toggle(wp); > + return; > default: > break; > } > @@ -821,7 +841,8 @@ > sy = screen_hsize(s) + sy; > > screen_set_selection( > - s, sx, sy, data->cx, screen_hsize(s) + data->cy, &gc); > + s, sx, sy, data->cx, screen_hsize(s) + data->cy, > + data->block_mode, data->marginl, data->marginr, &gc); > return (1); > } > > @@ -831,8 +852,9 @@ > struct window_copy_mode_data *data = wp->modedata; > struct screen *s = &data->screen; > char *buf; > - size_t off; > - u_int i, xx, yy, sx, sy, ex, ey, limit; > + size_t off; > + u_int i, xx, yy, sx, sy, ex, ey, limit; > + u_int realsx, realex, realEx, realSx; > > if (!s->sel.flag) > return; > @@ -863,17 +885,38 @@ > if (ex > xx) > ex = xx; > > + /*** > + * Incorporate magins for block-copy if necessary; four > + * kinds: start of first line (realsx), end of last line > + * (realex), start (realSx) and end (realEx) of all other > + * lines. > + ***/ > + if( data->block_mode ) { > + realex = data->marginr < ex ? data->marginr : ex; > + realEx = data->marginr < xx ? data->marginr : xx; > + realsx = data->marginl > sx ? data->marginl : sx; > + realSx = data->marginl > 0 ? data->marginl : 0; > + } else { > + realex = ex; > + realEx = xx; > + realsx = sx; > + realSx = 0; I don't like these variable names much, maybe firstsx, firstex, lastsx, lastex? Could do with renaming the others too maybe but let's leave that for now. > + } > + > /* Copy the lines. */ > - if (sy == ey) > - window_copy_copy_line(wp, &buf, &off, sy, sx, ex); > - else { > + if (sy == ey) { > + /* Incorporate magins for block-copy if necessary */ > + window_copy_copy_line(wp, &buf, &off, sy, realsx, realex); > + } else { > xx = screen_size_x(s); > - window_copy_copy_line(wp, &buf, &off, sy, sx, xx); > + window_copy_copy_line(wp, &buf, &off, sy, realsx, realex); > + > if (ey - sy > 1) { > for (i = sy + 1; i < ey; i++) > - window_copy_copy_line(wp, &buf, &off, i, 0, xx); > + window_copy_copy_line(wp, &buf, &off, i, > + realSx, realEx); > } > - window_copy_copy_line(wp, &buf, &off, ey, 0, ex); > + window_copy_copy_line(wp, &buf, &off, ey, realSx, realex); > } > > /* Don't bother if no data. */ > @@ -1287,3 +1330,58 @@ > screen_write_cursormove(&ctx, data->cx, data->cy); > screen_write_stop(&ctx); > } > + > +void > +window_copy_margin_left(struct window_pane *wp) > +{ > + struct window_copy_mode_data *data = wp->modedata; > + > + data->block_mode = 1; > + data->marginl = data->cx; > + > + window_copy_update_selection(wp); > + window_copy_redraw_screen(wp); > +} > + > +void > +window_copy_margin_right(struct window_pane *wp) > +{ > + struct window_copy_mode_data *data = wp->modedata; > + > + data->block_mode = 1; > + data->marginr = data->cx; > + > + window_copy_update_selection(wp); > + window_copy_redraw_screen(wp); > +} > + > +void > +window_copy_margin_toggle(struct window_pane *wp) > +{ > + struct window_copy_mode_data *data = wp->modedata; > + struct screen *s = &data->screen; > + > + if (data->block_mode) { > + data->block_mode = 0; > + } else { > + data->block_mode = 1; > + /* We're switching from non-block-copy to > + * block-copy; set the margins to the x values of > + * the start and end positions. If we haven't > + * started yet, do nothing. > + */ > + if ( s->sel.flag ) { > + if( data->cx < data->selx ) { > + data->marginl = data->cx; > + data->marginr = data->selx; > + } else { > + data->marginl = data->selx; > + data->marginr = data->cx; > + } > + } > + } > + > + window_copy_update_selection(wp); > + window_copy_redraw_screen(wp); > +} > + ------------------------------------------------------------------------------ Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users