Skip to main content

FlowModel

Struct FlowModel 

Source
pub struct FlowModel<'a> { /* private fields */ }
Expand description

The paragraphs under a root in a content tree, for one frame’s editing.

Implementations§

Source§

impl<'a> FlowModel<'a>

Source

pub fn new( content: &'a mut Element, styles: &'a mut Styles, root: Vec<usize>, editing: &'a mut Editing, ) -> Self

The paragraphs under the element at a path in a content tree, whose document’s styles are styles.

Source

pub fn tagged(self, tag: Vec<usize>) -> Self

Have the caret an undo step remembers begin with these indices, which the view takes off again when it is asked to put the caret back.

Source

pub fn within(self, scope: Vec<usize>) -> Self

Keep to the paragraphs under one element beneath the root, so that moving and joining never leave it: a slide’s label does not run on into the next shape.

Source

pub fn is_block(&self, selection: &Selection<Vec<usize>>, block: Block) -> bool

Whether a block is what every paragraph a selection runs over already is, which is when its button is lit and pressing it takes it off.

Source

pub fn replace_matches( &mut self, matches: &[&Match], with: &str, new_step: bool, ) -> Replaced

Replace each match of a search with a text, last first so that the offsets of the ones before hold. The first replacement begins an undo step when new_step says so and the rest join it. Answers how many were replaced.

Source

pub fn apply_block(&mut self, editor: &mut PageEditor, block: Block) -> bool

Make the paragraphs a selection runs over a kind of paragraph, or take them out of it where they already are one, as one step to undo, and put the selection back over the same paragraphs. Answers whether the document changed.

Trait Implementations§

Source§

impl Model for FlowModel<'_>

Source§

type Paragraph = Vec<usize>

Names a paragraph. An edit may change what any paragraph is called, so the editor holds only the positions the model hands back.
Source§

fn text(&self, paragraph: &Vec<usize>) -> Option<String>

The paragraph’s text, with a line break as '\n' and a tab as '\t'. None when the model has no such paragraph.
Source§

fn next(&self, paragraph: &Vec<usize>) -> Option<Vec<usize>>

The editable paragraph after this one in document order.
Source§

fn previous(&self, paragraph: &Vec<usize>) -> Option<Vec<usize>>

The editable paragraph before this one in document order.
Source§

fn first(&self) -> Option<Vec<usize>>

The first editable paragraph, None when there is none.
Source§

fn last(&self) -> Option<Vec<usize>>

The last editable paragraph, None when there is none.
Source§

fn marked( &self, from: &Position<Vec<usize>>, to: &Position<Vec<usize>>, mark: Mark, ) -> Option<bool>

Whether the text from one position to another carries a mark: Some when all of it says the same, None when it differs. Two positions that are the same answer for the text typed there would take its formatting from. A model that keeps no formatting leaves this as it is, which says nothing is marked, and refuses Edit::Format.
Source§

fn fragment( &self, from: &Position<Vec<usize>>, to: &Position<Vec<usize>>, ) -> Option<Fragment>

A copy of the text from one position to another that keeps what the plain text of it cannot, for pasting back into this model. The editor holds it beside the plain text it put on the clipboard and uses it only while the clipboard still holds that text. A model that keeps no formatting leaves this as it is and pastes are plain.
Source§

fn paste_fragment( &mut self, at: &Position<Vec<usize>>, fragment: &Fragment, new_step: bool, ) -> Option<Position<Vec<usize>>>

Put a Fragment this model made in at a position, as one edit, and answer where the caret stands after it. new_step is as for Self::apply. None refuses it, and the paste is plain.
Source§

fn apply( &mut self, edit: Edit<'_, Vec<usize>>, new_step: bool, ) -> Option<Position<Vec<usize>>>

Make an edit, and answer where the caret stands after it: after the replacing text, at the start of the second half of a split, or for a format at the end of the formatted text. None refuses the edit and leaves the document as it was. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for FlowModel<'a>

§

impl<'a> !RefUnwindSafe for FlowModel<'a>

§

impl<'a> !Send for FlowModel<'a>

§

impl<'a> !Sync for FlowModel<'a>

§

impl<'a> !UnwindSafe for FlowModel<'a>

§

impl<'a> Unpin for FlowModel<'a>

§

impl<'a> UnsafeUnpin for FlowModel<'a>

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