action.rs 1.04 KB
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
10
/// Use to switch views
type View = 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
    SetView(View),
24
    /// Switch to a view and latch
25
26
    LockView {
        lock: View,
27
        /// When unlocked by pressing it or emitting a key
28
        unlock: View,
29
    },
30
31
32
33
    /// Set this modifier TODO: release?
    SetModifier(Modifier),
    /// Submit some text
    Submit {
34
35
        /// Text to submit with input-method.
        /// If None, then keys are to be submitted instead.
36
37
        text: Option<CString>,
        /// The key events this symbol submits when submitting text is not possible
38
        keys: Vec<KeySym>,
39
    },
40
    ShowPreferences,
41
}