Skip to content

Commit c94cb22

Browse files
committed
Added stateful command
1 parent 403a16d commit c94cb22

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

client/src/setupConsole.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,16 @@ export default function setupConsole(context: ExtensionContext) {
5050
proc.on('close', (code) => {
5151
provider.webview?.webview.postMessage({ type: 'close', value: code?.toString() });
5252
sketchProcess = undefined;
53+
commands.executeCommand('setContext', 'processing.sketch.running', false);
5354
});
5455
provider.webview?.show?.(true);
5556
provider.webview?.webview.postMessage({ type: 'clear'});
5657
sketchProcess = proc;
58+
commands.executeCommand('setContext', 'processing.sketch.running', true);
59+
});
60+
61+
const restartSketch = commands.registerCommand('processing.sketch.restart', (resource: Uri) => {
62+
commands.executeCommand('processing.sketch.run', resource);
5763
});
5864

5965
const stopSketch = commands.registerCommand('processing.sketch.stop', () => {
@@ -66,6 +72,7 @@ export default function setupConsole(context: ExtensionContext) {
6672
context.subscriptions.push(
6773
register,
6874
startSketch,
75+
restartSketch,
6976
stopSketch
7077
);
7178
}

media/restart.svg

Lines changed: 5 additions & 0 deletions
Loading

package.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
"title": "Run the Processing Sketch",
5050
"icon": "media/start.svg"
5151
},
52+
{
53+
"command": "processing.sketch.restart",
54+
"title": "Restart the Processing Sketch",
55+
"icon": "media/restart.svg"
56+
},
5257
{
5358
"command": "processing.sketch.stop",
5459
"title": "Stop the Processing Sketch",
@@ -83,7 +88,12 @@
8388
"editor/title": [
8489
{
8590
"command": "processing.sketch.run",
86-
"when": "editorLangId == Processing || editorLangId == java",
91+
"when": "!processing.sketch.running && (editorLangId == Processing || editorLangId == java)",
92+
"group": "navigation"
93+
},
94+
{
95+
"command": "processing.sketch.restart",
96+
"when": "processing.sketch.running && (editorLangId == Processing || editorLangId == java)",
8797
"group": "navigation"
8898
},
8999
{

0 commit comments

Comments
 (0)