pub enum Register {
Unnamed,
Named(char),
System,
BlackHole,
Expression,
ReadOnly(char),
Numbered(u8),
}Expand description
A vim register name.
Parse user input with Register::from_input_char; the variants that
function never returns (Register::Expression,
Register::ReadOnly) are modelled for completeness and the WIT mirror
but nothing in the host produces or reads them yet.
§Examples
use lattice_grammar::Register;
assert_eq!(Register::from_input_char('a'), Some(Register::Named('a')));
assert_eq!(Register::from_input_char('3'), Some(Register::Numbered(3)));
assert_eq!(Register::from_input_char('+'), Some(Register::System));
assert_eq!(Register::from_input_char('_'), Some(Register::BlackHole));
// `"` re-selects the default.
assert_eq!(Register::from_input_char('"'), Some(Register::default()));
// `=` (expression) is not bindable through `"<X>`.
assert_eq!(Register::from_input_char('='), None);Variants§
Unnamed
"" – the default target of every yank / delete / put when no
register was named. With the clipboard option on, reads prefer the
system clipboard.
Named(char)
"a-"z / "A-"Z. The char is stored exactly as typed:
uppercase is a separate register, not vim’s append-to-lowercase
form (not implemented).
System
"+ / "* – the system clipboard. Both chars map here; writes
always mirror to the clipboard, reads fall back to the unnamed
register when the clipboard is unavailable.
BlackHole
"_ – the sink. Writes are discarded (and do not clobber the
unnamed register); reads yield nothing.
Expression
"= – vim’s expression register. Modelled, not implemented: no
input maps to it and the host stores nothing for it.
ReadOnly(char)
Vim’s read-only registers ("., "%, ":, "/), keyed by their
char. Modelled, not implemented: no input maps to it.
Numbered(u8)
"0-"9. A read is a projection of the host’s yank ring ("0 the
newest yank, "1-"9 the newest deletes), falling back to an
explicit write into that slot. Values above 9 are not produced by
Register::from_input_char.
Implementations§
Source§impl Register
impl Register
Sourcepub fn from_input_char(c: char) -> Option<Self>
pub fn from_input_char(c: char) -> Option<Self>
Map a user-typed register-prefix char (the <X> in "<X>)
to a Register variant. Returns None for chars that
don’t name any register (the App treats None as “drop
pending state” – see docs/dev/notes/8i-approach.md slice 8.i.3).
Mirrors vim’s :help registers: letters name a register,
digits name the numbered ring, " re-selects the unnamed
register, _ is the black-hole sink, + / * are the
system clipboard (X11 / macOS conventions overlap here).
Expression / readonly registers aren’t user-bindable via
"<X> and intentionally return None.
Trait Implementations§
impl Copy for Register
Source§impl<'de> Deserialize<'de> for Register
impl<'de> Deserialize<'de> for Register
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Register
impl StructuralPartialEq for Register
Auto Trait Implementations§
impl Freeze for Register
impl RefUnwindSafe for Register
impl Send for Register
impl Sync for Register
impl Unpin for Register
impl UnsafeUnpin for Register
impl UnwindSafe for Register
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.