From ab9dfc572e4759b3304c47e7914af87306f340f6 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sun, 30 Mar 2025 16:45:25 +0100 Subject: [PATCH] Very crude support for displaying pre-edit strings We simply pass each character to term_display_graphic_char and then put the cursor back where we found it. This works in simple cases, but is fundamentally wrong. Really we should do this in a way that doesn't touch the terminal state and just gets rendered on top of it somehow. --- terminal/terminal.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/terminal/terminal.c b/terminal/terminal.c index 5fc20b94..d945494b 100644 --- a/terminal/terminal.c +++ b/terminal/terminal.c @@ -8115,13 +8115,18 @@ void term_notify_window_size_pixels(Terminal *term, int x, int y) void term_set_preedit_text(Terminal *term, char *preedit_text) { BinarySource src[1]; + pos oldcurs = term->curs; if (preedit_text != NULL) { debug("Pre-edit:"); BinarySource_BARE_INIT(src, preedit_text, strlen(preedit_text)); - while (get_avail(src)) - debug(" U+%04X", decode_utf8(src, NULL)); + while (get_avail(src)) { + unsigned int c = decode_utf8(src, NULL); + debug(" U+%04X", c); + term_display_graphic_char(term, c); + } debug("\n"); + term->curs = oldcurs; } else { debug("Pre-edit finished\n"); }