Skip to main content

RegisterBank

Struct RegisterBank 

Source
pub struct RegisterBank { /* private fields */ }
Expand description

Register storage for yank/paste operations.

This is a pure data structure without any system clipboard integration. System clipboard access ("+ and "*) is handled at the driver level.

§Supported Registers

  • Unnamed register ("") - Default for all operations
  • Named registers ("a to "z) - User-specified storage

§Example

use reovim_kernel::api::v1::*;

let mut bank = RegisterBank::new();

// Set unnamed register (default yank target)
bank.set(RegisterContent::characterwise("hello"));
assert_eq!(bank.get().text, "hello");

// Use named register
bank.set_named('a', RegisterContent::linewise("line content"));
assert_eq!(bank.get_named('a').map(|r| r.text.as_str()), Some("line content"));

Implementations§

Source§

impl RegisterBank

Source

pub fn new() -> Self

Create a new empty register bank.

Source

pub const fn get(&self) -> &RegisterContent

Get the unnamed register content.

Source

pub fn set(&mut self, content: RegisterContent)

Set the unnamed register content.

Source

pub fn get_named(&self, name: char) -> Option<&RegisterContent>

Get a named register content (‘a’-‘z’).

Returns None if the register name is invalid or empty.

Source

pub fn set_named(&mut self, name: char, content: RegisterContent) -> bool

Set a named register content (‘a’-‘z’).

Returns true if successful, false if the register name is invalid.

Source

pub fn append_named(&mut self, name: char, content: &str) -> bool

Append to a named register (‘A’-‘Z’ appends to ‘a’-‘z’).

Returns true if successful, false if the register name is invalid.

Source

pub fn clear(&mut self)

Clear the unnamed register.

Source

pub fn clear_named(&mut self, name: char) -> bool

Clear a named register.

Returns true if the register existed and was cleared.

Source

pub fn clear_all(&mut self)

Clear all registers.

Source

pub fn get_by_name(&self, name: Option<char>) -> Option<&RegisterContent>

Get register by name.

  • None or '"' returns the unnamed register
  • 'a'-'z' returns named registers
Source

pub fn iter_non_empty(&self) -> impl Iterator<Item = (char, &RegisterContent)>

Iterate over all non-empty registers.

Returns an iterator of (name, content) pairs. The unnamed register uses '"' as its name.

Source

pub fn get_register(&self, reg: &Register) -> Option<&RegisterContent>

Get register content by typed Register.

Returns None for History, System, Session, and PeerHistory variants (not stored in the per-client bank).

§Example
use reovim_kernel::api::v1::*;

let mut bank = RegisterBank::new();
bank.set(RegisterContent::characterwise("hello"));

assert_eq!(bank.get_register(&Register::Default).map(|r| r.text.as_str()), Some("hello"));
assert!(bank.get_register(&Register::System).is_none());
Source

pub fn set_register(&mut self, reg: &Register, content: RegisterContent) -> bool

Set register content by typed Register.

Returns false for read-only or non-bank registers.

§Example
use reovim_kernel::api::v1::*;

let mut bank = RegisterBank::new();
assert!(bank.set_register(&Register::Slot('a'), RegisterContent::characterwise("alpha")));
assert!(!bank.set_register(&Register::System, RegisterContent::characterwise("nope")));
Source

pub fn append_slot(&mut self, slot: char, content: &str) -> bool

Append content to a slot register (lowercase a-z).

If the slot doesn’t exist, it is created with the given content. Returns false if the slot character is not lowercase a-z.

Source

pub fn set_by_name( &mut self, name: Option<char>, content: RegisterContent, ) -> bool

Set register by name.

  • None or '"' sets the unnamed register
  • 'a'-'z' sets named registers
  • 'A'-'Z' appends to named registers

Returns true if successful.

Trait Implementations§

Source§

impl Clone for RegisterBank

Source§

fn clone(&self) -> RegisterBank

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RegisterBank

Source§

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

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

impl Default for RegisterBank

Source§

fn default() -> Self

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

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.