1
0
Fork 0
mirror of https://github.com/Cloudef/bemenu synced 2024-05-09 09:06:43 +02:00

Add options to set cursor bg/fg color

This commit is contained in:
Daniel Lublin 2022-07-04 11:02:45 +02:00 committed by Jari Vetoniemi
parent bd97e05138
commit c04a3c7220
5 changed files with 22 additions and 2 deletions

View File

@ -285,6 +285,8 @@ do_getopt(struct client *client, int *argc, char **argv[])
{ "tf", required_argument, 0, 0x103 },
{ "fb", required_argument, 0, 0x104 },
{ "ff", required_argument, 0, 0x105 },
{ "cb", required_argument, 0, 0x126 },
{ "cf", required_argument, 0, 0x127 },
{ "nb", required_argument, 0, 0x106 },
{ "nf", required_argument, 0, 0x107 },
{ "hb", required_argument, 0, 0x108 },
@ -416,6 +418,12 @@ do_getopt(struct client *client, int *argc, char **argv[])
case 0x105:
client->colors[BM_COLOR_FILTER_FG] = optarg;
break;
case 0x126:
client->colors[BM_COLOR_CURSOR_BG] = optarg;
break;
case 0x127:
client->colors[BM_COLOR_CURSOR_FG] = optarg;
break;
case 0x106:
client->colors[BM_COLOR_ITEM_BG] = optarg;
break;

View File

@ -335,6 +335,8 @@ enum bm_color {
BM_COLOR_TITLE_FG,
BM_COLOR_FILTER_BG,
BM_COLOR_FILTER_FG,
BM_COLOR_CURSOR_BG,
BM_COLOR_CURSOR_FG,
BM_COLOR_ITEM_BG,
BM_COLOR_ITEM_FG,
BM_COLOR_HIGHLIGHTED_BG,

View File

@ -19,6 +19,8 @@ static const char *default_colors[BM_COLOR_LAST] = {
"#D81860FF", // BM_COLOR_TITLE_FG
"#121212FF", // BM_COLOR_FILTER_BG
"#CACACAFF", // BM_COLOR_FILTER_FG
"#121212FF", // BM_COLOR_CURSOR_BG
"#CACACAFF", // BM_COLOR_CURSOR_FG
"#121212FF", // BM_COLOR_ITEM_BG
"#CACACAFF", // BM_COLOR_ITEM_FG
"#121212FF", // BM_COLOR_HIGHLIGHTED_BG

View File

@ -27,6 +27,8 @@ struct cairo_paint {
uint32_t cursor;
uint32_t cursor_height;
uint32_t cursor_width;
struct cairo_color cursor_fg;
struct cairo_color cursor_bg;
uint32_t hpadding;
bool draw_cursor;
@ -161,7 +163,7 @@ bm_cairo_draw_line_str(struct cairo *cairo, struct cairo_paint *paint, struct ca
cursor_width = paint->cursor_width;
}
uint32_t cursor_height = fmin(paint->cursor_height == 0 ? line_height : paint->cursor_height, line_height);
cairo_set_source_rgba(cairo->cr, paint->fg.r, paint->fg.b, paint->fg.g, paint->fg.a);
cairo_set_source_rgba(cairo->cr, paint->cursor_fg.r, paint->cursor_fg.b, paint->cursor_fg.g, paint->cursor_fg.a);
cairo_rectangle(cairo->cr,
paint->pos.x + paint->box.lx + rect.x / PANGO_SCALE, paint->pos.y - paint->box.ty + ((line_height - cursor_height) / 2),
cursor_width, cursor_height);
@ -172,7 +174,7 @@ bm_cairo_draw_line_str(struct cairo *cairo, struct cairo_paint *paint, struct ca
cursor_width, line_height);
cairo_clip(cairo->cr);
cairo_set_source_rgba(cairo->cr, paint->bg.r, paint->bg.b, paint->bg.g, paint->bg.a);
cairo_set_source_rgba(cairo->cr, paint->cursor_bg.r, paint->cursor_bg.b, paint->cursor_bg.g, paint->cursor_bg.a);
cairo_move_to(cairo->cr, paint->box.lx + paint->pos.x, paint->pos.y - base + paint->baseline);
pango_cairo_show_layout(cairo->cr, layout);
cairo_reset_clip(cairo->cr);
@ -301,6 +303,8 @@ bm_cairo_paint(struct cairo *cairo, uint32_t width, uint32_t max_height, const s
bm_cairo_color_from_menu_color(menu, BM_COLOR_FILTER_FG, &paint.fg);
bm_cairo_color_from_menu_color(menu, BM_COLOR_FILTER_BG, &paint.bg);
bm_cairo_color_from_menu_color(menu, BM_COLOR_CURSOR_FG, &paint.cursor_fg);
bm_cairo_color_from_menu_color(menu, BM_COLOR_CURSOR_BG, &paint.cursor_bg);
paint.draw_cursor = true;
paint.cursor = menu->cursor;
paint.cursor_height = menu->cursor_height;

View File

@ -136,6 +136,10 @@ control the red, green, blue and alpha-transparency channels.
*--ff* <_color_> Filter foreground
*--cb* <_color_> Cursor background.
*--cf* <_color_> Cursor foreground
*--nb* <_color_> Normal background.
*--nf* <_color_> Normal foreground.