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>
pub fn views_of(&self, buffer: BufferId) -> impl Iterator<Item = &View>
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 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.
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.