pub struct Editor {
pub settings: Settings,
/* private fields */
}Fields§
§settings: SettingsImplementations§
Source§impl Editor
impl Editor
pub fn new() -> Self
pub fn with_clock(clock: Box<dyn Clock>) -> Self
pub fn add_buffer(&mut self, text: &str, meta: FileMeta) -> BufferId
pub fn add_view(&mut self, buffer: BufferId) -> Result<ViewId, ActionError>
pub fn remove_view(&mut self, view: ViewId) -> Option<View>
Sourcepub fn remove_buffer(&mut self, buffer: BufferId) -> Option<Buffer>
pub fn remove_buffer(&mut self, buffer: BufferId) -> Option<Buffer>
Removes the buffer and every view of it.
pub fn buffer(&self, id: BufferId) -> Option<&Buffer>
pub fn buffer_mut(&mut self, id: BufferId) -> Option<&mut Buffer>
pub fn view(&self, id: ViewId) -> Option<&View>
pub fn view_mut(&mut self, id: ViewId) -> Option<&mut View>
pub fn buffers(&self) -> impl Iterator<Item = &Buffer>
pub fn buffers_mut(&mut self) -> impl Iterator<Item = &mut Buffer>
pub fn views(&self) -> impl Iterator<Item = &View>
Sourcepub fn views_of(&self, buffer: BufferId) -> impl Iterator<Item = &View>
pub fn views_of(&self, buffer: BufferId) -> impl Iterator<Item = &View>
The views of buffer that are tabs (not auxiliary ones).
Sourcepub fn add_aux_view(&mut self, buffer: BufferId) -> Result<ViewId, ActionError>
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.
pub fn start_recording(&mut self)
pub fn is_recording(&self) -> bool
pub fn stop_recording(&mut self) -> Vec<Action>
Sourcepub fn begin_undo_group(&mut self, view: ViewId) -> Result<(), ActionError>
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.
pub fn end_undo_group(&mut self, view: ViewId) -> Result<(), ActionError>
Sourcepub fn apply(&mut self, view: ViewId, action: Action) -> Result<(), ActionError>
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.
Sourcepub fn apply_unrecorded(
&mut self,
view: ViewId,
action: Action,
) -> Result<(), ActionError>
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).
Sourcepub fn reload_buffer(
&mut self,
buffer: BufferId,
text: &str,
meta: FileMeta,
) -> Result<(), ActionError>
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).
Sourcepub fn append_unrecorded(
&mut self,
buffer_id: BufferId,
text: &str,
) -> Result<(), ActionError>
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.
Sourcepub fn set_filter(&mut self, view: ViewId, shown: Option<&[usize]>)
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.
Sourcepub fn filter_appended(&mut self, view: ViewId, from: usize, shown: &[usize])
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.
Sourcepub fn caret_lines(&self, view: ViewId) -> Vec<usize>
pub fn caret_lines(&self, view: ViewId) -> Vec<usize>
The lines of view holding a selection’s head, in order.
Sourcepub fn fold_at(&mut self, view: ViewId, line: usize) -> bool
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.
Sourcepub fn unfold_at(&mut self, view: ViewId, line: usize) -> bool
pub fn unfold_at(&mut self, view: ViewId, line: usize) -> bool
Unfolds the fold at line in view; returns whether there was one.
Sourcepub fn toggle_fold_at(&mut self, view: ViewId, line: usize) -> bool
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
impl Editor
Sourcepub fn play_macro(
&mut self,
view: ViewId,
actions: &[Action],
repeat: Repeat,
) -> Result<usize, MacroError>
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.