Commit graph

23 commits

Author SHA1 Message Date
Daniel Eklöf
7cb49681e7
ime: enter(): remove assertion on surface kind being TERM_SURF_GRID
The main surface is the *only* IME capable surface we have. If the
compositor is sending an ime::enter event for another surface, it is a
compositor bug, not a foot bug.
2021-02-07 11:11:58 +01:00
Tadeo Kondrak
1515b7e44b
ime: Reset terminal's IME state on text_input.leave
To reproduce issue:
- Launch an IME from inside foot
- Type in some preedit text
- Use Ctrl-C to close the IME
- IME text stays in terminal until focus is changed
2021-01-30 12:24:12 -07:00
Tadeo Kondrak
95c0c89cac
Send text_input_rectangle requests for text-input 2021-01-28 22:22:01 -07:00
Daniel Eklöf
a763531775
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.
2021-01-26 19:30:34 +01:00
Craig Barnes
e56136ce11 debug: rename assert() to xassert(), to avoid clashing with <assert.h> 2021-01-16 20:16:00 +00:00
Daniel Eklöf
2227e36c66
ime: don’t call text-input functions when it isn’t available
Closes #259
2020-12-26 12:09:48 +01:00
Daniel Eklöf
a6ed9a9773
ime: don’t underline characters inside the cursor-box 2020-12-07 20:44:15 +01:00
Daniel Eklöf
fd42a0bc23
ime: call render_refresh_search() instead of render_refresh()
When scrollback search is active
2020-12-07 20:44:14 +01:00
Daniel Eklöf
194fbff883
ime: store wchar version of pre-edit string in terminal struct 2020-12-07 20:44:14 +01:00
Daniel Eklöf
d87160e5f6
ime: commit text using search_add_chars() while in scrollback search mode 2020-12-07 20:44:12 +01:00
Daniel Eklöf
7eea6f94ed
ime: don’t commit to the slave while scrollback searching 2020-12-07 20:44:12 +01:00
Daniel Eklöf
b59d695b2b
ime: add functions to enable/disable IME, simplify code that enables IME
We may want to be able to enable/disable IME run-time, even though we
have received an ‘enter’ IME event.

This enables us to do that.

Also add functions to enable/disable IME on a per-terminal instance
basis.

A terminal may have multiple seats focusing it, and enabling/disabling
IME in a terminal instance enables/disables IME on all those seats.

Finally, the code to enable IME is simplified; the *only* surface that
can ever receive ‘enter’ IME events is the main grid. All other
surfaces are sub-surfaces, without their own keyboard focus.
2020-12-07 20:44:11 +01:00
Daniel Eklöf
5c17b7f8e7
ime: expand cursor cell-end across multi-cell characters
This fixes an issue where the cursor ended in the middle of e.g double
width characters.
2020-12-07 20:44:11 +01:00
Daniel Eklöf
001c82fa54
ime: don’t adjust cursor’s cell-end if it’s equal to the cell-begin 2020-12-07 20:44:11 +01:00
Daniel Eklöf
552b9884b9
ime: set cursor end correctly when it ends *after* the pre-edit string 2020-12-07 20:44:11 +01:00
Daniel Eklöf
cc76f91c43
ime: use correct index when calculating number of *cells* to advance 2020-12-07 20:44:11 +01:00
Daniel Eklöf
98bd798dae
ime: calculate wchar widths once 2020-12-07 20:44:10 +01:00
Daniel Eklöf
05083110c3
ime: make IME compile-time optional 2020-12-07 20:44:10 +01:00
Daniel Eklöf
8c3d48c5cd
ime: render pre-edit text
This is done by allocating cells for the pre-edit text when receiving
the text-input::done() call, and populating them by converting the
utf-8 formatted pre-edit text to wchars.

We also convert the pre-edit cursor position to cell positions (it can
cover multiple cells).

When rendering, we simply render the pre-edit cells on-top off the
regular grid. While doing so, we also mark the underlying, “real”,
cells as dirty, to ensure they are re-rendered when the pre-edit text
is modified or removed.
2020-12-07 20:44:10 +01:00
Daniel Eklöf
5745c610ac
ime: wip: commit all changes in ‘done()’ 2020-12-07 20:44:10 +01:00
Daniel Eklöf
b85e2f40bb
ime: feed committed string to client application 2020-12-07 20:44:10 +01:00
Daniel Eklöf
e97024116e
ime: disable text-input on surface leave 2020-12-07 20:44:10 +01:00
Daniel Eklöf
148bb1ff13
ime: wip: add text-input object to seat 2020-12-07 20:44:09 +01:00