[][src]Enum stakker_tui::Key

pub enum Key {
    Pr(char),
    Ctrl(char),
    F(u32),
    Tab,
    Return,
    BackSp,
    Esc,
    Up,
    Down,
    Left,
    Right,
    PgUp,
    PgDn,
    Home,
    Insert,
    Delete,
    End,
    Meta(char),
    MetaCtrl(char),
    MetaF(u32),
    MetaTab,
    MetaReturn,
    MetaBackSp,
    MetaEsc,
    MetaUp,
    MetaDown,
    MetaLeft,
    MetaRight,
    MetaPgUp,
    MetaPgDn,
    MetaHome,
    MetaInsert,
    MetaDelete,
    MetaEnd,
    PasteStart,
    PasteEnd,
    Check,
    Invalid,
}

A keypress

Note that not all possible combinations of keys can actually be transmitted as an ANSI sequence. Often Ctrl is only recognised with the 32 ASCII characters from @ to _. Some of the Meta combinations can only be generated by pressing Esc quickly followed by the key.

Variants

Pr(char)

Printable character without Ctrl or Alt

Ctrl(char)

Control key combination. Note that some control keys are passed through as specific values for convenience: Key::Tab for ^I (ASCII 9), Key::Return for ^M (ASCII 13), Key::Esc for ^[ (ASCII 27) and Key::BackSp for ^? (ASCII 127).

F(u32)

Function key, F1 to F20

Tab
Return
BackSp
Esc
Up
Down
Left
Right
PgUp
PgDn
Home
Insert
Delete
End
Meta(char)

Meta/Alt key combination

MetaCtrl(char)

Meta/Alt with Ctrl key combination

MetaF(u32)

Meta/Alt with function key F1 to F20

MetaTab
MetaReturn
MetaBackSp
MetaEsc
MetaUp
MetaDown
MetaLeft
MetaRight
MetaPgUp
MetaPgDn
MetaHome
MetaInsert
MetaDelete
MetaEnd
PasteStart

Appears before pasted text on some terminals

PasteEnd

Appears after pasted text on some terminals

Check

Check can be sent in a pause in typing, 300ms after the last keypress. It's a good time to do field validation if that validation is expensive. See Terminal::check.

Invalid

Invalid is generated for a keypress which cannot be decoded, e.g. invalid UTF-8 or some other problem

Implementations

impl Key[src]

pub fn meta(&self) -> Option<Self>[src]

Add meta to a key if possible, otherwise return None

pub fn decode(data: &[u8], force: bool) -> Option<(usize, Key)>[src]

Attempt to decode a keypress from data received from the terminal. Will not decode a partial sequence at the end of the buffer unless force is set. Returns count of bytes consumed and the decoded key, or else None.

Trait Implementations

impl Debug for Key[src]

impl Display for Key[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Convert to a display string, using M- and C- prefixes for Meta and Ctrl.

impl Eq for Key[src]

impl FromStr for Key[src]

type Err = ParseKeyError

The associated error which can be returned from parsing.

fn from_str(s: &str) -> Result<Key, ParseKeyError>[src]

Convert back from the Display representation of a key

impl PartialEq<Key> for Key[src]

impl StructuralEq for Key[src]

impl StructuralPartialEq for Key[src]

Auto Trait Implementations

impl RefUnwindSafe for Key

impl Send for Key

impl Sync for Key

impl Unpin for Key

impl UnwindSafe for Key

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Any for T where
    T: Any

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.