Skip to content
Myr

main: make selection color (background of selected list item) configurable

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Daniel Eklöf · committed by Daniel Eklöf · parent bddcebf · Browse files · 3 files+18 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+18 added−2 removed

  • other:+18 added−2 removed

3 files+18 added−2 removed

modified:main.c+11 added-1 removed
1037 unmodified lines
1038 {"geometry", required_argument, 0, 'g'},1039 {"background-color", required_argument, 0, 'b'},1040 {"text-color", required_argument, 0, 't'},1041 {"match-color", required_argument, 0, 'm'},1042 {"selection-color", required_argument, 0, 's'},1043 {"border-width", required_argument, 0, 'B'},1044 {"border-color", required_argument, 0, 'C'},1045 {NULL, no_argument, 0, 0},1046 };
6 unmodified lines
1053 int border_width = 1;1054 uint32_t text_color = 0xffffffff;1055 uint32_t match_color = 0xcc9393ff;1056 uint32_t background = 0x000000ff;1057 uint32_t selection_color = 0x333333ff;1058 uint32_t border_color = 0xffffffff;10591060 while (true) {1059 int c = getopt_long(argc, argv, ":o:f:g:b:t:m:B:C:", longopts, NULL);1061 int c = getopt_long(argc, argv, ":o:f:g:b:t:m:s:B:C:", longopts, NULL);1062 if (c == -1)1063 break;10641065 switch (c) {
32 unmodified lines
1098 return EXIT_FAILURE;1099 }1100 break;11011102 case 's':1103 if (sscanf(optarg, "%x", &selection_color) != 1) {1104 LOG_ERR("%s: invalid color", optarg);1105 return EXIT_FAILURE;1106 }1107 break;11081109 case 'B':1110 if (sscanf(optarg, "%d", &border_width) != 1) {1111 LOG_ERR(1112 "%s: invalid border width (must be an integer)", optarg);
189 unmodified lines
1302 .y_margin = c.y_margin,1303 .border_size = c.border_size,1304 .text_color = text_color,1305 .match_color = match_color,1306 .selection_color = selection_color,1307 .border_color = border_color,1308 };1309 c.render = render_init(font, options);1310
102 unmodified lines
modified:render.c+6 added-1 removed
230 unmodified lines
231 const struct match *match = &matches[i];232233 /* Hightlight selected entry */234 if (i == selected) {235 const uint32_t clr = render->options.selection_color;236 const double r = (double)((clr >> 24) & 0xff) / 255.0;237 const double g = (double)((clr >> 16) & 0xff) / 255.0;238 const double b = (double)((clr >> 8) & 0xff) / 255.0;239 const double a = (double)((clr >> 0) & 0xff) / 255.0;235 cairo_set_source_rgba(buf->cairo, 0.157, 0.157, 0.157, 0.9);240 cairo_set_source_rgba(buf->cairo, r, g, b, a);241 cairo_set_operator(buf->cairo, CAIRO_OPERATOR_SOURCE);242 cairo_rectangle(buf->cairo,243 x_margin - sel_margin,244 first_row + i * row_height,
67 unmodified lines
modified:render.h+1 added
13 unmodified lines
14 int border_size;1516 uint32_t text_color;17 uint32_t match_color;18 uint32_t selection_color;19 uint32_t border_color;20};2122struct prompt {
15 unmodified lines