@@ -10,6 +10,7 @@ import {DrawModeMove} from "./History/DrawModeMove";
10
10
import { DrawModeNode } from "./History/DrawModeNode" ;
11
11
import { DrawModeStack } from "./History/DrawModeStack" ;
12
12
import { ProofModeMove } from "./Proof/ProofModeMove" ;
13
+ import { ProofModeStack } from "./Proof/ProofModeStack" ;
13
14
import { ProofNode } from "./Proof/ProofNode" ;
14
15
import { redrawProof , redrawTree } from "./SharedToolUtils/DrawUtils" ;
15
16
@@ -52,7 +53,11 @@ export class TreeContext {
52
53
53
54
public static drawHistoryRedoStack : DrawModeStack = new DrawModeStack ( ) ;
54
55
55
- private static recentlyUndoneOrRedoneMove = false ;
56
+ private static recentlyUndoneOrRedoneDrawMove = false ;
57
+
58
+ public static proofHistoryRedoStack : ProofModeStack = new ProofModeStack ( ) ;
59
+
60
+ private static recentlyUndoneOrRedoneProofMove = false ;
56
61
57
62
//The proof is a series of ProofNodes.
58
63
public static proof : ProofNode [ ] = [ ] ;
@@ -75,9 +80,9 @@ export class TreeContext {
75
80
* @param newlyAppliedStep Incoming DrawModeMove.
76
81
*/
77
82
public static pushToDrawStack ( newlyAppliedStep : DrawModeMove ) : void {
78
- if ( this . recentlyUndoneOrRedoneMove ) {
83
+ if ( this . recentlyUndoneOrRedoneDrawMove ) {
79
84
this . drawHistoryRedoStack . clear ( ) ;
80
- this . recentlyUndoneOrRedoneMove = false ;
85
+ this . recentlyUndoneOrRedoneDrawMove = false ;
81
86
}
82
87
this . drawHistoryUndoStack . push ( new DrawModeNode ( this . tree , newlyAppliedStep ) ) ;
83
88
}
@@ -100,7 +105,7 @@ export class TreeContext {
100
105
101
106
redrawTree ( this . tree ) ;
102
107
103
- this . recentlyUndoneOrRedoneMove = true ;
108
+ this . recentlyUndoneOrRedoneDrawMove = true ;
104
109
}
105
110
106
111
public static redoDrawStep ( ) : void {
@@ -112,29 +117,48 @@ export class TreeContext {
112
117
113
118
this . drawHistoryUndoStack . push ( mostRecentStep ) ;
114
119
115
- //i seem to have accidentally made the correct procedure by copy/pasting the incorrect name
116
- //here and below are all supposed to be drawHistoryRedoStack but that ruins the behavior
117
120
this . tree = new AEGTree ( this . drawHistoryUndoStack . peek ( ) . tree . sheet ) ;
118
121
119
122
redrawTree ( this . tree ) ;
120
123
121
- this . recentlyUndoneOrRedoneMove = true ;
124
+ this . recentlyUndoneOrRedoneDrawMove = true ;
122
125
}
123
126
124
127
public static undoProofStep ( ) : void {
125
128
if ( this . proof . length <= 1 ) {
129
+ this . clearProof ( ) ;
126
130
return ;
127
131
}
128
132
129
- const stepToRemove : ProofNode = this . proof [ this . proof . length - 1 - 1 ] ;
133
+ const stepToRemove : ProofNode = this . proof [ this . proof . length - 1 ] ;
134
+
135
+ deleteMostRecentButton ( ) ;
130
136
131
- this . tree = new AEGTree ( stepToRemove . tree . sheet ) ;
132
- this . proof . splice ( this . proof . length - 1 , 1 ) [ 0 ] ;
137
+ this . proofHistoryRedoStack . push ( stepToRemove ) ;
138
+
139
+ this . proof . splice ( this . proof . length - 1 , 1 ) [ 0 ] ; //.pop();
133
140
stepBack ( this . proof [ this . proof . length - 1 ] ) ;
134
141
redrawProof ( ) ;
142
+
143
+ this . recentlyUndoneOrRedoneProofMove = true ;
135
144
}
136
145
137
146
public static redoProofStep ( ) : void {
147
+ if ( this . proofHistoryRedoStack . history . length === 0 ) {
148
+ return ;
149
+ }
150
+
151
+ const mostRecentStep : ProofNode | null = this . proofHistoryRedoStack . pop ( ) ;
152
+
153
+ if ( mostRecentStep === null || this . proof [ this . proof . length - 1 ] === null ) {
154
+ return ;
155
+ }
156
+
157
+ this . recentlyUndoneOrRedoneProofMove = false ;
158
+
159
+ this . pushToProof ( mostRecentStep ) ;
160
+
161
+ stepBack ( this . proof [ this . proof . length - 1 ] ) ;
138
162
redrawProof ( ) ;
139
163
}
140
164
@@ -159,6 +183,11 @@ export class TreeContext {
159
183
* @param newStep Incoming ProofNode.
160
184
*/
161
185
public static pushToProof ( newStep : ProofNode ) : void {
186
+ if ( this . recentlyUndoneOrRedoneProofMove ) {
187
+ this . proofHistoryRedoStack . clear ( ) ;
188
+ this . recentlyUndoneOrRedoneProofMove = false ;
189
+ }
190
+
162
191
if ( newStep . appliedRule === ProofModeMove . PASTE_GRAPH ) {
163
192
this . proof . pop ( ) ;
164
193
document . getElementById ( "Row: 1" ) ?. remove ( ) ;
0 commit comments