pub struct Keymap {
pub first: [Option<Thingy>; 256],
pub multi: HashMap<Vec<u8>, KeyBinding>,
pub primary: Option<String>,
pub flags: i32,
pub rc: i32,
}Expand description
Direct port of struct keymap from Src/Zle/zle_keymap.c:64.
A keymap — binding of keys to thingies.
Fields§
§first: [Option<Thingy>; 256]Thingy first[256] — c:65, base binding for each byte.
multi: HashMap<Vec<u8>, KeyBinding>HashTable multi — c:66, multi-character bindings.
primary: Option<String>KeymapName primary — c:78, primary alias for this map.
flags: i32int flags — c:79 (KM_IMMUTABLE).
rc: i32int rc — c:80, reference count (refkeymap/unrefkeymap/
deletekeymap).
Implementations§
Source§impl Keymap
impl Keymap
Sourcepub fn new() -> Keymap
pub fn new() -> Keymap
Construct an empty keymap with no bindings.
Equivalent to newkeytab() from Src/Zle/zle_keymap.c:278 — the
C source allocates a Keymap with the first[] array zeroed out
and an empty multi-byte hashtab.
Sourcepub fn bind_char(&mut self, c: u8, thingy: Thingy)
pub fn bind_char(&mut self, c: u8, thingy: Thingy)
Bind a 1-byte key to a Thingy via the first[] fast-path table.
Direct port of the single-byte path in bindkey() at
Src/Zle/zle_keymap.c:566; the C source writes into km->first[c]
when seq has length 1.
Sourcepub fn unbind_char(&mut self, c: u8)
pub fn unbind_char(&mut self, c: u8)
Clear a 1-byte binding.
Equivalent to bindkey -r against a single-byte sequence at
Src/Zle/zle_keymap.c:566 — flips the first[c] slot to None.
Sourcepub fn bind_seq(&mut self, seq: &[u8], thingy: Thingy)
pub fn bind_seq(&mut self, seq: &[u8], thingy: Thingy)
Install a multi-byte key sequence binding.
Direct port of bindkey(Keymap km, const char *seq, Thingy bind, char *str) from Src/Zle/zle_keymap.c:566 for the
len > 1 path: marks every proper prefix of seq as a prefix
node (prefixct increment) so getkeymapcmd’s trie walk knows to
keep reading bytes when it sees a partial match.
Sourcepub fn bind_str(&mut self, seq: &[u8], s: String)
pub fn bind_str(&mut self, seq: &[u8], s: String)
Install a multi-byte key sequence that maps to a literal string.
Port of the send-string variant of bindkey() at
Src/Zle/zle_keymap.c:566 — the C source stores str instead of
a Thingy when invoked via bindkey -s 'seq' 'string'. When the
trie hits this entry, getkeycmd ungets the string via
ungetbytes_unmeta (zle_keymap.c:1784) so it gets re-resolved
against the keymap.
Sourcepub fn unbind_seq(&mut self, seq: &[u8])
pub fn unbind_seq(&mut self, seq: &[u8])
Remove a multi-byte binding and decrement prefix counts on its
ancestors so the trie shrinks correctly.
Port of bindkey -r against a multi-byte sequence at
Src/Zle/zle_keymap.c:566 — the C source mirrors the prefix
reference-count machinery via the same prefixct decrement
pattern when removing a leaf.
Sourcepub fn lookup_char(&self, c: u8) -> Option<&Thingy>
pub fn lookup_char(&self, c: u8) -> Option<&Thingy>
Fast-path single-byte lookup through first[].
Equivalent to the 1-byte branch of keybind() at
Src/Zle/zle_keymap.c:659 — the C source’s km->first[*seq]
access for single-byte resolution.
Sourcepub fn lookup_seq(&self, seq: &[u8]) -> Option<&KeyBinding>
pub fn lookup_seq(&self, seq: &[u8]) -> Option<&KeyBinding>
Multi-byte sequence lookup through the multi hashtab.
Equivalent to the >1-byte branch of keybind() at
zle_keymap.c:659 — returns the KeyBinding entry if seq
matches a leaf, or one carrying prefixct > 0 if seq is a
prefix of one or more bound sequences.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Keymap
impl RefUnwindSafe for Keymap
impl Send for Keymap
impl Sync for Keymap
impl Unpin for Keymap
impl UnsafeUnpin for Keymap
impl UnwindSafe for Keymap
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
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>
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>
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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.