Skip to main content

Vi

Struct Vi 

Source
pub struct Vi {
    pub cursor: usize,
    pub scroll: usize,
    pub visual: Option<usize>,
    pub count: usize,
    pub g_pending: bool,
    pub pattern: String,
    pub dir: Option<Dir>,
    pub view: Cell<View>,
}

Fields§

§cursor: usize

selected message. only meaningful once the user has started navigating.

§scroll: usize

index of the newest message on screen — the viewport anchor.

§visual: Option<usize>

visual-mode anchor; the selection runs between this and the cursor.

§count: usize

pending motion count (5j). 0 means none typed.

§g_pending: bool

saw a bare g, waiting to see whether it’s gg / gt / gT.

§pattern: String

last search pattern and direction, for n / N.

§dir: Option<Dir>§view: Cell<View>

Implementations§

Source§

impl Vi

Source

pub fn reset(&mut self)

back to following live chat: no selection, pinned to the newest message.

Source

pub fn following(&self) -> bool

are we pinned to the bottom with nothing selected? while true the cursor bar stays hidden and new messages scroll in, so live chat reads clean and the first k is what reveals the cursor (less/copy-mode behaviour).

Source

pub fn take_count(&mut self) -> usize

consume the pending count, defaulting to 1.

Source

pub fn push_digit(&mut self, d: u32) -> bool

accumulate a count digit. 0 only counts as a digit mid-number, matching vi (a bare 0 is a motion, and here there is no column to move to).

Source

pub fn down(&mut self, n: usize)

move toward newer (down the file). saturates at the newest message.

Source

pub fn up(&mut self, n: usize, last: usize)

move toward older (up the file). saturates at the oldest one loaded.

Source

pub fn to_newest(&mut self)

G — the newest message.

Source

pub fn to_oldest(&mut self, last: usize)

gg — the oldest message still in the ring.

Source

pub fn selection(&self) -> Option<(usize, usize)>

the selected range as (newest_index, oldest_index), inclusive. None outside visual mode.

Source

pub fn selected(&self, idx: usize) -> bool

is this message inside the visual selection?

Source

pub fn keep_visible(&mut self)

pull the viewport so the cursor is on screen. count is what the last frame fit; heights vary, so this can be a row out for one frame and then settles — far cheaper than re-running layout inside the key handler.

Source

pub fn absorb_new(&mut self, added: usize, last: usize)

new messages arrived. while the user is reading scrollback we shift the viewport and cursor by the same amount, so the pane holds still and the cursor stays on the message it was on instead of sliding underneath. once they’re back at the bottom, chat follows live again.

Source

pub fn clamp(&mut self, last: usize)

clamp to a ring that may have shrunk (channel switched, messages evicted).

Trait Implementations§

Source§

impl Default for Vi

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl !Freeze for Vi

§

impl !RefUnwindSafe for Vi

§

impl !Sync for Vi

§

impl Forget for Vi

§

impl Send for Vi

§

impl Unpin for Vi

§

impl UnsafeUnpin for Vi

§

impl UnwindSafe for Vi

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.