Skip to main content

argui_core/
keyboard.rs

1#[derive(Clone, Copy, Debug, Eq, PartialEq)]
2pub enum KeyState {
3    Pressed,
4    Released,
5}
6
7#[derive(Clone, Debug, Eq, PartialEq)]
8pub enum Key {
9    Character(String),
10    Function(u8),
11    ContextMenu,
12    ArrowLeft,
13    ArrowRight,
14    ArrowUp,
15    ArrowDown,
16    PageUp,
17    PageDown,
18    Home,
19    End,
20    Backspace,
21    Delete,
22    Enter,
23    Tab,
24    Escape,
25    Other,
26}
27
28#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
29pub struct Modifiers {
30    pub shift: bool,
31    pub control: bool,
32    pub alt: bool,
33    pub super_key: bool,
34}
35
36impl Modifiers {
37    #[must_use]
38    pub const fn command(self) -> bool {
39        self.control || self.super_key
40    }
41}
42
43#[derive(Clone, Debug, Eq, PartialEq)]
44pub struct KeyInput {
45    pub key: Key,
46    pub state: KeyState,
47    pub modifiers: Modifiers,
48    pub repeat: bool,
49    pub text: Option<String>,
50}
51
52#[derive(Clone, Debug, Eq, PartialEq)]
53pub enum ImeInput {
54    Enabled,
55    Disabled,
56    Preedit {
57        text: String,
58        cursor: Option<(usize, usize)>,
59    },
60    Commit(String),
61}