1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-24 14:26:29 -05:00

Display some IM pre-edit state when painting the terminal

This is approximately how it should work: term_set_preedit_text stashes
data in the terminal structure and then do_paint() renders it in place
of what's in the terminal buffer.  Currently this only works for a
single narrow character, and it copies the existing attributes under the
cursor, but this might actually be enough for the UK keyboard layout in
GNOME.
This commit is contained in:
Ben Harris 2025-03-31 10:04:18 +01:00
parent ab9dfc572e
commit b72fec0a52
2 changed files with 12 additions and 5 deletions

View File

@ -6199,6 +6199,9 @@ static void do_paint(Terminal *term)
if (i == our_curs_y && j == our_curs_x)
tattr |= cursor;
if (term->preedit_char != -1)
tchar = term->preedit_char;
}
/* FULL-TERMCHAR */
newline[j].attr = tattr;
@ -8115,19 +8118,20 @@ 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)) {
if (get_avail(src)) {
unsigned int c = decode_utf8(src, NULL);
debug(" U+%04X", c);
term_display_graphic_char(term, c);
}
term->preedit_char = c;
} else
term->preedit_char = -1;
debug("\n");
term->curs = oldcurs;
} else {
debug("Pre-edit finished\n");
term->preedit_char = -1;
}
seen_disp_event(term);
}

View File

@ -442,6 +442,9 @@ struct terminal_tag {
*/
struct term_userpass_state *userpass_state;
bool userpass_utf8_override;
/* Input method state. */
int preedit_char; /* -1 for none */
};
static inline bool in_utf(Terminal *term)