pub struct EditorSession { /* private fields */ }Expand description
Multi-buffer editor session with active buffer + MRU ordering.
Implementations§
Source§impl EditorSession
impl EditorSession
Sourcepub fn open_initial_file(path: impl AsRef<Path>) -> Result<Self>
pub fn open_initial_file(path: impl AsRef<Path>) -> Result<Self>
Build a new session with a single initial file buffer.
Sourcepub fn open_file(&mut self, path: impl AsRef<Path>) -> Result<BufferId>
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.
Sourcepub fn open_ui_buffer(
&mut self,
name: impl Into<String>,
initial_text: &str,
) -> BufferId
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).
pub fn active_id(&self) -> BufferId
Sourcepub fn activate(&mut self, id: BufferId) -> bool
pub fn activate(&mut self, id: BufferId) -> bool
Activate the target buffer and promote it to the top of MRU order.
pub fn active_buffer(&self) -> &TextBuffer
pub fn active_buffer_mut(&mut self) -> &mut TextBuffer
pub fn active_meta(&self) -> &BufferMeta
pub fn active_meta_mut(&mut self) -> &mut BufferMeta
pub fn set_active_dirty(&mut self, dirty: bool)
Sourcepub fn recompute_active_dirty(&mut self) -> bool
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).
Sourcepub fn mark_active_clean(&mut self)
pub fn mark_active_clean(&mut self)
Record the active buffer’s current contents as the clean snapshot.
pub fn any_dirty(&self) -> bool
Sourcepub fn switch_next_mru(&mut self) -> Option<BufferId>
pub fn switch_next_mru(&mut self) -> Option<BufferId>
Cycle to the next buffer in MRU order.
Sourcepub fn switch_prev_mru(&mut self) -> Option<BufferId>
pub fn switch_prev_mru(&mut self) -> Option<BufferId>
Cycle to the previous buffer in MRU order.
pub fn summaries(&self) -> Vec<BufferSummary>
Sourcepub fn close_buffer(&mut self, id: BufferId) -> bool
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.
Sourcepub fn close_active_buffer(&mut self) -> bool
pub fn close_active_buffer(&mut self) -> bool
Close the currently active buffer.
Sourcepub fn save_active(&mut self) -> Result<()>
pub fn save_active(&mut self) -> Result<()>
Save the active file-backed buffer.