aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-04-19 12:50:48 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-04-19 12:50:48 +0000
commitb7593897b747bb9e37651fa147f705de5cd68a94 (patch)
treecfa44e8a381738ba31e3332fd94e77b018cf69fe /render.c
parentcsi: CSI Ps ; Ps ; Ps t: report logical pixels (diff)
render: search: improve handling of very long search strings
Diffstat (limited to 'render.c')
-rw-r--r--render.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/render.c b/render.c
index a9508f9c..fdaaf85d 100644
--- a/render.c
+++ b/render.c
@@ -1532,13 +1532,19 @@ render_search_box(struct terminal *term)
int y = margin;
pixman_color_t fg = color_hex_to_pixman(term->colors.table[0]);
- if (term->search.cursor < glyph_offset ||
- term->search.cursor >= glyph_offset + visible_chars + 1)
- {
- /* Make sure cursor is always visible */
+ /* Ensure cursor is visible */
+ if (term->search.cursor < glyph_offset)
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)) */
for (size_t i = glyph_offset;
i < term->search.len && i - glyph_offset < visible_chars;