Add popup-style and popup-border-style options, from Alexis Hildebrandt

in GitHub issue 2927.
This commit is contained in:
nicm 2021-10-13 09:28:36 +00:00
parent b8581ec80e
commit 837ca176d1
7 changed files with 59 additions and 10 deletions

View File

@ -747,7 +747,7 @@ mode_tree_draw(struct mode_tree_data *mtd)
mti = mti->parent;
screen_write_cursormove(&ctx, 0, h, 0);
screen_write_box(&ctx, w, sy - h);
screen_write_box(&ctx, w, sy - h, NULL);
if (mtd->sort_list != NULL) {
xasprintf(&text, " %s (sort: %s%s)", mti->name,

View File

@ -982,6 +982,24 @@ const struct options_table_entry options_table[] = {
.text = "The default colour palette for colours zero to 255."
},
{ .name = "popup-style",
.type = OPTIONS_TABLE_STRING,
.scope = OPTIONS_TABLE_WINDOW,
.default_str = "default",
.flags = OPTIONS_TABLE_IS_STYLE,
.separator = ",",
.text = "Default style of popups."
},
{ .name = "popup-border-style",
.type = OPTIONS_TABLE_STRING,
.scope = OPTIONS_TABLE_WINDOW,
.default_str = "default",
.flags = OPTIONS_TABLE_IS_STYLE,
.separator = ",",
.text = "Default style of popup borders."
},
{ .name = "remain-on-exit",
.type = OPTIONS_TABLE_CHOICE,
.scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE,

14
popup.c
View File

@ -212,16 +212,22 @@ popup_draw_cb(struct client *c, void *data, struct screen_redraw_ctx *rctx)
u_int i, px = pd->px, py = pd->py;
struct colour_palette *palette = &pd->palette;
struct grid_cell gc;
struct grid_cell bgc;
struct options *o = c->session->curw->window->options;
screen_init(&s, pd->sx, pd->sy, 0);
screen_write_start(&ctx, &s);
screen_write_clearscreen(&ctx, 8);
memcpy(&bgc, &grid_default_cell, sizeof bgc);
style_apply(&bgc, o, "popup-border-style", NULL);
bgc.attr = 0;
if (pd->flags & POPUP_NOBORDER) {
screen_write_cursormove(&ctx, 0, 0, 0);
screen_write_fast_copy(&ctx, &pd->s, 0, 0, pd->sx, pd->sy);
} else if (pd->sx > 2 && pd->sy > 2) {
screen_write_box(&ctx, pd->sx, pd->sy);
screen_write_box(&ctx, pd->sx, pd->sy, &bgc);
screen_write_cursormove(&ctx, 1, 1, 0);
screen_write_fast_copy(&ctx, &pd->s, 0, 0, pd->sx - 2,
pd->sy - 2);
@ -229,8 +235,10 @@ popup_draw_cb(struct client *c, void *data, struct screen_redraw_ctx *rctx)
screen_write_stop(&ctx);
memcpy(&gc, &grid_default_cell, sizeof gc);
gc.fg = pd->palette.fg;
gc.bg = pd->palette.bg;
style_apply(&gc, o, "popup-style", NULL);
gc.attr = 0;
palette->fg = gc.fg;
palette->bg = gc.bg;
if (pd->md != NULL) {
c->overlay_check = menu_check_cb;

View File

@ -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;

18
tmux.1
View File

@ -4258,6 +4258,24 @@ see the
section.
Attributes are ignored.
.Pp
.It Ic popup-style Ar style
Set the popup style.
For how to specify
.Ar style ,
see the
.Sx STYLES
section.
Attributes are ignored.
.Pp
.It Ic popup-border-style Ar style
Set the popup border style.
For how to specify
.Ar style ,
see the
.Sx STYLES
section.
Attributes are ignored.
.Pp
.It Ic window-status-activity-style Ar style
Set status line style for windows with an activity alert.
For how to specify

3
tmux.h
View File

@ -2699,7 +2699,8 @@ void screen_write_hline(struct screen_write_ctx *, u_int, int, int);
void screen_write_vline(struct screen_write_ctx *, u_int, int, int);
void screen_write_menu(struct screen_write_ctx *, struct menu *, int,
const struct grid_cell *);
void screen_write_box(struct screen_write_ctx *, u_int, u_int);
void screen_write_box(struct screen_write_ctx *, u_int, u_int,
const struct grid_cell *gc);
void screen_write_preview(struct screen_write_ctx *, struct screen *, u_int,
u_int);
void screen_write_backspace(struct screen_write_ctx *);

View File

@ -519,7 +519,7 @@ window_tree_draw_label(struct screen_write_ctx *ctx, u_int px, u_int py,
if (ox > 1 && ox + len < sx - 1 && sy >= 3) {
screen_write_cursormove(ctx, px + ox - 1, py + oy - 1, 0);
screen_write_box(ctx, len + 2, 3);
screen_write_box(ctx, len + 2, 3, NULL);
}
screen_write_cursormove(ctx, px + ox, py + oy, 0);
screen_write_puts(ctx, gc, "%s", label);