mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-18 22:05:25 -05:00
ime: fix rendering of pre-edit cursor when positioned after the pre-edit string
We failed to convert the byte-indices to cell indices, resulting in a box cursor covering the entire pre-edit string. Note that in addition to fixing the translation from byte index to cell index, the rendered had to be updated to dirty one extra cell from the original grid. Without this, we left trailing cursors behind us when the user deleted text from the pre-edit string.
This commit is contained in:
parent
f9a43209f2
commit
adbf036053
3 changed files with 25 additions and 9 deletions
13
render.c
13
render.c
|
|
@ -1073,6 +1073,17 @@ render_ime_preedit(struct terminal *term, struct buffer *buf)
|
|||
|
||||
int cells_needed = term->ime.preedit.count;
|
||||
|
||||
if (term->ime.preedit.cursor.start == cells_needed &&
|
||||
term->ime.preedit.cursor.end == cells_needed)
|
||||
{
|
||||
/* Cursor will be drawn *after* the pre-edit string, i.e. in
|
||||
* the cell *after*. This means we need to copy, and dirty,
|
||||
* one extra cell from the original grid, or we’ll leave
|
||||
* trailing “cursors” after us if the user deletes text while
|
||||
* pre-editing */
|
||||
cells_needed++;
|
||||
}
|
||||
|
||||
int row_idx = cursor.row;
|
||||
int col_idx = cursor.col;
|
||||
int ime_ofs = 0; /* Offset into pre-edit string to start rendering at */
|
||||
|
|
@ -1152,7 +1163,7 @@ render_ime_preedit(struct terminal *term, struct buffer *buf)
|
|||
int end = term->ime.preedit.cursor.end - ime_ofs;
|
||||
|
||||
if (!term->ime.preedit.cursor.hidden) {
|
||||
const struct cell *start_cell = &term->ime.preedit.cells[start + ime_ofs];
|
||||
const struct cell *start_cell = &term->ime.preedit.cells[0];
|
||||
|
||||
pixman_color_t fg = color_hex_to_pixman(term->colors.fg);
|
||||
pixman_color_t bg = color_hex_to_pixman(term->colors.bg);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue