diff --git a/package.json b/package.json index 38dc7d0..1217d3b 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,11 @@ "command": "mind-reader.runCursorContext", "title": "Run Cursor Context" }, + + { + "command": "mind-reader.getIndent", + "title": "Get Line Indentation" + } { "command": "mind-reader.connectHub", @@ -81,6 +86,7 @@ "title": "Stop running program on the LEGO Hub" }, + { "command": "mind-reader.deleteProgram", "title": "Delete a program from the LEGO Hub" @@ -112,6 +118,85 @@ "mac": "" } ], + + { + "command": "mind-reader.showAllSymbols", + "key": "Ctrl+T", + "mac": "" + }, + + { + "command": "mind-reader.gotoLine", + "key": "CTRL+G", + "mac": "" + }, + + { + "command": "mind-reader.quickOpen", + "key": "CTRL+P", + "mac": "" + }, + + { + "command": "mind-reader.gotoSymbol", + "key": "Ctrl+Shift+O", + "mac": "" + }, + + { + "command": "mind-reader.showProblems", + "key": "Ctrl+Shift+M", + "mac": "" + }, + + { + "command": "mind-reader.nextInFiles", + "key": "F8", + "mac": "" + }, + + { + "command": "mind-reader.prevInFiles", + "key": "Shift+F8", + "mac": "" + }, + + { + "command": "mind-reader.quickOpenPreviousRecentlyUsedEditorInGroup", + "key": "Ctrl+Tab", + "mac": "" + }, + + { + "command": "mind-reader.navigateBack", + "key": "Ctrl+Alt+-", + "mac": "" + }, + + { + "command": "mind-reader.getQuickInputBack", + "key": "Ctrl+Alt+-", + "mac": "" + }, + + { + "command": "mind-reader.navigateForward", + "key": "Ctrl+Shift+-", + "mac": "" + }, + + { + "command": "mind-reader.selectTheme", + "key": "Ctrl+Shift+1", + "mac": "" + }, + + { + "command": "mind-reader.getIndent", + "key": "Shift+Tab", + "mac": "" + } + ], "menus": { "editor/context": [ { diff --git a/src/accessNodeProvider.ts b/src/accessNodeProvider.ts new file mode 100644 index 0000000..9b0db83 --- /dev/null +++ b/src/accessNodeProvider.ts @@ -0,0 +1,47 @@ +import * as vscode from 'vscode'; + +// list of all actions +let actions: AccessAction[] = []; + +class AccessAction extends vscode.TreeItem { + constructor( + public readonly label: string, + public readonly command: vscode.Command + ) { + super(label, vscode.TreeItemCollapsibleState.None); + } +}; + +export default class AccessNodeProvider implements vscode.TreeDataProvider { + public getTreeItem(a: AccessAction): vscode.TreeItem { + return a; + } + + public async getChildren(): Promise { + if (actions.length === 0) { + // fetch and cache mind-reader options + let cmds: string[] = await vscode.commands.getCommands(true); // get non-builtin commands + cmds = cmds.filter(x => x.startsWith('mind-reader')); // filter mind-reader commands + + cmds.forEach(c => { + let humanReadable = c.replace(/^mind-reader\./, ''); // strip extensions name + + // Convert camelCaseText to Title Case Text + humanReadable = humanReadable.replace(/([A-Z])/g, ' $1'); + humanReadable = humanReadable.charAt(0).toUpperCase() + humanReadable.slice(1); + + // add item to actions + actions.push(new AccessAction( + humanReadable, + { + title: humanReadable, + command: c, + tooltip: humanReadable + } + )); + }); + } + + return Promise.resolve(actions); + } +} diff --git a/src/commands.ts b/src/commands.ts index 514dd7f..ea12505 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -53,6 +53,66 @@ const commands: Command[] = [ callback: resetEditorScale, }, + //Navigation Keys...... + { + name: 'mind-reader.showAllSymbols', + callback: () => vscode.commands.executeCommand('workbench.action.showAllSymbols'), + }, + + { + name: 'mind-reader.gotoLine', + callback: () => vscode.commands.executeCommand('workbench.action.gotoLine'), + }, + + { + name: 'mind-reader.quickOpen', + callback: () => vscode.commands.executeCommand('workbench.action.quickOpen'), + }, + + { + name: 'mind-reader.gotoSymbol', + callback: () => vscode.commands.executeCommand('workbench.action.gotoSymbol'), + }, + + { + name: 'mind-reader.showProblems', + callback: () => vscode.commands.executeCommand('workbench.actions.view.problems'), + }, + + { + name: 'mind-reader.nextInFiles', + callback: () => vscode.commands.executeCommand('editor.action.marker.nextInFiles'), + }, + + { + name: 'mind-reader.prevInFiles', + callback: () => vscode.commands.executeCommand('editor.action.marker.prevInFiles'), + }, + + { + name: 'mind-reader.showCommands', + callback: () => vscode.commands.executeCommand('workbench.action.showCommands'), + }, + + { + name: 'mind-reader.quickOpenPreviousRecentlyUsedEditorInGroup', + callback: () => vscode.commands.executeCommand('workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup'), + }, + + { + name: 'mind-reader.navigateBack', + callback: () => vscode.commands.executeCommand('workbench.action.navigateBack'), + }, + + { + name: 'mind-reader.getuickInputBack', + callback: () => vscode.commands.executeCommand('workbench.action.quickInputBack'), + }, + + { + name: 'mind-reader.navigateForward', + callback: () => vscode.commands.executeCommand('workbench.action.navigateForward'), + }, { name: 'mind-reader.runLineContext', callback: runLineContext, @@ -62,7 +122,6 @@ const commands: Command[] = [ name: 'mind-reader.runCursorContext', callback: runCursorContext }, - { name: 'mind-reader.connectHub', callback: connectHub @@ -91,6 +150,11 @@ const commands: Command[] = [ { name: 'mind-reader.deleteProgram', callback: deleteProgram + }, + + { + name: 'mind-reader.getIndent', + callback: getIndent } ]; @@ -120,9 +184,36 @@ function resetEditorScale(): void { vscode.commands.executeCommand('workbench.action.zoomReset'); } +function getIndent(): void { + let editor = vscode.window.activeTextEditor; + if(editor) + { + let lineNum = editor.selection.active.line + 1; + let textLine = editor.document.lineAt(lineNum - 1); + if(textLine.isEmptyOrWhitespace) + { + vscode.window.showInformationMessage("Line number " + lineNum.toString() + " Is Empty"); + } + else + { + // Grab tab format from open document + let tabFmt = { + size: editor.options.tabSize as number, + hard: !editor.options.insertSpaces + }; + let i = pl.Lexer.getIndent(textLine.text, tabFmt); + vscode.window.showInformationMessage("Line Number " + lineNum.toString() + " Indentation " + i.toString()); + } + } + else{ + vscode.window.showErrorMessage('No document currently active'); + } + +} + function runLineContext(): void { let editor = vscode.window.activeTextEditor; - if (editor) { + if (editor){ // current text and line number let editorText = editor.document.getText(); let line = editor.selection.active.line; diff --git a/src/extension.ts b/src/extension.ts index adfbf5f..a1762bc 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -59,6 +59,5 @@ export function activate(context: vscode.ExtensionContext) { let hubProvider = new CommandNodeProvider(hubCommands); vscode.window.registerTreeDataProvider('hubActions', hubProvider); -} export function deactivate() {}