mirror of
https://github.com/tmux/tmux.git
synced 2025-09-01 20:57:00 +00:00
Flag tabs if possible in the grid cell so they can be preserved on
copying and capture-pane. From Alexander Arch in GitHub issue 4201.
This commit is contained in:
27
input.c
27
input.c
@ -1213,6 +1213,10 @@ input_c0_dispatch(struct input_ctx *ictx)
|
||||
struct screen_write_ctx *sctx = &ictx->ctx;
|
||||
struct window_pane *wp = ictx->wp;
|
||||
struct screen *s = sctx->s;
|
||||
struct grid_cell gc, first_gc;
|
||||
u_int cx = s->cx, line = s->cy + s->grid->hsize;
|
||||
u_int width;
|
||||
int has_content = 0;
|
||||
|
||||
ictx->utf8started = 0; /* can't be valid UTF-8 */
|
||||
|
||||
@ -1234,11 +1238,28 @@ input_c0_dispatch(struct input_ctx *ictx)
|
||||
break;
|
||||
|
||||
/* Find the next tab point, or use the last column if none. */
|
||||
grid_get_cell(s->grid, s->cx, line, &first_gc);
|
||||
do {
|
||||
s->cx++;
|
||||
if (bit_test(s->tabs, s->cx))
|
||||
if (!has_content) {
|
||||
grid_get_cell(s->grid, cx, line, &gc);
|
||||
if (gc.data.size != 1 ||
|
||||
*gc.data.data != ' ' ||
|
||||
!grid_cells_look_equal(&gc, &first_gc))
|
||||
has_content = 1;
|
||||
}
|
||||
cx++;
|
||||
if (bit_test(s->tabs, cx))
|
||||
break;
|
||||
} while (s->cx < screen_size_x(s) - 1);
|
||||
} while (cx < screen_size_x(s) - 1);
|
||||
|
||||
width = cx - s->cx;
|
||||
if (has_content || width > sizeof gc.data.data)
|
||||
s->cx = cx;
|
||||
else {
|
||||
grid_get_cell(s->grid, s->cx, line, &gc);
|
||||
grid_set_tab(&gc, width);
|
||||
screen_write_collect_add(sctx, &gc);
|
||||
}
|
||||
break;
|
||||
case '\012': /* LF */
|
||||
case '\013': /* VT */
|
||||
|
Reference in New Issue
Block a user