Enable external change tracking
This commit is contained in:
parent
e942e649ed
commit
7830f4107c
4 changed files with 253 additions and 209 deletions
|
|
@ -1,5 +1,5 @@
|
|||
#[cfg(not(feature = "std"))]
|
||||
use alloc::string::String;
|
||||
use alloc::{string::String, vec::Vec};
|
||||
|
||||
#[cfg(feature = "swash")]
|
||||
use crate::Color;
|
||||
|
|
@ -93,6 +93,17 @@ pub enum Action {
|
|||
GotoLine(usize),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum ChangeItem {
|
||||
Delete(Cursor, String),
|
||||
Insert(Cursor, String),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct Change {
|
||||
items: Vec<ChangeItem>,
|
||||
}
|
||||
|
||||
/// A trait to allow easy replacements of [`Editor`], like `SyntaxEditor`
|
||||
pub trait Edit {
|
||||
/// Mutably borrows `self` together with an [`FontSystem`] for more convenient methods
|
||||
|
|
@ -147,6 +158,12 @@ pub trait Edit {
|
|||
/// attributes, or with the previous character's attributes if None is given.
|
||||
fn insert_string(&mut self, data: &str, attrs_list: Option<AttrsList>);
|
||||
|
||||
/// Start collecting change
|
||||
fn start_change(&mut self);
|
||||
|
||||
/// Get completed change
|
||||
fn finish_change(&mut self) -> Option<Change>;
|
||||
|
||||
/// Perform an [Action] on the editor
|
||||
fn action(&mut self, font_system: &mut FontSystem, action: Action);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue