pub struct KeyChord {
pub code: KeyCode,
pub mods: KeyModifiers,
}Expand description
A normalized key + modifier combination.
Fields§
§code: KeyCodeThe key code.
mods: KeyModifiersThe active modifiers (after normalization).
Implementations§
Source§impl KeyChord
impl KeyChord
Sourcepub fn normalized(code: KeyCode, mods: KeyModifiers) -> KeyChord
pub fn normalized(code: KeyCode, mods: KeyModifiers) -> KeyChord
Builds a normalized chord from a key code and modifiers.
Sourcepub fn from_event(ev: KeyEvent) -> KeyChord
pub fn from_event(ev: KeyEvent) -> KeyChord
Normalizes a terminal key event into a chord for lookup.
Sourcepub fn parse(s: &str) -> Option<KeyChord>
pub fn parse(s: &str) -> Option<KeyChord>
Parses a key string such as ctrl+u, alt+enter, shift+tab, f5, or
q. Returns None for malformed strings.
Sourcepub fn render(&self) -> String
pub fn render(&self) -> String
Renders this chord back to a key string (inverse of KeyChord::parse).
Sourcepub fn display(&self) -> String
pub fn display(&self) -> String
Renders this chord for on-screen hints and the help overlay:
terminal-pretty (↑, Enter, Shift+Tab, Ctrl-S, plain letters).
Distinct from KeyChord::render, which produces the lowercase
ctrl+u config format that round-trips through KeyChord::parse.
Trait Implementations§
impl Copy for KeyChord
impl Eq for KeyChord
impl StructuralPartialEq for KeyChord
Auto Trait Implementations§
impl Freeze for KeyChord
impl RefUnwindSafe for KeyChord
impl Send for KeyChord
impl Sync for KeyChord
impl Unpin for KeyChord
impl UnsafeUnpin for KeyChord
impl UnwindSafe for KeyChord
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more