mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-26 07:57:59 -04:00
Merge branch 'ime-preedit-cursor-at-the-end-of-the-preedit-string'
This commit is contained in:
commit
74f92c3959
3 changed files with 25 additions and 9 deletions
|
|
@ -94,6 +94,8 @@
|
||||||
* High CPU usage when holding down e.g. arrow keys while in scrollback
|
* High CPU usage when holding down e.g. arrow keys while in scrollback
|
||||||
search mode.
|
search mode.
|
||||||
* Rendering of composed characters in the scrollback search box.
|
* Rendering of composed characters in the scrollback search box.
|
||||||
|
* IME pre-edit cursor when positioned at the end of the pre-edit
|
||||||
|
string.
|
||||||
|
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
|
|
|
||||||
19
ime.c
19
ime.c
|
|
@ -194,6 +194,8 @@ done(void *data, struct zwp_text_input_v3 *zwp_text_input_v3,
|
||||||
cell_idx += width;
|
cell_idx += width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const size_t byte_len = strlen(seat->ime.preedit.pending.text);
|
||||||
|
|
||||||
/* Pre-edit cursor - hidden */
|
/* Pre-edit cursor - hidden */
|
||||||
if (seat->ime.preedit.pending.cursor_begin == -1 ||
|
if (seat->ime.preedit.pending.cursor_begin == -1 ||
|
||||||
seat->ime.preedit.pending.cursor_end == -1)
|
seat->ime.preedit.pending.cursor_end == -1)
|
||||||
|
|
@ -206,6 +208,15 @@ done(void *data, struct zwp_text_input_v3 *zwp_text_input_v3,
|
||||||
term->ime.preedit.cursor.end = -1;
|
term->ime.preedit.cursor.end = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (seat->ime.preedit.pending.cursor_begin == byte_len &&
|
||||||
|
seat->ime.preedit.pending.cursor_end == byte_len)
|
||||||
|
{
|
||||||
|
/* Cursor is *after* the entire pre-edit string */
|
||||||
|
term->ime.preedit.cursor.hidden = false;
|
||||||
|
term->ime.preedit.cursor.start = cell_count;
|
||||||
|
term->ime.preedit.cursor.end = cell_count;
|
||||||
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
/*
|
/*
|
||||||
* Translate cursor position to cell indices
|
* Translate cursor position to cell indices
|
||||||
|
|
@ -220,16 +231,8 @@ done(void *data, struct zwp_text_input_v3 *zwp_text_input_v3,
|
||||||
*
|
*
|
||||||
* When we find the matching *byte* index, we at the same
|
* When we find the matching *byte* index, we at the same
|
||||||
* time know both the unicode *and* cell index.
|
* time know both the unicode *and* cell index.
|
||||||
*
|
|
||||||
* Note that this has only been tested with
|
|
||||||
*
|
|
||||||
* cursor_begin == cursor_end == 0
|
|
||||||
*
|
|
||||||
* I haven't found an IME that requests anything else
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const size_t byte_len = strlen(seat->ime.preedit.pending.text);
|
|
||||||
|
|
||||||
int cell_begin = -1, cell_end = -1;
|
int cell_begin = -1, cell_end = -1;
|
||||||
for (size_t byte_idx = 0, wc_idx = 0, cell_idx = 0;
|
for (size_t byte_idx = 0, wc_idx = 0, cell_idx = 0;
|
||||||
byte_idx < byte_len &&
|
byte_idx < byte_len &&
|
||||||
|
|
|
||||||
13
render.c
13
render.c
|
|
@ -1096,6 +1096,17 @@ render_ime_preedit(struct terminal *term, struct buffer *buf)
|
||||||
|
|
||||||
int cells_needed = term->ime.preedit.count;
|
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 row_idx = cursor.row;
|
||||||
int col_idx = cursor.col;
|
int col_idx = cursor.col;
|
||||||
int ime_ofs = 0; /* Offset into pre-edit string to start rendering at */
|
int ime_ofs = 0; /* Offset into pre-edit string to start rendering at */
|
||||||
|
|
@ -1175,7 +1186,7 @@ render_ime_preedit(struct terminal *term, struct buffer *buf)
|
||||||
int end = term->ime.preedit.cursor.end - ime_ofs;
|
int end = term->ime.preedit.cursor.end - ime_ofs;
|
||||||
|
|
||||||
if (!term->ime.preedit.cursor.hidden) {
|
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 fg = color_hex_to_pixman(term->colors.fg);
|
||||||
pixman_color_t bg = color_hex_to_pixman(term->colors.bg);
|
pixman_color_t bg = color_hex_to_pixman(term->colors.bg);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue