1- # Undo done the right way!
1+ # Undo done the right way
22
3- Via https://gitlab.com/okannen/undo_2/-/tree/b32c34edb2c15c266b946f0d82188624f3aa3fdc
3+ Via [ original ] ( https://gitlab.com/okannen/undo_2/-/tree/b32c34edb2c15c266b946f0d82188624f3aa3fdc )
44
55## Introduction
66
@@ -10,34 +10,33 @@ end of the Undo history as a precursor to your new change. I found the idea in
1010[ zaboople/klong] [ zaboople ] . This crate is an implementation
1111of this idea with a minor variation explained below.
1212
13- As an example consider the following sequence of commands:
13+ As an example consider the following sequence of commands:
1414
1515| Command | State |
1616| ------- | ----- |
17- | Init | |
17+ | Init | |
1818| Do A | A |
1919| Do B | A, B |
20- | Undo | A |
21- | Do C | A, C |
20+ | Undo | A |
21+ | Do C | A, C |
2222
23- With the ** classical undo** , repeated undo would lead to the sequence:
23+ With the ** classical undo** , repeated undo would lead to the sequence:
2424
2525| Command | State |
2626| ---------| -------|
2727| | A, C |
2828| Undo | A |
29- | Undo | |
30-
29+ | Undo | |
3130
32- Starting from 5, with ** undo_2** , repeating undo would lead to the sequence:
31+ Starting from 5, with ** undo_2** , repeating undo would lead to the sequence:
3332
3433| Command | State |
3534| ---------| -------|
3635| | A, C |
3736| Undo | A |
38- | Undo | A,B |
39- | Undo | A |
40- | Undo | |
37+ | Undo | A,B |
38+ | Undo | A |
39+ | Undo | |
4140
4241** undo_2** 's undo navigates back in history, while classical undo navigates back
4342through the sequence of command that builds the state.
@@ -53,11 +52,11 @@ and it is similar to vim :earlier.
5352 4 . very lightweight, dumb and simple.
5453 5 . possibility to merge and splice commands.
5554
56- ## How to use it
55+ ## How to use it
5756
5857Add the dependency to the cargo file:
5958
60- ``` [ toml]
59+ ``` toml
6160[dependencies ]
6261undo_2 = " 0.1"
6362```
@@ -74,7 +73,7 @@ be interpreted by the application. This design pattern makes implementation
7473easier because it is not necessary to borrow data within the stored list of
7574commands.
7675
77- ```
76+ ``` rs
7877use undo_2 :: {Commands ,Action };
7978use Action :: {Do ,Undo };
8079
@@ -156,22 +155,22 @@ assert_eq!(editor.text, "a");
156155 forming the sequence are merged. This makes the traversal of the undo
157156 sequence more concise by avoiding state duplication.
158157
159- | Command | State | Comment |
158+ | Command | State | Comment |
160159| ---------| ------- | ----------------------|
161- | Init | | |
160+ | Init | | |
162161| Do A | A | |
163162| Do B | A,B | |
164163| Do C | A, B, C | |
165- | Undo | A, B | Merged |
166- | Undo | A | Merged |
167- | Do D | A, D | |
164+ | Undo | A, B | Merged |
165+ | Undo | A | Merged |
166+ | Do D | A, D | |
168167| Undo | A | Redo the 2 Merged Undo|
169- | Undo | A, B, C | |
170- | Undo | A, B | |
171- | Undo | A | |
172- | Undo | | |
168+ | Undo | A, B, C | |
169+ | Undo | A, B | |
170+ | Undo | A | |
171+ | Undo | | |
173172
174- 2 . Each execution of an undos or redo may lead to the execution of a sequence of
173+ 1 . Each execution of an undos or redo may lead to the execution of a sequence of
175174 actions in the form ` Undo(a)+Do(b)+Do(c) ` . Basic arithmetic is implemented
176175 assuming that ` Do(a)+Undo(a) ` is equivalent to not doing anything (here the
177176 2 ` a ` 's designate the same entity, not to equal objects).
@@ -249,13 +248,14 @@ assert_eq!(editor.text, "az12");
249248```
250249
251250## Release note
251+
252252### Version 0.3
253- - [ Action] is now an enum taking commands, the list of command to be
254- executed is of the form [ Action<T >] ;
255- - added [ Commands::can_undo] and [ Commands::can_redo] ;
256- - added [ Commands::rebuild] , which correspond to the classical redo;
257- - fixed a bug in [ Commands::undo_or_redo_to_index]
258- - Added support for special commands that represent a state setting. See [ SetOrTransition] .
259253
260- [ zaboople ] : https://github.com/zaboople/klonk/blob/master/TheGURQ.md
254+ - [ ` Action ` ] is now an enum taking commands, the list of command to be
255+ executed is of the form [ ` Action<T> ` ] ;
256+ - added [ ` Commands::can_undo ` ] and [ ` Commands::can_redo ` ] ;
257+ - added [ ` Commands::rebuild ` ] , which correspond to the classical redo;
258+ - fixed a bug in [ ` Commands::undo_or_redo_to_index ` ]
259+ - Added support for special commands that represent a state setting. See [ ` SetOrTransition ` ] .
261260
261+ [ zaboople ] : https://github.com/zaboople/klonk/blob/master/TheGURQ.md
0 commit comments