mod edit_box;
mod edit_field;
mod editor;
mod guard;
pub use edit_box::EditBox;
pub use edit_field::EditField;
pub use editor::Editor;
pub use guard::*;
use std::fmt::Debug;
use std::ops::Range;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum EditOp {
Initial,
Cursor,
KeyInput,
Ime,
Delete,
Clipboard,
Synthetic,
}
impl EditOp {
fn try_merge(self, last_op: &mut Option<Self>) -> bool {
match (self, last_op) {
(EditOp::Cursor, Some(last)) => {
*last = self;
true
}
(EditOp::KeyInput | EditOp::Delete, Some(last)) if self == *last => true,
_ => false,
}
}
}
enum CmdAction {
Unused,
Used,
Cursor,
Activate,
Edit,
}
#[derive(Clone, Debug, Default, PartialEq, Eq)]
enum CurrentAction {
#[default]
None,
ImeStart,
ImePreedit {
edit_range: Range<u32>,
},
Selection,
}
impl CurrentAction {
fn is_none(&self) -> bool {
*self == CurrentAction::None
}
fn is_ime_enabled(&self) -> bool {
matches!(
self,
CurrentAction::ImeStart | CurrentAction::ImePreedit { .. }
)
}
}