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