This repository has been archived by the owner on May 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Buttons
Marcel Kloubert edited this page Jun 13, 2021
·
2 revisions
Buttons can be used to run tasks, like scripts or shell commands, by user's click.
Create a buttons
section to the settings.json
file in the .vscode
sub folder of your workspace and add one or more entry:
{
"ego.power-tools": {
"buttons": [
{
"text": "Click me!",
"tooltip": "You run an awesome script by clicking that button!",
"action": {
"type": "script",
"script": "my_button.js"
}
}
]
}
}
For that example, create a my_button.js
file in your .vscode
folder and use the following skeleton:
exports.execute = async (args) => {
// args => https://egomobile.github.io/vscode-powertools/api/interfaces/_contracts_.buttonactionscriptarguments.html
// s. https://code.visualstudio.com/api/references/vscode-api
const vscode = args.require('vscode');
vscode.window.showInformationMessage(
'Hey, you clicked me!'
);
};
Name | Description | Required? |
---|---|---|
action |
The action to invoke. | yes |
color 1
|
The RGB text color. | no |
if |
(JavaScript) Code that checks if button is available or not. s. Conditional Settings | no |
ifFile |
The regular expression, that checks if that button should be visible for an active editor or not. Path separators will always be converted to / , even in Windows. |
no |
importValues |
Defines a list of properties, which uses (external) values for itself. s. Import Settings | no |
isRight |
Display button one the right side or not. Default: (false)
|
no |
onCreated |
The (JavaScript) code to executed after button has been created. s. Executable Settings | no |
onDestroyed |
The (JavaScript) code to executed after button has been destroyed. s. Executable Settings | no |
onEditorChanged |
The (JavaScript) code to executed after active editor has changed. s. Executable Settings | no |
platforms |
A list of one or more platform IDs, where the button should be available on. s. process.platform | no |
priority |
A (numeric) value that defines the priority, the button should be displayed with. | no |
text 1 2
|
The (display) text. | no |
tooltip 1
|
The tooltip text. | no |
1 supports placeholders
2 supports icons
Name | Description | Required? |
---|---|---|
type |
The type. Current supports: command , script and shell . Default: shell
|
no |
Runs a Node.js based script file.
{
"ego.power-tools": {
"buttons": [
{
"text": "Click me!",
"tooltip": "You run an awesome script by clicking that button!",
"action": {
"type": "script",
"script": "my_button.js"
}
}
]
}
}
Name | Description | Required? |
---|---|---|
options |
Options for the script. | no |
script 1
|
The path to the script that should be invoked. Relative paths will be mapped to the .vscode sub folder of the workspace or the .vscode-powertools sub folder inside the current user's home directory. |
yes |
1 supports placeholders
Runs a shell command.
{
"ego.power-tools": {
"buttons": [
{
"text": "Run 'npm install'",
"tooltip": "Runs 'npm install' from '${workspaceRoot}'",
"action": {
"type": "shell",
"command": "npm install"
}
}
]
}
}
Name | Description | Required? |
---|---|---|
command 1
|
The command that should be run. | no |
cwd 1
|
The working directory. Relative paths will be mapped to the workspace root folder. Default: (workspace root folder) | no |
silent |
Do not write result to output. Default: (true)
|
no |
wait |
Wait until command has been executed or not. Default: (true)
|
no |
1 supports placeholders
Runs a Visual Studio Code command.
{
"ego.power-tools": {
"buttons": [
{
"text": "Toggle Zen Mode",
"action": {
"type": "command",
"command": "workbench.action.toggleZenMode"
}
}
]
}
}
Name | Description | Required? |
---|---|---|
arguments |
A list of optional arguments to parse. | no |
command |
The ID of the command. | yes |
licensed under GDFL 1.3 - © Next.e.GO Mobile SE