Skip to main content

BufferExt

Trait BufferExt 

Source
pub trait BufferExt: Debug {
    // Required methods
    fn get_line(&self, idx: usize) -> Result<String>;
    fn get_lines(
        &self,
        line_range: RangeInclusive<usize>,
        strict_indexing: bool,
    ) -> Result<Box<dyn SuperIterator<String>>, Error>;
    fn get_buf_type(&self) -> Option<String>;
    fn get_channel(&self) -> Option<u32>;
    fn set_text_at_cursor_pos(&mut self, text: &str);
    fn get_pid(&self) -> Result<String>;

    // Provided methods
    fn get_text_between(
        &self,
        start: (usize, usize),
        end: (usize, usize),
        boundary: TextBoundary,
    ) -> Result<String> { ... }
    fn is_terminal(&self) -> bool { ... }
    fn send_command(&self, cmd: &str) -> Option<()> { ... }
}
Expand description

Extension trait for Buffer.

Required Methods§

Source

fn get_line(&self, idx: usize) -> Result<String>

Fetch a single line from a Buffer by 0-based index.

§Errors
  • Fetching the line fails or index is out of range.
Source

fn get_lines( &self, line_range: RangeInclusive<usize>, strict_indexing: bool, ) -> Result<Box<dyn SuperIterator<String>>, Error>

Retrieves a range of lines from the buffer.

§Errors
  • If strict_indexing is true and the range is out of bounds.
  • If the Nvim API call to fetch lines fails.
Source

fn get_buf_type(&self) -> Option<String>

Retrieves the buffer type via the buftype option.

Source

fn get_channel(&self) -> Option<u32>

Source

fn set_text_at_cursor_pos(&mut self, text: &str)

Inserts text at the current cursor position.

Source

fn get_pid(&self) -> Result<String>

Retrieves the process ID associated with the buffer.

§Errors
  • Buffer name retrieval or PID parsing fails.

Provided Methods§

Source

fn get_text_between( &self, start: (usize, usize), end: (usize, usize), boundary: TextBoundary, ) -> Result<String>

Get text between start and end positions.

§Errors
  • Substring extraction fails due to invalid indices.
Source

fn is_terminal(&self) -> bool

Source

fn send_command(&self, cmd: &str) -> Option<()>

Implementors§