-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
executable file
·115 lines (88 loc) · 1.18 KB
/
example.py
File metadata and controls
executable file
·115 lines (88 loc) · 1.18 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env python
from timemachine import altering, timemachine, reset, undo, redo
### EXAMPLE ###
@timemachine
class Counter(object):
def __init__(self):
self.count = 1
def __str__(self):
return "c: " + str(self.count)
@altering
def up(self):
self.count += 1
@altering
def down(self):
self.count -= 1
### TESTING ###
ot = Counter()
ex = Counter()
print ex
undo(ex)
print ex
undo(ex)
print ex
ex.up()
print ex
ex.up()
print ex
ex.down()
print ex
ex.up()
print ex
print ex._tm_undostack
print ot._tm_undostack
print ex._tm_initial_state
print ot._tm_initial_state
print ex
print "reset"
reset(ex)
print ex
ex.up()
print ex
ex.up()
print ex
ex.up()
print ex
ex.up()
print ex
ex.up()
print ex
print "undo"
undo(ex)
print ex
undo(ex)
print ex
undo(ex)
print ex
print ex._tm_redostack
print ot._tm_redostack
print "redo"
redo(ex)
print ex
redo(ex)
print ex
redo(ex)
print ex
redo(ex)
print ex
print "undo"
undo(ex)
print ex
undo(ex)
print ex
undo(ex)
print ex
print "redo"
redo(ex)
print ex
redo(ex)
print ex
redo(ex)
print ex
redo(ex)
print ex
print "undo+new_cmd"
undo(ex)
print ex._tm_redostack
ex.down()
print ex._tm_redostack