mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-06 04:06:06 -05:00
highlight colors
This commit is contained in:
parent
2609206c98
commit
68685fdf13
4 changed files with 49 additions and 22 deletions
14
config.c
14
config.c
|
|
@ -1493,6 +1493,20 @@ parse_color_theme(struct context *ctx, struct color_theme *theme)
|
|||
return true;
|
||||
}
|
||||
|
||||
else if (streq(key, "highlights")) {
|
||||
if (!value_to_two_colors(
|
||||
ctx,
|
||||
&theme->highlights.fg,
|
||||
&theme->highlights.bg,
|
||||
false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
theme->use_custom.highlights = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
else if (streq(key, "urls")) {
|
||||
if (!value_to_color(ctx, &theme->url, false))
|
||||
return false;
|
||||
|
|
|
|||
6
config.h
6
config.h
|
|
@ -184,6 +184,11 @@ struct color_theme {
|
|||
} match;
|
||||
} search_box;
|
||||
|
||||
struct {
|
||||
uint32_t fg;
|
||||
uint32_t bg;
|
||||
} highlights;
|
||||
|
||||
struct {
|
||||
bool cursor:1;
|
||||
bool jump_label:1;
|
||||
|
|
@ -191,6 +196,7 @@ struct color_theme {
|
|||
bool url:1;
|
||||
bool search_box_no_match:1;
|
||||
bool search_box_match:1;
|
||||
bool highlights:1;
|
||||
uint8_t dim;
|
||||
} use_custom;
|
||||
};
|
||||
|
|
|
|||
48
render.c
48
render.c
|
|
@ -727,8 +727,6 @@ render_cell(struct terminal *term, pixman_image_t *pix,
|
|||
const int y = term->margins.top + row_no * height;
|
||||
|
||||
const bool is_selected = cell->attrs.selected;
|
||||
const bool is_highlighted =
|
||||
is_cell_highlighted(term, (struct coord){.row = row_no, .col = col});
|
||||
|
||||
uint32_t _fg = 0;
|
||||
uint32_t _bg = 0;
|
||||
|
|
@ -808,10 +806,16 @@ render_cell(struct terminal *term, pixman_image_t *pix,
|
|||
alpha = 0xffff;
|
||||
}
|
||||
} else {
|
||||
const bool is_highlighted =
|
||||
is_cell_highlighted(term, (struct coord){.row = row_no, .col = col});
|
||||
if(is_highlighted) {
|
||||
// TODO (kociap): colors for the highlight.
|
||||
_fg = term->colors.table[0];
|
||||
_bg = term->colors.table[1];
|
||||
if(term->conf->colors.use_custom.highlights) {
|
||||
_fg = term->conf->colors.highlights.fg;
|
||||
_bg = term->conf->colors.highlights.bg;
|
||||
} else {
|
||||
_fg = term->colors.table[0];
|
||||
_bg = term->colors.table[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (unlikely(cell->attrs.reverse)) {
|
||||
|
|
@ -3738,20 +3742,30 @@ render_search_box(struct terminal *term)
|
|||
#define WINDOW_Y(y) (term->height - height + y)
|
||||
|
||||
const bool is_match = term->vimode.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;
|
||||
const bool custom_color_match =
|
||||
term->conf->colors.use_custom.search_box_match;
|
||||
const bool custom_color_no_match =
|
||||
term->conf->colors.use_custom.search_box_no_match;
|
||||
|
||||
/* Background - yellow on empty/match, red on mismatch (default) */
|
||||
const bool gamma_correct = wayl_do_linear_blending(term->wl, term->conf);
|
||||
const pixman_color_t bg = color_hex_to_pixman(
|
||||
is_match
|
||||
? (custom_colors
|
||||
? (custom_color_match
|
||||
? term->conf->colors.search_box.match.bg
|
||||
: term->colors.bg)
|
||||
: (custom_colors
|
||||
: term->colors.table[0]) // Black
|
||||
: (custom_color_no_match
|
||||
? term->conf->colors.search_box.no_match.bg
|
||||
: term->colors.table[1]),
|
||||
: term->colors.table[1]), // Red
|
||||
gamma_correct);
|
||||
const pixman_color_t fg = color_hex_to_pixman(
|
||||
is_match
|
||||
? (custom_color_match
|
||||
? term->conf->colors.search_box.match.fg
|
||||
: term->colors.table[245]) // Grey
|
||||
: (custom_color_no_match
|
||||
? term->conf->colors.search_box.no_match.fg
|
||||
: term->colors.table[0]), // Black
|
||||
gamma_correct);
|
||||
|
||||
pixman_image_fill_rectangles(
|
||||
|
|
@ -3763,16 +3777,6 @@ render_search_box(struct terminal *term)
|
|||
int x = 0;
|
||||
int y = 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)
|
||||
: (is_match
|
||||
? term->colors.table[245]
|
||||
: term->colors.table[0]),
|
||||
gamma_correct);
|
||||
|
||||
{
|
||||
/* Move offset we start rendering at, to ensure the cursor is visible */
|
||||
size_t cell_idx = 0;
|
||||
|
|
|
|||
|
|
@ -744,6 +744,9 @@ test_section_colors(void)
|
|||
test_two_colors(&ctx, &parse_section_colors, "search-box-match", false,
|
||||
&conf.colors.search_box.match.fg,
|
||||
&conf.colors.search_box.match.bg);
|
||||
test_two_colors(&ctx, &parse_section_colors, "highlights", false,
|
||||
&conf.colors.highlights.fg,
|
||||
&conf.colors.highlights.bg);
|
||||
|
||||
test_two_colors(&ctx, &parse_section_colors, "cursor", false,
|
||||
&conf.colors.cursor.text,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue