Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
216 changes: 198 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -491,34 +491,79 @@
"group": "inline"
},
{
"command": "extension.brightscript.setActiveDevice",
"when": "view == devicesView && viewItem =~ /^device-/",
"group": "navigation@1"
"command": "extension.brightscript.devicesView.deviceMenu.setActiveDevice",
"when": "view == devicesView && viewItem =~ /^device\\b/",
"group": "1_primary@1"
},
{
"command": "extension.brightscript.refreshDevice",
"when": "view == devicesView && viewItem =~ /^device-/",
"group": "navigation@2"
"command": "extension.brightscript.devicesView.deviceMenu.captureScreenshot",
"when": "view == devicesView && viewItem =~ /^device\\b/",
"group": "1_primary@2"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.switchTvInput",
"when": "view == devicesView && viewItem =~ /-isTv\\b/",
"group": "1_primary@3"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.refreshDevice",
"when": "view == devicesView && viewItem =~ /^device\\b/",
"group": "2_device@1"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.restartDevice",
"when": "view == devicesView && viewItem =~ /-canRestart\\b/",
"group": "2_device@2"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.checkAndInstallUpdates",
"when": "view == devicesView && viewItem =~ /-canRestart\\b/",
"group": "2_device@3"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.openWebPortal",
"when": "view == devicesView && viewItem =~ /^device\\b/",
"group": "3_web@1"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.viewRegistry",
"when": "view == devicesView && viewItem =~ /-canViewRegistry\\b/",
"group": "3_web@2"
},
{
"command": "extension.brightscript.addDeviceToUserSettings",
"when": "view == devicesView && (viewItem == 'device' || viewItem == 'device-workspace')",
"group": "settings@1"
"command": "extension.brightscript.devicesView.deviceMenu.setDevicePassword",
"when": "view == devicesView && viewItem =~ /-noPassword\\b/",
"group": "4_password@1"
},
{
"command": "extension.brightscript.editDeviceInUserSettings",
"when": "view == devicesView && (viewItem == 'device-user' || viewItem == 'device-user-workspace')",
"group": "settings@1"
"command": "extension.brightscript.devicesView.deviceMenu.changeDevicePassword",
"when": "view == devicesView && viewItem =~ /-hasPassword\\b/",
"group": "4_password@1"
},
{
"command": "extension.brightscript.addDeviceToWorkspaceSettings",
"when": "view == devicesView && (viewItem == 'device' || viewItem == 'device-user')",
"group": "settings@2"
"command": "extension.brightscript.devicesView.deviceMenu.clearDevicePassword",
"when": "view == devicesView && viewItem =~ /-hasPassword\\b/",
"group": "4_password@2"
},
{
"command": "extension.brightscript.editDeviceInWorkspaceSettings",
"when": "view == devicesView && (viewItem == 'device-workspace' || viewItem == 'device-user-workspace')",
"group": "settings@2"
"command": "extension.brightscript.devicesView.deviceMenu.addToUserSettings",
"when": "view == devicesView && viewItem =~ /-notInUser\\b/",
"group": "5_settings@1"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.editInUserSettings",
"when": "view == devicesView && viewItem =~ /-inUser\\b/",
"group": "5_settings@1"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.addToWorkspaceSettings",
"when": "view == devicesView && viewItem =~ /-notInWorkspace\\b/",
"group": "5_settings@2"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.editInWorkspaceSettings",
"when": "view == devicesView && viewItem =~ /-inWorkspace\\b/",
"group": "5_settings@2"
}
],
"explorer/context": [
Expand Down Expand Up @@ -702,6 +747,66 @@
{
"command": "extension.brightscript.devicesView.toggleFilter.autoDetected.active",
"when": "false"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.setActiveDevice",
"when": "false"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.captureScreenshot",
"when": "false"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.switchTvInput",
"when": "false"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.refreshDevice",
"when": "false"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.restartDevice",
"when": "false"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.checkAndInstallUpdates",
"when": "false"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.openWebPortal",
"when": "false"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.viewRegistry",
"when": "false"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.setDevicePassword",
"when": "false"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.changeDevicePassword",
"when": "false"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.clearDevicePassword",
"when": "false"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.addToUserSettings",
"when": "false"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.editInUserSettings",
"when": "false"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.addToWorkspaceSettings",
"when": "false"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.editInWorkspaceSettings",
"when": "false"
}
]
},
Expand Down Expand Up @@ -3914,6 +4019,81 @@
"category": "BrightScript",
"icon": "$(cloud-download)"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.setActiveDevice",
"title": "⭐ Set as Active Device",
"category": "BrightScript"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.captureScreenshot",
"title": "📷 Capture Screenshot",
"category": "BrightScript"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.switchTvInput",
"title": "📺 Switch TV Input",
"category": "BrightScript"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.refreshDevice",
"title": "🔃 Refresh Device",
"category": "BrightScript"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.restartDevice",
"title": "🔁 Restart Device",
"category": "BrightScript"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.checkAndInstallUpdates",
"title": "🔄 Check for Software Updates",
"category": "BrightScript"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.openWebPortal",
"title": "🔗 Open Device Web Portal",
"category": "BrightScript"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.viewRegistry",
"title": "📋 View Registry",
"category": "BrightScript"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.setDevicePassword",
"title": "🔑 Set Device Password",
"category": "BrightScript"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.changeDevicePassword",
"title": "🔑 Change Device Password",
"category": "BrightScript"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.clearDevicePassword",
"title": "🗑️ Clear Device Password",
"category": "BrightScript"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.addToUserSettings",
"title": "👤 Add to User Settings",
"category": "BrightScript"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.editInUserSettings",
"title": "👤 Edit in User Settings",
"category": "BrightScript"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.addToWorkspaceSettings",
"title": "📁 Add to Workspace Settings",
"category": "BrightScript"
},
{
"command": "extension.brightscript.devicesView.deviceMenu.editInWorkspaceSettings",
"title": "📁 Edit in Workspace Settings",
"category": "BrightScript"
},
{
"command": "extension.brightscript.addDeviceToUserSettings",
"title": "Add to User Settings",
Expand Down
65 changes: 65 additions & 0 deletions src/BrightScriptCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,71 @@ export class BrightScriptCommands {
this.registerCommand('devicesView.checkAndInstallUpdates', (element?: { key?: string }) => {
return this.checkForUpdates(element?.key ? this.deviceManager.getDevice(element.key)?.ip : undefined);
});

this.registerDeviceContextMenuCommands();
}

/**
* Register the commands behind the right-click context menu on a device in the Devices view.
* Each receives the clicked tree element and resolves it into the argument shape its
* underlying command expects. These are hidden from the command palette (they only make
* sense with a tree element), which also lets their titles carry the emoji icons shown
* in the context menu.
*/
private registerDeviceContextMenuCommands() {
const getDevice = (element?: { key?: string }) => {
return element?.key ? this.deviceManager.getDevice(element.key) : undefined;
};

this.registerCommand('devicesView.deviceMenu.setActiveDevice', (element?: { key?: string }) => {
return vscode.commands.executeCommand('extension.brightscript.setActiveDevice', element);
});
this.registerCommand('devicesView.deviceMenu.captureScreenshot', (element?: { key?: string }) => {
return vscode.commands.executeCommand('extension.brightscript.captureScreenshot', getDevice(element)?.ip);
});
this.registerCommand('devicesView.deviceMenu.switchTvInput', (element?: { key?: string }) => {
return vscode.commands.executeCommand('extension.brightscript.changeTvInput', getDevice(element)?.ip);
});
this.registerCommand('devicesView.deviceMenu.refreshDevice', (element?: { key?: string }) => {
return vscode.commands.executeCommand('extension.brightscript.refreshDevice', element);
});
this.registerCommand('devicesView.deviceMenu.restartDevice', (element?: { key?: string }) => {
return this.restartDevice(getDevice(element)?.ip);
});
this.registerCommand('devicesView.deviceMenu.checkAndInstallUpdates', (element?: { key?: string }) => {
return this.checkForUpdates(getDevice(element)?.ip);
});
this.registerCommand('devicesView.deviceMenu.openWebPortal', (element?: { key?: string }) => {
const ip = getDevice(element)?.ip;
if (!ip) {
return vscode.window.showErrorMessage('Could not determine the IP address for this device');
}
return vscode.commands.executeCommand('extension.brightscript.openUrl', `http://${ip}`);
});
this.registerCommand('devicesView.deviceMenu.viewRegistry', (element?: { key?: string }) => {
return vscode.commands.executeCommand('extension.brightscript.openRegistryInBrowser', getDevice(element)?.ip);
});
// Set and Change share a handler; the menu shows one or the other based on whether a password is stored
for (const commandName of ['devicesView.deviceMenu.setDevicePassword', 'devicesView.deviceMenu.changeDevicePassword']) {
this.registerCommand(commandName, (element?: { key?: string }) => {
return vscode.commands.executeCommand('extension.brightscript.setDevicePassword', getDevice(element)?.serialNumber);
});
}
this.registerCommand('devicesView.deviceMenu.clearDevicePassword', (element?: { key?: string }) => {
return vscode.commands.executeCommand('extension.brightscript.clearDevicePassword', getDevice(element)?.serialNumber);
});
this.registerCommand('devicesView.deviceMenu.addToUserSettings', (element?: { key?: string }) => {
return vscode.commands.executeCommand('extension.brightscript.addDeviceToUserSettings', element);
});
this.registerCommand('devicesView.deviceMenu.editInUserSettings', (element?: { key?: string }) => {
return vscode.commands.executeCommand('extension.brightscript.editDeviceInUserSettings', element);
});
this.registerCommand('devicesView.deviceMenu.addToWorkspaceSettings', (element?: { key?: string }) => {
return vscode.commands.executeCommand('extension.brightscript.addDeviceToWorkspaceSettings', element);
});
this.registerCommand('devicesView.deviceMenu.editInWorkspaceSettings', (element?: { key?: string }) => {
return vscode.commands.executeCommand('extension.brightscript.editDeviceInWorkspaceSettings', element);
});
}

private async sendAsciiToDevice(character: string) {
Expand Down
Loading
Loading