summaryrefslogtreecommitdiffstats
path: root/screen-write.c
diff options
context:
space:
mode:
authornicm <nicm>2021-10-20 09:50:40 +0000
committernicm <nicm>2021-10-20 09:50:40 +0000
commit8a9bfd0cddd783436e842495fc3039aa56571ed1 (patch)
tree664ad6f43dbfb7453bc43c3d300d9acfdd844f88 /screen-write.c
parentf26b8c57ffb253db08072629b7c969c021580492 (diff)
Add -T to set a popup title, from Alexis Hildebrandt in GitHub issue 2941.
Diffstat (limited to 'screen-write.c')
-rw-r--r--screen-write.c27
1 files changed, 16 insertions, 11 deletions
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);
}