Skip to main content

Document

Struct Document 

Source
pub struct Document { /* private fields */ }
Expand description

A markdown document as its editors share it.

Implementations§

Source§

impl Document

Source

pub fn new(source: &str, cx: &mut Context<'_, Self>) -> Self

Source

pub fn with_undo_limit(self, limit: usize) -> Self

How many undo steps to keep; crate::DEFAULT_UNDO_LIMIT until set. A run of typing coalesces into one step.

Source

pub fn with_marks(self, marks: Marks) -> Self

Read and write this document with marks of its own, rather than the ones markdown::AppExt::set_marks installed. For an app whose documents do not all speak the same dialect.

Source

pub fn with_mode(self, mode: Mode) -> Self

Open in Mode::Source rather than on the document — an app whose document is a markdown file first. Nothing is recorded: this is where the document starts, not a switch to step back over.

Source

pub fn source(&self) -> String

The document as markdown — see crate::Editor::source.

Source

pub fn mode(&self) -> Mode

Which form the document is being edited in.

Source

pub fn doc(&self) -> &Doc

Source

pub fn reload(&mut self, source: &str, cx: &mut Context<'_, Self>)

Read the document again from source, in the form it is in. The undo stack and the anchors go with the old text.

Source

pub fn anchors(&self) -> &[Anchor]

The comment ranges, mapped up to date with the document.

A range that reads Anchor::detached lost the words it pointed at. It is kept rather than dropped, because whether that means “outdated” or “resolved” is the app’s question.

Source

pub fn set_anchors(&mut self, anchors: Vec<Anchor>, cx: &mut Context<'_, Self>)

Hand over the whole list — the app keeps the threads, this keeps their ranges. One entry point rather than add/remove/update, since the app is already holding the list that decides all three.

Ranges are positions in Self::doc as it stands: the source fence in Mode::Source, the blocks otherwise.

Source

pub fn source_with_anchors(&self) -> (String, SourceRanges)

The markdown to save, and where each anchor’s ends land in it, in byte offsets, in the order of Self::anchors. A range with an end the markdown has no place for comes out None.

The string is Self::source but for whitespace a placed end keeps from being trailing; the ranges index this string, so it is the one to write beside them.

Source

pub fn set_source_anchors( &mut self, source: &str, anchors: Vec<SourceAnchor>, cx: &mut Context<'_, Self>, )

Self::set_anchors with ranges given in byte offsets into source, the markdown the document was read from. A range with an end the document has no place for comes in detached.

Trait Implementations§

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> 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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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