mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
feat: support pre-edit text display for IME (#35535)
* feat: support pre-edit text display for IME Signed-off-by: DK Liao <dklassic@gmail.com> * enable ime by show_ime Signed-off-by: DK Liao <dklassic@gmail.com> --------- Signed-off-by: DK Liao <dklassic@gmail.com>
This commit is contained in:
parent
42e873e9d9
commit
720bc725b0
6 changed files with 91 additions and 4 deletions
|
@ -988,6 +988,17 @@ impl<T: ClipboardProvider> TextInput<T> {
|
|||
KeyReaction::DispatchInput
|
||||
}
|
||||
|
||||
pub(crate) fn handle_compositionupdate(&mut self, event: &CompositionEvent) -> KeyReaction {
|
||||
let start = self.selection_start_offset().0;
|
||||
self.insert_string(event.data());
|
||||
self.set_selection_range(
|
||||
start as u32,
|
||||
(start + event.data().len_utf8().0) as u32,
|
||||
SelectionDirection::Forward,
|
||||
);
|
||||
KeyReaction::DispatchInput
|
||||
}
|
||||
|
||||
/// Whether the content is empty.
|
||||
pub(crate) fn is_empty(&self) -> bool {
|
||||
self.lines.len() <= 1 && self.lines.first().map_or(true, |line| line.is_empty())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue