mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-24 09:18:08 +02:00
IME: Render overlay at the last visible cursor position with a separate cursor
Fix the problem caused by wrong cursor coordinates. No more messing with the main cursor, instead the cursor is saved when receiving a pre-edit text update and used for drawing later. Update the overlay to the last visible cursor position before rendering to ensure it always moves with the cursor. Finally, draw the overlay after line rendering is complete, and restore the line buffer after updating the rendered data to ensure that the line text being read is correct at all times. This also improves performance by only rendering once when changes are made, eliminating the need to repeatedly disable and draw after various commands and not even comprehensively.
This commit is contained in:
@@ -68,15 +68,20 @@ typedef struct {
|
||||
|
||||
|
||||
typedef struct {
|
||||
PyObject *overlay_text;
|
||||
CPUCell *cpu_cells;
|
||||
GPUCell *gpu_cells;
|
||||
index_type xstart, ynum, xnum, cursor_x;
|
||||
bool is_active;
|
||||
index_type xstart, ynum, xnum;
|
||||
|
||||
bool is_dirty;
|
||||
struct {
|
||||
PyObject *overlay_text;
|
||||
const char *func_name;
|
||||
} save;
|
||||
CPUCell *cpu_cells;
|
||||
GPUCell *gpu_cells;
|
||||
Cursor cursor;
|
||||
} original_line;
|
||||
struct {
|
||||
index_type x, y;
|
||||
} last_ime_pos;
|
||||
} OverlayLine;
|
||||
|
||||
typedef struct {
|
||||
@@ -264,7 +269,8 @@ void screen_dirty_sprite_positions(Screen *self);
|
||||
void screen_rescale_images(Screen *self);
|
||||
void screen_report_size(Screen *, unsigned int which);
|
||||
void screen_manipulate_title_stack(Screen *, unsigned int op, unsigned int which);
|
||||
void screen_draw_overlay_text(Screen *self, const char *utf8_text);
|
||||
bool screen_is_overlay_active(Screen *self);
|
||||
void screen_update_overlay_text(Screen *self, const char *utf8_text);
|
||||
void screen_set_key_encoding_flags(Screen *self, uint32_t val, uint32_t how);
|
||||
void screen_push_key_encoding_flags(Screen *self, uint32_t val);
|
||||
void screen_pop_key_encoding_flags(Screen *self, uint32_t num);
|
||||
|
||||
Reference in New Issue
Block a user