orbclient_window_shortcuts 0.1.5

Shortcut support for orbclient::Window
use serde;
use serde_json;

use serde_derive;

/// A shortcut consists of an id and a combination of keystrokes
/// id can be of any generic type
#[derive(Deserialize, Clone, Debug)]
pub struct Shortcut {
    pub id: CommonId,
    pub keys: Vec<u8>,
}

/// Pseudo shortcut ids
#[derive(PartialEq, Clone, Copy, Debug)]
pub enum PseudoId {
    Pressed
}

/// Most common shortcut ids.
#[derive(Deserialize, PartialEq, Clone, Copy, Debug)]
pub enum CommonId {
    New, Open, Save, Help, Quit
}

/// Compares pressed keys against a set of supported shortcuts
#[derive(Deserialize, Clone, Debug)]
pub struct ShortcutComparator {
    /// A single Shortcut or None
    pub pressed: Vec<u8>,
    /// A set of Shortcuts or None
    pub supported: Option<Vec<Shortcut>>,
    /// optional flag for the comparator
    pub min_shortcut_len: u8,
}