Spaces:
Sleeping
Sleeping
Download src/editor/undo.js from hackathonM/Matou-Garou: direct link, hf CLI and curl.
- Browser
- Download file 689 Bytes
-
https://huggingface.co/spaces/hackathonM/Matou-Garou/resolve/main/src/editor/undo.js
- Command line
-
hf download hf://spaces/hackathonM/Matou-Garou/src/editor/undo.js
-
curl -L -o undo.js https://huggingface.co/spaces/hackathonM/Matou-Garou/resolve/main/src/editor/undo.js
689 Bytes
| const UNDO_STAX_MAX_LEN = 16 | |
| let undo_stack = []; | |
| let undoqueu = []; | |
| export function undo_mark_task_start(layer) { | |
| undoqueu = []; | |
| undoqueu.push(layer); | |
| } | |
| export function undo_add_index_to_task(tileindex) { | |
| undoqueu.push(tileindex); | |
| } | |
| export function undo_mark_task_end() { | |
| undo_stack.push(undoqueu); | |
| if (undo_stack.length > UNDO_STAX_MAX_LEN){ | |
| undo_stack.shift(); | |
| } | |
| } | |
| // utility function for adding a single tile as a task | |
| export function undo_add_single_index_as_task(layer, tileindex) { | |
| undo_mark_task_start(layer); | |
| undo_add_index_to_task(tileindex); | |
| undo_mark_task_end(); | |
| } | |
| export function undo_pop() { | |
| return undo_stack.pop(); | |
| } |