diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-12-08 19:06:22 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-12-08 19:06:22 +0000 |
| commit | 0263a152d490c4120f76ae5447a114b30a43e6c8 (patch) | |
| tree | de5c1ef01c33064df7c6dfac6505af98ddbf3e7f /search.c | |
| parent | changelog: DECSET 27127 - modifies Esc to send \E[27127~ instead of \E (diff) | |
| parent | install: simplify sentence (diff) | |
Merge branch 'input-method-editor'
Closes #134
Diffstat (limited to 'search.c')
| -rw-r--r-- | search.c | 26 |
1 files changed, 22 insertions, 4 deletions
@@ -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. @@ -98,6 +99,12 @@ search_cancel_keep_selection(struct terminal *term) term->is_searching = false; term->render.search_glyph_offset = 0; + /* Reset IME state */ + if (term_ime_is_enabled(term)) { + term_ime_disable(term); + term_ime_enable(term); + } + term_xcursor_update(term); render_refresh(term); } @@ -110,6 +117,12 @@ search_begin(struct terminal *term) search_cancel_keep_selection(term); selection_cancel(term); + /* Reset IME state */ + if (term_ime_is_enabled(term)) { + term_ime_disable(term); + term_ime_enable(term); + } + /* On-demand instantiate wayland surface */ struct wl_window *win = term->window; struct wayland *wayl = term->wl; @@ -124,6 +137,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); } @@ -332,8 +350,8 @@ search_find_next(struct terminal *term) #undef ROW_DEC } -static void -add_chars(struct terminal *term, const char *src, size_t count) +void +search_add_chars(struct terminal *term, const char *src, size_t count) { mbstate_t ps = {0}; size_t wchars = mbsnrtowcs(NULL, &src, count, 0, &ps); @@ -494,7 +512,7 @@ static void from_clipboard_cb(char *text, size_t size, void *user) { struct terminal *term = user; - add_chars(term, text, size); + search_add_chars(term, text, size); } static void @@ -722,7 +740,7 @@ search_input(struct seat *seat, struct terminal *term, uint32_t key, if (count == 0) return; - add_chars(term, (const char *)buf, count); + search_add_chars(term, (const char *)buf, count); update_search: LOG_DBG("search: buffer: %ls", term->search.buf); |
