Add copy-mode-position-format to configure the position indicator.

This commit is contained in:
nicm 2024-10-05 00:32:55 +00:00
parent 41f6b691e3
commit e0638c48cd
3 changed files with 31 additions and 5 deletions

View File

@ -971,6 +971,18 @@ const struct options_table_entry options_table[] = {
.text = "Style of the marked line in copy mode."
},
{ .name = "copy-mode-position-format",
.type = OPTIONS_TABLE_STRING,
.scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE,
.default_str = "#[align=right]"
"#{t/p:top_line_time}#{?#{e|>:#{top_line_time},0}, ,}"
"[#{scroll_position}/#{history_size}]"
"#{?search_timed_out, (timed out),"
"#{?search_count, (#{search_count}"
"#{?search_count_partial,+,} results),}}",
.text = "Format of the position indicator in copy mode."
},
{ .name = "fill-character",
.type = OPTIONS_TABLE_STRING,
.scope = OPTIONS_TABLE_WINDOW,

View File

@ -567,9 +567,11 @@ screen_write_fast_copy(struct screen_write_ctx *ctx, struct screen *src,
u_int px, u_int py, u_int nx, u_int ny)
{
struct screen *s = ctx->s;
struct window_pane *wp = ctx->wp;
struct tty_ctx ttyctx;
struct grid *gd = src->grid;
struct grid_cell gc;
u_int xx, yy, cx, cy;
u_int xx, yy, cx = s->cx, cy = s->cy;
if (nx == 0 || ny == 0)
return;
@ -578,18 +580,28 @@ screen_write_fast_copy(struct screen_write_ctx *ctx, struct screen *src,
for (yy = py; yy < py + ny; yy++) {
if (yy >= gd->hsize + gd->sy)
break;
cx = s->cx;
s->cx = cx;
if (wp != NULL)
screen_write_initctx(ctx, &ttyctx, 0);
for (xx = px; xx < px + nx; xx++) {
if (xx >= grid_get_line(gd, yy)->cellsize)
break;
grid_get_cell(gd, xx, yy, &gc);
if (xx + gc.data.width > px + nx)
break;
grid_view_set_cell(ctx->s->grid, cx, cy, &gc);
cx++;
grid_view_set_cell(ctx->s->grid, s->cx, s->cy, &gc);
if (wp != NULL) {
ttyctx.cell = &gc;
tty_write(tty_cmd_cell, &ttyctx);
ttyctx.ocx++;
}
s->cx++;
}
cy++;
s->cy++;
}
s->cx = cx;
s->cy = cy;
}
/* Select character set for drawing border lines. */

2
tmux.1
View File

@ -4833,6 +4833,8 @@ see the
.Sx STYLES
section.
.Pp
.It Ic copy-mode-position-format Ar format
Format of the position indicator in copy mode.
.It Xo Ic mode-keys
.Op Ic vi | emacs
.Xc