Merge branch 'master' into hub-communication

This commit is contained in:
Jake Grossman 2021-11-18 16:03:00 -06:00 committed by GitHub
commit 066a256923
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 225 additions and 3 deletions

View File

@ -55,6 +55,11 @@
"command": "mind-reader.runCursorContext", "command": "mind-reader.runCursorContext",
"title": "Run Cursor Context" "title": "Run Cursor Context"
}, },
{
"command": "mind-reader.getIndent",
"title": "Get Line Indentation"
}
{ {
"command": "mind-reader.connectHub", "command": "mind-reader.connectHub",
@ -81,6 +86,7 @@
"title": "Stop running program on the LEGO Hub" "title": "Stop running program on the LEGO Hub"
}, },
{ {
"command": "mind-reader.deleteProgram", "command": "mind-reader.deleteProgram",
"title": "Delete a program from the LEGO Hub" "title": "Delete a program from the LEGO Hub"
@ -112,6 +118,85 @@
"mac": "" "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": { "menus": {
"editor/context": [ "editor/context": [
{ {

47
src/accessNodeProvider.ts Normal file
View File

@ -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<AccessAction> {
public getTreeItem(a: AccessAction): vscode.TreeItem {
return a;
}
public async getChildren(): Promise<AccessAction[]> {
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);
}
}

View File

@ -53,6 +53,66 @@ const commands: Command[] = [
callback: resetEditorScale, 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', name: 'mind-reader.runLineContext',
callback: runLineContext, callback: runLineContext,
@ -62,7 +122,6 @@ const commands: Command[] = [
name: 'mind-reader.runCursorContext', name: 'mind-reader.runCursorContext',
callback: runCursorContext callback: runCursorContext
}, },
{ {
name: 'mind-reader.connectHub', name: 'mind-reader.connectHub',
callback: connectHub callback: connectHub
@ -91,6 +150,11 @@ const commands: Command[] = [
{ {
name: 'mind-reader.deleteProgram', name: 'mind-reader.deleteProgram',
callback: deleteProgram callback: deleteProgram
},
{
name: 'mind-reader.getIndent',
callback: getIndent
} }
]; ];
@ -120,9 +184,36 @@ function resetEditorScale(): void {
vscode.commands.executeCommand('workbench.action.zoomReset'); 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 { function runLineContext(): void {
let editor = vscode.window.activeTextEditor; let editor = vscode.window.activeTextEditor;
if (editor) { if (editor){
// current text and line number // current text and line number
let editorText = editor.document.getText(); let editorText = editor.document.getText();
let line = editor.selection.active.line; let line = editor.selection.active.line;

View File

@ -59,6 +59,5 @@ export function activate(context: vscode.ExtensionContext) {
let hubProvider = new CommandNodeProvider(hubCommands); let hubProvider = new CommandNodeProvider(hubCommands);
vscode.window.registerTreeDataProvider('hubActions', hubProvider); vscode.window.registerTreeDataProvider('hubActions', hubProvider);
}
export function deactivate() {} export function deactivate() {}