diff options
author | nicm <nicm> | 2013-10-23 11:31:03 +0000 |
---|---|---|
committer | nicm <nicm> | 2013-10-23 11:31:03 +0000 |
commit | 7fa55b0419b88b5568bb2fd99dd0de9fba80ac61 (patch) | |
tree | 51b8033e60bcb62452c5ff522459ac36cb526d6c /window-copy.c | |
parent | bf35441608b05d52627215aa70bd52d9460812d4 (diff) |
Key to swap to other end of selection (bound to o with vi keys), from J
Raynor.
Diffstat (limited to 'window-copy.c')
-rw-r--r-- | window-copy.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/window-copy.c b/window-copy.c index 7a647c51..275909cd 100644 --- a/window-copy.c +++ b/window-copy.c @@ -65,6 +65,7 @@ u_int window_copy_find_length(struct window_pane *, u_int); void window_copy_cursor_start_of_line(struct window_pane *); void window_copy_cursor_back_to_indentation(struct window_pane *); void window_copy_cursor_end_of_line(struct window_pane *); +void window_copy_other_end(struct window_pane *); void window_copy_cursor_left(struct window_pane *); void window_copy_cursor_right(struct window_pane *); void window_copy_cursor_up(struct window_pane *, int); @@ -415,6 +416,10 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key) case MODEKEYCOPY_CANCEL: window_pane_reset_mode(wp); return; + case MODEKEYCOPY_OTHEREND: + for (; np != 0; np--) + window_copy_other_end(wp); + break; case MODEKEYCOPY_LEFT: for (; np != 0; np--) window_copy_cursor_left(wp); @@ -1619,6 +1624,39 @@ window_copy_cursor_end_of_line(struct window_pane *wp) } void +window_copy_other_end(struct window_pane *wp) +{ + struct window_copy_mode_data *data = wp->modedata; + struct screen *s = &data->screen; + u_int selx, sely, cx, cy, yy; + + if (!s->sel.flag) + return; + + selx = data->selx; + sely = data->sely; + cx = data->cx; + cy = data->cy; + yy = screen_hsize(data->backing) + data->cy - data->oy; + + data->selx = cx; + data->sely = yy; + data->cx = selx; + + if (sely < screen_hsize(data->backing) - data->oy) { + data->oy = screen_hsize(data->backing) - sely; + data->cy = 0; + } else if (sely > screen_hsize(data->backing) - data->oy + screen_size_y(s)) { + data->oy = screen_hsize(data->backing) - sely + screen_size_y(s) - 1; + data->cy = screen_size_y(s) - 1; + + } else + data->cy = cy + sely - yy; + + window_copy_redraw_screen(wp); +} + +void window_copy_cursor_left(struct window_pane *wp) { struct window_copy_mode_data *data = wp->modedata; |