All Projects → evenorog → undo

evenorog / undo

Licence: Apache-2.0, MIT licenses found Licenses found Apache-2.0 LICENSE-APACHE MIT LICENSE-MIT
A undo-redo library.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to undo

Redux Undo
♻️ higher order reducer to add undo/redo functionality to redux state containers
Stars: ✭ 2,744 (+7121.05%)
Mutual labels:  redo, undo
Regret
[Moved to MavenCentral] An undo-redo Android library which works with any objects and with an easy implementation. Perfect for drawing, text and photo editing apps.
Stars: ✭ 65 (+71.05%)
Mutual labels:  redo, undo
undox
⎌ Redux Implementation of Undo/Redo based on storing actions instead of states.
Stars: ✭ 25 (-34.21%)
Mutual labels:  redo, undo
rundo
Rundo is a undo redo library for rust which can auto generate undo op
Stars: ✭ 32 (-15.79%)
Mutual labels:  redo, undo
UndoRedo.js
A powerful and simple JavaScript library provides a history for undo/redo functionality. Just like a time machine! 🕐
Stars: ✭ 19 (-50%)
Mutual labels:  redo, undo
actions
Software without side-effects. Redo and Undo.
Stars: ✭ 23 (-39.47%)
Mutual labels:  redo, undo
js-undo-manager
Simple JavaScript undo/redo command manager supporting transactions with no dependencies
Stars: ✭ 23 (-39.47%)
Mutual labels:  redo, undo
zundo
🍜 undo/redo middleware for zustand
Stars: ✭ 170 (+347.37%)
Mutual labels:  redo, undo
mfrc522
A platform agnostic driver to interface the MFRC522 (RFID reader/writer)
Stars: ✭ 27 (-28.95%)
Mutual labels:  no-std
drone-stm32-map
STM32 peripheral mappings for Drone, an Embedded Operating System.
Stars: ✭ 16 (-57.89%)
Mutual labels:  no-std
undo
Gelöschte Artikel, Slices und Kategorien wiederherstellen
Stars: ✭ 31 (-18.42%)
Mutual labels:  undo
fixedvec-rs
Heapless vector implementation for Rust
Stars: ✭ 39 (+2.63%)
Mutual labels:  no-std
m4vga-rs
VGA-style video output for STM32F4 processors, in Rust
Stars: ✭ 122 (+221.05%)
Mutual labels:  no-std
metric
This library provides zero-cost dimensional analysis for safe, unit-aware numeric computations in Rust.
Stars: ✭ 23 (-39.47%)
Mutual labels:  no-std
semval
Semantic validation for Rust
Stars: ✭ 77 (+102.63%)
Mutual labels:  no-std
alloc-cortex-m
A heap allocator for Cortex-M processors
Stars: ✭ 139 (+265.79%)
Mutual labels:  no-std
vcell
Just like `Cell` but with volatile read / write operations
Stars: ✭ 16 (-57.89%)
Mutual labels:  no-std
register-rs
Unified interface for type-safe MMIO and CPU register access in Rust
Stars: ✭ 48 (+26.32%)
Mutual labels:  no-std
rust-amplify
Amplifying Rust language capabilities: multiple generic trait implementations, type wrappers, bit-precise numerics, derive macros
Stars: ✭ 38 (+0%)
Mutual labels:  no-std
restricted-sparse-merkle-tree
An optimized sparse merkle tree.
Stars: ✭ 47 (+23.68%)
Mutual labels:  no-std

undo

A undo-redo library.

Rust Crates.io Docs

It is an implementation of the command pattern, where all modifications are done by creating objects that applies the modifications. All objects knows how to undo the changes it applies, and by using the provided data structures it is easy to apply, undo, and redo changes made to a target.

Features

  • Action provides the base functionality for all actions.
  • Record provides basic undo-redo functionality.
  • Timeline provides basic undo-redo functionality using a fixed size.
  • History provides non-linear undo-redo functionality that allows you to jump between different branches.
  • A queue that wraps a record or history and extends them with queue functionality.
  • A checkpoint that wraps a record or history and extends them with checkpoint functionality.
  • Actions can be merged into a single action by implementing the merge method on the action. This allows smaller actions to be used to build more complex operations, or smaller incremental changes to be merged into larger changes that can be undone and redone in a single step.
  • The target can be marked as being saved to disk and the data-structures can track the saved state and notify when it changes.
  • The amount of changes being tracked can be configured by the user so only the N most recent changes are stored.
  • Configurable display formatting using the display structure.
  • The library can be used as no_std.

Cargo Feature Flags

  • alloc: Enables the use of the alloc crate, enabled by default.
  • colored: Enables colored output when visualizing the display structures, enabled by default.
  • chrono: Enables time stamps and time travel.
  • serde: Enables serialization and deserialization.

Examples

use undo::{Action, History};

struct Add(char);

impl Action for Add {
    type Target = String;
    type Output = ();
    type Error = &'static str;

    fn apply(&mut self, s: &mut String) -> undo::Result<Add> {
        s.push(self.0);
        Ok(())
    }

    fn undo(&mut self, s: &mut String) -> undo::Result<Add> {
        self.0 = s.pop().ok_or("s is empty")?;
        Ok(())
    }
}

fn main() {
    let mut target = String::new();
    let mut history = History::new();
    history.apply(&mut target, Add('a')).unwrap();
    history.apply(&mut target, Add('b')).unwrap();
    history.apply(&mut target, Add('c')).unwrap();
    assert_eq!(target, "abc");
    history.undo(&mut target).unwrap();
    history.undo(&mut target).unwrap();
    history.undo(&mut target).unwrap();
    assert_eq!(target, "");
    history.redo(&mut target).unwrap();
    history.redo(&mut target).unwrap();
    history.redo(&mut target).unwrap();
    assert_eq!(target, "abc");
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].