mirror of
https://github.com/We-Dont-Byte/Mind_Reader.git
synced 2024-11-15 03:35:59 +00:00
b3984daad5
* Add persistent accessibility pane This will facilitate more extensive usage of the menu than the context menu. * Fixed missing files * Add missing semicolon * Implement HubController * Parse messages on arrival Rather than queuing inbound messages, the HubController now saves pending promises/rejects for each pending request. Each inbound packet is checked at the time of arrival, and if the ID matches a pending response, the corresponding promise is called. This fixes a problem where the longer the time between reads, the more garbage responses queue up that are guaranteed to get thrown away the next time the next response was gathered. * Add clarification comment to send * Add logger, output * Use stat+stream instead of reading entire file on upload * Split MindReader view into accessability and hub sub-views * Add missing comma from conflict resolution * Fix issues, split commands into sub-lists * Add rebuild instructions * More accurate * Add tools for native modules instructions to README.md * Move commands to correct spot * Remove automatic connection I did not heed the warning where 'only the path is guaranteed' when listing open serial ports and made the assumption that the manufacturer would be known (hint: it wasn't). * Use device specific language for output title
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import * as vscode from 'vscode';
|
|
|
|
import { CommandEntry } from './commands';
|
|
|
|
export class CommandItem extends vscode.TreeItem {
|
|
constructor(
|
|
public readonly label: string,
|
|
public readonly command: vscode.Command
|
|
) {
|
|
super(label, vscode.TreeItemCollapsibleState.None);
|
|
}
|
|
};
|
|
|
|
export default class CommandNodeProvider implements vscode.TreeDataProvider<CommandItem> {
|
|
private items: CommandItem[] = [];
|
|
|
|
public constructor(commands: CommandEntry[]) {
|
|
// build and cache command items
|
|
for (const c of commands) {
|
|
let humanReadable = c.name.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);
|
|
|
|
this.items.push(new CommandItem(
|
|
humanReadable,
|
|
{
|
|
title: humanReadable,
|
|
command: c.name,
|
|
tooltip: humanReadable
|
|
}
|
|
));
|
|
}
|
|
}
|
|
|
|
public getTreeItem(item: CommandItem): vscode.TreeItem {
|
|
return item;
|
|
}
|
|
|
|
public async getChildren(): Promise<CommandItem[]> {
|
|
return Promise.resolve(this.items);
|
|
}
|
|
}
|