Skip to main content

Documents

Struct Documents 

Source
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

Source

pub fn new(new_engine: EngineFactory) -> Self

A session holding ONE empty document built by new_engine.

Source

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

Source

pub fn engine(&self) -> &EngineState

Source

pub fn engine_mut(&mut self) -> &mut EngineState

Source

pub fn active(&self) -> &Document

Source

pub fn active_mut(&mut self) -> &mut Document

Source

pub fn active_index(&self) -> usize

Source

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.

Source

pub fn len(&self) -> usize

Source

pub fn get(&self, index: usize) -> Option<&Document>

Source

pub fn get_mut(&mut self, index: usize) -> Option<&mut Document>

Source

pub fn iter(&self) -> Iter<'_, Document>

Source

pub fn iter_mut(&mut self) -> IterMut<'_, Document>

Source

pub fn index_of(&self, name: &str) -> Option<usize>

The tab holding the document stored under name, if any.

Source

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.

Source

pub fn open_document(&mut self, doc: Document) -> usize

Add doc as a new tab and make it active.

Source

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

Source

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

Source

pub fn refresh_dirty_markers(&mut self)

Refresh every tab’s dirty dot (see Document::refresh_dirty_marker).

Source

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.

Source

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§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more