mirror of
https://github.com/We-Dont-Byte/Mind_Reader.git
synced 2024-11-15 03:35:59 +00:00
Merge branch 'master' into hub-communication
This commit is contained in:
commit
066a256923
85
package.json
85
package.json
@ -56,6 +56,11 @@
|
||||
"title": "Run Cursor Context"
|
||||
},
|
||||
|
||||
{
|
||||
"command": "mind-reader.getIndent",
|
||||
"title": "Get Line Indentation"
|
||||
}
|
||||
|
||||
{
|
||||
"command": "mind-reader.connectHub",
|
||||
"title": "Connect LEGO Hub"
|
||||
@ -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": [
|
||||
{
|
||||
|
47
src/accessNodeProvider.ts
Normal file
47
src/accessNodeProvider.ts
Normal 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);
|
||||
}
|
||||
}
|
@ -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,6 +184,33 @@ 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){
|
||||
|
@ -59,6 +59,5 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
let hubProvider = new CommandNodeProvider(hubCommands);
|
||||
vscode.window.registerTreeDataProvider('hubActions', hubProvider);
|
||||
}
|
||||
|
||||
export function deactivate() {}
|
||||
|
Loading…
Reference in New Issue
Block a user