forked from limetext/commands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathundoredo.go
45 lines (37 loc) · 790 Bytes
/
undoredo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2013 The lime Authors.
// Use of this source code is governed by a 2-clause
// BSD-style license that can be found in the LICENSE file.
package commands
import (
"github.com/limetext/backend"
)
type (
Undo struct {
backend.BypassUndoCommand
hard bool
}
Redo struct {
backend.BypassUndoCommand
hard bool
}
)
// Run executes the Undo command.
func (c *Undo) Run(v *backend.View, e *backend.Edit) error {
v.UndoStack().Undo(c.hard)
return nil
}
// Run executes the Redo command.
func (c *Redo) Run(v *backend.View, e *backend.Edit) error {
v.UndoStack().Redo(c.hard)
return nil
}
func init() {
register([]backend.Command{
&Undo{hard: true},
&Redo{hard: true},
})
registerByName([]namedCmd{
{"soft_undo", &Undo{}},
{"soft_redo", &Redo{}},
})
}