extending undo...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-02-09 17:09:53 +03:00
parent b4eb5e3101
commit 06d60a9109

View File

@ -2087,7 +2087,7 @@ var JournalActions = actions.Actions({
[e.action].apply(that, e.args) }) }],
// XXX would be a good idea to add arguments this this:
// <count> - number of actions to undo
// <count> - number of actions to undo (DONE)
// 'unsaved' - all actions till last save marker
// XXX needs very careful revision...
// - should this be thread safe??? (likely not)
@ -2098,6 +2098,7 @@ var JournalActions = actions.Actions({
// XXX should we run undo of every action that supports it in the chain???
// ...i.e. multiple extending actions can support undo
// XXX will also need to handle other methods + aliases in chain...
// XXX EXPERIMENTAL...
undo: ['Edit/Undo',
doc`Undo last action from .journal that can be undone
@ -2112,14 +2113,18 @@ var JournalActions = actions.Actions({
`,
{mode: function(){
return (this.journal && this.journal.length > 0) || 'disabled' }},
function(){
function(count=1){
var journal = this.journal.slice() || []
var rjournal = this.rjournal =
var rjournal =
this.rjournal =
(this.hasOwnProperty('rjournal') || this.rjournal) ?
this.rjournal || []
: []
// XXX add test for save point...
// XXX this counts undoable actions only -- is this correct...
while(count-- > 0
&& journal.length > 1){
for(var i = journal.length-1; i >= 0; i--){
var a = journal[i]
@ -2154,7 +2159,7 @@ var JournalActions = actions.Actions({
this.journal = journal
this.rjournal = rjournal
break } } }],
break } } } }],
redo: ['Edit/Redo',
doc`Redo an action from .rjournal