mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-23 08:33:17 +01:00
Correctly redraw the top two lines in copy mode when they are selected -
the selection was being updated before the redraw so the markings were lost. Based on a fix from J Raynor.
This commit is contained in:
parent
7fa55b0419
commit
a6cd84869e
@ -51,7 +51,7 @@ void window_copy_search_down(struct window_pane *, const char *);
|
||||
void window_copy_goto_line(struct window_pane *, const char *);
|
||||
void window_copy_update_cursor(struct window_pane *, u_int, u_int);
|
||||
void window_copy_start_selection(struct window_pane *);
|
||||
int window_copy_update_selection(struct window_pane *);
|
||||
int window_copy_update_selection(struct window_pane *, int);
|
||||
void *window_copy_get_selection(struct window_pane *, size_t *);
|
||||
void window_copy_copy_buffer(struct window_pane *, int, void *, size_t);
|
||||
void window_copy_copy_pipe(
|
||||
@ -329,7 +329,7 @@ window_copy_pageup(struct window_pane *wp)
|
||||
data->oy = screen_hsize(data->backing);
|
||||
else
|
||||
data->oy += n;
|
||||
window_copy_update_selection(wp);
|
||||
window_copy_update_selection(wp, 1);
|
||||
window_copy_redraw_screen(wp);
|
||||
}
|
||||
|
||||
@ -458,7 +458,7 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key)
|
||||
else
|
||||
data->oy -= n;
|
||||
}
|
||||
window_copy_update_selection(wp);
|
||||
window_copy_update_selection(wp, 1);
|
||||
window_copy_redraw_screen(wp);
|
||||
break;
|
||||
case MODEKEYCOPY_HALFPAGEUP:
|
||||
@ -469,7 +469,7 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key)
|
||||
else
|
||||
data->oy += n;
|
||||
}
|
||||
window_copy_update_selection(wp);
|
||||
window_copy_update_selection(wp, 1);
|
||||
window_copy_redraw_screen(wp);
|
||||
break;
|
||||
case MODEKEYCOPY_HALFPAGEDOWN:
|
||||
@ -480,39 +480,39 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key)
|
||||
else
|
||||
data->oy -= n;
|
||||
}
|
||||
window_copy_update_selection(wp);
|
||||
window_copy_update_selection(wp, 1);
|
||||
window_copy_redraw_screen(wp);
|
||||
break;
|
||||
case MODEKEYCOPY_TOPLINE:
|
||||
data->cx = 0;
|
||||
data->cy = 0;
|
||||
window_copy_update_selection(wp);
|
||||
window_copy_update_selection(wp, 1);
|
||||
window_copy_redraw_screen(wp);
|
||||
break;
|
||||
case MODEKEYCOPY_MIDDLELINE:
|
||||
data->cx = 0;
|
||||
data->cy = (screen_size_y(s) - 1) / 2;
|
||||
window_copy_update_selection(wp);
|
||||
window_copy_update_selection(wp, 1);
|
||||
window_copy_redraw_screen(wp);
|
||||
break;
|
||||
case MODEKEYCOPY_BOTTOMLINE:
|
||||
data->cx = 0;
|
||||
data->cy = screen_size_y(s) - 1;
|
||||
window_copy_update_selection(wp);
|
||||
window_copy_update_selection(wp, 1);
|
||||
window_copy_redraw_screen(wp);
|
||||
break;
|
||||
case MODEKEYCOPY_HISTORYTOP:
|
||||
data->cx = 0;
|
||||
data->cy = 0;
|
||||
data->oy = screen_hsize(data->backing);
|
||||
window_copy_update_selection(wp);
|
||||
window_copy_update_selection(wp, 1);
|
||||
window_copy_redraw_screen(wp);
|
||||
break;
|
||||
case MODEKEYCOPY_HISTORYBOTTOM:
|
||||
data->cx = 0;
|
||||
data->cy = screen_size_y(s) - 1;
|
||||
data->oy = 0;
|
||||
window_copy_update_selection(wp);
|
||||
window_copy_update_selection(wp, 1);
|
||||
window_copy_redraw_screen(wp);
|
||||
break;
|
||||
case MODEKEYCOPY_STARTSELECTION:
|
||||
@ -865,7 +865,7 @@ window_copy_mouse(
|
||||
if (s->mode & MODE_MOUSE_BUTTON) {
|
||||
if (~m->event & MOUSE_EVENT_UP) {
|
||||
window_copy_update_cursor(wp, m->x, m->y);
|
||||
if (window_copy_update_selection(wp))
|
||||
if (window_copy_update_selection(wp, 1))
|
||||
window_copy_redraw_screen(wp);
|
||||
return;
|
||||
}
|
||||
@ -915,7 +915,7 @@ window_copy_scroll_to(struct window_pane *wp, u_int px, u_int py)
|
||||
}
|
||||
data->oy = gd->hsize - offset;
|
||||
|
||||
window_copy_update_selection(wp);
|
||||
window_copy_update_selection(wp, 1);
|
||||
window_copy_redraw_screen(wp);
|
||||
}
|
||||
|
||||
@ -1108,7 +1108,7 @@ window_copy_goto_line(struct window_pane *wp, const char *linestr)
|
||||
return;
|
||||
|
||||
data->oy = lineno;
|
||||
window_copy_update_selection(wp);
|
||||
window_copy_update_selection(wp, 1);
|
||||
window_copy_redraw_screen(wp);
|
||||
}
|
||||
|
||||
@ -1221,11 +1221,11 @@ window_copy_start_selection(struct window_pane *wp)
|
||||
data->sely = screen_hsize(data->backing) + data->cy - data->oy;
|
||||
|
||||
s->sel.flag = 1;
|
||||
window_copy_update_selection(wp);
|
||||
window_copy_update_selection(wp, 1);
|
||||
}
|
||||
|
||||
int
|
||||
window_copy_update_selection(struct window_pane *wp)
|
||||
window_copy_update_selection(struct window_pane *wp, int may_redraw)
|
||||
{
|
||||
struct window_copy_mode_data *data = wp->modedata;
|
||||
struct screen *s = &data->screen;
|
||||
@ -1260,7 +1260,7 @@ window_copy_update_selection(struct window_pane *wp)
|
||||
screen_set_selection(s,
|
||||
sx, sy, data->cx, screen_hsize(s) + data->cy, data->rectflag, &gc);
|
||||
|
||||
if (data->rectflag) {
|
||||
if (data->rectflag && may_redraw) {
|
||||
/*
|
||||
* Can't rely on the caller to redraw the right lines for
|
||||
* rectangle selection - find the highest line and the number
|
||||
@ -1564,7 +1564,7 @@ window_copy_cursor_start_of_line(struct window_pane *wp)
|
||||
}
|
||||
}
|
||||
window_copy_update_cursor(wp, 0, data->cy);
|
||||
if (window_copy_update_selection(wp))
|
||||
if (window_copy_update_selection(wp, 1))
|
||||
window_copy_redraw_lines(wp, data->cy, 1);
|
||||
}
|
||||
|
||||
@ -1589,7 +1589,7 @@ window_copy_cursor_back_to_indentation(struct window_pane *wp)
|
||||
}
|
||||
|
||||
window_copy_update_cursor(wp, px, data->cy);
|
||||
if (window_copy_update_selection(wp))
|
||||
if (window_copy_update_selection(wp, 1))
|
||||
window_copy_redraw_lines(wp, data->cy, 1);
|
||||
}
|
||||
|
||||
@ -1619,7 +1619,7 @@ window_copy_cursor_end_of_line(struct window_pane *wp)
|
||||
}
|
||||
window_copy_update_cursor(wp, px, data->cy);
|
||||
|
||||
if (window_copy_update_selection(wp))
|
||||
if (window_copy_update_selection(wp, 1))
|
||||
window_copy_redraw_lines(wp, data->cy, 1);
|
||||
}
|
||||
|
||||
@ -1666,7 +1666,7 @@ window_copy_cursor_left(struct window_pane *wp)
|
||||
window_copy_cursor_end_of_line(wp);
|
||||
} else {
|
||||
window_copy_update_cursor(wp, data->cx - 1, data->cy);
|
||||
if (window_copy_update_selection(wp))
|
||||
if (window_copy_update_selection(wp, 1))
|
||||
window_copy_redraw_lines(wp, data->cy, 1);
|
||||
}
|
||||
}
|
||||
@ -1689,7 +1689,7 @@ window_copy_cursor_right(struct window_pane *wp)
|
||||
window_copy_cursor_down(wp, 0);
|
||||
} else {
|
||||
window_copy_update_cursor(wp, data->cx + 1, data->cy);
|
||||
if (window_copy_update_selection(wp))
|
||||
if (window_copy_update_selection(wp, 1))
|
||||
window_copy_redraw_lines(wp, data->cy, 1);
|
||||
}
|
||||
}
|
||||
@ -1719,7 +1719,7 @@ window_copy_cursor_up(struct window_pane *wp, int scroll_only)
|
||||
}
|
||||
} else {
|
||||
window_copy_update_cursor(wp, data->cx, data->cy - 1);
|
||||
if (window_copy_update_selection(wp)) {
|
||||
if (window_copy_update_selection(wp, 1)) {
|
||||
if (data->cy == screen_size_y(s) - 1)
|
||||
window_copy_redraw_lines(wp, data->cy, 1);
|
||||
else
|
||||
@ -1757,7 +1757,7 @@ window_copy_cursor_down(struct window_pane *wp, int scroll_only)
|
||||
window_copy_redraw_lines(wp, data->cy - 1, 2);
|
||||
} else {
|
||||
window_copy_update_cursor(wp, data->cx, data->cy + 1);
|
||||
if (window_copy_update_selection(wp))
|
||||
if (window_copy_update_selection(wp, 1))
|
||||
window_copy_redraw_lines(wp, data->cy - 1, 2);
|
||||
}
|
||||
|
||||
@ -1789,7 +1789,7 @@ window_copy_cursor_jump(struct window_pane *wp)
|
||||
if (!(gc->flags & GRID_FLAG_PADDING) &&
|
||||
ud.size == 1 && *ud.data == data->jumpchar) {
|
||||
window_copy_update_cursor(wp, px, data->cy);
|
||||
if (window_copy_update_selection(wp))
|
||||
if (window_copy_update_selection(wp, 1))
|
||||
window_copy_redraw_lines(wp, data->cy, 1);
|
||||
return;
|
||||
}
|
||||
@ -1818,7 +1818,7 @@ window_copy_cursor_jump_back(struct window_pane *wp)
|
||||
if (!(gc->flags & GRID_FLAG_PADDING) &&
|
||||
ud.size == 1 && *ud.data == data->jumpchar) {
|
||||
window_copy_update_cursor(wp, px, data->cy);
|
||||
if (window_copy_update_selection(wp))
|
||||
if (window_copy_update_selection(wp, 1))
|
||||
window_copy_redraw_lines(wp, data->cy, 1);
|
||||
return;
|
||||
}
|
||||
@ -1847,7 +1847,7 @@ window_copy_cursor_jump_to(struct window_pane *wp)
|
||||
if (!(gc->flags & GRID_FLAG_PADDING) &&
|
||||
ud.size == 1 && *ud.data == data->jumpchar) {
|
||||
window_copy_update_cursor(wp, px - 1, data->cy);
|
||||
if (window_copy_update_selection(wp))
|
||||
if (window_copy_update_selection(wp, 1))
|
||||
window_copy_redraw_lines(wp, data->cy, 1);
|
||||
return;
|
||||
}
|
||||
@ -1876,7 +1876,7 @@ window_copy_cursor_jump_to_back(struct window_pane *wp)
|
||||
if (!(gc->flags & GRID_FLAG_PADDING) &&
|
||||
ud.size == 1 && *ud.data == data->jumpchar) {
|
||||
window_copy_update_cursor(wp, px + 1, data->cy);
|
||||
if (window_copy_update_selection(wp))
|
||||
if (window_copy_update_selection(wp, 1))
|
||||
window_copy_redraw_lines(wp, data->cy, 1);
|
||||
return;
|
||||
}
|
||||
@ -1924,7 +1924,7 @@ window_copy_cursor_next_word(struct window_pane *wp, const char *separators)
|
||||
} while (expected == 1);
|
||||
|
||||
window_copy_update_cursor(wp, px, data->cy);
|
||||
if (window_copy_update_selection(wp))
|
||||
if (window_copy_update_selection(wp, 1))
|
||||
window_copy_redraw_lines(wp, data->cy, 1);
|
||||
}
|
||||
|
||||
@ -1974,7 +1974,7 @@ window_copy_cursor_next_word_end(struct window_pane *wp, const char *separators)
|
||||
px--;
|
||||
|
||||
window_copy_update_cursor(wp, px, data->cy);
|
||||
if (window_copy_update_selection(wp))
|
||||
if (window_copy_update_selection(wp, 1))
|
||||
window_copy_redraw_lines(wp, data->cy, 1);
|
||||
}
|
||||
|
||||
@ -2012,7 +2012,7 @@ window_copy_cursor_previous_word(struct window_pane *wp, const char *separators)
|
||||
|
||||
out:
|
||||
window_copy_update_cursor(wp, px, data->cy);
|
||||
if (window_copy_update_selection(wp))
|
||||
if (window_copy_update_selection(wp, 1))
|
||||
window_copy_redraw_lines(wp, data->cy, 1);
|
||||
}
|
||||
|
||||
@ -2029,6 +2029,8 @@ window_copy_scroll_up(struct window_pane *wp, u_int ny)
|
||||
return;
|
||||
data->oy -= ny;
|
||||
|
||||
window_copy_update_selection(wp, 0);
|
||||
|
||||
screen_write_start(&ctx, wp, NULL);
|
||||
screen_write_cursormove(&ctx, 0, 0);
|
||||
screen_write_deleteline(&ctx, ny);
|
||||
@ -2038,12 +2040,9 @@ window_copy_scroll_up(struct window_pane *wp, u_int ny)
|
||||
window_copy_write_line(wp, &ctx, 1);
|
||||
if (screen_size_y(s) > 3)
|
||||
window_copy_write_line(wp, &ctx, screen_size_y(s) - 2);
|
||||
if (s->sel.flag && screen_size_y(s) > ny) {
|
||||
window_copy_update_selection(wp);
|
||||
if (s->sel.flag && screen_size_y(s) > ny)
|
||||
window_copy_write_line(wp, &ctx, screen_size_y(s) - ny - 1);
|
||||
}
|
||||
screen_write_cursormove(&ctx, data->cx, data->cy);
|
||||
window_copy_update_selection(wp);
|
||||
screen_write_stop(&ctx);
|
||||
}
|
||||
|
||||
@ -2063,17 +2062,17 @@ window_copy_scroll_down(struct window_pane *wp, u_int ny)
|
||||
return;
|
||||
data->oy += ny;
|
||||
|
||||
window_copy_update_selection(wp, 0);
|
||||
|
||||
screen_write_start(&ctx, wp, NULL);
|
||||
screen_write_cursormove(&ctx, 0, 0);
|
||||
screen_write_insertline(&ctx, ny);
|
||||
window_copy_write_lines(wp, &ctx, 0, ny);
|
||||
if (s->sel.flag && screen_size_y(s) > ny) {
|
||||
window_copy_update_selection(wp);
|
||||
if (s->sel.flag && screen_size_y(s) > ny)
|
||||
window_copy_write_line(wp, &ctx, ny);
|
||||
} else if (ny == 1) /* nuke position */
|
||||
else if (ny == 1) /* nuke position */
|
||||
window_copy_write_line(wp, &ctx, 1);
|
||||
screen_write_cursormove(&ctx, data->cx, data->cy);
|
||||
window_copy_update_selection(wp);
|
||||
screen_write_stop(&ctx);
|
||||
}
|
||||
|
||||
@ -2090,6 +2089,6 @@ window_copy_rectangle_toggle(struct window_pane *wp)
|
||||
if (data->cx > px)
|
||||
window_copy_update_cursor(wp, px, data->cy);
|
||||
|
||||
window_copy_update_selection(wp);
|
||||
window_copy_update_selection(wp, 1);
|
||||
window_copy_redraw_screen(wp);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user