From 8c3d48c5cdb2ae4e8bdbdc48f155f53d1a92973b Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 2 Dec 2020 18:52:50 +0100 Subject: ime: render pre-edit text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is done by allocating cells for the pre-edit text when receiving the text-input::done() call, and populating them by converting the utf-8 formatted pre-edit text to wchars. We also convert the pre-edit cursor position to cell positions (it can cover multiple cells). When rendering, we simply render the pre-edit cells on-top off the regular grid. While doing so, we also mark the underlying, “real”, cells as dirty, to ensure they are re-rendered when the pre-edit text is modified or removed. --- terminal.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index 3bb41d12..d08d8658 100644 --- a/terminal.c +++ b/terminal.c @@ -1403,6 +1403,8 @@ term_destroy(struct terminal *term) tll_free(term->alt.sixel_images); sixel_fini(term); + free(term->ime.preedit.cells); + free(term->foot_exe); free(term->cwd); @@ -2216,6 +2218,13 @@ term_kbd_focus_out(struct terminal *term) if (it->item.kbd_focus == term) return; + if (term->ime.preedit.cells != NULL) { + free(term->ime.preedit.cells); + term->ime.preedit.cells = NULL; + term->ime.preedit.count = 0; + render_refresh(term); + } + term->kbd_focus = false; cursor_refresh(term); -- cgit v1.3