UndoRedoManager

Struct UndoRedoManager 

Source
pub struct UndoRedoManager<P: Project> { /* private fields */ }

Implementations§

Source§

impl<P: Project> UndoRedoManager<P>

Source

pub fn new() -> Self

Examples found in repository?
examples/slides.rs (line 298)
269fn main() {
270
271    let mut client = alisa::Client::<SlipsProject>::local("my_cool_path.slips").unwrap();
272
273    let mut action = alisa::Action::new();
274    client.perform(&mut action, SetName {
275        name: "My Cool Name".to_string(),
276    });
277
278    if let Some(ptr) = client.next_ptr() {
279        client.perform(&mut action, CreateSlide {
280            ptr,
281            parent: (),
282            idx: client.project().slides.n_children(),
283            data: SlideTreeData {
284                title: "New Slide".to_owned(),
285                text_boxes: alisa::UnorderedChildListTreeData::default()
286            },
287        });
288    }
289
290    client.tick(&mut ());
291
292    for slide_ptr in client.project().slides.iter() {
293        if let Some(slide) = client.get(slide_ptr) {
294            println!("{}", slide.title);
295        }
296    }
297    
298    let mut undo_redo = alisa::UndoRedoManager::new();
299
300    // Add the action to the list of undo's 
301    undo_redo.add(action);
302
303    // If there's an action to undo, undo it
304    undo_redo.undo(&client);
305
306    client.tick(&mut ());
307
308}
Source

pub fn add(&self, action: Action<P>)

Examples found in repository?
examples/slides.rs (line 301)
269fn main() {
270
271    let mut client = alisa::Client::<SlipsProject>::local("my_cool_path.slips").unwrap();
272
273    let mut action = alisa::Action::new();
274    client.perform(&mut action, SetName {
275        name: "My Cool Name".to_string(),
276    });
277
278    if let Some(ptr) = client.next_ptr() {
279        client.perform(&mut action, CreateSlide {
280            ptr,
281            parent: (),
282            idx: client.project().slides.n_children(),
283            data: SlideTreeData {
284                title: "New Slide".to_owned(),
285                text_boxes: alisa::UnorderedChildListTreeData::default()
286            },
287        });
288    }
289
290    client.tick(&mut ());
291
292    for slide_ptr in client.project().slides.iter() {
293        if let Some(slide) = client.get(slide_ptr) {
294            println!("{}", slide.title);
295        }
296    }
297    
298    let mut undo_redo = alisa::UndoRedoManager::new();
299
300    // Add the action to the list of undo's 
301    undo_redo.add(action);
302
303    // If there's an action to undo, undo it
304    undo_redo.undo(&client);
305
306    client.tick(&mut ());
307
308}
Source

pub fn can_undo(&self) -> bool

Source

pub fn can_redo(&self) -> bool

Source

pub fn undo(&mut self, client: &Client<P>)

Examples found in repository?
examples/slides.rs (line 304)
269fn main() {
270
271    let mut client = alisa::Client::<SlipsProject>::local("my_cool_path.slips").unwrap();
272
273    let mut action = alisa::Action::new();
274    client.perform(&mut action, SetName {
275        name: "My Cool Name".to_string(),
276    });
277
278    if let Some(ptr) = client.next_ptr() {
279        client.perform(&mut action, CreateSlide {
280            ptr,
281            parent: (),
282            idx: client.project().slides.n_children(),
283            data: SlideTreeData {
284                title: "New Slide".to_owned(),
285                text_boxes: alisa::UnorderedChildListTreeData::default()
286            },
287        });
288    }
289
290    client.tick(&mut ());
291
292    for slide_ptr in client.project().slides.iter() {
293        if let Some(slide) = client.get(slide_ptr) {
294            println!("{}", slide.title);
295        }
296    }
297    
298    let mut undo_redo = alisa::UndoRedoManager::new();
299
300    // Add the action to the list of undo's 
301    undo_redo.add(action);
302
303    // If there's an action to undo, undo it
304    undo_redo.undo(&client);
305
306    client.tick(&mut ());
307
308}
Source

pub fn redo(&mut self, client: &Client<P>)

Auto Trait Implementations§

§

impl<P> !Freeze for UndoRedoManager<P>

§

impl<P> !RefUnwindSafe for UndoRedoManager<P>

§

impl<P> !Send for UndoRedoManager<P>

§

impl<P> !Sync for UndoRedoManager<P>

§

impl<P> Unpin for UndoRedoManager<P>

§

impl<P> !UnwindSafe for UndoRedoManager<P>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.