aboutsummaryrefslogtreecommitdiff
path: root/search.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-12-05 22:29:12 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-12-07 19:44:13 +0000
commitb4a0f5b13b44525bd1dbdbc12e4e412fc9a0a1cb (patch)
tree09ed7a541b32cf190ba746b0e4d3f342defbfe92 /search.c
parentrender: search: wcsnlen() -> wcswidth() (diff)
render: search: glyph_offset is in *cells*, cursor position in *characters*
When calculating the offset into the search string, from where to start rendering, take into account that the cursor position is in *characters*, and the glyph-offset is in *cells*.
Diffstat (limited to 'search.c')
-rw-r--r--search.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/search.c b/search.c
index a9f5499a..83f86390 100644
--- a/search.c
+++ b/search.c
@@ -18,6 +18,7 @@
#include "selection.h"
#include "shm.h"
#include "util.h"
+#include "xmalloc.h"
/*
* Ensures a "new" viewport doesn't contain any unallocated rows.
@@ -124,6 +125,11 @@ search_begin(struct terminal *term)
term->search.view_followed_offset = term->grid->view == term->grid->offset;
term->is_searching = true;
+ term->search.len = 0;
+ term->search.sz = 64;
+ term->search.buf = xmalloc(term->search.sz * sizeof(term->search.buf[0]));
+ term->search.buf[0] = L'\0';
+
term_xcursor_update(term);
render_refresh_search(term);
}