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 fresh document built by new_engine.
Sourcepub fn wrap_engine_factory(
&mut self,
wrap: impl Fn(EngineState) -> EngineState + 'static,
)
pub fn wrap_engine_factory( &mut self, wrap: impl Fn(EngineState) -> EngineState + 'static, )
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).
Build every later tab’s engine through wrap as well: the app’s live
PLM reconnect puts the new store’s settings over the factory’s.
pub fn spawn_engine(&self) -> EngineState
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, a crash-recovery 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 pump_all(&mut self) -> bool
pub fn pump_all(&mut self) -> bool
Land every open document’s finished runs; true while any of them still
has work in flight, so the frame loop keeps pumping.
EVERY open document is pumped, not just the active one: a run belongs to
the engine that submitted it (each document owns its own runner), so a
run still in flight when the user switches tabs must land in ITS
document rather than be dropped or, worse, applied to whatever is on
screen. An idle document’s pump is a couple of empty try_recvs.
The kernel’s parts library is one store for every tab, and a pump can
SUBMIT a run as well as land one: EngineState::pump re-runs after its
runner refused a run for a library it no longer holds, after a ports
edit moved a point, and when a mesh reconstruction lands (its STEP is
imported, which writes the store into the document and runs). A submit hands the runner whatever library is
in the store, and a run that lands mirrors the store it ran with into
its document’s own partsLibrary block. So a tab in the BACKGROUND that
may do either — a run in flight, or a point move waiting — is pumped with
ITS library installed, and the active document’s is put back right after.
(A STEP probe’s reply only stashes what it found, and landing a run
submits nothing, so those need no more than run_pending.)
Pumped with the active one’s, it resolved its components against another
document’s parts, and the run that landed wrote that into its own file.
An idle background tab submits and lands nothing, so it costs nothing.
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).
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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.