Skip to main content

Editor

Struct Editor 

Source
pub struct Editor {
    pub settings: Settings,
    /* private fields */
}

Fields§

§settings: Settings

Implementations§

Source§

impl Editor

Source

pub fn new() -> Self

Source

pub fn with_clock(clock: Box<dyn Clock>) -> Self

Source

pub fn add_buffer(&mut self, text: &str, meta: FileMeta) -> BufferId

Source

pub fn add_view(&mut self, buffer: BufferId) -> Result<ViewId, ActionError>

Source

pub fn remove_view(&mut self, view: ViewId) -> Option<View>

Source

pub fn remove_buffer(&mut self, buffer: BufferId) -> Option<Buffer>

Removes the buffer and every view of it.

Source

pub fn buffer(&self, id: BufferId) -> Option<&Buffer>

Source

pub fn buffer_mut(&mut self, id: BufferId) -> Option<&mut Buffer>

Source

pub fn view(&self, id: ViewId) -> Option<&View>

Source

pub fn view_mut(&mut self, id: ViewId) -> Option<&mut View>

Source

pub fn buffers(&self) -> impl Iterator<Item = &Buffer>

Source

pub fn buffers_mut(&mut self) -> impl Iterator<Item = &mut Buffer>

Source

pub fn views(&self) -> impl Iterator<Item = &View>

Source

pub fn views_of(&self, buffer: BufferId) -> impl Iterator<Item = &View>

The views of buffer that are tabs (not auxiliary ones).

Source

pub fn add_aux_view(&mut self, buffer: BufferId) -> Result<ViewId, ActionError>

A view that is not a tab of its own (one side of a compare view). It follows edits like any view, is left out of views_of, and goes when its buffer is removed.

Source

pub fn start_recording(&mut self)

Source

pub fn is_recording(&self) -> bool

Source

pub fn stop_recording(&mut self) -> Vec<Action>

Source

pub fn recorded(&self) -> Option<&[Action]>

The actions recorded so far, while recording.

Source

pub fn begin_undo_group(&mut self, view: ViewId) -> Result<(), ActionError>

Everything applied to view’s buffer until the matching Self::end_undo_group undoes as one step.

Source

pub fn end_undo_group(&mut self, view: ViewId) -> Result<(), ActionError>

Source

pub fn apply(&mut self, view: ViewId, action: Action) -> Result<(), ActionError>

Resolves action against view and applies it: edits the rope, pushes undo, maps other views’ selections, marks dirty lines for the highlighter, bumps the revision and records the action if recording.

Source

pub fn apply_unrecorded( &mut self, view: ViewId, action: Action, ) -> Result<(), ActionError>

Like apply, but never recorded in a macro being recorded: for commands that act outside the view the macro plays in (Replace All in all open documents).

Source

pub fn reload_buffer( &mut self, buffer: BufferId, text: &str, meta: FileMeta, ) -> Result<(), ActionError>

Replaces a buffer’s text with text read from disk (an external change), as one undoable step; carets keep their line and column. The buffer takes meta and is marked saved. It mirrors the file, so it goes through even when the buffer refuses edits (Read-Only).

Source

pub fn append_unrecorded( &mut self, buffer_id: BufferId, text: &str, ) -> Result<(), ActionError>

Appends text that the file on disk gained (follow mode, PLAN_v0.3.0 P6). It is not an undo step: undoing earlier steps keeps it. A clean buffer stays clean. Carets at the end move along to the new end.

Source

pub fn set_filter(&mut self, view: ViewId, shown: Option<&[usize]>)

Shows only the lines shown (sorted line numbers) of view, or every line again with None: the filter view (PLAN_v0.3.0 P6). Carets on lines it hides move to the start of the nearest shown line. With no line to show, the primary caret’s line stays.

Source

pub fn filter_appended(&mut self, view: ViewId, from: usize, shown: &[usize])

After text was appended to a filtered view (follow mode): hides the lines from from on but shown (sorted) and the lines holding a caret, leaving the lines before from as they were.

Source

pub fn caret_lines(&self, view: ViewId) -> Vec<usize>

The lines of view holding a selection’s head, in order.

Source

pub fn fold_at(&mut self, view: ViewId, line: usize) -> bool

Folds the region line heads in view; returns whether it did. Carets inside move to the end of the header line.

Source

pub fn unfold_at(&mut self, view: ViewId, line: usize) -> bool

Unfolds the fold at line in view; returns whether there was one.

Source

pub fn toggle_fold_at(&mut self, view: ViewId, line: usize) -> bool

Unfolds line if it is folded, else folds the region it heads.

Source§

impl Editor

Source

pub fn play_macro( &mut self, view: ViewId, actions: &[Action], repeat: Repeat, ) -> Result<usize, MacroError>

Plays actions on view. The whole playback is one undo step and is not itself recorded. Returns the number of complete runs.

With Repeat::Times the first failing action aborts playback and is reported. With Repeat::UntilEnd a failure is the normal way to stop.

Trait Implementations§

Source§

impl Default for Editor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Editor

§

impl !Sync for Editor

§

impl !UnwindSafe for Editor

§

impl Freeze for Editor

§

impl Send for Editor

§

impl Unpin for Editor

§

impl UnsafeUnpin for Editor

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.