Skip to main content

Document

Struct Document 

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

A model and the cursors of its only editor. Editors sharing a model use TextModel, Cursors and Editor directly.

Implementations§

Source§

impl Document

Source

pub fn new(text: &str) -> Self

Source

pub fn model(&self) -> &TextModel

Source

pub fn editor(&mut self) -> Editor<'_>

Source

pub fn rope(&self) -> &Rope

Source

pub fn text(&self) -> String

Source

pub fn len_chars(&self) -> usize

Source

pub fn version(&self) -> u64

Source

pub fn line_ending(&self) -> LineEnding

Source

pub fn options(&self) -> Options

Source

pub fn set_options(&mut self, options: Options)

Source

pub fn selections(&self) -> &Selections

Source

pub fn can_undo(&self) -> bool

Source

pub fn can_redo(&self) -> bool

Source

pub fn checkpoint(&mut self)

Source

pub fn set_text(&mut self, text: &str)

Replaces the whole text and clears the undo history.

Source

pub fn take_events(&mut self) -> Vec<EditEvent>

Returns the edits applied since the last call, in application order. Calls must come at least every 1024 change sets, or older events are lost.

Source

pub fn copy(&mut self) -> String

Source

pub fn set_selections(&mut self, selections: Selections)

Source

pub fn insert(&mut self, text: &str)

Source

pub fn newline(&mut self)

Source

pub fn indent(&mut self)

Source

pub fn delete_backward(&mut self)

Source

pub fn delete_forward(&mut self)

Source

pub fn delete_word_backward(&mut self)

Source

pub fn delete_word_forward(&mut self)

Source

pub fn apply_edits(&mut self, edits: Vec<Edit>)

Source

pub fn cut(&mut self) -> String

Source

pub fn paste(&mut self, text: &str)

Source

pub fn move_left(&mut self, extend: bool)

Source

pub fn move_right(&mut self, extend: bool)

Source

pub fn move_word_left(&mut self, extend: bool)

Source

pub fn move_word_right(&mut self, extend: bool)

Source

pub fn move_up(&mut self, extend: bool)

Source

pub fn move_down(&mut self, extend: bool)

Source

pub fn move_vertical(&mut self, lines: isize, extend: bool)

Source

pub fn move_line_start(&mut self, extend: bool)

Source

pub fn move_line_end(&mut self, extend: bool)

Source

pub fn move_document_start(&mut self, extend: bool)

Source

pub fn move_document_end(&mut self, extend: bool)

Source

pub fn select_all(&mut self)

Source

pub fn add_cursor_vertical(&mut self, below: bool)

Source

pub fn undo(&mut self) -> bool

Source

pub fn redo(&mut self) -> bool

Source

pub fn tab(&mut self)

Source

pub fn indent_lines(&mut self)

Source

pub fn outdent_lines(&mut self)

Source

pub fn move_lines(&mut self, up: bool)

Source

pub fn copy_lines(&mut self, up: bool)

Source

pub fn delete_lines(&mut self)

Source

pub fn insert_line(&mut self, below: bool)

Source

pub fn toggle_line_comment(&mut self)

Source

pub fn toggle_block_comment(&mut self)

Source

pub fn type_char(&mut self, c: char)

Source

pub fn delete_backward_pair(&mut self)

Source

pub fn add_next_occurrence(&mut self)

Source

pub fn select_all_occurrences(&mut self)

Source

pub fn transform_case(&mut self, upper: bool)

Source

pub fn trim_trailing_whitespace(&mut self)

Source

pub fn cursor_undo(&mut self) -> bool

Source

pub fn shrink_selection(&mut self) -> bool

Source

pub fn type_char_in(&mut self, c: char, in_literal: bool)

Source

pub fn expand_selection(&mut self, ranges: &[Range<usize>]) -> bool

Source

pub fn set_language_editing(&mut self, editing: LanguageEditing)

Trait Implementations§

Source§

impl Clone for Document

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Document

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.