action.rs 991 Bytes
Newer Older
Dorota Czaplejewicz's avatar
WIP    
Dorota Czaplejewicz committed
1
/*! The symbol object, defining actions that the key can do when activated */
2

Dorota Czaplejewicz's avatar
WIP    
Dorota Czaplejewicz committed
3
use std::ffi::CString;
4

5
6
7
/// Name of the keysym
#[derive(Debug, Clone, PartialEq)]
pub struct KeySym(pub String);
8
9

/// Use to switch layouts
10
type Level = String;
11
12

/// Use to send modified keypresses
13
#[derive(Debug, Clone, PartialEq)]
14
15
16
17
18
19
pub enum Modifier {
    Control,
    Alt,
}

/// Action to perform on the keypress and, in reverse, on keyrelease
20
#[derive(Debug, Clone, PartialEq)]
21
pub enum Action {
22
    /// Switch to this view
23
    SetLevel(Level),
24
25
26
27
28
29
    /// Switch to a view and latch
    LockLevel {
        lock: Level,
        /// When unlocked by pressing it or emitting a key
        unlock: Level,
    },
30
31
32
33
    /// Set this modifier TODO: release?
    SetModifier(Modifier),
    /// Submit some text
    Submit {
Dorota Czaplejewicz's avatar
WIP    
Dorota Czaplejewicz committed
34
        /// Text to submit with input-method
35
36
        text: Option<CString>,
        /// The key events this symbol submits when submitting text is not possible
37
        keys: Vec<KeySym>,
38
39
    },
}