[vscode] extractKeyboardShortcuts

This commit is contained in:
2021-04-02 17:19:45 -06:00
parent 09ccbb3d51
commit ffb01bd7d8
2 changed files with 17 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ package;
import kiss.Kiss;
import kiss.Prelude;
import kiss.Operand;
import kiss.Stream;
import vscode.*;
import js.lib.Promise;
import js.node.ChildProcess;

View File

@@ -30,7 +30,7 @@
// TODO make an async annotation that throws an error if the promise is not wrapped in awaitLet or awaitBegin or returned by an async function?
// but in some cases it doesn't matter and there are so many edge cases.
(defun insertAt [:Position pos text]
(defun insertAt [:vscode.Position pos text]
(.edit activeTextEditor
(lambda [e]
(e.insert pos text))))
@@ -100,6 +100,21 @@
// TODO
(errorMessage "Keyboard shortcut commands are not yet implemented"))
// Extract [k]eyboard [s]hortcuts from a string:
(defun extractKeyboardShortcuts [str &opt :Stream stream :String shortcuts]
(unless stream (set stream (Stream.fromString str)))
(unless shortcuts (set shortcuts ""))
(case (stream.takeUntilAndDrop "[")
((Some _)
(case (stream.takeUntilAndDrop "]")
((Some newShortcuts)
(extractKeyboardShortcuts str stream (+ shortcuts (newShortcuts.toLowerCase))))
(None
(warningMessage "unclosed [ in $str")
"")))
(None
shortcuts)))
(defun registerCommand [description command]
(dictSet commands description command))