pub struct Documents { /* private fields */ }Expand description
Every open document + which one is active. Always holds AT LEAST ONE
document: closing the last tab leaves a fresh untitled one in its place, so
Documents::engine_mut is infallible and the shell never has to render a
“no document” state that would be an empty viewport with extra steps.
Implementations§
Source§impl Documents
impl Documents
Sourcepub fn new(new_engine: EngineFactory) -> Self
pub fn new(new_engine: EngineFactory) -> Self
A session holding ONE empty document built by new_engine.
Sourcepub fn spawn_engine(&self) -> EngineState
pub fn spawn_engine(&self) -> EngineState
A fresh engine for a document about to be opened — the caller loads into
it and hands the result to Self::open_document.
Seeded with the WHOLE of the session’s settings, workbench included, so a new tab continues what you were doing. The load that follows overrides the workbench if the document names one (see the module header).
pub fn engine(&self) -> &EngineState
pub fn engine_mut(&mut self) -> &mut EngineState
pub fn active(&self) -> &Document
pub fn active_mut(&mut self) -> &mut Document
pub fn active_index(&self) -> usize
Sourcepub fn active_id(&self) -> u64
pub fn active_id(&self) -> u64
The ACTIVE document’s handle — the shell compares it frame to frame to notice a switch from ANY source (a tab click, a close, New, Open, Open Part, the session restore) with one check instead of a hook per site.
pub fn len(&self) -> usize
pub fn get(&self, index: usize) -> Option<&Document>
pub fn get_mut(&mut self, index: usize) -> Option<&mut Document>
pub fn iter(&self) -> Iter<'_, Document> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, Document> ⓘ
Sourcepub fn index_of(&self, name: &str) -> Option<usize>
pub fn index_of(&self, name: &str) -> Option<usize>
The tab holding the document stored under name, if any.
Sourcepub fn focus_named(&mut self, name: &str) -> bool
pub fn focus_named(&mut self, name: &str) -> bool
Activate the tab already holding name; false when it is not open.
The “focus the existing tab” half of open-or-focus.
Sourcepub fn open_document(&mut self, doc: Document) -> usize
pub fn open_document(&mut self, doc: Document) -> usize
Add doc as a new tab and make it active.
Sourcepub fn activate(&mut self, index: usize)
pub fn activate(&mut self, index: usize)
Make tab index active, carrying the session’s display settings over to
it. Out-of-range indices are ignored (a stale click never panics).
Sourcepub fn close(&mut self, index: usize)
pub fn close(&mut self, index: usize)
Close tab index. Closing the LAST document leaves a fresh untitled one
(the always-one-document invariant); closing a tab before the active one
keeps the same document active at its new index.
The caller is responsible for the unsaved-changes prompt — this is the
mechanical close (panels::file owns the confirmation).
Sourcepub fn refresh_dirty_markers(&mut self)
pub fn refresh_dirty_markers(&mut self)
Refresh every tab’s dirty dot (see Document::refresh_dirty_marker).
Sourcepub fn session_json(&self) -> String
pub fn session_json(&self) -> String
The persisted session: the NAMED documents in tab order plus the active one’s name. A never-saved document has no store identity, so it cannot be restored and is not listed — reloading loses an unsaved scratch document exactly as it did when the app held one document and persisted none.
Sourcepub fn restore_session(&mut self, store: &dyn ModelStore, json: &str) -> usize
pub fn restore_session(&mut self, store: &dyn ModelStore, json: &str) -> usize
Restore a persisted session, REPLACING the current open list. Names the store no longer holds (or cannot load) are skipped — a deleted file must not stop the rest of the session coming back — and the count of documents actually restored is returned, so the caller can seed instead when it is 0.
Auto Trait Implementations§
impl !RefUnwindSafe for Documents
impl !Send for Documents
impl !Sync for Documents
impl !UnwindSafe for Documents
impl Freeze for Documents
impl Unpin for Documents
impl UnsafeUnpin for Documents
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more