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
impl Buffer
Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
Total number of lines in the buffer.
Sourcepub fn get_line(&self, index: usize) -> Option<&Line>
pub fn get_line(&self, index: usize) -> Option<&Line>
Get a reference to a line by index, if it exists.
pub fn current_line(&self) -> Option<&Line>
Sourcepub fn visible_lines(&self) -> &[Line]
pub fn visible_lines(&self) -> &[Line]
Get the lines currently visible in the viewport.
Sourcepub fn scroll_down(&mut self, n: usize)
pub fn scroll_down(&mut self, n: usize)
Scroll down by n lines, clamping to bounds.
Sourcepub fn cursor_down(&mut self, n: usize)
pub fn cursor_down(&mut self, n: usize)
Move cursor down, scrolling viewport if needed.
Sourcepub fn cursor_right(&mut self, n: usize)
pub fn cursor_right(&mut self, n: usize)
Move cursor right within the current line.
Sourcepub fn cursor_left(&mut self, n: usize)
pub fn cursor_left(&mut self, n: usize)
Move cursor left within the current line.
Sourcepub fn cursor_top(&mut self)
pub fn cursor_top(&mut self)
Jump cursor to the first line.
Sourcepub fn cursor_bottom(&mut self)
pub fn cursor_bottom(&mut self)
Jump cursor to the last line.
Sourcepub fn half_page_down(&mut self)
pub fn half_page_down(&mut self)
Half-page down.
Sourcepub fn half_page_up(&mut self)
pub fn half_page_up(&mut self)
Half-page up.
pub fn page_down(&mut self)
pub fn page_up(&mut self)
pub fn cursor_line_start(&mut self)
pub fn cursor_line_end(&mut self)
pub fn cursor_first_nonblank(&mut self)
pub fn cursor_view_top(&mut self)
pub fn cursor_view_middle(&mut self)
pub fn cursor_view_bottom(&mut self)
pub fn set_cursor(&mut self, row: usize, col: usize)
Sourcepub fn resize(&mut self, width: usize, height: usize)
pub fn resize(&mut self, width: usize, height: usize)
Update viewport dimensions (called on terminal resize).
Sourcepub fn ensure_cursor_visible_pub(&mut self)
pub fn ensure_cursor_visible_pub(&mut self)
Public version of ensure_cursor_visible for external callers.
pub fn preferred_col(&self) -> usize
Auto Trait Implementations§
impl Freeze for Buffer
impl RefUnwindSafe for Buffer
impl Send for Buffer
impl Sync for Buffer
impl Unpin for Buffer
impl UnsafeUnpin for Buffer
impl UnwindSafe for Buffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more