Skip to main content

Register

Enum Register 

Source
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

Source

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§

Source§

impl Clone for Register

Source§

fn clone(&self) -> Register

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Register

Source§

impl Debug for Register

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Register

Source§

fn default() -> Register

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Register

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Register

Source§

impl Hash for Register

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Register

Source§

fn eq(&self, other: &Register) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Register

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Register

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more