Implements #51: Folding commands

This commit is contained in:
Zef Hemel
2023-06-14 19:27:18 +02:00
parent 260c91e4b1
commit 1b922791f3
7 changed files with 105 additions and 2 deletions
+23 -1
View File
@@ -1,5 +1,14 @@
import { Editor } from "../editor.tsx";
import { EditorView, Transaction, Vim, vimGetCm } from "../deps.ts";
import {
EditorView,
foldAll,
foldCode,
Transaction,
unfoldAll,
unfoldCode,
Vim,
vimGetCm,
} from "../deps.ts";
import { SysCallMapping } from "../../plugos/system.ts";
import type { FilterOption } from "../types.ts";
@@ -172,6 +181,19 @@ export function editorSyscalls(editor: Editor): SysCallMapping {
const cm = vimGetCm(editor.editorView!)!;
return Vim.handleEx(cm, exCommand);
},
// Folding
"editor.fold": () => {
foldCode(editor.editorView!);
},
"editor.unfold": () => {
unfoldCode(editor.editorView!);
},
"editor.foldAll": () => {
foldAll(editor.editorView!);
},
"editor.unfoldAll": () => {
unfoldAll(editor.editorView!);
},
};
return syscalls;