mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
render: ime: calculate on-screen cursor position ourselves
The position calculated by render_grid() may be -1,-1 if the cursor is currently hidden. This fixes a crash when trying to input IME while the cursor is hidden.
This commit is contained in:
parent
98bd798dae
commit
e9f99df2ab
1 changed files with 12 additions and 3 deletions
15
render.c
15
render.c
|
|
@ -1022,14 +1022,23 @@ render_sixel_images(struct terminal *term, pixman_image_t *pix)
|
|||
}
|
||||
|
||||
static void
|
||||
render_ime_preedit(struct terminal *term, struct buffer *buf,
|
||||
struct coord cursor)
|
||||
render_ime_preedit(struct terminal *term, struct buffer *buf)
|
||||
{
|
||||
#if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED
|
||||
|
||||
if (likely(term->ime.preedit.cells == NULL))
|
||||
return;
|
||||
|
||||
/* Adjust cursor position to viewport */
|
||||
struct coord cursor;
|
||||
cursor = term->grid->cursor.point;
|
||||
cursor.row += term->grid->offset;
|
||||
cursor.row -= term->grid->view;
|
||||
cursor.row &= term->grid->num_rows - 1;
|
||||
|
||||
if (cursor.row < 0 || cursor.row >= term->rows)
|
||||
return;
|
||||
|
||||
int cells_needed = term->ime.preedit.count;
|
||||
|
||||
int row_idx = cursor.row;
|
||||
|
|
@ -2012,7 +2021,7 @@ grid_render(struct terminal *term)
|
|||
}
|
||||
|
||||
/* Render IME pre-edit text */
|
||||
render_ime_preedit(term, buf, cursor);
|
||||
render_ime_preedit(term, buf);
|
||||
|
||||
if (term->flash.active) {
|
||||
/* Note: alpha is pre-computed in each color component */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue