version 1.51, 2023/08/08 08:08:47 |
version 1.52, 2023/08/15 07:01:47 |
|
|
|
|
struct grid_cell style; |
struct grid_cell style; |
struct grid_cell border_style; |
struct grid_cell border_style; |
|
struct grid_cell selected_style; |
enum box_lines border_lines; |
enum box_lines border_lines; |
|
|
struct cmd_find_state fs; |
struct cmd_find_state fs; |
|
|
struct menu *menu = md->menu; |
struct menu *menu = md->menu; |
struct screen_write_ctx ctx; |
struct screen_write_ctx ctx; |
u_int i, px = md->px, py = md->py; |
u_int i, px = md->px, py = md->py; |
struct grid_cell gc; |
|
|
|
screen_write_start(&ctx, s); |
screen_write_start(&ctx, s); |
screen_write_clearscreen(&ctx, 8); |
screen_write_clearscreen(&ctx, 8); |
|
|
screen_write_box(&ctx, menu->width + 4, menu->count + 2, |
screen_write_box(&ctx, menu->width + 4, menu->count + 2, |
md->border_lines, &md->border_style, menu->title); |
md->border_lines, &md->border_style, menu->title); |
} |
} |
style_apply(&gc, c->session->curw->window->options, "mode-style", NULL); |
|
|
|
screen_write_menu(&ctx, menu, md->choice, md->border_lines, |
screen_write_menu(&ctx, menu, md->choice, md->border_lines, |
&md->style, &md->border_style, &gc); |
&md->style, &md->border_style, &md->selected_style); |
screen_write_stop(&ctx); |
screen_write_stop(&ctx); |
|
|
for (i = 0; i < screen_size_y(&md->s); i++) { |
for (i = 0; i < screen_size_y(&md->s); i++) { |
|
|
return (1); |
return (1); |
} |
} |
|
|
|
static void |
|
menu_set_style(struct client *c, struct grid_cell *gc, const char *style, |
|
const char *option) |
|
{ |
|
struct style sytmp; |
|
struct options *o = c->session->curw->window->options; |
|
|
|
memcpy(gc, &grid_default_cell, sizeof *gc); |
|
style_apply(gc, o, option, NULL); |
|
if (style != NULL) { |
|
style_set(&sytmp, &grid_default_cell); |
|
if (style_parse(&sytmp, gc, style) == 0) { |
|
gc->fg = sytmp.gc.fg; |
|
gc->bg = sytmp.gc.bg; |
|
} |
|
} |
|
gc->attr = 0; |
|
} |
|
|
struct menu_data * |
struct menu_data * |
menu_prepare(struct menu *menu, int flags, int starting_choice, |
menu_prepare(struct menu *menu, int flags, int starting_choice, |
struct cmdq_item *item, u_int px, u_int py, struct client *c, |
struct cmdq_item *item, u_int px, u_int py, struct client *c, |
enum box_lines lines, const char *style, const char *border_style, |
enum box_lines lines, const char *style, const char *selected_style, |
struct cmd_find_state *fs, menu_choice_cb cb, void *data) |
const char *border_style, struct cmd_find_state *fs, menu_choice_cb cb, |
|
void *data) |
{ |
{ |
struct menu_data *md; |
struct menu_data *md; |
int choice; |
int choice; |
const char *name; |
const char *name; |
struct style sytmp; |
|
struct options *o = c->session->curw->window->options; |
struct options *o = c->session->curw->window->options; |
|
|
if (c->tty.sx < menu->width + 4 || c->tty.sy < menu->count + 2) |
if (c->tty.sx < menu->width + 4 || c->tty.sy < menu->count + 2) |
|
|
md->flags = flags; |
md->flags = flags; |
md->border_lines = lines; |
md->border_lines = lines; |
|
|
memcpy(&md->style, &grid_default_cell, sizeof md->style); |
menu_set_style(c, &md->style, style, "menu-style"); |
style_apply(&md->style, o, "menu-style", NULL); |
menu_set_style(c, &md->selected_style, selected_style, |
if (style != NULL) { |
"menu-selected-style"); |
style_set(&sytmp, &grid_default_cell); |
menu_set_style(c, &md->border_style, border_style, "menu-border-style"); |
if (style_parse(&sytmp, &md->style, style) == 0) { |
|
md->style.fg = sytmp.gc.fg; |
|
md->style.bg = sytmp.gc.bg; |
|
} |
|
} |
|
md->style.attr = 0; |
|
|
|
memcpy(&md->border_style, &grid_default_cell, sizeof md->border_style); |
|
style_apply(&md->border_style, o, "menu-border-style", NULL); |
|
if (border_style != NULL) { |
|
style_set(&sytmp, &grid_default_cell); |
|
if (style_parse(&sytmp, &md->border_style, border_style) == 0) { |
|
md->border_style.fg = sytmp.gc.fg; |
|
md->border_style.bg = sytmp.gc.bg; |
|
} |
|
} |
|
md->border_style.attr = 0; |
|
|
|
if (fs != NULL) |
if (fs != NULL) |
cmd_find_copy_state(&md->fs, fs); |
cmd_find_copy_state(&md->fs, fs); |
screen_init(&md->s, menu->width + 4, menu->count + 2, 0); |
screen_init(&md->s, menu->width + 4, menu->count + 2, 0); |
|
|
int |
int |
menu_display(struct menu *menu, int flags, int starting_choice, |
menu_display(struct menu *menu, int flags, int starting_choice, |
struct cmdq_item *item, u_int px, u_int py, struct client *c, |
struct cmdq_item *item, u_int px, u_int py, struct client *c, |
enum box_lines lines, const char *style, const char *border_style, |
enum box_lines lines, const char *style, const char *selected_style, |
struct cmd_find_state *fs, menu_choice_cb cb, void *data) |
const char *border_style, struct cmd_find_state *fs, menu_choice_cb cb, |
|
void *data) |
{ |
{ |
struct menu_data *md; |
struct menu_data *md; |
|
|
md = menu_prepare(menu, flags, starting_choice, item, px, py, c, lines, |
md = menu_prepare(menu, flags, starting_choice, item, px, py, c, lines, |
style, border_style, fs, cb, data); |
style, selected_style, border_style, fs, cb, data); |
if (md == NULL) |
if (md == NULL) |
return (-1); |
return (-1); |
server_client_set_overlay(c, 0, NULL, menu_mode_cb, menu_draw_cb, |
server_client_set_overlay(c, 0, NULL, menu_mode_cb, menu_draw_cb, |