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: usizeselected message. only meaningful once the user has started navigating.
scroll: usizeindex of the newest message on screen — the viewport anchor.
visual: Option<usize>visual-mode anchor; the selection runs between this and the cursor.
count: usizepending motion count (5j). 0 means none typed.
g_pending: boolsaw a bare g, waiting to see whether it’s gg / gt / gT.
pattern: Stringlast search pattern and direction, for n / N.
dir: Option<Dir>§view: Cell<View>Implementations§
Source§impl Vi
impl Vi
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
back to following live chat: no selection, pinned to the newest message.
Sourcepub fn following(&self) -> bool
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).
Sourcepub fn take_count(&mut self) -> usize
pub fn take_count(&mut self) -> usize
consume the pending count, defaulting to 1.
Sourcepub fn push_digit(&mut self, d: u32) -> bool
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).
Sourcepub fn down(&mut self, n: usize)
pub fn down(&mut self, n: usize)
move toward newer (down the file). saturates at the newest message.
Sourcepub fn up(&mut self, n: usize, last: usize)
pub fn up(&mut self, n: usize, last: usize)
move toward older (up the file). saturates at the oldest one loaded.
Sourcepub fn selection(&self) -> Option<(usize, usize)>
pub fn selection(&self) -> Option<(usize, usize)>
the selected range as (newest_index, oldest_index), inclusive. None
outside visual mode.
Sourcepub fn keep_visible(&mut self)
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.
Sourcepub fn absorb_new(&mut self, added: usize, last: usize)
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.