|
1 | 1 | import { basename, dirname, join } from 'path'; |
2 | 2 | import { ExtensionContext, commands, Uri, window, workspace } from 'vscode'; |
3 | | -import { state } from './extension'; |
| 3 | +// import { state } from './extension'; |
4 | 4 |
|
5 | | -const sketchNumber = 0; |
| 5 | +// const sketchNumber = 0; |
6 | 6 |
|
7 | 7 | export function setupCommands(context: ExtensionContext) { |
8 | | - const runSketch = commands.registerCommand('processing.sketch.run', (resource: Uri) => { |
9 | | - // TODO: Use VScode contexts to highlight run button when sketch is running, blocked until we do not run the sketch in a terminal |
10 | | - // https://code.visualstudio.com/api/references/when-clause-contexts |
11 | | - |
12 | | - const autosave = workspace |
13 | | - .getConfiguration('processing') |
14 | | - .get<boolean>('autosave'); |
15 | | - if (autosave === true) { |
16 | | - // Save all files before running the sketch |
17 | | - commands.executeCommand('workbench.action.files.saveAll'); |
18 | | - } |
19 | | - if (resource == undefined) { |
20 | | - const editor = window.activeTextEditor; |
21 | | - if (editor) { |
22 | | - resource = editor.document.uri; |
23 | | - } |
24 | | - } |
25 | | - |
26 | | - if (!resource) { |
27 | | - return; |
28 | | - } |
29 | | - |
30 | | - // TODO: Give feedback if the sketch is starting |
31 | | - |
32 | | - let terminal = state.terminal; |
33 | | - // Create a new terminal |
34 | | - if (terminal === undefined || terminal.exitStatus) { |
35 | | - window.terminals.forEach(t => { |
36 | | - if (t.name === "Sketch") { |
37 | | - t.dispose(); |
38 | | - } |
39 | | - }); |
40 | | - state.terminal = window.createTerminal("Sketch"); |
41 | | - terminal = state.terminal; |
42 | | - // Show the terminal panel the first time |
43 | | - terminal.show(true); |
44 | | - } else { |
45 | | - // Send the command to the terminal |
46 | | - terminal.sendText('\x03', false); |
47 | | - } |
48 | | - |
49 | | - // clear the terminal |
50 | | - terminal.sendText("clear", true); |
51 | | - |
52 | | - let path = state.selectedVersion.path; |
53 | | - if (process.platform === "win32") { |
54 | | - // on windows we need to escape spaces |
55 | | - path = `& "${path}"`; |
56 | | - } |
57 | | - |
58 | | - let cmd = `${path} cli --sketch="${dirname(resource.fsPath)}" --run`; |
59 | | - if (process.platform === "win32") { |
60 | | - // on windows we need to pipe stderr to stdout and convert to string |
61 | | - cmd += ` 2>&1`; |
62 | | - } |
63 | | - |
64 | | - terminal.sendText(cmd, true); |
65 | | - }); |
66 | | - |
67 | | - const stopSketch = commands.registerCommand('processing.sketch.stop', () => { |
68 | | - if (state.terminal === undefined) { |
69 | | - return; |
70 | | - } |
71 | | - |
72 | | - // Send the command to the terminal |
73 | | - state.terminal.sendText('\x03', false); |
74 | | - }); |
| 8 | + // const runSketch = commands.registerCommand('processing.sketch.run', (resource: Uri) => { |
| 9 | + // // TODO: Use VScode contexts to highlight run button when sketch is running, blocked until we do not run the sketch in a terminal |
| 10 | + // // https://code.visualstudio.com/api/references/when-clause-contexts |
| 11 | + |
| 12 | + // const autosave = workspace |
| 13 | + // .getConfiguration('processing') |
| 14 | + // .get<boolean>('autosave'); |
| 15 | + // if (autosave === true) { |
| 16 | + // // Save all files before running the sketch |
| 17 | + // commands.executeCommand('workbench.action.files.saveAll'); |
| 18 | + // } |
| 19 | + // if (resource == undefined) { |
| 20 | + // const editor = window.activeTextEditor; |
| 21 | + // if (editor) { |
| 22 | + // resource = editor.document.uri; |
| 23 | + // } |
| 24 | + // } |
| 25 | + |
| 26 | + // if (!resource) { |
| 27 | + // return; |
| 28 | + // } |
| 29 | + |
| 30 | + // return; |
| 31 | + |
| 32 | + // let terminal = state.terminal; |
| 33 | + // // Create a new terminal |
| 34 | + // if (terminal === undefined || terminal.exitStatus) { |
| 35 | + // window.terminals.forEach(t => { |
| 36 | + // if (t.name === "Sketch") { |
| 37 | + // t.dispose(); |
| 38 | + // } |
| 39 | + // }); |
| 40 | + // state.terminal = window.createTerminal("Sketch"); |
| 41 | + // terminal = state.terminal; |
| 42 | + // // Show the terminal panel the first time |
| 43 | + // terminal.show(true); |
| 44 | + // } else { |
| 45 | + // // Send the command to the terminal |
| 46 | + // terminal.sendText('\x03', false); |
| 47 | + // } |
| 48 | + |
| 49 | + // // clear the terminal |
| 50 | + // terminal.sendText("clear", true); |
| 51 | + |
| 52 | + // let path = state.selectedVersion.path; |
| 53 | + // if (process.platform === "win32") { |
| 54 | + // // on windows we need to escape spaces |
| 55 | + // path = `& "${path}"`; |
| 56 | + // } |
| 57 | + |
| 58 | + // let cmd = `${path} cli --sketch="${dirname(resource.fsPath)}" --run`; |
| 59 | + // if (process.platform === "win32") { |
| 60 | + // // on windows we need to pipe stderr to stdout and convert to string |
| 61 | + // cmd += ` 2>&1`; |
| 62 | + // } |
| 63 | + |
| 64 | + // terminal.sendText(cmd, true); |
| 65 | + // }); |
| 66 | + |
| 67 | + // const stopSketch = commands.registerCommand('processing.sketch.stop', () => { |
| 68 | + // if (state.terminal === undefined) { |
| 69 | + // return; |
| 70 | + // } |
| 71 | + |
| 72 | + // // Send the command to the terminal |
| 73 | + // state.terminal.sendText('\x03', false); |
| 74 | + // }); |
75 | 75 |
|
76 | 76 | const openSketch = commands.registerCommand('processing.sketch.open', async (folder: string, isReadOnly: boolean) => { |
77 | 77 | if (!folder) { |
@@ -161,7 +161,7 @@ export function setupCommands(context: ExtensionContext) { |
161 | 161 |
|
162 | 162 | // TODO: Add command to select Processing version and set the setting |
163 | 163 |
|
164 | | - context.subscriptions.push(runSketch, stopSketch, openSketch, newSketch); |
| 164 | + context.subscriptions.push(openSketch, newSketch); |
165 | 165 | } |
166 | 166 |
|
167 | 167 | // Helper function to convert a number to alphabetical (e.g., 0 = a, 1 = b, ..., 25 = z, 26 = aa, etc.) |
|
0 commit comments