Skip to main content

Buffer

Struct Buffer 

Source
pub struct Buffer {
    pub lines: Vec<Line>,
    pub viewport: Viewport,
    pub cursor: Cursor,
    pub selection: Option<Selection>,
    /* private fields */
}
Expand description

The main buffer holding all parsed lines and view state.

Fields§

§lines: Vec<Line>§viewport: Viewport§cursor: Cursor§selection: Option<Selection>

Implementations§

Source§

impl Buffer

Source

pub fn new(lines: Vec<Line>) -> Self

Create a new buffer from parsed lines.

Source

pub fn line_count(&self) -> usize

Total number of lines in the buffer.

Source

pub fn get_line(&self, index: usize) -> Option<&Line>

Get a reference to a line by index, if it exists.

Source

pub fn current_line(&self) -> Option<&Line>

Source

pub fn visible_lines(&self) -> &[Line]

Get the lines currently visible in the viewport.

Source

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

Scroll down by n lines, clamping to bounds.

Source

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

Scroll up by n lines, clamping to bounds.

Source

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

Move cursor down, scrolling viewport if needed.

Source

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

Move cursor up, scrolling viewport if needed.

Source

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

Move cursor right within the current line.

Source

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

Move cursor left within the current line.

Source

pub fn cursor_top(&mut self)

Jump cursor to the first line.

Source

pub fn cursor_bottom(&mut self)

Jump cursor to the last line.

Source

pub fn half_page_down(&mut self)

Half-page down.

Source

pub fn half_page_up(&mut self)

Half-page up.

Source

pub fn page_down(&mut self)

Source

pub fn page_up(&mut self)

Source

pub fn cursor_line_start(&mut self)

Source

pub fn cursor_line_end(&mut self)

Source

pub fn cursor_first_nonblank(&mut self)

Source

pub fn cursor_view_top(&mut self)

Source

pub fn cursor_view_middle(&mut self)

Source

pub fn cursor_view_bottom(&mut self)

Source

pub fn set_cursor(&mut self, row: usize, col: usize)

Source

pub fn resize(&mut self, width: usize, height: usize)

Update viewport dimensions (called on terminal resize).

Source

pub fn ensure_cursor_visible_pub(&mut self)

Public version of ensure_cursor_visible for external callers.

Source

pub fn preferred_col(&self) -> usize

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.