1 | new L<UndoableWithAnswer> undoList; |
2 | |
3 | void addUndo(UndoableWithAnswer undo) {
|
4 | if (undo == null) ret; |
5 | undoList.add(undo); |
6 | change(); |
7 | print("Undo added: " + undo);
|
8 | } |
9 | void clearUndos q {
|
10 | if (empty(undoList)) ret; |
11 | undoList.clear(); |
12 | change; |
13 | print("Undo list cleared");
|
14 | } |
15 | |
16 | S singleUndo() {
|
17 | UndoableWithAnswer undo = popLast(undoList); |
18 | if (undo == null) ret "Nothing to undo"; |
19 | change(); |
20 | ret or2(undo.undo(), "Last action undone"); |
21 | } |
22 | |
23 | S undoActions(S s) {
|
24 | if "undo" ret singleUndo(); |
25 | if "anything to undo" |
26 | ret empty(undoList) ? "Nothing to undo" : n2(undoList, "undoable action"); |
27 | if "clear undos" ret "OK" with clearUndos(); |
28 | null; |
29 | } |
30 | |
31 | // API |
32 | |
33 | UndoableWithAnswer lastUndo() {
|
34 | ret dm_q(() -> last(undoList)); |
35 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1027563 |
| Snippet name: | Undo Manager [Include] |
| Eternal ID of this version: | #1027563/2 |
| Text MD5: | ef8ad959c4cfa9c11765bf96f687ec79 |
| Author: | stefan |
| Category: | javax / a.i. |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-03-23 22:47:42 |
| Source code size: | 772 bytes / 35 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 382 / 688 |
| Version history: | 1 change(s) |
| Referenced in: | [show references] |