Add runLastCommand and stub for runKeyboardShortcut
This commit is contained in:
@@ -28,25 +28,48 @@
|
|||||||
(document.getText range))
|
(document.getText range))
|
||||||
""))
|
""))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* State
|
||||||
|
*/
|
||||||
|
|
||||||
|
(defvar :Map<String,Command> commands (new Map))
|
||||||
|
(defvar &mut :String lastCommand null)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Functionality
|
* Functionality
|
||||||
*/
|
*/
|
||||||
(defvar :Map<String,Command> commands (new Map))
|
|
||||||
|
|
||||||
(defun runCommand []
|
(defun runCommand [&opt command]
|
||||||
(let [commandList
|
(if command
|
||||||
(for description (commands.keys)
|
{(set lastCommand command) ((dictGet commands command) (selectedText))}
|
||||||
(object
|
(let [commandList
|
||||||
label description
|
(for description (commands.keys)
|
||||||
description null
|
(object
|
||||||
detail null
|
label description
|
||||||
picked null
|
description null
|
||||||
alwaysShow null))]
|
detail null
|
||||||
(awaitLet [chosenCommand (quickPick commandList)]
|
picked null
|
||||||
((dictGet commands chosenCommand.label) (selectedText)))))
|
alwaysShow null))]
|
||||||
|
(awaitLet [chosenCommand (quickPick commandList)]
|
||||||
|
(set lastCommand chosenCommand.label)
|
||||||
|
((dictGet commands chosenCommand.label) (selectedText)))))
|
||||||
|
(return))
|
||||||
|
|
||||||
|
(defun runLastCommand [&opt _]
|
||||||
|
(if lastCommand
|
||||||
|
(runCommand lastCommand)
|
||||||
|
(errorMessage "No Kiss command was run previously."))
|
||||||
|
(return))
|
||||||
|
|
||||||
|
(defun runKeyboardShortcut [&opt _]
|
||||||
|
// TODO
|
||||||
|
(errorMessage "Keyboard shortcut commands are not yet implemented")
|
||||||
|
(return))
|
||||||
|
|
||||||
(defun registerCommand [description command]
|
(defun registerCommand [description command]
|
||||||
(dictSet commands description command))
|
(dictSet commands description command))
|
||||||
|
|
||||||
(defun registerBuiltins []
|
(defun registerBuiltins []
|
||||||
|
(registerCommand "Rerun last command" runLastCommand)
|
||||||
|
(registerCommand "Run a keyboard shortcut command" runKeyboardShortcut)
|
||||||
(return))
|
(return))
|
||||||
|
|||||||
@@ -10,7 +10,10 @@
|
|||||||
"Programming Languages"
|
"Programming Languages"
|
||||||
],
|
],
|
||||||
"activationEvents": [
|
"activationEvents": [
|
||||||
|
"onStartupFinished",
|
||||||
"onCommand:kiss.runCommand",
|
"onCommand:kiss.runCommand",
|
||||||
|
"onCommand:kiss.runLastCommand",
|
||||||
|
"onCommand:kiss.runKeyboardShortcut",
|
||||||
"onCommand:kiss.reloadConfig"
|
"onCommand:kiss.reloadConfig"
|
||||||
],
|
],
|
||||||
"main": "bin/extension.js",
|
"main": "bin/extension.js",
|
||||||
@@ -20,6 +23,14 @@
|
|||||||
"command": "kiss.runCommand",
|
"command": "kiss.runCommand",
|
||||||
"title": "Kiss: Run a Kiss command"
|
"title": "Kiss: Run a Kiss command"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "kiss.runLastCommand",
|
||||||
|
"title": "Kiss: Rerun the last command"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "kiss.runKeyboardShortcut",
|
||||||
|
"title": "Kiss: Run a Kiss keyboard shortcut command"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "kiss.reloadConfig",
|
"command": "kiss.reloadConfig",
|
||||||
"title": "Kiss: Reload Kiss config"
|
"title": "Kiss: Reload Kiss config"
|
||||||
|
|||||||
@@ -11,12 +11,14 @@ import uuid.Uuid;
|
|||||||
using StringTools;
|
using StringTools;
|
||||||
using uuid.Uuid;
|
using uuid.Uuid;
|
||||||
|
|
||||||
typedef Command = (String) -> Void;
|
typedef Command = (?String) -> Void;
|
||||||
|
|
||||||
typedef KissConfig = {
|
typedef KissConfig = {
|
||||||
registerBuiltins:() -> Void,
|
registerBuiltins:() -> Void,
|
||||||
registerCommand:(String, Command) -> Void,
|
registerCommand:(String, Command) -> Void,
|
||||||
runCommand:() -> Void,
|
runCommand:Command,
|
||||||
|
runLastCommand:Command,
|
||||||
|
runKeyboardShortcut:Command,
|
||||||
init:() -> Void
|
init:() -> Void
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,24 @@
|
|||||||
(Vscode.window.showErrorMessage "Can't run commands! No config is loaded."))
|
(Vscode.window.showErrorMessage "Can't run commands! No config is loaded."))
|
||||||
(return))))
|
(return))))
|
||||||
|
|
||||||
|
(context.subscriptions.push
|
||||||
|
(Vscode.commands.registerCommand
|
||||||
|
"kiss.runLastCommand"
|
||||||
|
(lambda []
|
||||||
|
(if config
|
||||||
|
(.runLastCommand (the KissConfig config))
|
||||||
|
(Vscode.window.showErrorMessage "Can't run commands! No config is loaded."))
|
||||||
|
(return))))
|
||||||
|
|
||||||
|
(context.subscriptions.push
|
||||||
|
(Vscode.commands.registerCommand
|
||||||
|
"kiss.runKeyboardShortcut"
|
||||||
|
(lambda []
|
||||||
|
(if config
|
||||||
|
(.runKeyboardShortcut (the KissConfig config))
|
||||||
|
(Vscode.window.showErrorMessage "Can't run commands! No config is loaded."))
|
||||||
|
(return))))
|
||||||
|
|
||||||
// TODO overload Prelude.print to use showInformationMessage
|
// TODO overload Prelude.print to use showInformationMessage
|
||||||
|
|
||||||
(set activeConfigDir (Path.join [context.extensionPath "config"]))
|
(set activeConfigDir (Path.join [context.extensionPath "config"]))
|
||||||
|
|||||||
Reference in New Issue
Block a user