Implements #51: Folding commands
This commit is contained in:
@@ -84,6 +84,7 @@ import { Panel } from "./components/panel.tsx";
|
||||
import { TopBar } from "./components/top_bar.tsx";
|
||||
import {
|
||||
BookIcon,
|
||||
codeFolding,
|
||||
HomeIcon,
|
||||
preactRender,
|
||||
TerminalIcon,
|
||||
@@ -879,6 +880,9 @@ export class Editor {
|
||||
history(),
|
||||
drawSelection(),
|
||||
dropCursor(),
|
||||
codeFolding({
|
||||
placeholderText: "…",
|
||||
}),
|
||||
indentOnInput(),
|
||||
...cleanModePlugins(this),
|
||||
EditorView.lineWrapping,
|
||||
@@ -914,6 +918,7 @@ export class Editor {
|
||||
run: (): boolean => {
|
||||
this.viewDispatch({ type: "start-navigate" });
|
||||
this.space.updatePageList();
|
||||
|
||||
return true;
|
||||
},
|
||||
},
|
||||
|
||||
@@ -21,6 +21,18 @@
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
// Gutter styling
|
||||
.cm-gutters {
|
||||
background-color: transparent;
|
||||
border-right: none;
|
||||
|
||||
}
|
||||
|
||||
.cm-foldPlaceholder {
|
||||
background-color: transparent;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
|
||||
// Indentation of follow-up lines
|
||||
@mixin lineOverflow($baseIndent, $bulletIndent: 0) {
|
||||
|
||||
+23
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user