mirror of
https://github.com/We-Dont-Byte/Mind_Reader.git
synced 2024-11-15 03:35:59 +00:00
Fix issues, split commands into sub-lists
This commit is contained in:
parent
8d757b943c
commit
9514db2fdc
@ -116,8 +116,7 @@
|
||||
"command": "mind-reader.resetEditorScale",
|
||||
"key": "shift+enter",
|
||||
"mac": ""
|
||||
}
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
"command": "mind-reader.showAllSymbols",
|
||||
|
@ -1,5 +1,7 @@
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { CommandEntry } from './commands';
|
||||
|
||||
export class CommandItem extends vscode.TreeItem {
|
||||
constructor(
|
||||
public readonly label: string,
|
||||
@ -12,19 +14,19 @@ export class CommandItem extends vscode.TreeItem {
|
||||
export default class CommandNodeProvider implements vscode.TreeDataProvider<CommandItem> {
|
||||
private items: CommandItem[] = [];
|
||||
|
||||
public constructor(commands: string[]) {
|
||||
public constructor(commands: CommandEntry[]) {
|
||||
// build and cache command items
|
||||
for (const c of commands) {
|
||||
console.log(commands.length);
|
||||
let humanReadable = c.name.replace(/^mind-reader\./, ''); // strip extensions name
|
||||
// Convert camelCaseText to Title Case Text
|
||||
let humanReadable = c.replace(/([A-Z])/g, ' $1');
|
||||
humanReadable = humanReadable.replace(/([A-Z])/g, ' $1');
|
||||
humanReadable = humanReadable.charAt(0).toUpperCase() + humanReadable.slice(1);
|
||||
|
||||
this.items.push(new CommandItem(
|
||||
humanReadable,
|
||||
{
|
||||
title: humanReadable,
|
||||
command: 'mind-reader.' + c,
|
||||
command: c.name,
|
||||
tooltip: humanReadable
|
||||
}
|
||||
));
|
||||
|
@ -9,13 +9,13 @@ import HubManager from './hubManager';
|
||||
* @prop {string} command // Name of the command; e.g., 'mind-reader.selectTheme'
|
||||
* @prop {callback} callback // Callback to register when `command` is invoked
|
||||
*/
|
||||
type Command = {
|
||||
export type CommandEntry = {
|
||||
name: string,
|
||||
callback: () => void
|
||||
};
|
||||
|
||||
// The list of commands to register in the extension
|
||||
const commands: Command[] = [
|
||||
// Accessibility Commands
|
||||
export const accessCommands: CommandEntry[] = [
|
||||
{
|
||||
name: 'mind-reader.selectTheme',
|
||||
|
||||
@ -53,6 +53,13 @@ const commands: Command[] = [
|
||||
callback: resetEditorScale,
|
||||
},
|
||||
|
||||
{
|
||||
name: 'mind-reader.getIndent',
|
||||
callback: getIndent,
|
||||
}
|
||||
];
|
||||
|
||||
export const navCommands: CommandEntry[] = [
|
||||
//Navigation Keys......
|
||||
{
|
||||
name: 'mind-reader.showAllSymbols',
|
||||
@ -105,7 +112,7 @@ const commands: Command[] = [
|
||||
},
|
||||
|
||||
{
|
||||
name: 'mind-reader.getuickInputBack',
|
||||
name: 'mind-reader.getQuickInputBack',
|
||||
callback: () => vscode.commands.executeCommand('workbench.action.quickInputBack'),
|
||||
},
|
||||
|
||||
@ -121,7 +128,10 @@ const commands: Command[] = [
|
||||
{
|
||||
name: 'mind-reader.runCursorContext',
|
||||
callback: runCursorContext
|
||||
},
|
||||
}
|
||||
];
|
||||
|
||||
export const hubCommands: CommandEntry[] = [
|
||||
{
|
||||
name: 'mind-reader.connectHub',
|
||||
callback: connectHub
|
||||
@ -151,11 +161,6 @@ const commands: Command[] = [
|
||||
name: 'mind-reader.deleteProgram',
|
||||
callback: deleteProgram
|
||||
},
|
||||
|
||||
{
|
||||
name: 'mind-reader.getIndent',
|
||||
callback: getIndent
|
||||
}
|
||||
];
|
||||
|
||||
// COMMAND CALLBACK IMPLEMENTATIONS
|
||||
@ -331,7 +336,7 @@ function runCursorContext(): void {
|
||||
}
|
||||
|
||||
// Current connected hub
|
||||
let hub: HubManager | null;
|
||||
let hub: HubManager | null = null;
|
||||
|
||||
// TODO: port option
|
||||
async function connectHub(): Promise<void> {
|
||||
@ -469,6 +474,3 @@ async function deleteProgram(): Promise<void> {
|
||||
await hub.deleteProgram(parseInt(slotID.label));
|
||||
vscode.window.showInformationMessage('Deleted program ' + slotID.label);
|
||||
}
|
||||
|
||||
|
||||
export default commands;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import * as vscode from 'vscode';
|
||||
import * as pl from './pylex';
|
||||
|
||||
import commands from './commands';
|
||||
import { accessCommands, hubCommands, navCommands } from './commands';
|
||||
|
||||
import CommandNodeProvider from './commandNodeProvider';
|
||||
import Logger from './log';
|
||||
@ -18,8 +18,10 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
parser.parse('Beep Boop');
|
||||
|
||||
let allCommands = accessCommands.concat(hubCommands).concat(navCommands);
|
||||
|
||||
// Register Commands
|
||||
commands.forEach(command => {
|
||||
allCommands.forEach(command => {
|
||||
let disposable = vscode.commands.registerCommand(
|
||||
command.name,
|
||||
command.callback
|
||||
@ -27,37 +29,11 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
context.subscriptions.push(disposable);
|
||||
});
|
||||
|
||||
// list of all commands to present in the access pane
|
||||
const accessActions: string[] = [
|
||||
'increaseFontScale',
|
||||
'decreaseFontScale',
|
||||
'resetFontScale',
|
||||
|
||||
'increaseEditorScale',
|
||||
'decreaseEditorScale',
|
||||
'resetEditorScale',
|
||||
|
||||
'selectTheme',
|
||||
|
||||
'runLineContext',
|
||||
'runCursorContext',
|
||||
];
|
||||
|
||||
let accessProvider = new CommandNodeProvider(accessActions);
|
||||
let accessProvider = new CommandNodeProvider(accessCommands);
|
||||
vscode.window.registerTreeDataProvider('accessActions', accessProvider);
|
||||
|
||||
|
||||
// list of all commands to present in the hub pane
|
||||
const hubCommands: string[] = [
|
||||
'connectHub',
|
||||
'diconnectHub',
|
||||
'uploadCurrentFile',
|
||||
'runProgram',
|
||||
'stopExecution',
|
||||
'deleteProgram',
|
||||
];
|
||||
|
||||
let hubProvider = new CommandNodeProvider(hubCommands);
|
||||
vscode.window.registerTreeDataProvider('hubActions', hubProvider);
|
||||
}
|
||||
|
||||
export function deactivate() {}
|
||||
|
Loading…
Reference in New Issue
Block a user