From e8f2609ca445b09b04cb131059e5b71c3a40f451 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 8 Mar 2017 20:05:25 +0000 Subject: [PATCH] Skip over padding cells when moving the cursor left or right. --- window-copy.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/window-copy.c b/window-copy.c index bf7dae56..e50db0a1 100644 --- a/window-copy.c +++ b/window-copy.c @@ -1921,14 +1921,22 @@ static void window_copy_cursor_left(struct window_pane *wp) { struct window_copy_mode_data *data = wp->modedata; - u_int py; + u_int py, cx; + struct grid_cell gc; py = screen_hsize(data->backing) + data->cy - data->oy; - if (data->cx == 0 && py > 0) { + cx = data->cx; + while (cx > 0) { + grid_get_cell(data->backing->grid, cx, py, &gc); + if (~gc.flags & GRID_FLAG_PADDING) + break; + cx--; + } + if (cx == 0 && py > 0) { window_copy_cursor_up(wp, 0); window_copy_cursor_end_of_line(wp); - } else if (data->cx > 0) { - window_copy_update_cursor(wp, data->cx - 1, data->cy); + } else if (cx > 0) { + window_copy_update_cursor(wp, cx - 1, data->cy); if (window_copy_update_selection(wp, 1)) window_copy_redraw_lines(wp, data->cy, 1); } @@ -1938,21 +1946,29 @@ static void window_copy_cursor_right(struct window_pane *wp) { struct window_copy_mode_data *data = wp->modedata; - u_int px, py, yy; + u_int px, py, yy, cx, cy; + struct grid_cell gc; py = screen_hsize(data->backing) + data->cy - data->oy; yy = screen_hsize(data->backing) + screen_size_y(data->backing) - 1; if (data->screen.sel.flag && data->rectflag) px = screen_size_x(&data->screen); - else { + else px = window_copy_find_length(wp, py); - } if (data->cx >= px && py < yy) { window_copy_cursor_start_of_line(wp); window_copy_cursor_down(wp, 0); } else if (data->cx < px) { - window_copy_update_cursor(wp, data->cx + 1, data->cy); + cx = data->cx + 1; + cy = screen_hsize(data->backing) + data->cy - data->oy; + while (cx < px) { + grid_get_cell(data->backing->grid, cx, cy, &gc); + if (~gc.flags & GRID_FLAG_PADDING) + break; + cx++; + } + window_copy_update_cursor(wp, cx, data->cy); if (window_copy_update_selection(wp, 1)) window_copy_redraw_lines(wp, data->cy, 1); }