From 837ca176d1874273f3de615c75b506e1b1787a1b Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 13 Oct 2021 09:28:36 +0000 Subject: Add popup-style and popup-border-style options, from Alexis Hildebrandt in GitHub issue 2927. --- screen-write.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'screen-write.c') diff --git a/screen-write.c b/screen-write.c index c09d09ab..e3b2b977 100644 --- a/screen-write.c +++ b/screen-write.c @@ -645,7 +645,7 @@ screen_write_menu(struct screen_write_ctx *ctx, struct menu *menu, memcpy(&default_gc, &grid_default_cell, sizeof default_gc); - screen_write_box(ctx, menu->width + 4, menu->count + 2); + screen_write_box(ctx, menu->width + 4, menu->count + 2, NULL); screen_write_cursormove(ctx, cx + 2, cy, 0); format_draw(ctx, &default_gc, menu->width, menu->title, NULL); @@ -677,16 +677,20 @@ screen_write_menu(struct screen_write_ctx *ctx, struct menu *menu, /* Draw a box on screen. */ void -screen_write_box(struct screen_write_ctx *ctx, u_int nx, u_int ny) +screen_write_box(struct screen_write_ctx *ctx, u_int nx, u_int ny, + const struct grid_cell *gcp) { struct screen *s = ctx->s; - struct grid_cell gc; + struct grid_cell gc; u_int cx, cy, i; cx = s->cx; cy = s->cy; - memcpy(&gc, &grid_default_cell, sizeof gc); + if (gcp != NULL) + memcpy(&gc, gcp, sizeof gc); + else + memcpy(&gc, &grid_default_cell, sizeof gc); gc.attr |= GRID_ATTR_CHARSET; gc.flags |= GRID_FLAG_NOPALETTE; -- cgit From add20637f256c0118d3c687d5d1446612d14389a Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 14 Oct 2021 13:19:01 +0000 Subject: Add popup-border-lines option to set popup line style, from Alexis Hildebrandt, GitHub issue 2930. --- screen-write.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 12 deletions(-) (limited to 'screen-write.c') diff --git a/screen-write.c b/screen-write.c index e3b2b977..3cd0fb55 100644 --- a/screen-write.c +++ b/screen-write.c @@ -645,7 +645,8 @@ screen_write_menu(struct screen_write_ctx *ctx, struct menu *menu, memcpy(&default_gc, &grid_default_cell, sizeof default_gc); - screen_write_box(ctx, menu->width + 4, menu->count + 2, NULL); + screen_write_box(ctx, menu->width + 4, menu->count + 2, + BOX_LINES_DEFAULT, NULL); screen_write_cursormove(ctx, cx + 2, cy, 0); format_draw(ctx, &default_gc, menu->width, menu->title, NULL); @@ -675,10 +676,45 @@ screen_write_menu(struct screen_write_ctx *ctx, struct menu *menu, screen_write_set_cursor(ctx, cx, cy); } +static void +screen_write_box_border_set(enum box_lines box_lines, int cell_type, + struct grid_cell *gc) +{ + switch (box_lines) { + case BOX_LINES_NONE: + break; + case BOX_LINES_DOUBLE: + gc->attr &= ~GRID_ATTR_CHARSET; + utf8_copy(&gc->data, tty_acs_double_borders(cell_type)); + break; + case BOX_LINES_HEAVY: + gc->attr &= ~GRID_ATTR_CHARSET; + utf8_copy(&gc->data, tty_acs_heavy_borders(cell_type)); + break; + case BOX_LINES_ROUNDED: + gc->attr &= ~GRID_ATTR_CHARSET; + utf8_copy(&gc->data, tty_acs_rounded_borders(cell_type)); + break; + case BOX_LINES_SIMPLE: + gc->attr &= ~GRID_ATTR_CHARSET; + utf8_set(&gc->data, SIMPLE_BORDERS[cell_type]); + break; + case BOX_LINES_PADDED: + gc->attr &= ~GRID_ATTR_CHARSET; + utf8_set(&gc->data, PADDED_BORDERS[cell_type]); + break; + case BOX_LINES_SINGLE: + case BOX_LINES_DEFAULT: + gc->attr |= GRID_ATTR_CHARSET; + utf8_set(&gc->data, CELL_BORDERS[cell_type]); + break; + } +} + /* Draw a box on screen. */ void screen_write_box(struct screen_write_ctx *ctx, u_int nx, u_int ny, - const struct grid_cell *gcp) + enum box_lines l, const struct grid_cell *gcp) { struct screen *s = ctx->s; struct grid_cell gc; @@ -694,24 +730,34 @@ screen_write_box(struct screen_write_ctx *ctx, u_int nx, u_int ny, gc.attr |= GRID_ATTR_CHARSET; gc.flags |= GRID_FLAG_NOPALETTE; - screen_write_putc(ctx, &gc, 'l'); + /* Draw top border */ + screen_write_box_border_set(l, CELL_TOPLEFT, &gc); + screen_write_cell(ctx, &gc); + screen_write_box_border_set(l, CELL_LEFTRIGHT, &gc); for (i = 1; i < nx - 1; i++) - screen_write_putc(ctx, &gc, 'q'); - screen_write_putc(ctx, &gc, 'k'); + screen_write_cell(ctx, &gc); + screen_write_box_border_set(l, CELL_TOPRIGHT, &gc); + screen_write_cell(ctx, &gc); + /* Draw bottom border */ screen_write_set_cursor(ctx, cx, cy + ny - 1); - screen_write_putc(ctx, &gc, 'm'); + screen_write_box_border_set(l, CELL_BOTTOMLEFT, &gc); + screen_write_cell(ctx, &gc); + screen_write_box_border_set(l, CELL_LEFTRIGHT, &gc); for (i = 1; i < nx - 1; i++) - screen_write_putc(ctx, &gc, 'q'); - screen_write_putc(ctx, &gc, 'j'); + screen_write_cell(ctx, &gc); + screen_write_box_border_set(l, CELL_BOTTOMRIGHT, &gc); + screen_write_cell(ctx, &gc); + /* Draw sides */ + screen_write_box_border_set(l, CELL_TOPBOTTOM, &gc); for (i = 1; i < ny - 1; i++) { + /* left side */ screen_write_set_cursor(ctx, cx, cy + i); - screen_write_putc(ctx, &gc, 'x'); - } - for (i = 1; i < ny - 1; i++) { + screen_write_cell(ctx, &gc); + /* right side */ screen_write_set_cursor(ctx, cx + nx - 1, cy + i); - screen_write_putc(ctx, &gc, 'x'); + screen_write_cell(ctx, &gc); } screen_write_set_cursor(ctx, cx, cy); -- cgit From 8a9bfd0cddd783436e842495fc3039aa56571ed1 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 20 Oct 2021 09:50:40 +0000 Subject: Add -T to set a popup title, from Alexis Hildebrandt in GitHub issue 2941. --- screen-write.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'screen-write.c') diff --git a/screen-write.c b/screen-write.c index 3cd0fb55..e2904ef6 100644 --- a/screen-write.c +++ b/screen-write.c @@ -646,9 +646,7 @@ screen_write_menu(struct screen_write_ctx *ctx, struct menu *menu, memcpy(&default_gc, &grid_default_cell, sizeof default_gc); screen_write_box(ctx, menu->width + 4, menu->count + 2, - BOX_LINES_DEFAULT, NULL); - screen_write_cursormove(ctx, cx + 2, cy, 0); - format_draw(ctx, &default_gc, menu->width, menu->title, NULL); + BOX_LINES_DEFAULT, &default_gc, menu->title); for (i = 0; i < menu->count; i++) { name = menu->items[i].name; @@ -714,7 +712,7 @@ screen_write_box_border_set(enum box_lines box_lines, int cell_type, /* Draw a box on screen. */ void screen_write_box(struct screen_write_ctx *ctx, u_int nx, u_int ny, - enum box_lines l, const struct grid_cell *gcp) + enum box_lines lines, const struct grid_cell *gcp, const char *title) { struct screen *s = ctx->s; struct grid_cell gc; @@ -727,30 +725,31 @@ screen_write_box(struct screen_write_ctx *ctx, u_int nx, u_int ny, memcpy(&gc, gcp, sizeof gc); else memcpy(&gc, &grid_default_cell, sizeof gc); + gc.attr |= GRID_ATTR_CHARSET; gc.flags |= GRID_FLAG_NOPALETTE; /* Draw top border */ - screen_write_box_border_set(l, CELL_TOPLEFT, &gc); + screen_write_box_border_set(lines, CELL_TOPLEFT, &gc); screen_write_cell(ctx, &gc); - screen_write_box_border_set(l, CELL_LEFTRIGHT, &gc); + screen_write_box_border_set(lines, CELL_LEFTRIGHT, &gc); for (i = 1; i < nx - 1; i++) screen_write_cell(ctx, &gc); - screen_write_box_border_set(l, CELL_TOPRIGHT, &gc); + screen_write_box_border_set(lines, CELL_TOPRIGHT, &gc); screen_write_cell(ctx, &gc); /* Draw bottom border */ screen_write_set_cursor(ctx, cx, cy + ny - 1); - screen_write_box_border_set(l, CELL_BOTTOMLEFT, &gc); + screen_write_box_border_set(lines, CELL_BOTTOMLEFT, &gc); screen_write_cell(ctx, &gc); - screen_write_box_border_set(l, CELL_LEFTRIGHT, &gc); + screen_write_box_border_set(lines, CELL_LEFTRIGHT, &gc); for (i = 1; i < nx - 1; i++) screen_write_cell(ctx, &gc); - screen_write_box_border_set(l, CELL_BOTTOMRIGHT, &gc); + screen_write_box_border_set(lines, CELL_BOTTOMRIGHT, &gc); screen_write_cell(ctx, &gc); /* Draw sides */ - screen_write_box_border_set(l, CELL_TOPBOTTOM, &gc); + screen_write_box_border_set(lines, CELL_TOPBOTTOM, &gc); for (i = 1; i < ny - 1; i++) { /* left side */ screen_write_set_cursor(ctx, cx, cy + i); @@ -760,6 +759,12 @@ screen_write_box(struct screen_write_ctx *ctx, u_int nx, u_int ny, screen_write_cell(ctx, &gc); } + if (title != NULL) { + gc.attr &= ~GRID_ATTR_CHARSET; + screen_write_cursormove(ctx, cx + 2, cy, 0); + format_draw(ctx, &gc, nx - 4, title, NULL); + } + screen_write_set_cursor(ctx, cx, cy); } -- cgit From 0cca695d6e75426e295e03668a4ed35ee62afe7c Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 25 Oct 2021 09:22:17 +0000 Subject: Instead of setting the popup default colours in the draw callback, set it up in popup_display and follow the same routine as panes in the draw and init_ctx callbacks - use the palette if the option value is default. Allows application-set fg and bg to work in panes again. --- screen-write.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'screen-write.c') diff --git a/screen-write.c b/screen-write.c index e2904ef6..251ca823 100644 --- a/screen-write.c +++ b/screen-write.c @@ -184,8 +184,10 @@ screen_write_initctx(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx, if (ctx->init_ctx_cb != NULL) { ctx->init_ctx_cb(ctx, ttyctx); if (ttyctx->palette != NULL) { - ttyctx->defaults.fg = ttyctx->palette->fg; - ttyctx->defaults.bg = ttyctx->palette->bg; + if (COLOUR_DEFAULT(ttyctx->defaults.fg)) + ttyctx->defaults.fg = ttyctx->palette->fg; + if (COLOUR_DEFAULT(ttyctx->defaults.bg)) + ttyctx->defaults.bg = ttyctx->palette->bg; } } else { ttyctx->redraw_cb = screen_write_redraw_cb; -- cgit From ef46eb91a5e0b6e2b023544f45dbc98c8fe1377f Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 25 Oct 2021 09:38:36 +0000 Subject: Add -s and -S to display-popup to set popup and border style, from Alexis Hildebrandt in GitHub issue 2931. --- screen-write.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'screen-write.c') diff --git a/screen-write.c b/screen-write.c index 251ca823..cead12d4 100644 --- a/screen-write.c +++ b/screen-write.c @@ -184,9 +184,9 @@ screen_write_initctx(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx, if (ctx->init_ctx_cb != NULL) { ctx->init_ctx_cb(ctx, ttyctx); if (ttyctx->palette != NULL) { - if (COLOUR_DEFAULT(ttyctx->defaults.fg)) + if (ttyctx->defaults.fg == 8) ttyctx->defaults.fg = ttyctx->palette->fg; - if (COLOUR_DEFAULT(ttyctx->defaults.bg)) + if (ttyctx->defaults.bg == 8) ttyctx->defaults.bg = ttyctx->palette->bg; } } else { -- cgit From 5745bd27fdfd0e806fb3f734966f66f302c76c48 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 26 Oct 2021 12:22:23 +0000 Subject: Do not allow inline styles to replace mode-style for the selected item, from Alexis Hildebrandt in GitHub issue 2946. --- screen-write.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'screen-write.c') diff --git a/screen-write.c b/screen-write.c index cead12d4..0d70f668 100644 --- a/screen-write.c +++ b/screen-write.c @@ -665,10 +665,12 @@ screen_write_menu(struct screen_write_ctx *ctx, struct menu *menu, if (*name == '-') { name++; default_gc.attr |= GRID_ATTR_DIM; - format_draw(ctx, gc, menu->width, name, NULL); + format_draw(ctx, gc, menu->width, name, NULL, + 0); default_gc.attr &= ~GRID_ATTR_DIM; } else - format_draw(ctx, gc, menu->width, name, NULL); + format_draw(ctx, gc, menu->width, name, NULL, + gc == choice_gc); gc = &default_gc; } } @@ -764,7 +766,7 @@ screen_write_box(struct screen_write_ctx *ctx, u_int nx, u_int ny, if (title != NULL) { gc.attr &= ~GRID_ATTR_CHARSET; screen_write_cursormove(ctx, cx + 2, cy, 0); - format_draw(ctx, &gc, nx - 4, title, NULL); + format_draw(ctx, &gc, nx - 4, title, NULL, 0); } screen_write_set_cursor(ctx, cx, cy); -- cgit From 10d689e7354f789f951016f7f4d57a0c2d14e124 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 17 Mar 2022 11:35:37 +0000 Subject: Add an option (scroll-on-clear) to control if tmux scrolls into history on clear, from Robert Lange in GitHub issue 3121. --- screen-write.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'screen-write.c') diff --git a/screen-write.c b/screen-write.c index 0d70f668..aa898f78 100644 --- a/screen-write.c +++ b/screen-write.c @@ -1427,7 +1427,11 @@ screen_write_clearendofscreen(struct screen_write_ctx *ctx, u_int bg) ttyctx.bg = bg; /* Scroll into history if it is enabled and clearing entire screen. */ - if (s->cx == 0 && s->cy == 0 && (gd->flags & GRID_HISTORY)) + if (s->cx == 0 && + s->cy == 0 && + (gd->flags & GRID_HISTORY) && + ctx->wp != NULL && + options_get_number(ctx->wp->options, "scroll-on-clear")) grid_view_clear_history(gd, bg); else { if (s->cx <= sx - 1) -- cgit From 6a1706a62fb2442326cd37d84ff8b0d39bf0b7a6 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 17 Mar 2022 13:39:13 +0000 Subject: Check scroll-on-clear for ED also. --- screen-write.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'screen-write.c') diff --git a/screen-write.c b/screen-write.c index aa898f78..6b6a750e 100644 --- a/screen-write.c +++ b/screen-write.c @@ -1479,7 +1479,9 @@ screen_write_clearscreen(struct screen_write_ctx *ctx, u_int bg) ttyctx.bg = bg; /* Scroll into history if it is enabled. */ - if (s->grid->flags & GRID_HISTORY) + if ((s->grid->flags & GRID_HISTORY) && + ctx->wp != NULL && + options_get_number(ctx->wp->options, "scroll-on-clear")) grid_view_clear_history(s->grid, bg); else grid_view_clear(s->grid, 0, 0, sx, sy, bg); -- cgit From ccc9dc3bb49ac258c856d8478346b4ce829b188e Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 9 Jun 2022 09:12:55 +0000 Subject: If an application gives the first parameter to OSC 52, validate and pass on to outside terminal. GitHub issue 3192. --- screen-write.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'screen-write.c') diff --git a/screen-write.c b/screen-write.c index 6b6a750e..213b533c 100644 --- a/screen-write.c +++ b/screen-write.c @@ -2085,12 +2085,14 @@ screen_write_overwrite(struct screen_write_ctx *ctx, struct grid_cell *gc, /* Set external clipboard. */ void -screen_write_setselection(struct screen_write_ctx *ctx, u_char *str, u_int len) +screen_write_setselection(struct screen_write_ctx *ctx, const char *flags, + u_char *str, u_int len) { struct tty_ctx ttyctx; screen_write_initctx(ctx, &ttyctx, 0); ttyctx.ptr = str; + ttyctx.ptr2 = (void *)flags; ttyctx.num = len; tty_write(tty_cmd_setselection, &ttyctx); -- cgit