mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-20 05:33:47 -04:00
render: search: improve handling of very long search strings
This commit is contained in:
parent
e93757198a
commit
b7593897b7
1 changed files with 10 additions and 4 deletions
14
render.c
14
render.c
|
|
@ -1532,13 +1532,19 @@ render_search_box(struct terminal *term)
|
||||||
int y = margin;
|
int y = margin;
|
||||||
pixman_color_t fg = color_hex_to_pixman(term->colors.table[0]);
|
pixman_color_t fg = color_hex_to_pixman(term->colors.table[0]);
|
||||||
|
|
||||||
if (term->search.cursor < glyph_offset ||
|
/* Ensure cursor is visible */
|
||||||
term->search.cursor >= glyph_offset + visible_chars + 1)
|
if (term->search.cursor < glyph_offset)
|
||||||
{
|
|
||||||
/* Make sure cursor is always visible */
|
|
||||||
term->render.search_glyph_offset = glyph_offset = term->search.cursor;
|
term->render.search_glyph_offset = glyph_offset = term->search.cursor;
|
||||||
|
else if (term->search.cursor > glyph_offset + visible_chars) {
|
||||||
|
term->render.search_glyph_offset = glyph_offset =
|
||||||
|
term->search.cursor - min(term->search.cursor, visible_chars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Move offset if there is free space available */
|
||||||
|
if (term->search.len - glyph_offset < visible_chars)
|
||||||
|
term->render.search_glyph_offset = glyph_offset =
|
||||||
|
term->search.len - min(term->search.len, visible_chars);
|
||||||
|
|
||||||
/* Text (what the user entered - *not* match(es)) */
|
/* Text (what the user entered - *not* match(es)) */
|
||||||
for (size_t i = glyph_offset;
|
for (size_t i = glyph_offset;
|
||||||
i < term->search.len && i - glyph_offset < visible_chars;
|
i < term->search.len && i - glyph_offset < visible_chars;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue