aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2022-07-27 17:14:27 +0000
committerDaniel Eklöf <daniel@ekloef.se>2022-07-28 17:02:56 +0000
commitd79a3b9350ba864464229a1c188e2f696fac5a26 (patch)
treefec4b0cc07164d74ab66b6230f52b522df610057 /render.c
parenttest: config: test colors.{jump-labels,scrollback-indicator} (diff)
config: add colors.search-box-{no-,}match
Closes #1112
Diffstat (limited to 'render.c')
-rw-r--r--render.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/render.c b/render.c
index 0dd251ae..9333deb7 100644
--- a/render.c
+++ b/render.c
@@ -3046,10 +3046,20 @@ render_search_box(struct terminal *term)
#define WINDOW_X(x) (margin + x)
#define WINDOW_Y(y) (term->height - margin - height + y)
- /* Background - yellow on empty/match, red on mismatch */
- pixman_color_t color = color_hex_to_pixman(
- term->search.match_len == text_len
- ? term->colors.table[3] : term->colors.table[1]);
+ const bool is_match = term->search.match_len == text_len;
+ const bool custom_colors = is_match
+ ? term->conf->colors.use_custom.search_box_match
+ : term->conf->colors.use_custom.search_box_no_match;
+
+ /* Background - yellow on empty/match, red on mismatch (default) */
+ const pixman_color_t color = color_hex_to_pixman(
+ is_match
+ ? (custom_colors
+ ? term->conf->colors.search_box.match.bg
+ : term->colors.table[3])
+ : (custom_colors
+ ? term->conf->colors.search_box.no_match.bg
+ : term->colors.table[1]));
pixman_image_fill_rectangles(
PIXMAN_OP_SRC, buf->pix[0], &color,
@@ -3065,7 +3075,12 @@ render_search_box(struct terminal *term)
const int x_ofs = term->font_x_ofs;
int x = x_left;
int y = margin;
- pixman_color_t fg = color_hex_to_pixman(term->colors.table[0]);
+ pixman_color_t fg = color_hex_to_pixman(
+ custom_colors
+ ? (is_match
+ ? term->conf->colors.search_box.match.fg
+ : term->conf->colors.search_box.no_match.fg)
+ : term->colors.table[0]);
/* Move offset we start rendering at, to ensure the cursor is visible */
for (size_t i = 0, cell_idx = 0; i <= term->search.cursor; cell_idx += widths[i], i++) {