diff --git a/src/commands/nav.ts b/src/commands/nav.ts index f694e40..a9be064 100755 --- a/src/commands/nav.ts +++ b/src/commands/nav.ts @@ -1,24 +1,21 @@ -import * as vscode from 'vscode'; -import * as fs from 'fs'; +import * as vscode from "vscode"; +// import * as fs from "fs"; +// import * as os from 'os'; -import { CommandEntry } from './commandEntry'; +import { CommandEntry } from "./commandEntry"; export const navCommands: CommandEntry[] = [ { name: 'mind-reader.openWebview', callback: openWebview, }, - { - name: 'mind-reader.openKeyBindWin', - callback: () => openKeyBindWin('Windows') - }, - { - name: 'mind-reader.openKeyBindMac', - callback: () => openKeyBindWin('Mac'), + name: "mind-reader.openKeybinds", + callback: () => vscode.commands.executeCommand("workbench.action.openGlobalKeybindings", "mind-reader"), }, //Navigation Keys...... + // TODO: Why is this here? Extensions can rebind existing keybinds. { name: 'mind-reader.showAllSymbols', callback: () => vscode.commands.executeCommand('workbench.action.showAllSymbols'), @@ -82,35 +79,148 @@ export const navCommands: CommandEntry[] = [ // COMMAND CALLBACK IMPLEMENTATIONS function openWebview(): void { - //vscode.commands.executeCommand('workbench.action.zoomOut'); const panel = vscode.window.createWebviewPanel( - 'mindReader', // Identifies the type of the webview. Used internally - 'Mind Reader', // Title of the panel displayed to the user + "mindReader", // Identifies the type of the webview. Used internally + "Mind Reader", // Title of the panel displayed to the user vscode.ViewColumn.One, // Editor column to show the new webview panel in. {} ); // Webview options. More on these later. - panel.webview.html = getWebviewContent('media/html/main.html'); + panel.webview.html = getWebviewContent(); } -function getWebviewContent(filepath: string) { - return fs.readFileSync(filepath, {encoding: 'utf-8'}); +// function getWebviewContent(filepath: string) { +// return fs.readFileSync(filepath, {encoding: 'utf-8'}); +// } + +function getWebviewContent() { + return ` + + + + + Mind Reader + + + +

+

Welcome to Mind_Reader!

+

We are the Single Semester Snobs and this is our tool to Help Blind Students Program Lego Mindstorms Robots in Python.

+ +

Use the following key binding to bring up a page for all key bindings for windows +
+ Control and Shift and 8 +

+

Use this key binding to do the same for mac computers: +
+ Command and Shift and 9 +

+

This is the Lego Spike Prime! +

+ +

+ Get the robot! + + `; } -function openKeyBindWin(os: 'Mac' | 'Windows'): void { - //vscode.commands.executeCommand('workbench.action.zoomOut'); - const panel = vscode.window.createWebviewPanel( - 'mindReader', // Identifies the type of the webview. Used internally - 'MR Key Bindings', // Title of the panel displayed to the user - vscode.ViewColumn.One, // Editor column to show the new webview panel in. - {} - ); // Webview options. More on these later. +// export function getPlatform(): 'windows' | 'mac' | 'linux' | undefined { +// let platform: 'windows' | 'mac' | 'linux' | undefined; - if (os === 'Windows') { - panel.webview.html = getWebviewContent('media/html/winkeys.html'); - } else if (os === 'Mac') { - panel.webview.html = getWebviewContent('media/html/mackeys.html'); - } -} +// if (os.platform().toUpperCase() === 'WIN32') { +// platform = 'windows'; +// return platform; +// } +// if (os.platform().toUpperCase() === 'DARWIN') { +// platform = 'mac'; +// return platform; +// } +// if (os.platform().toUpperCase() === 'linux') { +// platform = 'linux'; +// return platform; +// } + +// platform = undefined; +// return platform; +// } + +// function getDocumentWorkspaceFolder(): string | undefined { +// const fileName = vscode.window.activeTextEditor?.document.fileName; +// return vscode.workspace.workspaceFolders +// ?.map((folder) => folder.uri.fsPath) +// .filter((fsPath) => fileName?.startsWith(fsPath))[0]; +// } + +// function openKeyBindWin(): void { +// //vscode.commands.executeCommand('workbench.action.zoomOut'); +// const panel = vscode.window.createWebviewPanel( +// 'mindReader', // Identifies the type of the webview. Used internally +// 'MR Key Bindings', // Title of the panel displayed to the user +// vscode.ViewColumn.One, // Editor column to show the new webview panel in. +// {} +// ); // Webview options. More on these later. + +// const userPlatform: 'windows' | 'mac' | 'linux' | undefined = getPlatform(); + +// switch (userPlatform) { +// case 'windows': +// if(vscode.workspace.workspaceFolders !== undefined) { +// let wf = vscode.workspace.workspaceFolders[0].uri.path; +// let f = vscode.workspace.workspaceFolders[0].uri.fsPath; +// const message = `YOUR-EXTENSION: folder: ${wf} - ${f}`; +// vscode.window.showInformationMessage(message); +// } +// else { +// const message = "YOUR-EXTENSION: Working folder not found, open a folder an try again" ; +// vscode.window.showErrorMessage(message); +// } +// // panel.webview.html = getWebviewContent('media/html/winkeys.html'); +// break; +// case 'mac': +// // panel.webview.html = getWebviewContent('media/html/mackeys.html'); +// break; +// case 'linux': +// // panel.webview.html = getWebviewContent('media/html/linuxkeys.html'); +// break; +// default: +// // panel.webview.html = getWebviewContent("../../media/html/main.html"); +// break; +// } +// } + +// function openKeyBindWin(os: 'Mac' | 'Windows'): void { +// //vscode.commands.executeCommand('workbench.action.zoomOut'); +// const panel = vscode.window.createWebviewPanel( +// 'mindReader', // Identifies the type of the webview. Used internally +// 'MR Key Bindings', // Title of the panel displayed to the user +// vscode.ViewColumn.One, // Editor column to show the new webview panel in. +// {} +// ); // Webview options. More on these later. + +// if (os === 'Windows') { +// panel.webview.html = getWebviewContent('WINDOWS'); +// // panel.webview.html = getWebviewContent('/media/html/winkeys.html'); +// } else if (os === 'Mac') { +// panel.webview.html = getWebviewContent('MAC'); +// // panel.webview.html = getWebviewContent('/media/html/mackeys.html'); +// } +// } + +//vscode.commands.executeCommand('workbench.action.openGlobalKeybindings');