Skip to main content

EditorSession

Struct EditorSession 

Source
pub struct EditorSession { /* private fields */ }
Expand description

Multi-buffer editor session with active buffer + MRU ordering.

Implementations§

Source§

impl EditorSession

Source

pub fn open_initial_file(path: impl AsRef<Path>) -> Result<Self>

Build a new session with a single initial file buffer.

Source

pub fn open_file(&mut self, path: impl AsRef<Path>) -> Result<BufferId>

Open (or switch to) a file-backed buffer.

  • Existing open path: activates and returns existing buffer ID.
  • Missing path: creates an empty file-backed buffer marked as new.
Source

pub fn open_ui_buffer( &mut self, name: impl Into<String>, initial_text: &str, ) -> BufferId

Open an in-memory UI buffer (future floating picker/menu hook).

Source

pub fn active_id(&self) -> BufferId

Source

pub fn activate(&mut self, id: BufferId) -> bool

Activate the target buffer and promote it to the top of MRU order.

Source

pub fn active_buffer(&self) -> &TextBuffer

Source

pub fn active_buffer_mut(&mut self) -> &mut TextBuffer

Source

pub fn active_meta(&self) -> &BufferMeta

Source

pub fn active_meta_mut(&mut self) -> &mut BufferMeta

Source

pub fn set_active_dirty(&mut self, dirty: bool)

Source

pub fn recompute_active_dirty(&mut self) -> bool

Recompute active buffer dirty state by comparing current contents against the last clean snapshot (opened-from-disk or last successful save).

Source

pub fn mark_active_clean(&mut self)

Record the active buffer’s current contents as the clean snapshot.

Source

pub fn any_dirty(&self) -> bool

Source

pub fn switch_next_mru(&mut self) -> Option<BufferId>

Cycle to the next buffer in MRU order.

Source

pub fn switch_prev_mru(&mut self) -> Option<BufferId>

Cycle to the previous buffer in MRU order.

Source

pub fn summaries(&self) -> Vec<BufferSummary>

Source

pub fn close_buffer(&mut self, id: BufferId) -> bool

Close a buffer by id, activating the next MRU buffer if needed.

Returns false if the id does not exist or this is the last remaining buffer.

Source

pub fn close_active_buffer(&mut self) -> bool

Close the currently active buffer.

Source

pub fn save_active(&mut self) -> Result<()>

Save the active file-backed buffer.

Source

pub fn buffer(&self, id: BufferId) -> Option<&TextBuffer>

Source

pub fn buffer_mut(&mut self, id: BufferId) -> Option<&mut TextBuffer>

Source

pub fn meta(&self, id: BufferId) -> Option<&BufferMeta>

Trait Implementations§

Source§

impl Debug for EditorSession

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EditorSession

Source§

fn default() -> Self

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

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<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 = 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.