wl: the text before the cursor, and the runes to take back
The surrounding_text event was taken and thrown away. It carries the text around the cursor with a byte offset into it, and belongs to the activation like the content type, so it is pending until done and starts empty at every activate. delete_surrounding_text counts bytes where the engine counts runes, and the frontend holds the text those runes are in, so it measures them itself. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -107,6 +107,30 @@ wl_forwarded_keys(struct ct *t)
|
||||
* Arming a repeat needs the engine, which is not here; ending one does
|
||||
* not, and a repeat that outlives its key is the worst this can do.
|
||||
*/
|
||||
/*
|
||||
* The text before the cursor is what a reading may reach into, and a
|
||||
* take-back is measured in the bytes those runes hold.
|
||||
*/
|
||||
void
|
||||
wl_surrounding_text(struct ct *t)
|
||||
{
|
||||
sclear(&pendingsurround);
|
||||
imsurrounding(nil, nil, "가나다라", 9, 9);
|
||||
checkstr(t, "the text before the cursor", "가나다", &pendingsurround);
|
||||
surround = pendingsurround;
|
||||
CT_EQ_INT(t, 3, backbytes(1));
|
||||
CT_EQ_INT(t, 6, backbytes(2));
|
||||
CT_EQ_INT(t, 9, backbytes(9));
|
||||
CT_EQ_INT(t, 0, backbytes(0));
|
||||
/* A cursor past the end of the buffer is the whole of it. */
|
||||
imsurrounding(nil, nil, "ab", 99, 99);
|
||||
checkstr(t, "a cursor past the end", "ab", &pendingsurround);
|
||||
/* An activation starts with none, whatever the last one had. */
|
||||
imactivate(nil, nil);
|
||||
CT_EQ_INT(t, 0, pendingsurround.n);
|
||||
sclear(&surround);
|
||||
}
|
||||
|
||||
void
|
||||
wl_repeat_ends(struct ct *t)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user