From 5a7fc30e4c250e305aab5aa2bc4feb3d2e5970f2 Mon Sep 17 00:00:00 2001 From: tel0065 <77864718+tel0065@users.noreply.github.com> Date: Wed, 27 Apr 2022 11:55:01 -0500 Subject: [PATCH 01/19] Update package.json --- package.json | 46 ++++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index 457e219..aecd638 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mind-reader", "displayName": "Mind_Reader", - "repository": "https://github.com/SingleSemesterSnobs/Mind_Reader", + "repository": "https://github.com/We-Dont-Byte/Mind_Reader", "version": "1.0.0", "engines": { "vscode": "^1.60.0" @@ -14,8 +14,7 @@ ], "main": "./out/extension.js", "contributes": { - "commands": [ - { + "commands": [{ "command": "mind-reader.helloWorld", "title": "Hello World" }, @@ -96,8 +95,7 @@ "title": "Delete a program from the LEGO Hub" } ], - "keybindings": [ - { + "keybindings": [{ "command": "mind-reader.decreaseFontScale", "key": "numpad_subtract", "mac": "d" @@ -199,14 +197,11 @@ } ], "menus": { - "editor/context": [ - { - "submenu": "mind-reader.editor.context", - "group": "mind-reader" - } - ], - "mind-reader.editor.context": [ - { + "editor/context": [{ + "submenu": "mind-reader.editor.context", + "group": "mind-reader" + }], + "mind-reader.editor.context": [{ "command": "mind-reader.increaseEditorScale", "group": "mind-reader", "when": "activeEditor" @@ -258,12 +253,10 @@ } ] }, - "submenus": [ - { - "id": "mind-reader.editor.context", - "label": "Mind_Reader" - } - ], + "submenus": [{ + "id": "mind-reader.editor.context", + "label": "Mind_Reader" + }], "configuration": { "title": "Mind_Reader", "properties": { @@ -312,8 +305,7 @@ } }, "views": { - "MindReader": [ - { + "MindReader": [{ "id": "accessActions", "name": "Access Actions", "icon": "media/dep.svg", @@ -328,13 +320,11 @@ ] }, "viewsContainers": { - "activitybar": [ - { - "id": "MindReader", - "title": "MindReader Actions", - "icon": "media/dep.svg" - } - ] + "activitybar": [{ + "id": "MindReader", + "title": "MindReader Actions", + "icon": "media/dep.svg" + }] } }, "scripts": { From 7d615c0bca159d6a2570e7bfb55c582c8b437c1d Mon Sep 17 00:00:00 2001 From: tel0065 <77864718+tel0065@users.noreply.github.com> Date: Wed, 27 Apr 2022 11:58:14 -0500 Subject: [PATCH 02/19] Added linehighlighter.ts --- src/lineHighlighter.ts | 364 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 364 insertions(+) create mode 100644 src/lineHighlighter.ts diff --git a/src/lineHighlighter.ts b/src/lineHighlighter.ts new file mode 100644 index 0000000..9896a4e --- /dev/null +++ b/src/lineHighlighter.ts @@ -0,0 +1,364 @@ +/** +* ? ██╗ ██╗██╗ ██████╗ ██╗ ██╗██╗ ██╗ ██████╗ ██╗ ██╗████████╗ ██╗████████╗ +* ? ██║ ██║██║██╔════╝ ██║ ██║██║ ██║██╔════╝ ██║ ██║╚══██╔══╝ ██║╚══██╔══╝ +* ? ███████║██║██║ ███╗███████║██║ ██║██║ ███╗███████║ ██║ █████╗██║ ██║ +* ? ██╔══██║██║██║ ██║██╔══██║██║ ██║██║ ██║██╔══██║ ██║ ╚════╝██║ ██║ +* ? ██║ ██║██║╚██████╔╝██║ ██║███████╗██║╚██████╔╝██║ ██║ ██║ ██║ ██║ +* ? ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ +**/ +import { Position, window, workspace, TextEditorDecorationType, TextEditor, WorkspaceConfiguration, Range } from 'vscode'; + +export { lineHighlighter }; + +let highlightStyle: TextEditorDecorationType; + +function lineHighlighter(): void { + let highlightStyle : TextEditorDecorationType = getHighlighterStyle(); + let activeTextEditor : TextEditor | undefined = window.activeTextEditor; + let isEnabled : boolean | undefined = getHighlighterStatus(); + let multiLineIsEnabled: boolean | undefined = getMultiLineHighlighterStatus(); + + /** + * Trigger the line highlight when the extension + * loads so current line gets highlighted + */ + triggerHighlight(); + + /** + * Trigger for when the active text editor changes + */ + window.onDidChangeActiveTextEditor((editor) => { + if (!editor) { + return; + } + + triggerHighlight(); + }); + + /** + * Trigger for when text selection changes + */ + window.onDidChangeTextEditorSelection((editor) => { + if (!editor.textEditor) { + console.error(`[*] onDidChangeTextEditorSelection(${editor}) -> no active text editor`); + return; + } + + triggerHighlight(); + }); + + /** + * Trigger for when the text document changes + */ + workspace.onDidChangeTextDocument((editor) => { + if (!activeTextEditor) { + console.error(`[*] onDidChangeTextDocument(${editor}) -> no active text editor`); + return; + } + + triggerHighlight(); + }); + + /** + * Trigger for when the window state changes + */ + window.onDidChangeWindowState((editor) => { + if (!editor) { + return; + } + + triggerHighlight(); + }); + + /** + * Trigger for when configuration changes + */ + workspace.onDidChangeConfiguration((editor) => { + if (!editor) { + return; + } + + // Dump existing styling + highlightStyle.dispose(); + // check if line highlighter is enable/disabled + isEnabled = getHighlighterStatus(); + multiLineIsEnabled = getMultiLineHighlighterStatus(); + // get new line highlighter styling + highlightStyle = getHighlighterStyle(); + // trigger highlight with new styling + triggerHighlight(); + }); + + /** + * main function that triggers the highlights + */ + function triggerHighlight(): void { + if (!activeTextEditor) { + console.error("[*] NO Active Text Editor"); + return; + } + + /** + * Sets the activeTextEditor to the current active window + */ + activeTextEditor = window.activeTextEditor; + if (activeTextEditor !== undefined) { + /** + * If the line highlighter function is enabled + * set the decorations with our chosen highlighting style on the selection + * otherwise (highlighter is disabled) dump our highlighting style + */ + // (isEnabled) + // ? activeTextEditor!.setDecorations(highlightStyle, activeTextEditor!.selections) + // : highlightStyle.dispose(); + switch (isEnabled) { + case true: // isEnabled is true + switch (multiLineIsEnabled) { + case true: // isEnabled is true and multiLineIsEnabled is true + // const startLine = activeTextEditor!.selection.start; + // const endLine = activeTextEditor!.selection.end; + // const rangeToHighlight = { range: new Range(startLine, endLine) }; + // activeTextEditor!.setDecorations(highlightStyle, [rangeToHighlight]); + // const currentLineRange = activeTextEditor!.document.lineAt(activeTextEditor!.selection.anchor).range; + // activeTextEditor!.setDecorations(highlightStyle, [currentLineRange]); + // const startLine = activeTextEditor!.selection.start.line; + // const endLine = activeTextEditor!.selection.end; + // const rangeToHighlight = { range: new Range(startLine, endLine) }; + activeTextEditor.setDecorations(highlightStyle, activeTextEditor.selections); + break; + case false: // isEnabled is true and multiLineIsEnabled is false + switch (activeTextEditor.selection.isSingleLine) { + case true: // isEnabled is true and multiLineIsEnabled is false and VSCode is reporting a single line + let currentPosition = []; + for (let i = 0; i < activeTextEditor.selections.length; i++) { + currentPosition[i] = { range: new Range(activeTextEditor.selections[i].anchor, activeTextEditor.selections[i].anchor) }; + } + + activeTextEditor.setDecorations(highlightStyle, currentPosition); + // const currentLine = activeTextEditor.selection.active.line; + // const newDecoration = { range: new Range(currentPosition, currentPosition) }; + // const singleLineHighlight = { range: new Range(activeTextEditor!.selection.anchor.line, activeTextEditor!.selection.anchor.line) }; + // activeTextEditor!.setDecorations(highlightStyle, [singleLineRange]); + // activeTextEditor.setDecorations(highlightStyle, [activeTextEditor.selection]); + break; + case false: // isEnabled is true and multiLineIsEnabled is false and VSCode is reporting multiple lines + // Dispose of our highlighting style so multiple lines aren't all highlighted when clicking and dragging to highlight + // highlightStyle.dispose(); + activeTextEditor.setDecorations(highlightStyle, []); + // Since we disposed of our highlighting style, we need to re-acquire it for highlighting to continue to work after clicking and dragging to highlight + // highlightStyle = getHighlighterStyle(); + break; + default: // isEnabled is true and multiLineIsEnabled is false and VSCode is reporting something else - break out of 3rd switch + break; + } + break; + default: // isEnabled is true and multiLineIsEnabled is undetected - break out of 2nd switch statement + break; + } + break; + case false: // isEnabled is false + highlightStyle.dispose(); + break; + default: // break out of initial switch is true or false not found + break; + } + + // Track new position, without this the line the the cursor begins on will never get styled + new Position(activeTextEditor.selection.start.line, activeTextEditor.selection.start.character); + } + } + + /** + * Function to get the user configured highlighting styles, or use defaults + * + * Designed with user configuration in mind, able to control different sides + * independently from each other (in most cases). This allows for many different + * configurations. + * + * @returns highlighterStyle + */ + function getHighlighterStyle(): TextEditorDecorationType { + // Used so we don't have to type out workspace.getConfiguration('mind-reader.lineHighlight') on every line, ie: shorthand + const userConfig: WorkspaceConfiguration = workspace.getConfiguration('mind-reader.lineHighlight'); + + const borderWidthTop : string = userConfig.get('borderWidthTop') || "0"; + const borderWidthRight : string = userConfig.get('borderWidthRight') || "0"; + const borderWidthBottom : string = userConfig.get('borderWidthBottom') || "2px"; + const borderWidthLeft : string = userConfig.get('borderWidthLeft') || "0"; + + const borderStyleTop : string = userConfig.get('borderStyleTop') || "solid"; + const borderStyleRight : string = userConfig.get('borderStyleRight') || "solid"; + const borderStyleBottom : string = userConfig.get('borderStyleBottom') || "solid"; + const borderStyleLeft : string = userConfig.get('borderStyleLeft') || "solid"; + + const borderColorTop : string = userConfig.get('borderColorTop') || "#191970"; + const borderColorRight : string = userConfig.get('borderColorRight') || "#191970"; + const borderColorBottom : string = userConfig.get('borderColorBottom') || "#191970"; + const borderColorLeft : string = userConfig.get('borderColorLeft') || "#191970"; + + const backgroundColor : string = userConfig.get('backgroundColor') || "#00fa9a"; + + const fontStyle : string = userConfig.get('fontStyle') || "normal"; + const fontWeight : string = userConfig.get('fontWeight') || "normal"; + const outlineColor : string = userConfig.get('outlineColor') || "#191970"; + const outlineStyle : string = userConfig.get('outlineStyle') || "solid"; + const outlineWidth : string = userConfig.get('outlineWidth') || "0"; + const textDecoration : string = userConfig.get('textDecoration') || "normal"; + const textColor : string = userConfig.get('textColor') || "normal"; + + // Combine all our styling into a single variable to return + const highlighterStyle : TextEditorDecorationType = window.createTextEditorDecorationType({ + isWholeLine : true, + backgroundColor : `${backgroundColor}`, + fontStyle : `${fontStyle}`, + fontWeight : `${fontWeight}`, + textDecoration : `${textDecoration}`, + color : `${textColor}`, + borderColor : `${borderColorTop} ${borderColorRight} ${borderColorBottom} ${borderColorLeft}`, + borderWidth : `${borderWidthTop} ${borderWidthRight} ${borderWidthBottom} ${borderWidthLeft}`, + borderStyle : `${borderStyleTop} ${borderStyleRight} ${borderStyleBottom} ${borderStyleLeft}`, + outlineColor : `${outlineColor}`, + outlineWidth : `${outlineWidth}`, + outlineStyle : `${outlineStyle}`, + }); + + // Return our variable + return highlighterStyle; + } + + /** + * Function to retrieve the 'isEnabled' status + * + * This will determine if the line highlighter will display or not + * - enabled -> will show + * - disabled -> will not show + * + * @returns enabledStatus + */ + function getHighlighterStatus(): boolean | undefined { + // set a boolean variable + let enabledStatus: boolean | undefined; + + /*** + * if "isEnabled" is missing from the settings (aka undefined) + * - set our variable to true (default) + * otherwise, "isEnabled" is listed in the settings + * - so we just pull its value + */ + (workspace.getConfiguration("mind-reader.lineHighlight").get("isEnabled") === undefined) + ? (enabledStatus = true) + : (enabledStatus = workspace.getConfiguration("mind-reader.lineHighlight").get("isEnabled")); + + // return the enabledStatus + return enabledStatus; + } + + function getMultiLineHighlighterStatus(): boolean | undefined { + // set a boolean variable + let multiLineIsEnabled: boolean | undefined; + + /*** + * if "isEnabled" is missing from the settings (aka undefined) + * - set our variable to true (default) + * otherwise, "isEnabled" is listed in the settings + * - so we just pull its value + */ + (workspace.getConfiguration("mind-reader.lineHighlight").get("multiLineIsEnabled") === undefined) + ? (multiLineIsEnabled = true) + : (multiLineIsEnabled = workspace.getConfiguration("mind-reader.lineHighlight").get("multiLineIsEnabled")); + + // return the enabledStatus + return multiLineIsEnabled; + } +} + +// Clean-up after ourself +export function deactivate() { + // when the plugin is terminated remove all highlighting + if (highlightStyle !== undefined) { + highlightStyle.dispose(); + } +} + + /** + * Border Width Settings + * borderWidthTop = Top Border Width + * borderWidthRight = Right Border Width * Right border is a little finicky, I have all others at 1px, but need 15px for this one to match + * borderWidthBottom = Bottom Border Width + * borderWidthLeft = Left Border Width + * + * Uses CSS so should accept: + * thin | medium | thick + * px + * rem + * em + * cm + * % - Weird behavior + * inherit + * + * If no value is found in the settings, we set the value after the double pipes (||) instead + */ + + /** + * Border Style Settings + * borderStyleTop = Top Border Style + * borderStyleRight = Right Border Style + * borderStyleBottom = Bottom Border Style + * borderStyleLeft = Left Border Style + * + * Uses CSS so should accept: (Some of them I can't tell a difference, but they do something) + * none + * hidden + * dotted + * dashed + * solid + * double + * groove + * ridge + * inset + * outset + * + * If no value is found in the settings, we set the value after the double pipes (||) instead + */ + + /** + * Border Color Settings + * borderColorRight = Right Border Color + * borderColorBottom = Bottom Border Color + * borderColorTop = Top Border Color + * borderColorLeft = Left Border Color + * + * Uses CSS so should accept: (Some of them I can't tell a difference, but they do something) + * none - This one doesn't play nice + * string value like "red" | "blue" | "orange" etc - https://www.w3schools.com/cssref/css_colors.asp + * # + * rgb(###, ###, ###) + * rgba(###, ###, ###, ###) + * hsla(##, ##%, ##%, .#); + * inherit - This one has weird behavior as well + * + * If no value is found in the settings, we set the value after the double pipes (||) instead + */ + + /** + * Color of the background + * + * Uses CSS so should accept: + * none - This one doesn't play nice + * string value like "red" | "blue" | "orange" etc - https://www.w3schools.com/cssref/css_colors.asp + * # + * rgb(###, ###, ###) + * rgba(###, ###, ###, ###) + * hsla(##, ##%, ##%, .#); + * inherit - This one has weird behavior as well + * + * If no value is found in the settings, we set the value after the double pipes (||) instead + */ + + /** + * font-style: normal|italic|oblique|initial|inherit + */ + + /** + * font-weight: normal|bold|bolder|lighter|number|initial|inherit + */ \ No newline at end of file From 16869aa5b66cd24974cd67faaa42977f29065672 Mon Sep 17 00:00:00 2001 From: tel0065 <77864718+tel0065@users.noreply.github.com> Date: Wed, 27 Apr 2022 11:59:16 -0500 Subject: [PATCH 03/19] Added linehighlighter added linehighlighter to be activated --- src/extension.ts | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 5496408..2aa31e5 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,49 +1,46 @@ -import * as vscode from 'vscode'; -import * as pl from './pylex'; +import * as vscode from "vscode"; +import * as pl from "./pylex"; +import CommandNodeProvider from "./commandNodeProvider"; +import Logger from "./log"; +import { lineHighlighter } from "./lineHighlighter"; -import { - accessCommands, - hubCommands, - navCommands, - textCommands -} from './commands'; - -import CommandNodeProvider from './commandNodeProvider'; -import Logger from './log'; +import { accessCommands, hubCommands, navCommands, textCommands } from "./commands"; // Output Logger -const product: string = vscode.workspace.getConfiguration('mindReader').get('productType')!; -const outputChannel = vscode.window.createOutputChannel(product + " Output"); -export const logger = new Logger(outputChannel); +const product: string = vscode.workspace.getConfiguration("mindReader").get("productType")!; +const outputChannel = vscode.window.createOutputChannel(product + " Output"); +export const logger = new Logger(outputChannel); let parser: pl.Parser = new pl.Parser(); export function activate(context: vscode.ExtensionContext) { - vscode.window.showInformationMessage('Mind_Reader is loaded!'); + vscode.window.showInformationMessage("Mind_Reader is loaded!"); - parser.parse('Beep Boop'); + lineHighlighter(); + + parser.parse("Beep Boop"); const allCommands = [ accessCommands, hubCommands, navCommands, - textCommands + textCommands, ].flat(1); // Register Commands - allCommands.forEach(command => { - let disposable = vscode.commands.registerCommand( - command.name, - command.callback + allCommands.forEach((command) => { + context.subscriptions.push( + vscode.commands.registerCommand(command.name, command.callback) ); - context.subscriptions.push(disposable); }); - let accessProvider = new CommandNodeProvider([accessCommands, textCommands].flat(1)); - vscode.window.registerTreeDataProvider('accessActions', accessProvider); + let accessProvider = new CommandNodeProvider( + [accessCommands, textCommands].flat(1) + ); + vscode.window.registerTreeDataProvider("accessActions", accessProvider); let hubProvider = new CommandNodeProvider(hubCommands); - vscode.window.registerTreeDataProvider('hubActions', hubProvider); + vscode.window.registerTreeDataProvider("hubActions", hubProvider); } export function deactivate() {} From 5d3dc7acea95a7920f96d1e076ce731fcd503a32 Mon Sep 17 00:00:00 2001 From: tel0065 <77864718+tel0065@users.noreply.github.com> Date: Wed, 27 Apr 2022 12:00:59 -0500 Subject: [PATCH 04/19] added new function added fetchNumberOfSelectedLines and getNumberOfSelectedLines --- src/commands/text.ts | 97 ++++++++++++++++++++++++++++++++------------ 1 file changed, 70 insertions(+), 27 deletions(-) diff --git a/src/commands/text.ts b/src/commands/text.ts index 8621a2a..7c0c122 100755 --- a/src/commands/text.ts +++ b/src/commands/text.ts @@ -16,6 +16,10 @@ export const textCommands: CommandEntry[] = [ name: 'mind-reader.getLeadingSpaces', callback: getLeadingSpaces, }, + { + name: 'mind-reader.getNumberOfSelectedLines', + callback: getNumberOfSelectedLines, + }, { name: 'mind-reader.runLineContext', callback: runLineContext, @@ -27,20 +31,54 @@ export const textCommands: CommandEntry[] = [ ]; /* Helper Function - * This function returns the line number of the active text editor window +* This function returns the number of selected lines in the active text editor window +*/ +function fetchNumberOfSelectedLines(editor: vscode.TextEditor | undefined): number { + let numberOfSelectedLines: number = 0; + + if (editor) { + numberOfSelectedLines = editor.selections.reduce((prev, curr) => prev + (curr.end.line - curr.start.line), 1); + } + + return numberOfSelectedLines; +} + +/* Helper Function +* This function returns the line number of the active text editor window */ function fetchLineNumber(editor: any): number { return editor.selection.active.line + 1; } /* Helper Function - * This function returns the text from the current line of the active text editor window - */ +* This function returns the text from the current line of the active text editor window +*/ function fetchTextLine(editor: any): string { return editor.document.lineAt(fetchLineNumber(editor) - 1); } -// Function that outputs the current line number the cursor is on +/** Function + * Function to return the number of selected (highlighted) lines + * Changes output to 'Line' for 1 line and 'Lines' for all other instances + */ +function getNumberOfSelectedLines(): void { + const editor: any = vscode.window.activeTextEditor; + + if (editor) { + const numberOfSelectedLines: number = fetchNumberOfSelectedLines(editor); + + (numberOfSelectedLines !== 1) + ? vscode.window.showInformationMessage(`${numberOfSelectedLines.toString()} Lines Selected`) + : vscode.window.showInformationMessage(`${numberOfSelectedLines.toString()} Line Selected`); + } + else { + vscode.window.showErrorMessage('No document currently active'); + } +} + +/** Function + * Outputs the current line number the cursor is on + */ function getLineNumber(): void { const editor: any = vscode.window.activeTextEditor; @@ -54,6 +92,9 @@ function getLineNumber(): void { } } +/** Function + * Used to get the number of indents on a line + */ function getIndent(): void { const editor: any = vscode.window.activeTextEditor; @@ -72,7 +113,9 @@ function getIndent(): void { }; const i: number = pl.Lexer.getIndent(textLine.text, tabFmt); - vscode.window.showInformationMessage(`Line ${lineNum.toString()}: ${i.toString()} indents`); + (i !== 1) + ? vscode.window.showInformationMessage(`Line ${lineNum.toString()}: ${i.toString()} indents`) + : vscode.window.showInformationMessage(`Line ${lineNum.toString()}: ${i.toString()} indent`); } } else { @@ -100,8 +143,8 @@ function getLeadingSpaces(): void { const editor: any = vscode.window.activeTextEditor; if (editor) { - const lineNum: number = fetchLineNumber(editor); - const textLine: any = fetchTextLine(editor); + const lineNum : number = fetchLineNumber(editor); + const textLine: any = fetchTextLine(editor); if (textLine.isEmptyOrWhitespace) { vscode.window.showInformationMessage(`Line ${lineNum.toString()} is empty`); @@ -114,14 +157,14 @@ function getLeadingSpaces(): void { * default: false */ const calculateLeadingSpaces: boolean = false; // change boolean value to change method - const numSpaces: number = (calculateLeadingSpaces) ? - pl.Lexer.getLeadingSpacesByArithmetic(textLine) : - pl.Lexer.getLeadingSpacesByIndex(textLine); + const numSpaces: number = (calculateLeadingSpaces) + ? pl.Lexer.getLeadingSpacesByArithmetic(textLine) + : pl.Lexer.getLeadingSpacesByIndex(textLine); /* Ternary operator to change the tense of 'space' to 'spaces' for the output if numSpaces is 0 or greater than 1 */ - (numSpaces !== 1) ? - vscode.window.showInformationMessage(`Line ${lineNum.toString()}: ${numSpaces.toString()} spaces`): - vscode.window.showInformationMessage(`Line ${lineNum.toString()}: ${numSpaces.toString()} space`); + (numSpaces !== 1) + ? vscode.window.showInformationMessage(`Line ${lineNum.toString()}: ${numSpaces.toString()} spaces`) + : vscode.window.showInformationMessage(`Line ${lineNum.toString()}: ${numSpaces.toString()} space`); } } else { @@ -134,13 +177,13 @@ function runLineContext(): void { if (editor) { // current text and line number - const editorText: string = editor.document.getText(); - const line: string = editor.selection.active.line; + const editorText: string = editor.document.getText(); + const line : string = editor.selection.active.line; // get tab info settings - const size: number = parseInt(editor.options.tabSize); - const hard: boolean = !editor.options.insertSpaces; + const size : number = parseInt(editor.options.tabSize); + const hard : boolean = !editor.options.insertSpaces; // initialize parser - const parser: any = new pl.Parser(editorText, { + const parser : any = new pl.Parser(editorText, { size, hard }); @@ -199,15 +242,15 @@ function runCursorContext(): void { return; } - const cursorPos: any = editor.selection.active; - const text: string = editor.document.lineAt(cursorPos).text; - const windowSize: any = vscode.workspace.getConfiguration('mindReader').get('reader.contextWindow'); - let trimmedText: string = text.trimStart(); // trim leading whitespace - const leadingWS: number = text.length - trimmedText.length; // # of characters of leading whitespace - let pos: number = leadingWS; - const maxPos: number = text.length; + const cursorPos : any = editor.selection.active; + const text : string = editor.document.lineAt(cursorPos).text; + const windowSize : any = vscode.workspace.getConfiguration('mindReader').get('reader.contextWindow'); + let trimmedText: string = text.trimStart(); // trim leading whitespace + const leadingWS : number = text.length - trimmedText.length; // # of characters of leading whitespace + let pos : number = leadingWS; + const maxPos : number = text.length; // clamp cursor start/end to new range - let col: number = cursorPos.character; // effective column of the cursor position + let col : number = cursorPos.character; // effective column of the cursor position trimmedText = trimmedText.trimEnd(); // trim trailing whitespace @@ -242,7 +285,7 @@ function runCursorContext(): void { // find word the user is in let contextStart: number = -1; - let contextEnd: number = -1; + let contextEnd : number = -1; for (let i: number = 0; i < spaceWords.length; i++) { if (col >= spaceWords[i].start && col <= spaceWords[i].end) { From dd10e928ef3d0e8464032f86b9eaf9379a67da7a Mon Sep 17 00:00:00 2001 From: tel0065 <77864718+tel0065@users.noreply.github.com> Date: Wed, 27 Apr 2022 12:01:44 -0500 Subject: [PATCH 05/19] updated webview --- src/commands/nav.ts | 170 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 140 insertions(+), 30 deletions(-) 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'); From 34af00139656242c3f57981ccd9eedac0ed03733 Mon Sep 17 00:00:00 2001 From: tel0065 <77864718+tel0065@users.noreply.github.com> Date: Wed, 27 Apr 2022 12:07:13 -0500 Subject: [PATCH 06/19] Deleted linehighlighter wrong version --- src/lineHighlighter.ts | 364 ----------------------------------------- 1 file changed, 364 deletions(-) delete mode 100644 src/lineHighlighter.ts diff --git a/src/lineHighlighter.ts b/src/lineHighlighter.ts deleted file mode 100644 index 9896a4e..0000000 --- a/src/lineHighlighter.ts +++ /dev/null @@ -1,364 +0,0 @@ -/** -* ? ██╗ ██╗██╗ ██████╗ ██╗ ██╗██╗ ██╗ ██████╗ ██╗ ██╗████████╗ ██╗████████╗ -* ? ██║ ██║██║██╔════╝ ██║ ██║██║ ██║██╔════╝ ██║ ██║╚══██╔══╝ ██║╚══██╔══╝ -* ? ███████║██║██║ ███╗███████║██║ ██║██║ ███╗███████║ ██║ █████╗██║ ██║ -* ? ██╔══██║██║██║ ██║██╔══██║██║ ██║██║ ██║██╔══██║ ██║ ╚════╝██║ ██║ -* ? ██║ ██║██║╚██████╔╝██║ ██║███████╗██║╚██████╔╝██║ ██║ ██║ ██║ ██║ -* ? ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ -**/ -import { Position, window, workspace, TextEditorDecorationType, TextEditor, WorkspaceConfiguration, Range } from 'vscode'; - -export { lineHighlighter }; - -let highlightStyle: TextEditorDecorationType; - -function lineHighlighter(): void { - let highlightStyle : TextEditorDecorationType = getHighlighterStyle(); - let activeTextEditor : TextEditor | undefined = window.activeTextEditor; - let isEnabled : boolean | undefined = getHighlighterStatus(); - let multiLineIsEnabled: boolean | undefined = getMultiLineHighlighterStatus(); - - /** - * Trigger the line highlight when the extension - * loads so current line gets highlighted - */ - triggerHighlight(); - - /** - * Trigger for when the active text editor changes - */ - window.onDidChangeActiveTextEditor((editor) => { - if (!editor) { - return; - } - - triggerHighlight(); - }); - - /** - * Trigger for when text selection changes - */ - window.onDidChangeTextEditorSelection((editor) => { - if (!editor.textEditor) { - console.error(`[*] onDidChangeTextEditorSelection(${editor}) -> no active text editor`); - return; - } - - triggerHighlight(); - }); - - /** - * Trigger for when the text document changes - */ - workspace.onDidChangeTextDocument((editor) => { - if (!activeTextEditor) { - console.error(`[*] onDidChangeTextDocument(${editor}) -> no active text editor`); - return; - } - - triggerHighlight(); - }); - - /** - * Trigger for when the window state changes - */ - window.onDidChangeWindowState((editor) => { - if (!editor) { - return; - } - - triggerHighlight(); - }); - - /** - * Trigger for when configuration changes - */ - workspace.onDidChangeConfiguration((editor) => { - if (!editor) { - return; - } - - // Dump existing styling - highlightStyle.dispose(); - // check if line highlighter is enable/disabled - isEnabled = getHighlighterStatus(); - multiLineIsEnabled = getMultiLineHighlighterStatus(); - // get new line highlighter styling - highlightStyle = getHighlighterStyle(); - // trigger highlight with new styling - triggerHighlight(); - }); - - /** - * main function that triggers the highlights - */ - function triggerHighlight(): void { - if (!activeTextEditor) { - console.error("[*] NO Active Text Editor"); - return; - } - - /** - * Sets the activeTextEditor to the current active window - */ - activeTextEditor = window.activeTextEditor; - if (activeTextEditor !== undefined) { - /** - * If the line highlighter function is enabled - * set the decorations with our chosen highlighting style on the selection - * otherwise (highlighter is disabled) dump our highlighting style - */ - // (isEnabled) - // ? activeTextEditor!.setDecorations(highlightStyle, activeTextEditor!.selections) - // : highlightStyle.dispose(); - switch (isEnabled) { - case true: // isEnabled is true - switch (multiLineIsEnabled) { - case true: // isEnabled is true and multiLineIsEnabled is true - // const startLine = activeTextEditor!.selection.start; - // const endLine = activeTextEditor!.selection.end; - // const rangeToHighlight = { range: new Range(startLine, endLine) }; - // activeTextEditor!.setDecorations(highlightStyle, [rangeToHighlight]); - // const currentLineRange = activeTextEditor!.document.lineAt(activeTextEditor!.selection.anchor).range; - // activeTextEditor!.setDecorations(highlightStyle, [currentLineRange]); - // const startLine = activeTextEditor!.selection.start.line; - // const endLine = activeTextEditor!.selection.end; - // const rangeToHighlight = { range: new Range(startLine, endLine) }; - activeTextEditor.setDecorations(highlightStyle, activeTextEditor.selections); - break; - case false: // isEnabled is true and multiLineIsEnabled is false - switch (activeTextEditor.selection.isSingleLine) { - case true: // isEnabled is true and multiLineIsEnabled is false and VSCode is reporting a single line - let currentPosition = []; - for (let i = 0; i < activeTextEditor.selections.length; i++) { - currentPosition[i] = { range: new Range(activeTextEditor.selections[i].anchor, activeTextEditor.selections[i].anchor) }; - } - - activeTextEditor.setDecorations(highlightStyle, currentPosition); - // const currentLine = activeTextEditor.selection.active.line; - // const newDecoration = { range: new Range(currentPosition, currentPosition) }; - // const singleLineHighlight = { range: new Range(activeTextEditor!.selection.anchor.line, activeTextEditor!.selection.anchor.line) }; - // activeTextEditor!.setDecorations(highlightStyle, [singleLineRange]); - // activeTextEditor.setDecorations(highlightStyle, [activeTextEditor.selection]); - break; - case false: // isEnabled is true and multiLineIsEnabled is false and VSCode is reporting multiple lines - // Dispose of our highlighting style so multiple lines aren't all highlighted when clicking and dragging to highlight - // highlightStyle.dispose(); - activeTextEditor.setDecorations(highlightStyle, []); - // Since we disposed of our highlighting style, we need to re-acquire it for highlighting to continue to work after clicking and dragging to highlight - // highlightStyle = getHighlighterStyle(); - break; - default: // isEnabled is true and multiLineIsEnabled is false and VSCode is reporting something else - break out of 3rd switch - break; - } - break; - default: // isEnabled is true and multiLineIsEnabled is undetected - break out of 2nd switch statement - break; - } - break; - case false: // isEnabled is false - highlightStyle.dispose(); - break; - default: // break out of initial switch is true or false not found - break; - } - - // Track new position, without this the line the the cursor begins on will never get styled - new Position(activeTextEditor.selection.start.line, activeTextEditor.selection.start.character); - } - } - - /** - * Function to get the user configured highlighting styles, or use defaults - * - * Designed with user configuration in mind, able to control different sides - * independently from each other (in most cases). This allows for many different - * configurations. - * - * @returns highlighterStyle - */ - function getHighlighterStyle(): TextEditorDecorationType { - // Used so we don't have to type out workspace.getConfiguration('mind-reader.lineHighlight') on every line, ie: shorthand - const userConfig: WorkspaceConfiguration = workspace.getConfiguration('mind-reader.lineHighlight'); - - const borderWidthTop : string = userConfig.get('borderWidthTop') || "0"; - const borderWidthRight : string = userConfig.get('borderWidthRight') || "0"; - const borderWidthBottom : string = userConfig.get('borderWidthBottom') || "2px"; - const borderWidthLeft : string = userConfig.get('borderWidthLeft') || "0"; - - const borderStyleTop : string = userConfig.get('borderStyleTop') || "solid"; - const borderStyleRight : string = userConfig.get('borderStyleRight') || "solid"; - const borderStyleBottom : string = userConfig.get('borderStyleBottom') || "solid"; - const borderStyleLeft : string = userConfig.get('borderStyleLeft') || "solid"; - - const borderColorTop : string = userConfig.get('borderColorTop') || "#191970"; - const borderColorRight : string = userConfig.get('borderColorRight') || "#191970"; - const borderColorBottom : string = userConfig.get('borderColorBottom') || "#191970"; - const borderColorLeft : string = userConfig.get('borderColorLeft') || "#191970"; - - const backgroundColor : string = userConfig.get('backgroundColor') || "#00fa9a"; - - const fontStyle : string = userConfig.get('fontStyle') || "normal"; - const fontWeight : string = userConfig.get('fontWeight') || "normal"; - const outlineColor : string = userConfig.get('outlineColor') || "#191970"; - const outlineStyle : string = userConfig.get('outlineStyle') || "solid"; - const outlineWidth : string = userConfig.get('outlineWidth') || "0"; - const textDecoration : string = userConfig.get('textDecoration') || "normal"; - const textColor : string = userConfig.get('textColor') || "normal"; - - // Combine all our styling into a single variable to return - const highlighterStyle : TextEditorDecorationType = window.createTextEditorDecorationType({ - isWholeLine : true, - backgroundColor : `${backgroundColor}`, - fontStyle : `${fontStyle}`, - fontWeight : `${fontWeight}`, - textDecoration : `${textDecoration}`, - color : `${textColor}`, - borderColor : `${borderColorTop} ${borderColorRight} ${borderColorBottom} ${borderColorLeft}`, - borderWidth : `${borderWidthTop} ${borderWidthRight} ${borderWidthBottom} ${borderWidthLeft}`, - borderStyle : `${borderStyleTop} ${borderStyleRight} ${borderStyleBottom} ${borderStyleLeft}`, - outlineColor : `${outlineColor}`, - outlineWidth : `${outlineWidth}`, - outlineStyle : `${outlineStyle}`, - }); - - // Return our variable - return highlighterStyle; - } - - /** - * Function to retrieve the 'isEnabled' status - * - * This will determine if the line highlighter will display or not - * - enabled -> will show - * - disabled -> will not show - * - * @returns enabledStatus - */ - function getHighlighterStatus(): boolean | undefined { - // set a boolean variable - let enabledStatus: boolean | undefined; - - /*** - * if "isEnabled" is missing from the settings (aka undefined) - * - set our variable to true (default) - * otherwise, "isEnabled" is listed in the settings - * - so we just pull its value - */ - (workspace.getConfiguration("mind-reader.lineHighlight").get("isEnabled") === undefined) - ? (enabledStatus = true) - : (enabledStatus = workspace.getConfiguration("mind-reader.lineHighlight").get("isEnabled")); - - // return the enabledStatus - return enabledStatus; - } - - function getMultiLineHighlighterStatus(): boolean | undefined { - // set a boolean variable - let multiLineIsEnabled: boolean | undefined; - - /*** - * if "isEnabled" is missing from the settings (aka undefined) - * - set our variable to true (default) - * otherwise, "isEnabled" is listed in the settings - * - so we just pull its value - */ - (workspace.getConfiguration("mind-reader.lineHighlight").get("multiLineIsEnabled") === undefined) - ? (multiLineIsEnabled = true) - : (multiLineIsEnabled = workspace.getConfiguration("mind-reader.lineHighlight").get("multiLineIsEnabled")); - - // return the enabledStatus - return multiLineIsEnabled; - } -} - -// Clean-up after ourself -export function deactivate() { - // when the plugin is terminated remove all highlighting - if (highlightStyle !== undefined) { - highlightStyle.dispose(); - } -} - - /** - * Border Width Settings - * borderWidthTop = Top Border Width - * borderWidthRight = Right Border Width * Right border is a little finicky, I have all others at 1px, but need 15px for this one to match - * borderWidthBottom = Bottom Border Width - * borderWidthLeft = Left Border Width - * - * Uses CSS so should accept: - * thin | medium | thick - * px - * rem - * em - * cm - * % - Weird behavior - * inherit - * - * If no value is found in the settings, we set the value after the double pipes (||) instead - */ - - /** - * Border Style Settings - * borderStyleTop = Top Border Style - * borderStyleRight = Right Border Style - * borderStyleBottom = Bottom Border Style - * borderStyleLeft = Left Border Style - * - * Uses CSS so should accept: (Some of them I can't tell a difference, but they do something) - * none - * hidden - * dotted - * dashed - * solid - * double - * groove - * ridge - * inset - * outset - * - * If no value is found in the settings, we set the value after the double pipes (||) instead - */ - - /** - * Border Color Settings - * borderColorRight = Right Border Color - * borderColorBottom = Bottom Border Color - * borderColorTop = Top Border Color - * borderColorLeft = Left Border Color - * - * Uses CSS so should accept: (Some of them I can't tell a difference, but they do something) - * none - This one doesn't play nice - * string value like "red" | "blue" | "orange" etc - https://www.w3schools.com/cssref/css_colors.asp - * # - * rgb(###, ###, ###) - * rgba(###, ###, ###, ###) - * hsla(##, ##%, ##%, .#); - * inherit - This one has weird behavior as well - * - * If no value is found in the settings, we set the value after the double pipes (||) instead - */ - - /** - * Color of the background - * - * Uses CSS so should accept: - * none - This one doesn't play nice - * string value like "red" | "blue" | "orange" etc - https://www.w3schools.com/cssref/css_colors.asp - * # - * rgb(###, ###, ###) - * rgba(###, ###, ###, ###) - * hsla(##, ##%, ##%, .#); - * inherit - This one has weird behavior as well - * - * If no value is found in the settings, we set the value after the double pipes (||) instead - */ - - /** - * font-style: normal|italic|oblique|initial|inherit - */ - - /** - * font-weight: normal|bold|bolder|lighter|number|initial|inherit - */ \ No newline at end of file From 2bbc5bce1fc4f6ad60b252623bd1292f328a098b Mon Sep 17 00:00:00 2001 From: tel0065 <77864718+tel0065@users.noreply.github.com> Date: Wed, 27 Apr 2022 12:07:33 -0500 Subject: [PATCH 07/19] Added lineHighlighter.ts --- src/lineHighlighter.ts | 364 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 364 insertions(+) create mode 100644 src/lineHighlighter.ts diff --git a/src/lineHighlighter.ts b/src/lineHighlighter.ts new file mode 100644 index 0000000..90ad27e --- /dev/null +++ b/src/lineHighlighter.ts @@ -0,0 +1,364 @@ +/** +* ? ██╗ ██╗██╗ ██████╗ ██╗ ██╗██╗ ██╗ ██████╗ ██╗ ██╗████████╗ ██╗████████╗ +* ? ██║ ██║██║██╔════╝ ██║ ██║██║ ██║██╔════╝ ██║ ██║╚══██╔══╝ ██║╚══██╔══╝ +* ? ███████║██║██║ ███╗███████║██║ ██║██║ ███╗███████║ ██║ █████╗██║ ██║ +* ? ██╔══██║██║██║ ██║██╔══██║██║ ██║██║ ██║██╔══██║ ██║ ╚════╝██║ ██║ +* ? ██║ ██║██║╚██████╔╝██║ ██║███████╗██║╚██████╔╝██║ ██║ ██║ ██║ ██║ +* ? ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ +**/ +import { Position, window, workspace, TextEditorDecorationType, TextEditor, WorkspaceConfiguration, Range } from 'vscode'; + +export { lineHighlighter }; + +let highlightStyle: TextEditorDecorationType; + +function lineHighlighter(): void { + let highlightStyle : TextEditorDecorationType = getHighlighterStyle(); + let activeTextEditor : TextEditor | undefined = window.activeTextEditor; + let isEnabled : boolean | undefined = getHighlighterStatus(); + let multiLineIsEnabled: boolean | undefined = getMultiLineHighlighterStatus(); + + /** + * Trigger the line highlight when the extension + * loads so current line gets highlighted + */ + triggerHighlight(); + + /** + * Trigger for when the active text editor changes + */ + window.onDidChangeActiveTextEditor((editor) => { + if (!editor) { + return; + } + + triggerHighlight(); + }); + + /** + * Trigger for when text selection changes + */ + window.onDidChangeTextEditorSelection((editor) => { + if (!editor.textEditor) { + console.error(`[*] onDidChangeTextEditorSelection(${editor}) -> no active text editor`); + return; + } + + triggerHighlight(); + }); + + /** + * Trigger for when the text document changes + */ + workspace.onDidChangeTextDocument((editor) => { + if (!activeTextEditor) { + console.error(`[*] onDidChangeTextDocument(${editor}) -> no active text editor`); + return; + } + + triggerHighlight(); + }); + + /** + * Trigger for when the window state changes + */ + window.onDidChangeWindowState((editor) => { + if (!editor) { + return; + } + + triggerHighlight(); + }); + + /** + * Trigger for when configuration changes + */ + workspace.onDidChangeConfiguration((editor) => { + if (!editor) { + return; + } + + // Dump existing styling + highlightStyle.dispose(); + // check if line highlighter is enable/disabled + isEnabled = getHighlighterStatus(); + multiLineIsEnabled = getMultiLineHighlighterStatus(); + // get new line highlighter styling + highlightStyle = getHighlighterStyle(); + // trigger highlight with new styling + triggerHighlight(); + }); + + /** + * main function that triggers the highlights + */ + function triggerHighlight(): void { + if (!activeTextEditor) { + console.error("[*] NO Active Text Editor"); + return; + } + + /** + * Sets the activeTextEditor to the current active window + */ + activeTextEditor = window.activeTextEditor; + if (activeTextEditor !== undefined) { + /** + * If the line highlighter function is enabled + * set the decorations with our chosen highlighting style on the selection + * otherwise (highlighter is disabled) dump our highlighting style + */ + // (isEnabled) + // ? activeTextEditor!.setDecorations(highlightStyle, activeTextEditor!.selections) + // : highlightStyle.dispose(); + switch (isEnabled) { + case true: // isEnabled is true + switch (multiLineIsEnabled) { + case true: // isEnabled is true and multiLineIsEnabled is true + // const startLine = activeTextEditor!.selection.start; + // const endLine = activeTextEditor!.selection.end; + // const rangeToHighlight = { range: new Range(startLine, endLine) }; + // activeTextEditor!.setDecorations(highlightStyle, [rangeToHighlight]); + // const currentLineRange = activeTextEditor!.document.lineAt(activeTextEditor!.selection.anchor).range; + // activeTextEditor!.setDecorations(highlightStyle, [currentLineRange]); + // const startLine = activeTextEditor!.selection.start.line; + // const endLine = activeTextEditor!.selection.end; + // const rangeToHighlight = { range: new Range(startLine, endLine) }; + activeTextEditor.setDecorations(highlightStyle, activeTextEditor.selections); + break; + case false: // isEnabled is true and multiLineIsEnabled is false + switch (activeTextEditor.selection.isSingleLine) { + case true: // isEnabled is true and multiLineIsEnabled is false and VSCode is reporting a single line + let currentPosition = []; + for (let i = 0; i < activeTextEditor.selections.length; i++) { + currentPosition[i] = { range: new Range(activeTextEditor.selections[i].anchor, activeTextEditor.selections[i].anchor) }; + } + + activeTextEditor.setDecorations(highlightStyle, currentPosition); + // const currentLine = activeTextEditor.selection.active.line; + // const newDecoration = { range: new Range(currentPosition, currentPosition) }; + // const singleLineHighlight = { range: new Range(activeTextEditor!.selection.anchor.line, activeTextEditor!.selection.anchor.line) }; + // activeTextEditor!.setDecorations(highlightStyle, [singleLineRange]); + // activeTextEditor.setDecorations(highlightStyle, [activeTextEditor.selection]); + break; + case false: // isEnabled is true and multiLineIsEnabled is false and VSCode is reporting multiple lines + // Dispose of our highlighting style so multiple lines aren't all highlighted when clicking and dragging to highlight + // highlightStyle.dispose(); + activeTextEditor.setDecorations(highlightStyle, []); + // Since we disposed of our highlighting style, we need to re-acquire it for highlighting to continue to work after clicking and dragging to highlight + // highlightStyle = getHighlighterStyle(); + break; + default: // isEnabled is true and multiLineIsEnabled is false and VSCode is reporting something else - break out of 3rd switch + break; + } + break; + default: // isEnabled is true and multiLineIsEnabled is undetected - break out of 2nd switch statement + break; + } + break; + case false: // isEnabled is false + highlightStyle.dispose(); + break; + default: // break out of initial switch is true or false not found + break; + } + + // Track new position, without this the line the the cursor begins on will never get styled + new Position(activeTextEditor.selection.start.line, activeTextEditor.selection.start.character); + } + } + + /** + * Function to get the user configured highlighting styles, or use defaults + * + * Designed with user configuration in mind, able to control different sides + * independently from each other (in most cases). This allows for many different + * configurations. + * + * @returns highlighterStyle + */ + function getHighlighterStyle(): TextEditorDecorationType { + // Used so we don't have to type out workspace.getConfiguration('mind-reader.lineHighlight') on every line, ie: shorthand + const userConfig: WorkspaceConfiguration = workspace.getConfiguration('mind-reader.lineHighlight'); + + const borderWidthTop : string = userConfig.get('borderWidthTop') || "1px"; + const borderWidthRight : string = userConfig.get('borderWidthRight') || "16px"; + const borderWidthBottom : string = userConfig.get('borderWidthBottom') || "1px"; + const borderWidthLeft : string = userConfig.get('borderWidthLeft') || "1px"; + + const borderStyleTop : string = userConfig.get('borderStyleTop') || "solid"; + const borderStyleRight : string = userConfig.get('borderStyleRight') || "solid"; + const borderStyleBottom : string = userConfig.get('borderStyleBottom') || "solid"; + const borderStyleLeft : string = userConfig.get('borderStyleLeft') || "solid"; + + const borderColorTop : string = userConfig.get('borderColorTop') || "#FFFFFF"; + const borderColorRight : string = userConfig.get('borderColorRight') || "#FFFFFF"; + const borderColorBottom : string = userConfig.get('borderColorBottom') || "#FFFFFF"; + const borderColorLeft : string = userConfig.get('borderColorLeft') || "#FFFFFF"; + + const backgroundColor : string = userConfig.get('backgroundColor') || "#232C5C"; + + const fontStyle : string = userConfig.get('fontStyle') || "normal"; + const fontWeight : string = userConfig.get('fontWeight') || "bolder"; + const outlineColor : string = userConfig.get('outlineColor') || "#4866FE"; + const outlineStyle : string = userConfig.get('outlineStyle') || "solid"; + const outlineWidth : string = userConfig.get('outlineWidth') || "1px"; + const textDecoration : string = userConfig.get('textDecoration') || "none"; + const textColor : string = userConfig.get('textColor') || "#FFFFFF"; + + // Combine all our styling into a single variable to return + const highlighterStyle : TextEditorDecorationType = window.createTextEditorDecorationType({ + isWholeLine : true, + backgroundColor : `${backgroundColor}`, + fontStyle : `${fontStyle}`, + fontWeight : `${fontWeight}`, + textDecoration : `${textDecoration}`, + color : `${textColor}`, + borderColor : `${borderColorTop} ${borderColorRight} ${borderColorBottom} ${borderColorLeft}`, + borderWidth : `${borderWidthTop} ${borderWidthRight} ${borderWidthBottom} ${borderWidthLeft}`, + borderStyle : `${borderStyleTop} ${borderStyleRight} ${borderStyleBottom} ${borderStyleLeft}`, + outlineColor : `${outlineColor}`, + outlineWidth : `${outlineWidth}`, + outlineStyle : `${outlineStyle}`, + }); + + // Return our variable + return highlighterStyle; + } + + /** + * Function to retrieve the 'isEnabled' status + * + * This will determine if the line highlighter will display or not + * - enabled -> will show + * - disabled -> will not show + * + * @returns enabledStatus + */ + function getHighlighterStatus(): boolean | undefined { + // set a boolean variable + let enabledStatus: boolean | undefined; + + /*** + * if "isEnabled" is missing from the settings (aka undefined) + * - set our variable to true (default) + * otherwise, "isEnabled" is listed in the settings + * - so we just pull its value + */ + (workspace.getConfiguration("mind-reader.lineHighlight").get("isEnabled") === undefined) + ? (enabledStatus = true) + : (enabledStatus = workspace.getConfiguration("mind-reader.lineHighlight").get("isEnabled")); + + // return the enabledStatus + return enabledStatus; + } + + function getMultiLineHighlighterStatus(): boolean | undefined { + // set a boolean variable + let multiLineIsEnabled: boolean | undefined; + + /*** + * if "isEnabled" is missing from the settings (aka undefined) + * - set our variable to true (default) + * otherwise, "isEnabled" is listed in the settings + * - so we just pull its value + */ + (workspace.getConfiguration("mind-reader.lineHighlight").get("multiLineIsEnabled") === undefined) + ? (multiLineIsEnabled = true) + : (multiLineIsEnabled = workspace.getConfiguration("mind-reader.lineHighlight").get("multiLineIsEnabled")); + + // return the enabledStatus + return multiLineIsEnabled; + } +} + +// Clean-up after ourself +export function deactivate() { + // when the plugin is terminated remove all highlighting + if (highlightStyle !== undefined) { + highlightStyle.dispose(); + } +} + + /** + * Border Width Settings + * borderWidthTop = Top Border Width + * borderWidthRight = Right Border Width * Right border is a little finicky, I have all others at 1px, but need 15px for this one to match + * borderWidthBottom = Bottom Border Width + * borderWidthLeft = Left Border Width + * + * Uses CSS so should accept: + * thin | medium | thick + * px + * rem + * em + * cm + * % - Weird behavior + * inherit + * + * If no value is found in the settings, we set the value after the double pipes (||) instead + */ + + /** + * Border Style Settings + * borderStyleTop = Top Border Style + * borderStyleRight = Right Border Style + * borderStyleBottom = Bottom Border Style + * borderStyleLeft = Left Border Style + * + * Uses CSS so should accept: (Some of them I can't tell a difference, but they do something) + * none + * hidden + * dotted + * dashed + * solid + * double + * groove + * ridge + * inset + * outset + * + * If no value is found in the settings, we set the value after the double pipes (||) instead + */ + + /** + * Border Color Settings + * borderColorRight = Right Border Color + * borderColorBottom = Bottom Border Color + * borderColorTop = Top Border Color + * borderColorLeft = Left Border Color + * + * Uses CSS so should accept: (Some of them I can't tell a difference, but they do something) + * none - This one doesn't play nice + * string value like "red" | "blue" | "orange" etc - https://www.w3schools.com/cssref/css_colors.asp + * # + * rgb(###, ###, ###) + * rgba(###, ###, ###, ###) + * hsla(##, ##%, ##%, .#); + * inherit - This one has weird behavior as well + * + * If no value is found in the settings, we set the value after the double pipes (||) instead + */ + + /** + * Color of the background + * + * Uses CSS so should accept: + * none - This one doesn't play nice + * string value like "red" | "blue" | "orange" etc - https://www.w3schools.com/cssref/css_colors.asp + * # + * rgb(###, ###, ###) + * rgba(###, ###, ###, ###) + * hsla(##, ##%, ##%, .#); + * inherit - This one has weird behavior as well + * + * If no value is found in the settings, we set the value after the double pipes (||) instead + */ + + /** + * font-style: normal|italic|oblique|initial|inherit + */ + + /** + * font-weight: normal|bold|bolder|lighter|number|initial|inherit + */ \ No newline at end of file From c17b718ce65c6312f13c3d9e2e9b9da853189be9 Mon Sep 17 00:00:00 2001 From: tel0065 <77864718+tel0065@users.noreply.github.com> Date: Sun, 1 May 2022 20:22:26 -0500 Subject: [PATCH 08/19] Added New Function Added Senior Design Day Spring 2022 suggestion of selecting the leading whitespace characters. Had to refactor getLeadingWhitespace to include a helper function. Also added imports for vscode. Finally shifted helper functions together and added comments. --- src/commands/text.ts | 220 ++++++++++++++++++++++++++++--------------- 1 file changed, 145 insertions(+), 75 deletions(-) diff --git a/src/commands/text.ts b/src/commands/text.ts index 7c0c122..6e72604 100755 --- a/src/commands/text.ts +++ b/src/commands/text.ts @@ -1,7 +1,7 @@ "use strict"; -import { CommandEntry } from './commandEntry'; -import vscode = require("vscode"); -import pl = require("../pylex"); +import pl = require("../pylex"); +import { CommandEntry } from './commandEntry'; +import { Position, Selection, TextEditor, TextLine, window, workspace } from "vscode"; export const textCommands: CommandEntry[] = [ { @@ -16,6 +16,10 @@ export const textCommands: CommandEntry[] = [ name: 'mind-reader.getLeadingSpaces', callback: getLeadingSpaces, }, + { + name: 'mind-reader.selectLeadingWhitespace', + callback: selectLeadingWhitespace + }, { name: 'mind-reader.getNumberOfSelectedLines', callback: getNumberOfSelectedLines, @@ -30,10 +34,54 @@ export const textCommands: CommandEntry[] = [ } ]; -/* Helper Function -* This function returns the number of selected lines in the active text editor window +/** Helper Function + * + * @param editor + * @returns numSpaces + ** There are two methods that can be used to find the leading spaces: + ** method 1: + ** calculates the number of leading spaces by finding the length of the current line + ** then subtracting from that the length of the text after trimming the whitespace at the start + ** which will equal the number of whitespace characters + ** + ** TO-USE: set calculateLeadingSpaces to true + ** + ** method 2 (default): + ** finds the index position of the first non-whitespace character in a 0-index + ** this number will equal the number of spaces preceding the non-whitespace character + ** due to the nature of 0-indexes. + ** + ** TO-USE: set calculateLeadingSpaces to false + */ +function fetchNumberOfLeadingSpaces(editor: TextEditor | undefined): number { + let numSpaces: number = 0; + + + if (editor) { + /* + * set true to use method 1: find the number of leading spaces through arithmetic + * set false to use method 2: find the index position of the first non-whitespace character in a 0-index + * default: false + */ + const calculateLeadingSpaces: boolean = false; // change boolean value to change method + const lineNum: number = (fetchLineNumber(editor) - 1); // We want the line index, so we remove the 1 we added to the result in fetchLineNumber + const line : any = editor.document.lineAt(lineNum); + + /* If true, calculate by arithmetic otherwise get index */ + numSpaces = (calculateLeadingSpaces) + ? pl.Lexer.getLeadingSpacesByArithmetic(line) + : pl.Lexer.getLeadingSpacesByIndex(line); + } + + return numSpaces; +} + +/** Helper Function +* * This function returns the number of selected lines in the active text editor window + @param editor + @returns numberOfSelectedLines */ -function fetchNumberOfSelectedLines(editor: vscode.TextEditor | undefined): number { +function fetchNumberOfSelectedLines(editor: TextEditor | undefined): number { let numberOfSelectedLines: number = 0; if (editor) { @@ -43,67 +91,71 @@ function fetchNumberOfSelectedLines(editor: vscode.TextEditor | undefined): numb return numberOfSelectedLines; } -/* Helper Function -* This function returns the line number of the active text editor window +/** Helper Function + ** This function returns the line number of the active text editor window + * @param editor + * @returns editor!.selection.active.line + 1 */ -function fetchLineNumber(editor: any): number { - return editor.selection.active.line + 1; +function fetchLineNumber(editor: TextEditor | undefined): number { + return editor!.selection.active.line + 1; // line numbers start at 1, not 0, so we add 1 to the result } -/* Helper Function -* This function returns the text from the current line of the active text editor window -*/ -function fetchTextLine(editor: any): string { - return editor.document.lineAt(fetchLineNumber(editor) - 1); +/** Helper Function + ** This function returns the text from the current line of the active text editor window + * @param editor + * @returns editor.document.lineAt(fetchLineNumber(editor) - 1) + */ +function fetchLine(editor: TextEditor | undefined): TextLine { + return editor!.document.lineAt(fetchLineNumber(editor) - 1); // We want the line index, so we remove the 1 we added to the result in fetchLineNumber } -/** Function +/* Function * Function to return the number of selected (highlighted) lines * Changes output to 'Line' for 1 line and 'Lines' for all other instances */ function getNumberOfSelectedLines(): void { - const editor: any = vscode.window.activeTextEditor; + const editor: any = window.activeTextEditor; if (editor) { const numberOfSelectedLines: number = fetchNumberOfSelectedLines(editor); (numberOfSelectedLines !== 1) - ? vscode.window.showInformationMessage(`${numberOfSelectedLines.toString()} Lines Selected`) - : vscode.window.showInformationMessage(`${numberOfSelectedLines.toString()} Line Selected`); + ? window.showInformationMessage(`${numberOfSelectedLines.toString()} Lines Selected`) + : window.showInformationMessage(`${numberOfSelectedLines.toString()} Line Selected`); } else { - vscode.window.showErrorMessage('No document currently active'); + window.showErrorMessage('No document currently active'); } } -/** Function +/* Function * Outputs the current line number the cursor is on */ function getLineNumber(): void { - const editor: any = vscode.window.activeTextEditor; + const editor: any = window.activeTextEditor; if (editor) { const lineNum: number = fetchLineNumber(editor); - vscode.window.showInformationMessage(`Line ${lineNum.toString()}`); + window.showInformationMessage(`Line ${lineNum.toString()}`); } else { - vscode.window.showErrorMessage('No document currently active'); + window.showErrorMessage('No document currently active'); } } -/** Function +/* Function * Used to get the number of indents on a line */ function getIndent(): void { - const editor: any = vscode.window.activeTextEditor; + const editor: any = window.activeTextEditor; if (editor) { - const lineNum: number = fetchLineNumber(editor); - const textLine: any = editor.document.lineAt(lineNum - 1); + const lineNum: number = (fetchLineNumber(editor) - 1); // We want the line index, so we remove the 1 we added to the result in fetchLineNumber + const line : any = editor.document.lineAt(lineNum); - if (textLine.isEmptyOrWhitespace) { - vscode.window.showInformationMessage(`Line ${lineNum.toString()} is Empty`); + if (line.isEmptyOrWhitespace) { + window.showInformationMessage(`Line ${lineNum.toString()} is Empty`); } else { // Grab tab format from open document @@ -111,69 +163,85 @@ function getIndent(): void { size: editor.options.tabSize, hard: !editor.options.insertSpaces }; - const i: number = pl.Lexer.getIndent(textLine.text, tabFmt); + const i: number = pl.Lexer.getIndent(line.text, tabFmt); (i !== 1) - ? vscode.window.showInformationMessage(`Line ${lineNum.toString()}: ${i.toString()} indents`) - : vscode.window.showInformationMessage(`Line ${lineNum.toString()}: ${i.toString()} indent`); + ? window.showInformationMessage(`Line ${lineNum.toString()}: ${i.toString()} indents`) + : window.showInformationMessage(`Line ${lineNum.toString()}: ${i.toString()} indent`); } } else { - vscode.window.showErrorMessage('No document currently active'); + window.showErrorMessage('No document currently active'); } } -/* Function -> Returns the number of leading spaces on the line the cursor is on - * There are two methods that can be used to find the leading spaces: - * method 1: - * calculates the number of leading spaces by finding the length of the current line - * then subtracting from that the length of the text after trimming the whitespace at the start - * which will equal the number of whitespace characters - * - * TO-USE: set calculateLeadingSpaces to true - * - * method 2 (default): - * finds the index position of the first non-whitespace character in a 0-index - * this number will equal the number of spaces preceding the non-whitespace character - * due to the nature of 0-indexes. - * - * TO-USE: set calculateLeadingSpaces to false +/* Function + * Returns the number of leading spaces on the line the cursor is on */ function getLeadingSpaces(): void { - const editor: any = vscode.window.activeTextEditor; + const editor: any = window.activeTextEditor; if (editor) { const lineNum : number = fetchLineNumber(editor); - const textLine: any = fetchTextLine(editor); + const line : any = fetchLine(editor); - if (textLine.isEmptyOrWhitespace) { - vscode.window.showInformationMessage(`Line ${lineNum.toString()} is empty`); + if (line.isEmptyOrWhitespace) { + window.showInformationMessage(`Line ${lineNum.toString()} is empty`); } else { - /* - * set true to use method 1: find the number of leading spaces through arithmetic - * set false to use method 2: find the index position of the first non-whitespace character in a 0-index - * - * default: false - */ - const calculateLeadingSpaces: boolean = false; // change boolean value to change method - const numSpaces: number = (calculateLeadingSpaces) - ? pl.Lexer.getLeadingSpacesByArithmetic(textLine) - : pl.Lexer.getLeadingSpacesByIndex(textLine); + const numSpaces = fetchNumberOfLeadingSpaces(editor); /* Ternary operator to change the tense of 'space' to 'spaces' for the output if numSpaces is 0 or greater than 1 */ (numSpaces !== 1) - ? vscode.window.showInformationMessage(`Line ${lineNum.toString()}: ${numSpaces.toString()} spaces`) - : vscode.window.showInformationMessage(`Line ${lineNum.toString()}: ${numSpaces.toString()} space`); + ? window.showInformationMessage(`Line ${lineNum.toString()}: ${numSpaces.toString()} spaces`) + : window.showInformationMessage(`Line ${lineNum.toString()}: ${numSpaces.toString()} space`); } } else { - vscode.window.showErrorMessage('No document currently active'); + window.showErrorMessage('No document currently active'); + } +} + +/* Function + * Selects the leading whitespace at the beginning of a line + * This feature was a request from Senior Design Day Spring 2022 + */ +function selectLeadingWhitespace(): void { + const editor : any = window.activeTextEditor; + + if (editor) { + const numSpaces = fetchNumberOfLeadingSpaces(editor); // This will be used for the output message + const lineNum : number = (fetchLineNumber(editor) - 1); // We want the line index, so we remove the 1 we added to the result in fetchLineNumber + + /* If numSpaces isn't greater than 1, then there is no leading whitespace to select */ + if (numSpaces >= 1) { + const line : any = editor.document.lineAt(lineNum); // Get our line + const startPos: any = line.range.start.character; // Start at the starting character position + const endPos : any = line.firstNonWhitespaceCharacterIndex; // End at the first non whitespace character index + + /* Apply our selection */ + editor.selection = new Selection(new Position(lineNum, startPos), new Position(lineNum, endPos)); + /* After the selection is made, the editor loses focus. We need to re-focus the editor so typing isn't interrupted */ + window.showTextDocument(editor.document); + + + /* Ternary operator to change the tense of 'space' to 'spaces' for the output if numSpaces is 0 or greater than 1 */ + (numSpaces !== 1) + ? window.showInformationMessage(`Line ${lineNum.toString()}: ${numSpaces.toString()} spaces selected`) + : window.showInformationMessage(`Line ${lineNum.toString()}: ${numSpaces.toString()} space selected`); + } + else { + window.showErrorMessage(`Line ${lineNum.toString()}: No leading spaces to select!`); // No whitespace to select + window.showTextDocument(editor.document); // Refocus editor + } + } + else { + window.showErrorMessage('No document currently active'); // No active document } } function runLineContext(): void { - const editor: any = vscode.window.activeTextEditor; + const editor: any = window.activeTextEditor; if (editor) { // current text and line number @@ -193,10 +261,10 @@ function runLineContext(): void { // build text const contentString: string = createContextString(context, line); - vscode.window.showInformationMessage(contentString); + window.showInformationMessage(contentString); } else { - vscode.window.showErrorMessage('No document currently active'); + window.showErrorMessage('No document currently active'); } } @@ -232,19 +300,21 @@ function createContextString(context: any, line: string): string { return contextString; } -// find up to `n` words around the cursor, where `n` is -// the value of `#mindReader.reader.contextWindow` +/* + * find up to `n` words around the cursor, where `n` is + * the value of `#mindReader.reader.contextWindow` + */ function runCursorContext(): void { - const editor: any = vscode.window.activeTextEditor; + const editor: any = window.activeTextEditor; if (!editor) { - vscode.window.showErrorMessage('RunCursorContext: No Active Editor'); + window.showErrorMessage('RunCursorContext: No Active Editor'); return; } const cursorPos : any = editor.selection.active; const text : string = editor.document.lineAt(cursorPos).text; - const windowSize : any = vscode.workspace.getConfiguration('mindReader').get('reader.contextWindow'); + const windowSize : any = workspace.getConfiguration('mindReader').get('reader.contextWindow'); let trimmedText: string = text.trimStart(); // trim leading whitespace const leadingWS : number = text.length - trimmedText.length; // # of characters of leading whitespace let pos : number = leadingWS; @@ -299,7 +369,7 @@ function runCursorContext(): void { contextString += spaceWords[i].word + ' '; } // output cursor context string - vscode.window.showInformationMessage(contextString); + window.showInformationMessage(contextString); return; } } From cc1c23a16fb9f12cb4772e201934fdd8ba139fe6 Mon Sep 17 00:00:00 2001 From: tel0065 <77864718+tel0065@users.noreply.github.com> Date: Wed, 4 May 2022 19:27:17 -0500 Subject: [PATCH 09/19] added function, fixed bug Added function for selectLeadingSpaces, fixed bug which was reporting the wrong line number on some functions, added window focusing to most of the functions --- src/commands/text.ts | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/commands/text.ts b/src/commands/text.ts index 6e72604..14300cc 100755 --- a/src/commands/text.ts +++ b/src/commands/text.ts @@ -64,8 +64,7 @@ function fetchNumberOfLeadingSpaces(editor: TextEditor | undefined): number { * default: false */ const calculateLeadingSpaces: boolean = false; // change boolean value to change method - const lineNum: number = (fetchLineNumber(editor) - 1); // We want the line index, so we remove the 1 we added to the result in fetchLineNumber - const line : any = editor.document.lineAt(lineNum); + const line : any = fetchLine(editor); /* If true, calculate by arithmetic otherwise get index */ numSpaces = (calculateLeadingSpaces) @@ -126,6 +125,8 @@ function getNumberOfSelectedLines(): void { else { window.showErrorMessage('No document currently active'); } + + window.showTextDocument(editor.document); // After the selection is made, the editor loses focus. We need to re-focus the editor so typing isn't interrupted } /* Function @@ -142,6 +143,8 @@ function getLineNumber(): void { else { window.showErrorMessage('No document currently active'); } + + window.showTextDocument(editor.document); // After the selection is made, the editor loses focus. We need to re-focus the editor so typing isn't interrupted } /* Function @@ -151,14 +154,14 @@ function getIndent(): void { const editor: any = window.activeTextEditor; if (editor) { - const lineNum: number = (fetchLineNumber(editor) - 1); // We want the line index, so we remove the 1 we added to the result in fetchLineNumber - const line : any = editor.document.lineAt(lineNum); + const lineNum: number = (fetchLineNumber(editor)); + const line : any = fetchLine(editor); if (line.isEmptyOrWhitespace) { window.showInformationMessage(`Line ${lineNum.toString()} is Empty`); } else { - // Grab tab format from open document + /* Grab tab format from open document */ const tabFmt: any = { size: editor.options.tabSize, hard: !editor.options.insertSpaces @@ -173,6 +176,8 @@ function getIndent(): void { else { window.showErrorMessage('No document currently active'); } + + window.showTextDocument(editor.document); // After the selection is made, the editor loses focus. We need to re-focus the editor so typing isn't interrupted } /* Function @@ -200,6 +205,8 @@ function getLeadingSpaces(): void { else { window.showErrorMessage('No document currently active'); } + + window.showTextDocument(editor.document); // After the selection is made, the editor loses focus. We need to re-focus the editor so typing isn't interrupted } /* Function @@ -207,22 +214,21 @@ function getLeadingSpaces(): void { * This feature was a request from Senior Design Day Spring 2022 */ function selectLeadingWhitespace(): void { - const editor : any = window.activeTextEditor; + const editor : any = window.activeTextEditor; if (editor) { - const numSpaces = fetchNumberOfLeadingSpaces(editor); // This will be used for the output message - const lineNum : number = (fetchLineNumber(editor) - 1); // We want the line index, so we remove the 1 we added to the result in fetchLineNumber + const numSpaces = fetchNumberOfLeadingSpaces(editor); // This will be used for the output message + const lineNum : number = (fetchLineNumber(editor)); // Get the displayed line number /* If numSpaces isn't greater than 1, then there is no leading whitespace to select */ if (numSpaces >= 1) { - const line : any = editor.document.lineAt(lineNum); // Get our line + const line : any = fetchLine(editor); const startPos: any = line.range.start.character; // Start at the starting character position const endPos : any = line.firstNonWhitespaceCharacterIndex; // End at the first non whitespace character index /* Apply our selection */ - editor.selection = new Selection(new Position(lineNum, startPos), new Position(lineNum, endPos)); - /* After the selection is made, the editor loses focus. We need to re-focus the editor so typing isn't interrupted */ - window.showTextDocument(editor.document); + /* We need to subtract 1 from lineNum because we added 1 during the fetchLineNumber above and we want the 0-index for position, so remove it */ + editor.selection = new Selection(new Position((lineNum - 1), startPos), new Position((lineNum - 1), endPos)); /* Ternary operator to change the tense of 'space' to 'spaces' for the output if numSpaces is 0 or greater than 1 */ @@ -232,12 +238,13 @@ function selectLeadingWhitespace(): void { } else { window.showErrorMessage(`Line ${lineNum.toString()}: No leading spaces to select!`); // No whitespace to select - window.showTextDocument(editor.document); // Refocus editor } } else { window.showErrorMessage('No document currently active'); // No active document } + + window.showTextDocument(editor.document); // After the selection is made, the editor loses focus. We need to re-focus the editor so typing isn't interrupted } function runLineContext(): void { From af9308744b34f214a8c91f1555d4674c0af00d8d Mon Sep 17 00:00:00 2001 From: tel0065 <77864718+tel0065@users.noreply.github.com> Date: Wed, 4 May 2022 19:28:10 -0500 Subject: [PATCH 10/19] added user config options Added configuration options for the line highlighter feature --- package.json | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 107 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index aecd638..491a94a 100644 --- a/package.json +++ b/package.json @@ -297,10 +297,115 @@ "type": "string", "markdownDescription": "The default port to try and establish a connection on." }, - "mindReader.connection.clearOutputOnRun": { + "mindReader.lineHighlighter.isEnabled": { "type": "boolean", - "description": "Whether to clear the output each time the program is run", + "description": "Enable/Disable the line highlighter", "default": "true" + }, + "mindReader.lineHighlighter.multiLineIsEnabled": { + "type": "boolean", + "description": "Turn off the line highlighter if highlighting multiple lines", + "default": "false" + }, + "mindReader.lineHighlighter.backgroundColor": { + "type": "string", + "markdownDescription": "Set the background color of the line highlighter", + "default": "#232C5C" + }, + "mindReader.lineHighlighter.outlineColor": { + "type": "string", + "markdownDescription": "Set the outline color of the line highlighter", + "default": "#4866FE" + }, + "mindReader.lineHighlighter.outlineWidth": { + "type": "string", + "markdownDescription": "Set the outline width of the line highlighter", + "default": "1px" + }, + "mindReader.lineHighlighter.outlineStyle": { + "type": "string", + "markdownDescription": "Set the outline style of the line highlighter", + "default": "solid" + }, + "mindReader.lineHighlighter.borderColorTop": { + "type": "string", + "markdownDescription": "Set the top border color of the line highlighter", + "default": "#FFFFFF" + }, + "mindReader.lineHighlighter.borderColorRight": { + "type": "string", + "markdownDescription": "Set the right border color of the line highlighter", + "default": "#FFFFFF" + }, + "mindReader.lineHighlighter.borderColorBottom": { + "type": "string", + "markdownDescription": "Set the bottom border color of the line highlighter", + "default": "#FFFFFF" + }, + "mindReader.lineHighlighter.borderColorLeft": { + "type": "string", + "markdownDescription": "Set the left border color of the line highlighter", + "default": "#FFFFFF" + }, + "mindReader.lineHighlighter.borderWidthTop": { + "type": "string", + "markdownDescription": "Set the top border width of the line highlighter", + "default": "1px" + }, + "mindReader.lineHighlighter.borderWidthRight": { + "type": "string", + "markdownDescription": "Set the right border width of the line highlighter", + "default": "16px" + }, + "mindReader.lineHighlighter.borderWidthBottom": { + "type": "string", + "markdownDescription": "Set the bottom border width of the line highlighter", + "default": "1px" + }, + "mindReader.lineHighlighter.borderWidthLeft": { + "type": "string", + "markdownDescription": "Set the left border width of the line highlighter", + "default": "1px" + }, + "mindReader.lineHighlighter.borderStyleTop": { + "type": "string", + "markdownDescription": "Set the top border style of the line highlighter", + "default": "solid" + }, + "mindReader.lineHighlighter.borderStyleRight": { + "type": "string", + "markdownDescription": "Set the right border style of the line highlighter", + "default": "solid" + }, + "mindReader.lineHighlighter.borderStyleBottom": { + "type": "string", + "markdownDescription": "Set the bottom border style of the line highlighter", + "default": "solid" + }, + "mindReader.lineHighlighter.borderStyleLeft": { + "type": "string", + "markdownDescription": "Set the left border style of the line highlighter", + "default": "solid" + }, + "mindReader.lineHighlighter.fontStyle": { + "type": "string", + "markdownDescription": "Set the font style of the line highlighter", + "default": "normal" + }, + "mindReader.lineHighlighter.fontWeight": { + "type": "string", + "markdownDescription": "Set the font weight of the line highlighter", + "default": "bolder" + }, + "mindReader.lineHighlighter.textDecoration": { + "type": "string", + "markdownDescription": "Set the text decoration of the line highlighter", + "default": "none" + }, + "mindReader.lineHighlighter.textColor": { + "type": "string", + "markdownDescription": "Set the text color of the line highlighter", + "default": "#FFFFFF" } } }, From cc8fbc26ad711d961703a8df79aa625811e04f56 Mon Sep 17 00:00:00 2001 From: tel0065 <77864718+tel0065@users.noreply.github.com> Date: Wed, 4 May 2022 19:40:33 -0500 Subject: [PATCH 11/19] Cleaned Up Code Removed commented out code, added comments, etc --- src/lineHighlighter.ts | 187 +++++++++++------------------------------ 1 file changed, 48 insertions(+), 139 deletions(-) diff --git a/src/lineHighlighter.ts b/src/lineHighlighter.ts index 90ad27e..65445f7 100644 --- a/src/lineHighlighter.ts +++ b/src/lineHighlighter.ts @@ -6,6 +6,7 @@ * ? ██║ ██║██║╚██████╔╝██║ ██║███████╗██║╚██████╔╝██║ ██║ ██║ ██║ ██║ * ? ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ **/ +'use strict'; import { Position, window, workspace, TextEditorDecorationType, TextEditor, WorkspaceConfiguration, Range } from 'vscode'; export { lineHighlighter }; @@ -19,8 +20,7 @@ function lineHighlighter(): void { let multiLineIsEnabled: boolean | undefined = getMultiLineHighlighterStatus(); /** - * Trigger the line highlight when the extension - * loads so current line gets highlighted + * Trigger the line highlight when the extension loads so current line gets highlighted */ triggerHighlight(); @@ -40,7 +40,6 @@ function lineHighlighter(): void { */ window.onDidChangeTextEditorSelection((editor) => { if (!editor.textEditor) { - console.error(`[*] onDidChangeTextEditorSelection(${editor}) -> no active text editor`); return; } @@ -50,9 +49,8 @@ function lineHighlighter(): void { /** * Trigger for when the text document changes */ - workspace.onDidChangeTextDocument((editor) => { + workspace.onDidChangeTextDocument(() => { if (!activeTextEditor) { - console.error(`[*] onDidChangeTextDocument(${editor}) -> no active text editor`); return; } @@ -78,15 +76,11 @@ function lineHighlighter(): void { return; } - // Dump existing styling - highlightStyle.dispose(); - // check if line highlighter is enable/disabled - isEnabled = getHighlighterStatus(); - multiLineIsEnabled = getMultiLineHighlighterStatus(); - // get new line highlighter styling - highlightStyle = getHighlighterStyle(); - // trigger highlight with new styling - triggerHighlight(); + highlightStyle.dispose(); // Dump existing styling + isEnabled = getHighlighterStatus(); // check if line highlighter is enable/disabled + multiLineIsEnabled = getMultiLineHighlighterStatus(); // Check if multiline highlighting is enabled/disabled + highlightStyle = getHighlighterStyle(); // get new line highlighter styling + triggerHighlight(); // trigger highlight with new styling }); /** @@ -94,7 +88,6 @@ function lineHighlighter(): void { */ function triggerHighlight(): void { if (!activeTextEditor) { - console.error("[*] NO Active Text Editor"); return; } @@ -108,78 +101,77 @@ function lineHighlighter(): void { * set the decorations with our chosen highlighting style on the selection * otherwise (highlighter is disabled) dump our highlighting style */ - // (isEnabled) - // ? activeTextEditor!.setDecorations(highlightStyle, activeTextEditor!.selections) - // : highlightStyle.dispose(); switch (isEnabled) { - case true: // isEnabled is true + case true: /* isEnabled is true */ switch (multiLineIsEnabled) { - case true: // isEnabled is true and multiLineIsEnabled is true - // const startLine = activeTextEditor!.selection.start; - // const endLine = activeTextEditor!.selection.end; - // const rangeToHighlight = { range: new Range(startLine, endLine) }; - // activeTextEditor!.setDecorations(highlightStyle, [rangeToHighlight]); - // const currentLineRange = activeTextEditor!.document.lineAt(activeTextEditor!.selection.anchor).range; - // activeTextEditor!.setDecorations(highlightStyle, [currentLineRange]); - // const startLine = activeTextEditor!.selection.start.line; - // const endLine = activeTextEditor!.selection.end; - // const rangeToHighlight = { range: new Range(startLine, endLine) }; + case true: /* isEnabled is true and multiLineIsEnabled is true */ activeTextEditor.setDecorations(highlightStyle, activeTextEditor.selections); break; - case false: // isEnabled is true and multiLineIsEnabled is false + case false: /* isEnabled is true and multiLineIsEnabled is false */ switch (activeTextEditor.selection.isSingleLine) { - case true: // isEnabled is true and multiLineIsEnabled is false and VSCode is reporting a single line + case true: /* isEnabled is true and multiLineIsEnabled is false and VSCode is reporting a single line */ let currentPosition = []; for (let i = 0; i < activeTextEditor.selections.length; i++) { currentPosition[i] = { range: new Range(activeTextEditor.selections[i].anchor, activeTextEditor.selections[i].anchor) }; } activeTextEditor.setDecorations(highlightStyle, currentPosition); - // const currentLine = activeTextEditor.selection.active.line; - // const newDecoration = { range: new Range(currentPosition, currentPosition) }; - // const singleLineHighlight = { range: new Range(activeTextEditor!.selection.anchor.line, activeTextEditor!.selection.anchor.line) }; - // activeTextEditor!.setDecorations(highlightStyle, [singleLineRange]); - // activeTextEditor.setDecorations(highlightStyle, [activeTextEditor.selection]); break; - case false: // isEnabled is true and multiLineIsEnabled is false and VSCode is reporting multiple lines + case false: /* isEnabled is true and multiLineIsEnabled is false and VSCode is reporting multiple lines */ // Dispose of our highlighting style so multiple lines aren't all highlighted when clicking and dragging to highlight - // highlightStyle.dispose(); - activeTextEditor.setDecorations(highlightStyle, []); - // Since we disposed of our highlighting style, we need to re-acquire it for highlighting to continue to work after clicking and dragging to highlight - // highlightStyle = getHighlighterStyle(); + activeTextEditor.setDecorations(highlightStyle, []); // This will dispose of a single editor instead of all editors break; - default: // isEnabled is true and multiLineIsEnabled is false and VSCode is reporting something else - break out of 3rd switch + default: /* isEnabled is true and multiLineIsEnabled is false and VSCode is reporting something else - break out of 3rd switch */ break; } break; - default: // isEnabled is true and multiLineIsEnabled is undetected - break out of 2nd switch statement + default: /* isEnabled is true and multiLineIsEnabled is undetected - break out of 2nd switch statement */ break; } break; - case false: // isEnabled is false + case false: /* isEnabled is false */ highlightStyle.dispose(); break; - default: // break out of initial switch is true or false not found + default: /* break out of initial switch if 'true or false' is not found */ break; } - // Track new position, without this the line the the cursor begins on will never get styled + // Keep track of position new Position(activeTextEditor.selection.start.line, activeTextEditor.selection.start.character); } } /** - * Function to get the user configured highlighting styles, or use defaults + * * Function to get the user configured highlighting styles, or use defaults * - * Designed with user configuration in mind, able to control different sides - * independently from each other (in most cases). This allows for many different - * configurations. + * * Designed with user configuration in mind, able to control different sides + * * independently from each other (in most cases). This allows for many different + * * configurations. + * + * ? Colors Can be input with the following values: + * * https://www.w3schools.com/cssref/css_colors.asp for string based color values + * * Hex -> # | rgb(###, ###, ###) | rgba(###, ###, ###, ###) | hsla(##, ##%, ##%, .#) + * + * ? Width Input Values + * ! Some work better than others, if one isn't working try a different method: + * * thin | medium | thick | px | rem | em | cm | % | inherit + * + * ? Other values + * * font-style : normal|italic|oblique|initial|inherit; + * * font-weight : normal|bold|bolder|lighter|number|initial|inherit; + * * border-style : none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset|initial|inherit; + * * outline-style : none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset|initial|inherit; + * * outline-width : medium|thin|thick|length|initial|inherit; + * * border-width : medium|thin|thick|length|initial|inherit; + * ! https://www.w3schools.com/cssref/pr_text_text-decoration.asp for text-decoration + * + * ! borderWidthRight acts weirdly, on my system 16px works best with the other directions set to 1px * * @returns highlighterStyle */ function getHighlighterStyle(): TextEditorDecorationType { - // Used so we don't have to type out workspace.getConfiguration('mind-reader.lineHighlight') on every line, ie: shorthand - const userConfig: WorkspaceConfiguration = workspace.getConfiguration('mind-reader.lineHighlight'); + // Used so we don't have to type out workspace.getConfiguration('mindReader.lineHighlighter') on every line, ie: shorthand + const userConfig: WorkspaceConfiguration = workspace.getConfiguration('mindReader.lineHighlighter'); const borderWidthTop : string = userConfig.get('borderWidthTop') || "1px"; const borderWidthRight : string = userConfig.get('borderWidthRight') || "16px"; @@ -245,9 +237,9 @@ function lineHighlighter(): void { * otherwise, "isEnabled" is listed in the settings * - so we just pull its value */ - (workspace.getConfiguration("mind-reader.lineHighlight").get("isEnabled") === undefined) + (workspace.getConfiguration("mindReader.lineHighlighter").get("isEnabled") === undefined) ? (enabledStatus = true) - : (enabledStatus = workspace.getConfiguration("mind-reader.lineHighlight").get("isEnabled")); + : (enabledStatus = workspace.getConfiguration("mindReader.lineHighlighter").get("isEnabled")); // return the enabledStatus return enabledStatus; @@ -263,9 +255,9 @@ function lineHighlighter(): void { * otherwise, "isEnabled" is listed in the settings * - so we just pull its value */ - (workspace.getConfiguration("mind-reader.lineHighlight").get("multiLineIsEnabled") === undefined) + (workspace.getConfiguration("mindReader.lineHighlighter").get("multiLineIsEnabled") === undefined) ? (multiLineIsEnabled = true) - : (multiLineIsEnabled = workspace.getConfiguration("mind-reader.lineHighlight").get("multiLineIsEnabled")); + : (multiLineIsEnabled = workspace.getConfiguration("mindReader.lineHighlighter").get("multiLineIsEnabled")); // return the enabledStatus return multiLineIsEnabled; @@ -279,86 +271,3 @@ export function deactivate() { highlightStyle.dispose(); } } - - /** - * Border Width Settings - * borderWidthTop = Top Border Width - * borderWidthRight = Right Border Width * Right border is a little finicky, I have all others at 1px, but need 15px for this one to match - * borderWidthBottom = Bottom Border Width - * borderWidthLeft = Left Border Width - * - * Uses CSS so should accept: - * thin | medium | thick - * px - * rem - * em - * cm - * % - Weird behavior - * inherit - * - * If no value is found in the settings, we set the value after the double pipes (||) instead - */ - - /** - * Border Style Settings - * borderStyleTop = Top Border Style - * borderStyleRight = Right Border Style - * borderStyleBottom = Bottom Border Style - * borderStyleLeft = Left Border Style - * - * Uses CSS so should accept: (Some of them I can't tell a difference, but they do something) - * none - * hidden - * dotted - * dashed - * solid - * double - * groove - * ridge - * inset - * outset - * - * If no value is found in the settings, we set the value after the double pipes (||) instead - */ - - /** - * Border Color Settings - * borderColorRight = Right Border Color - * borderColorBottom = Bottom Border Color - * borderColorTop = Top Border Color - * borderColorLeft = Left Border Color - * - * Uses CSS so should accept: (Some of them I can't tell a difference, but they do something) - * none - This one doesn't play nice - * string value like "red" | "blue" | "orange" etc - https://www.w3schools.com/cssref/css_colors.asp - * # - * rgb(###, ###, ###) - * rgba(###, ###, ###, ###) - * hsla(##, ##%, ##%, .#); - * inherit - This one has weird behavior as well - * - * If no value is found in the settings, we set the value after the double pipes (||) instead - */ - - /** - * Color of the background - * - * Uses CSS so should accept: - * none - This one doesn't play nice - * string value like "red" | "blue" | "orange" etc - https://www.w3schools.com/cssref/css_colors.asp - * # - * rgb(###, ###, ###) - * rgba(###, ###, ###, ###) - * hsla(##, ##%, ##%, .#); - * inherit - This one has weird behavior as well - * - * If no value is found in the settings, we set the value after the double pipes (||) instead - */ - - /** - * font-style: normal|italic|oblique|initial|inherit - */ - - /** - * font-weight: normal|bold|bolder|lighter|number|initial|inherit - */ \ No newline at end of file From 630391b5fe97138d0be9702e8bef12d2674eed4d Mon Sep 17 00:00:00 2001 From: tel0065 <77864718+tel0065@users.noreply.github.com> Date: Thu, 5 May 2022 11:51:12 -0500 Subject: [PATCH 12/19] Many Changes Added settings for line highlighter, added contributors section, added bugs section, added homepage section, changed all instances of mindReader to mind-reader, changed all instances of Mind_Reader to Mind Reader --- package.json | 476 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 307 insertions(+), 169 deletions(-) diff --git a/package.json b/package.json index 491a94a..23a4863 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,53 @@ { "name": "mind-reader", - "displayName": "Mind_Reader", - "repository": "https://github.com/We-Dont-Byte/Mind_Reader", + "displayName": "Mind Reader", + "homepage": "https://github.com/We-Dont-Byte/Mind_Reader/wiki", + "repository": { + "type": "git", + "url": "https://github.com/We-Dont-Byte/Mind_Reader" + }, + "bugs": { + "type": "git", + "url": "https://github.com/We-Dont-Byte/Mind_Reader/issues" + }, + "contributors": [ + { + "name" : "Jake Grossman", + "email" : "JacobGrossman2@my.unt.edu" + }, + { + "name" : "Cal Wooten", + "email" : "calwooten@my.unt.edu" + }, + { + "name" : "Josiah Mosesn", + "email" : "josiahmoses@my.unt.edu" + }, + { + "name" : "Sophia Drewfs", + "email" : "sophiadrewfs@my.unt.edu" + }, + { + "name" : "John Breaux", + "email" : "JohnBreaux@my.unt.edu" + }, + { + "name" : "Thomas Lane", + "email" : "ThomasLane2@my.unt.edu" + }, + { + "name" : "Ryan Tolbert", + "email" : "RyanTolbert@my.unt.edu" + }, + { + "name" : "Kendrick Johnson", + "email" : "KendrickJohnson@my.unt.edu" + }, + { + "name" : "Pedro Alvarez", + "email" : "PedroAlvarez3@my.unt.edu" + } + ], "version": "1.0.0", "engines": { "vscode": "^1.60.0" @@ -15,10 +61,6 @@ "main": "./out/extension.js", "contributes": { "commands": [{ - "command": "mind-reader.helloWorld", - "title": "Hello World" - }, - { "command": "mind-reader.increaseFontScale", "title": "Increase Font Scale" }, @@ -66,9 +108,25 @@ "command": "mind-reader.runCursorContext", "title": "Run Cursor Context" }, + { + "command": "mind-reader.getLineNumber", + "title": "Get The Current Line Number" + }, { "command": "mind-reader.getIndent", - "title": "Get Line Indentation" + "title": "Get The Number Of Line Indentation" + }, + { + "command": "mind-reader.getLeadingSpaces", + "title": "Get The Number Of Leading Spaces" + }, + { + "command": "mind-reader.selectLeadingWhitespace", + "title": "Select The Leading Whitespace" + }, + { + "command": "mind-reader.getNumberOfSelectedLines", + "title": "Get The Number Of Selected Lines" }, { "command": "mind-reader.connectHub", @@ -95,105 +153,126 @@ "title": "Delete a program from the LEGO Hub" } ], - "keybindings": [{ + "keybindings": [ + { + "command": "mind-reader.selectTheme", + "key": "", + "mac": "" + }, + { "command": "mind-reader.decreaseFontScale", - "key": "numpad_subtract", - "mac": "d" + "key": "", + "mac": "" }, { "command": "mind-reader.increaseFontScale", - "key": "numpad_add", - "mac": "[NumpadAdd]" + "key": "", + "mac": "" }, { "command": "mind-reader.increaseEditorScale", - "key": "shift+numpad_add", - "mac": "Shift+[NumpadAdd]" + "key": "", + "mac": "" }, { "command": "mind-reader.decreaseEditorScale", - "key": "shift+numpad_subtract", - "mac": "Shift+[NumpadSubtract]" + "key": "", + "mac": "" }, { "command": "mind-reader.resetEditorScale", - "key": "shift+enter", - "mac": "Shift+[Enter]" + "key": "", + "mac": "" }, { "command": "mind-reader.showAllSymbols", - "key": "Ctrl+T", - "mac": "Cmd+[KeyT]" + "key": "", + "mac": "" }, { "command": "mind-reader.gotoLine", - "key": "CTRL+G", - "mac": "Cmd+[KeyG]" + "key": "", + "mac": "" }, { "command": "mind-reader.quickOpen", - "key": "CTRL+P", - "mac": "Cmd+[KeyP]" + "key": "", + "mac": "" }, { "command": "mind-reader.gotoSymbol", - "key": "Ctrl+Shift+O", - "mac": "Cmd+Shift+[KeyO]" + "key": "", + "mac": "" }, { "command": "mind-reader.showProblems", - "key": "Ctrl+Shift+M", - "mac": "Cmd+Shift+[KeyM]" + "key": "", + "mac": "" }, { "command": "mind-reader.nextInFiles", - "key": "F8", - "mac": "[F8]" + "key": "", + "mac": "" }, { "command": "mind-reader.prevInFiles", - "key": "Shift+F8", - "mac": "Shift+[F8]" + "key": "", + "mac": "" }, { "command": "mind-reader.quickOpenPreviousRecentlyUsedEditorInGroup", - "key": "Ctrl+Tab", - "mac": "Cmd+[Tab]" + "key": "", + "mac": "" }, { "command": "mind-reader.navigateBack", - "key": "Ctrl+Alt+-", - "mac": "Cmd+Alt+[Minus]" + "key": "", + "mac": "" }, { "command": "mind-reader.getQuickInputBack", - "key": "Ctrl+Alt+-", - "mac": "Cmd+Alt+[Minus]" + "key": "", + "mac": "" }, { "command": "mind-reader.navigateForward", - "key": "Ctrl+Shift+-", - "mac": "Cmd+Shift+[Minus]" + "key": "", + "mac": "" }, { - "command": "mind-reader.selectTheme", - "key": "Ctrl+Shift+1", - "mac": "Cmd+Shift+[Digit1]" + "command": "mind-reader.getLineNumber", + "key": "", + "mac": "" }, { "command": "mind-reader.getIndent", - "key": "Shift+Tab", - "mac": "Shift+[Tab]" + "key": "", + "mac": "" + }, + { + "command": "mind-reader.getLeadingSpaces", + "key": "", + "mac": "" + }, + { + "command": "mind-reader.selectLeadingWhitespace", + "key": "", + "mac": "" + }, + { + "command": "mind-reader.getNumberOfSelectedLines", + "key": "", + "mac": "" }, { "command": "mind-reader.openKeyBindWin", - "key": "Ctrl+Shift+8", - "mac": "Cmd+Shift+8" + "key": "", + "mac": "" }, { "command": "mind-reader.openKeyBindMac", - "key": "Ctrl+Shift+9", - "mac": "Cmd+Shift+9" + "key": "", + "mac": "" } ], "menus": { @@ -201,8 +280,14 @@ "submenu": "mind-reader.editor.context", "group": "mind-reader" }], - "mind-reader.editor.context": [{ - "command": "mind-reader.increaseEditorScale", + "mind-reader.editor.context": [ + { + "command": "mind-reader.selectTheme", + "group": "mind-reader", + "when": "activeEditor" + }, + { + "command": "mind-reader.increaseFontScale", "group": "mind-reader", "when": "activeEditor" }, @@ -232,7 +317,27 @@ "when": "activeEditor" }, { - "command": "mind-reader.selectTheme", + "command": "mind-reader.getLineNumber", + "group": "mind-reader", + "when": "activeEditor" + }, + { + "command": "mind-reader.getIndent", + "group": "mind-reader", + "when": "activeEditor" + }, + { + "command": "mind-reader.getLeadingSpaces", + "group": "mind-reader", + "when": "activeEditor" + }, + { + "command": "mind-reader.selectLeadingWhitespace", + "group": "mind-reader", + "when": "activeEditor" + }, + { + "command": "mind-reader.getNumberOfSelectedLines", "group": "mind-reader", "when": "activeEditor" }, @@ -255,12 +360,14 @@ }, "submenus": [{ "id": "mind-reader.editor.context", - "label": "Mind_Reader" + "label": "Mind Reader" }], - "configuration": { - "title": "Mind_Reader", + "configuration": [{ + "title": "Mind Reader", + "order": 0, "properties": { - "mindReader.productType": { + "mind-reader.productType": { + "order": 1, "type": "string", "description": "Specifies the LEGO® product.", "default": "MINDSTORMS EV3", @@ -273,7 +380,8 @@ "LEGO® Education SPIKE™ Prime Set (45678)" ] }, - "mindReader.reader.screenReader": { + "mind-reader.reader.screenReader": { + "order": 0, "type": "string", "description": "Specifies which screen reader to optimize for.", "default": "NVDA", @@ -288,127 +396,157 @@ "Apple VoiceOver (macOS)" ] }, - "mindReader.reader.contextWindow": { + "mind-reader.reader.contextWindow": { + "order": 3, "type": "number", "description": "The number of words around the cursor to use when reading the cursor context", "default": 1 }, - "mindReader.connection.portPath": { + "mind-reader.connection.portPath": { + "order": 2, "type": "string", "markdownDescription": "The default port to try and establish a connection on." - }, - "mindReader.lineHighlighter.isEnabled": { - "type": "boolean", - "description": "Enable/Disable the line highlighter", - "default": "true" - }, - "mindReader.lineHighlighter.multiLineIsEnabled": { - "type": "boolean", - "description": "Turn off the line highlighter if highlighting multiple lines", - "default": "false" - }, - "mindReader.lineHighlighter.backgroundColor": { - "type": "string", - "markdownDescription": "Set the background color of the line highlighter", - "default": "#232C5C" - }, - "mindReader.lineHighlighter.outlineColor": { - "type": "string", - "markdownDescription": "Set the outline color of the line highlighter", - "default": "#4866FE" - }, - "mindReader.lineHighlighter.outlineWidth": { - "type": "string", - "markdownDescription": "Set the outline width of the line highlighter", - "default": "1px" - }, - "mindReader.lineHighlighter.outlineStyle": { - "type": "string", - "markdownDescription": "Set the outline style of the line highlighter", - "default": "solid" - }, - "mindReader.lineHighlighter.borderColorTop": { - "type": "string", - "markdownDescription": "Set the top border color of the line highlighter", - "default": "#FFFFFF" - }, - "mindReader.lineHighlighter.borderColorRight": { - "type": "string", - "markdownDescription": "Set the right border color of the line highlighter", - "default": "#FFFFFF" - }, - "mindReader.lineHighlighter.borderColorBottom": { - "type": "string", - "markdownDescription": "Set the bottom border color of the line highlighter", - "default": "#FFFFFF" - }, - "mindReader.lineHighlighter.borderColorLeft": { - "type": "string", - "markdownDescription": "Set the left border color of the line highlighter", - "default": "#FFFFFF" - }, - "mindReader.lineHighlighter.borderWidthTop": { - "type": "string", - "markdownDescription": "Set the top border width of the line highlighter", - "default": "1px" - }, - "mindReader.lineHighlighter.borderWidthRight": { - "type": "string", - "markdownDescription": "Set the right border width of the line highlighter", - "default": "16px" - }, - "mindReader.lineHighlighter.borderWidthBottom": { - "type": "string", - "markdownDescription": "Set the bottom border width of the line highlighter", - "default": "1px" - }, - "mindReader.lineHighlighter.borderWidthLeft": { - "type": "string", - "markdownDescription": "Set the left border width of the line highlighter", - "default": "1px" - }, - "mindReader.lineHighlighter.borderStyleTop": { - "type": "string", - "markdownDescription": "Set the top border style of the line highlighter", - "default": "solid" - }, - "mindReader.lineHighlighter.borderStyleRight": { - "type": "string", - "markdownDescription": "Set the right border style of the line highlighter", - "default": "solid" - }, - "mindReader.lineHighlighter.borderStyleBottom": { - "type": "string", - "markdownDescription": "Set the bottom border style of the line highlighter", - "default": "solid" - }, - "mindReader.lineHighlighter.borderStyleLeft": { - "type": "string", - "markdownDescription": "Set the left border style of the line highlighter", - "default": "solid" - }, - "mindReader.lineHighlighter.fontStyle": { - "type": "string", - "markdownDescription": "Set the font style of the line highlighter", - "default": "normal" - }, - "mindReader.lineHighlighter.fontWeight": { - "type": "string", - "markdownDescription": "Set the font weight of the line highlighter", - "default": "bolder" - }, - "mindReader.lineHighlighter.textDecoration": { - "type": "string", - "markdownDescription": "Set the text decoration of the line highlighter", - "default": "none" - }, - "mindReader.lineHighlighter.textColor": { - "type": "string", - "markdownDescription": "Set the text color of the line highlighter", - "default": "#FFFFFF" } } }, + { + "title": "Line Highlighter [Must Close Settings And RESTART VSCode For The Line Highlighter To Function]", + "order": 1, + "properties": { + "mind-reader.lineHighlighter.isEnabled": { + "order": 4, + "type": "boolean", + "markdownDescription": "Enable/Disable the line highlighter.\n\n\n* `Enabled (our default)`: Checked: Line Highlighter is turned `ON`\n* `Disabled`: Unchecked: Line Highlighter is turned `OFF`\n\n### `NOTE`: You Must Close Settings And RESTART Visual Studio Code For The Line Highlighter To Function\n#### Even If No Changes Were Made", + "default": "true" + }, + "mind-reader.lineHighlighter.multiLineIsEnabled": { + "order": 5, + "type": "boolean", + "markdownDescription": "Temporarily Disable highlighting when highlighting multiple lines.\n\n\n* `Enabled`: Checked: Multiline Highlighting is turned `ON`:\n* * When you click and drag line highlights will be applied to all lines\n* `Disabled (our default)`: Unchecked: Multiline Highlighting is turned `OFF`:\n* * When you click and drag the line highlighter will disable itself then re-enable itself when you click onto a single line.", + "default": "false" + }, + "mind-reader.lineHighlighter.backgroundColor": { + "order": 6, + "type": "string", + "markdownDescription": "Set the background color to be used by the line highlighter.\n\nSyntax: _color_ or `transparent`\n\nAvailable color formats include:\n* `HEX(A)`: for Hexadecimal Colors: `#RRGGBB` or `#RRGGBBAA` to add transparency\n* `RGB(A)`: for RGB Colors: `rgb(red, green, blue)` or `rgba(red, green, blue, alpha)`\n* `HSL(A)`: for HSL Colors: `hsl(hue, saturation, lightness)` or `hsla(hue, saturation, lightness, alpha)`\n* `Predefined Color Names`: 140 color names are predefined in the HTML and CSS color specification: `blue`, `red`, `coral`, `brown`, [etc...](https://www.w3schools.com/colors/colors_names.asp)\n* `None`: For no color to be applied: Sometimes VSCode will pull a color from your theme, other times it uses black\n* `#232C5C` is our default", + "default": "#232C5C" + }, + "mind-reader.lineHighlighter.outlineColor": { + "order": 7, + "type": "string", + "markdownDescription": "Set the outline color to be used by the line highlighter.\n\nSyntax: _color_ or `transparent`\n\nAvailable color formats include:\n* `HEX(A)`: for Hexadecimal Colors: `#RRGGBB` or `#RRGGBBAA` to add transparency\n* `RGB(A)`: for RGB Colors: `rgb(red, green, blue)` or `rgba(red, green, blue, alpha)`\n* `HSL(A)`: for HSL Colors: `hsl(hue, saturation, lightness)` or `hsla(hue, saturation, lightness, alpha)`\n* `Predefined Color Names`: 140 color names are predefined in the HTML and CSS color specification: `blue`, `red`, `coral`, `brown`, [etc...](https://www.w3schools.com/colors/colors_names.asp)\n* `None`: For no color to be applied: Sometimes VSCode will pull a color from your theme, other times it uses black\n* `#4866FE` is our default", + "default": "#4866FE" + }, + "mind-reader.lineHighlighter.outlineWidth": { + "order": 8, + "type": "string", + "markdownDescription": "Set the outline width to be used by the line highlighter.\n\nSyntax: `medium` or `thin` or `thick` or `length` or `none`\n* `medium`: Specifies a medium outline. (usual default)\n* `thin`: Specifies a thin outline\n* `thick`: Specifies a thick outline\n* `length`: you to define the thickness of the outline in [length](https://www.w3schools.com/cssref/css_units.asp) units.\n* `none`: No outline width will be applied\n* `1px` is our default", + "default": "1px" + }, + "mind-reader.lineHighlighter.outlineStyle": { + "order": 9, + "type": "string", + "markdownDescription": "Set the outline style to be used by the line highlighter.\n\nSyntax: `none` or `hidden` or `dotted` or `dashed` or `solid` or `double` or `groove` or `ridge` or `inset` or `outset`\n* `none`: No border will be applied (usual default)\n* `hidden`: The same as `none`\n* `dotted`: Dotted border\n* `dashed`: Dashed border\n* `solid (our default)`: Solid border\n* `double`: Double border\n* `groove`: 3D grooved border, depends on the outline-color value.\n* `ridge`: 3D ridged border, depends on the outline-color value.\n* `inset`: 3D inset border, depends on the outline-color value.\n* `outset`: 3D outset border, depends on the outline-color value.", + "default": "solid" + }, + "mind-reader.lineHighlighter.borderColorTop": { + "order": 10, + "type": "string", + "markdownDescription": "Set the top border color to be used by the line highlighter.\n\nSyntax: _color_ or `transparent`\n\nAvailable color formats include:\n* `HEX(A)`: for Hexadecimal Colors: `#RRGGBB` or `#RRGGBBAA` to add transparency\n* `RGB(A)`: for RGB Colors: `rgb(red, green, blue)` or `rgba(red, green, blue, alpha)`\n* `HSL(A)`: for HSL Colors: `hsl(hue, saturation, lightness)` or `hsla(hue, saturation, lightness, alpha)`\n* `Predefined Color Names`: 140 color names are predefined in the HTML and CSS color specification: `blue`, `red`, `coral`, `brown`, [etc...](https://www.w3schools.com/colors/colors_names.asp)\n* `None`: For no color to be applied: Sometimes VSCode will pull a color from your theme, other times it uses black\n* `#FFFFFF` is our default", + "default": "#FFFFFF" + }, + "mind-reader.lineHighlighter.borderColorRight": { + "order": 11, + "type": "string", + "markdownDescription": "Set the right border color to be used by the line highlighter.\n\nSyntax: _color_ or `transparent`\n\nAvailable color formats include:\n* `HEX(A)`: for Hexadecimal Colors: `#RRGGBB` or `#RRGGBBAA` to add transparency\n* `RGB(A)`: for RGB Colors: `rgb(red, green, blue)` or `rgba(red, green, blue, alpha)`\n* `HSL(A)`: for HSL Colors: `hsl(hue, saturation, lightness)` or `hsla(hue, saturation, lightness, alpha)`\n* `Predefined Color Names`: 140 color names are predefined in the HTML and CSS color specification: `blue`, `red`, `coral`, `brown`, [etc...](https://www.w3schools.com/colors/colors_names.asp)\n* `None`: For no color to be applied: Sometimes VSCode will pull a color from your theme, other times it uses black\n* `#FFFFFF` is our default", + "default": "#FFFFFF" + }, + "mind-reader.lineHighlighter.borderColorBottom": { + "order": 12, + "type": "string", + "markdownDescription": "Set the bottom border color to be used by the line highlighter.\n\nSyntax: _color_ or `transparent`\n\nAvailable color formats include:\n* `HEX(A)`: for Hexadecimal Colors: `#RRGGBB` or `#RRGGBBAA` to add transparency\n* `RGB(A)`: for RGB Colors: `rgb(red, green, blue)` or `rgba(red, green, blue, alpha)`\n* `HSL(A)`: for HSL Colors: `hsl(hue, saturation, lightness)` or `hsla(hue, saturation, lightness, alpha)`\n* `Predefined Color Names`: 140 color names are predefined in the HTML and CSS color specification: `blue`, `red`, `coral`, `brown`, [etc...](https://www.w3schools.com/colors/colors_names.asp)\n* `None`: For no color to be applied: Sometimes VSCode will pull a color from your theme, other times it uses black\n* `#FFFFFF` is our default", + "default": "#FFFFFF" + }, + "mind-reader.lineHighlighter.borderColorLeft": { + "order": 13, + "type": "string", + "markdownDescription": "Set the left border color to be used by the line highlighter.\n\nSyntax: _color_ or `transparent`\n\nAvailable color formats include:\n* `HEX(A)`: for Hexadecimal Colors: `#RRGGBB` or `#RRGGBBAA` to add transparency\n* `RGB(A)`: for RGB Colors: `rgb(red, green, blue)` or `rgba(red, green, blue, alpha)`\n* `HSL(A)`: for HSL Colors: `hsl(hue, saturation, lightness)` or `hsla(hue, saturation, lightness, alpha)`\n* `Predefined Color Names`: 140 color names are predefined in the HTML and CSS color specification: `blue`, `red`, `coral`, `brown`, [etc...](https://www.w3schools.com/colors/colors_names.asp)\n* `None`: For no color to be applied: Sometimes VSCode will pull a color from your theme, other times it uses black\n* `#FFFFFF` is our default", + "default": "#FFFFFF" + }, + "mind-reader.lineHighlighter.borderWidthTop": { + "order": 14, + "type": "string", + "markdownDescription": "Set the top border width to be used by the line highlighter.\n\nSyntax: `medium` or `thin` or `thick` or `length` or `none`\n* `medium`: Specifies a medium border. (usual default)\n* `thin`: Specifies a thin border\n* `thick`: Specifies a thick border\n* `length`: you to define the thickness of the border in [length](https://www.w3schools.com/cssref/css_units.asp) units.\n* `none`: No border width will be applied\n* `1px` is our default", + "default": "1px" + }, + "mind-reader.lineHighlighter.borderWidthRight": { + "order": 15, + "type": "string", + "markdownDescription": "Set the right border width to be used by the line highlighter.\n\nSyntax: `medium` or `thin` or `thick` or `length` or `none`\n* `medium`: Specifies a medium border. (usual default)\n* `thin`: Specifies a thin border\n* `thick`: Specifies a thick border\n* `length`: you to define the thickness of the border in [length](https://www.w3schools.com/cssref/css_units.asp) units.\n* `none`: No border width will be applied\n* `16px` is our default\n\n#### \nborderWidthRight exhibits odd behavior, play around with different sizes to find what works best for your environment.", + "default": "16px" + }, + "mind-reader.lineHighlighter.borderWidthBottom": { + "order": 16, + "type": "string", + "markdownDescription": "Set the bottom border width to be used by the line highlighter.\n\nSyntax: `medium` or `thin` or `thick` or `length` or `none`\n* `medium`: Specifies a medium border. (usual default)\n* `thin`: Specifies a thin border\n* `thick`: Specifies a thick border\n* `length`: you to define the thickness of the border in [length](https://www.w3schools.com/cssref/css_units.asp) units.\n* `none`: No border width will be applied\n* `1px` is our default", + "default": "1px" + }, + "mind-reader.lineHighlighter.borderWidthLeft": { + "order": 17, + "type": "string", + "markdownDescription": "Set the left border width to be used by the line highlighter.\n\nSyntax: `medium` or `thin` or `thick` or `length` or `none`\n* `medium`: Specifies a medium border. (usual default)\n* `thin`: Specifies a thin border\n* `thick`: Specifies a thick border\n* `length`: you to define the thickness of the border in [length](https://www.w3schools.com/cssref/css_units.asp) units.\n* `none`: No border width will be applied\n* `1px` is our default", + "default": "1px" + }, + "mind-reader.lineHighlighter.borderStyleTop": { + "order": 18, + "type": "string", + "markdownDescription": "Set the top border style to be used by the line highlighter.\n\nSyntax: `none` or `hidden` or `dotted` or `dashed` or `solid` or `double` or `groove` or `ridge` or `inset` or `outset`\n* `none`: No border will be applied (usual default)\n* `hidden`: The same as `none`\n* `dotted`: Dotted border\n* `dashed`: Dashed border\n* `solid (our default)`: Solid border\n* `double`: Double border\n* `groove`: 3D grooved border, depends on the border-color value.\n* `ridge`: 3D ridged border, depends on the border-color value.\n* `inset`: 3D inset border, depends on the border-color value.\n* `outset`: 3D outset border, depends on the border-color value.", + "default": "solid" + }, + "mind-reader.lineHighlighter.borderStyleRight": { + "order": 19, + "type": "string", + "markdownDescription": "Set the right border style to be used by the line highlighter.\n\nSyntax: `none` or `hidden` or `dotted` or `dashed` or `solid` or `double` or `groove` or `ridge` or `inset` or `outset`\n* `none`: No border will be applied (usual default)\n* `hidden`: The same as `none`\n* `dotted`: Dotted border\n* `dashed`: Dashed border\n* `solid (our default)`: Solid border\n* `double`: Double border\n* `groove`: 3D grooved border, depends on the border-color value.\n* `ridge`: 3D ridged border, depends on the border-color value.\n* `inset`: 3D inset border, depends on the border-color value.\n* `outset`: 3D outset border, depends on the border-color value.", + "default": "solid" + }, + "mind-reader.lineHighlighter.borderStyleBottom": { + "order": 20, + "type": "string", + "markdownDescription": "Set the bottom border style to be used by the line highlighter.\n\nSyntax: `none` or `hidden` or `dotted` or `dashed` or `solid` or `double` or `groove` or `ridge` or `inset` or `outset`\n* `none`: No border will be applied (usual default)\n* `hidden`: The same as `none`\n* `dotted`: Dotted border\n* `dashed`: Dashed border\n* `solid (our default)`: Solid border\n* `double`: Double border\n* `groove`: 3D grooved border, depends on the border-color value.\n* `ridge`: 3D ridged border, depends on the border-color value.\n* `inset`: 3D inset border, depends on the border-color value.\n* `outset`: 3D outset border, depends on the border-color value.", + "default": "solid" + }, + "mind-reader.lineHighlighter.borderStyleLeft": { + "order": 21, + "type": "string", + "markdownDescription": "Set the left border style to be used by the line highlighter.\n\nSyntax: `none` or `hidden` or `dotted` or `dashed` or `solid` or `double` or `groove` or `ridge` or `inset` or `outset`\n* `none`: No border will be applied (usual default)\n* `hidden`: The same as `none`\n* `dotted`: Dotted border\n* `dashed`: Dashed border\n* `solid (our default)`: Solid border\n* `double`: Double border\n* `groove`: 3D grooved border, depends on the border-color value.\n* `ridge`: 3D ridged border, depends on the border-color value.\n* `inset`: 3D inset border, depends on the border-color value.\n* `outset`: 3D outset border, depends on the border-color value.", + "default": "solid" + }, + "mind-reader.lineHighlighter.fontStyle": { + "order": 22, + "type": "string", + "markdownDescription": "Set the font style to be used by the line highlighter.\n\nSyntax: `normal` or `italic` or `oblique` or `none`\n* `normal (our default)`: Displays a normal font style. This is default\n* `italic`: Displays an italic font style\n* `oblique`: Displays an oblique font style\n* `none`: No font style will be applied", + "default": "normal" + }, + "mind-reader.lineHighlighter.fontWeight": { + "order": 23, + "type": "string", + "markdownDescription": "Set the font weight to be used by the line highlighter.\n\nSyntax: `normal` or `bold` or `bolder` or `lighter` or _number_ or `none`\n* `normal`: Normal Characters. (usual default)\n* `bold`: Thick Characters\n* `bolder (our default)`: Thicker Characters\n* `lighter`: Lighter Characters\n * _number_: From `thin` to `thick` characters: `100`, `200`, `300`, `400`, `500`, `600`, `700`, `800`, or `900`: `400` is the same as normal, and `700` is the same as bold.\n* `none`: No font weight will be applied", + "default": "bolder" + }, + "mind-reader.lineHighlighter.textDecoration": { + "order": 24, + "type": "string", + "markdownDescription": "Set the text decoration to be used by the line highlighter.\n\nSyntax: `(text-decoration-line)` `(text-decoration-color)` `(text-decoration-style)` `(text-decoration-thickness)`\n* `text-decoration-line (required)`: Sets the kind of text decoration to use: `underline`, `overline`, `line-through`\n* `text-decoration-color`: Sets the color of the text decoration\n* `text-decoration-style`: Sets the style of the text decoration: `solid`, `wavy`, `dotted`, `dashed`, `double`\n* `text-decoration-thickness`: Sets the thickness of the decoration line\n* `none (our default)`: No text decorations will be applied\n\n`Examples`:\n1. underline blue wavy 5px\n2. line-through\n3. underline overline dotted red", + "default": "none" + }, + "mind-reader.lineHighlighter.textColor": { + "order": 25, + "type": "string", + "markdownDescription": "Set the text color to be used by the line highlighter.\n\nSyntax: _color_ or `transparent`\n\nAvailable color formats include:\n* `HEX(A)`: for Hexadecimal Colors: `#RRGGBB` or `#RRGGBBAA` to add transparency\n* `RGB(A)`: for RGB Colors: `rgb(red, green, blue)` or `rgba(red, green, blue, alpha)`\n* `HSL(A)`: for HSL Colors: `hsl(hue, saturation, lightness)` or `hsla(hue, saturation, lightness, alpha)`\n* `Predefined Color Names`: 140 color names are predefined in the HTML and CSS color specification: `blue`, `red`, `coral`, `brown`, [etc...](https://www.w3schools.com/colors/colors_names.asp)\n* `None`: For no color to be applied: Sometimes VSCode will pull a color from your theme, other times it uses black\n* `#FFFFFF` is our default", + "default": "#FFFFFF" + } + } + }], "views": { "MindReader": [{ "id": "accessActions", From 940a8ed3177110583303da5547bb7847d6b2de58 Mon Sep 17 00:00:00 2001 From: tel0065 <77864718+tel0065@users.noreply.github.com> Date: Thu, 5 May 2022 11:53:02 -0500 Subject: [PATCH 13/19] Configuration Variables Updated Updated configuration variables to match package.json calls, added TODO line at the top --- src/lineHighlighter.ts | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/lineHighlighter.ts b/src/lineHighlighter.ts index 65445f7..e8ebc13 100644 --- a/src/lineHighlighter.ts +++ b/src/lineHighlighter.ts @@ -5,6 +5,7 @@ * ? ██╔══██║██║██║ ██║██╔══██║██║ ██║██║ ██║██╔══██║ ██║ ╚════╝██║ ██║ * ? ██║ ██║██║╚██████╔╝██║ ██║███████╗██║╚██████╔╝██║ ██║ ██║ ██║ ██║ * ? ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ +* TODO: Add ability for user to change options through a command pallette configurator **/ 'use strict'; import { Position, window, workspace, TextEditorDecorationType, TextEditor, WorkspaceConfiguration, Range } from 'vscode'; @@ -151,27 +152,27 @@ function lineHighlighter(): void { * ? Colors Can be input with the following values: * * https://www.w3schools.com/cssref/css_colors.asp for string based color values * * Hex -> # | rgb(###, ###, ###) | rgba(###, ###, ###, ###) | hsla(##, ##%, ##%, .#) - * + * * ? Width Input Values * ! Some work better than others, if one isn't working try a different method: - * * thin | medium | thick | px | rem | em | cm | % | inherit + * * thin | medium | thick | px | rem | em | cm * * ? Other values - * * font-style : normal|italic|oblique|initial|inherit; - * * font-weight : normal|bold|bolder|lighter|number|initial|inherit; - * * border-style : none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset|initial|inherit; - * * outline-style : none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset|initial|inherit; - * * outline-width : medium|thin|thick|length|initial|inherit; - * * border-width : medium|thin|thick|length|initial|inherit; - * ! https://www.w3schools.com/cssref/pr_text_text-decoration.asp for text-decoration - * + * * font-style : none|normal|italic|oblique; + * * font-weight : none|normal|bold|bolder|lighter|number; + * * border-style : none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset; + * * outline-style : none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset; + * * outline-width : none|medium|thin|thick|length; + * * border-width : none|medium|thin|thick|length; + * ? https://www.w3schools.com/cssref/pr_text_text-decoration.asp for text-decoration + * * ! borderWidthRight acts weirdly, on my system 16px works best with the other directions set to 1px * * @returns highlighterStyle */ function getHighlighterStyle(): TextEditorDecorationType { - // Used so we don't have to type out workspace.getConfiguration('mindReader.lineHighlighter') on every line, ie: shorthand - const userConfig: WorkspaceConfiguration = workspace.getConfiguration('mindReader.lineHighlighter'); + // Used so we don't have to type out workspace.getConfiguration('mind-reader.lineHighlighter') on every line, ie: shorthand + const userConfig: WorkspaceConfiguration = workspace.getConfiguration('mind-reader.lineHighlighter'); const borderWidthTop : string = userConfig.get('borderWidthTop') || "1px"; const borderWidthRight : string = userConfig.get('borderWidthRight') || "16px"; @@ -237,9 +238,9 @@ function lineHighlighter(): void { * otherwise, "isEnabled" is listed in the settings * - so we just pull its value */ - (workspace.getConfiguration("mindReader.lineHighlighter").get("isEnabled") === undefined) + (workspace.getConfiguration("mind-reader.lineHighlighter").get("isEnabled") === undefined) ? (enabledStatus = true) - : (enabledStatus = workspace.getConfiguration("mindReader.lineHighlighter").get("isEnabled")); + : (enabledStatus = workspace.getConfiguration("mind-reader.lineHighlighter").get("isEnabled")); // return the enabledStatus return enabledStatus; @@ -255,9 +256,9 @@ function lineHighlighter(): void { * otherwise, "isEnabled" is listed in the settings * - so we just pull its value */ - (workspace.getConfiguration("mindReader.lineHighlighter").get("multiLineIsEnabled") === undefined) + (workspace.getConfiguration("mind-reader.lineHighlighter").get("multiLineIsEnabled") === undefined) ? (multiLineIsEnabled = true) - : (multiLineIsEnabled = workspace.getConfiguration("mindReader.lineHighlighter").get("multiLineIsEnabled")); + : (multiLineIsEnabled = workspace.getConfiguration("mind-reader.lineHighlighter").get("multiLineIsEnabled")); // return the enabledStatus return multiLineIsEnabled; From bb0b1be0d41e0bfe0041f3600a8ae61120d5d070 Mon Sep 17 00:00:00 2001 From: tel0065 <77864718+tel0065@users.noreply.github.com> Date: Thu, 5 May 2022 11:54:32 -0500 Subject: [PATCH 14/19] Updated Messages Changed the wording of the loading message --- src/extension.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 2aa31e5..fcc634a 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -14,8 +14,7 @@ export const logger = new Logger(outputChannel); let parser: pl.Parser = new pl.Parser(); export function activate(context: vscode.ExtensionContext) { - vscode.window.showInformationMessage("Mind_Reader is loaded!"); - + // Engage LineHighlighter lineHighlighter(); parser.parse("Beep Boop"); @@ -41,6 +40,8 @@ export function activate(context: vscode.ExtensionContext) { let hubProvider = new CommandNodeProvider(hubCommands); vscode.window.registerTreeDataProvider("hubActions", hubProvider); + + vscode.window.showInformationMessage("Mind Reader finished loading!"); } export function deactivate() {} From a10200f2bca5ad7694ede14db3d473c68525d0d1 Mon Sep 17 00:00:00 2001 From: tel0065 <77864718+tel0065@users.noreply.github.com> Date: Thu, 5 May 2022 11:56:39 -0500 Subject: [PATCH 15/19] Updated indention Indention was incorrect, fixed. --- src/pylex/lexer.ts | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/pylex/lexer.ts b/src/pylex/lexer.ts index 9135aeb..b5b1f9a 100644 --- a/src/pylex/lexer.ts +++ b/src/pylex/lexer.ts @@ -1,9 +1,9 @@ -import { LineToken } from '.'; +import { LineToken } from '.'; import { Symbol, EOFTOKEN, TabInfo } from './token'; type Rule = { pattern: RegExp, - type: Symbol, + type : Symbol, }; /** @@ -11,8 +11,7 @@ type Rule = { * The first item is a recognition pattern, used to recognize the token * the second item is the token type */ -const rules: Rule[] = [ - { +const rules: Rule[] = [{ pattern: /^\s*def\s+(?[a-zA-Z_][a-zA-Z0-9_]*)\(/, type: Symbol.FUNCTION }, @@ -62,8 +61,8 @@ const rules: Rule[] = [ * Line-By-Line Lexer */ export default class Lexer { - private textLines: string[] = []; // array of text lines - private pos: number = 0; + private textLines : string[] = []; // array of text lines + private pos : number = 0; private _currToken: LineToken = EOFTOKEN; /** @@ -93,8 +92,8 @@ export default class Lexer { * @param `text` The new text to lex. */ restart(text ? : string): void { - this.pos = 0; - this._currToken = EOFTOKEN; // if no input, already on EOFTOKEN + this.pos = 0; + this._currToken = EOFTOKEN; // if no input, already on EOFTOKEN if (text) { this.textLines = text.split('\n'); this.next(); // advance to the first token @@ -120,9 +119,9 @@ export default class Lexer { // Until a LineToken is found, or EOF while (this.pos < this.textLines.length) { - const line: string = this.textLines[this.pos]; + const line : string = this.textLines[this.pos]; const indent: number = Lexer.getIndent(line, this.tabFmt!); - let token: LineToken; + let token : LineToken; for (var r of rules) { // Does line match pattern? @@ -131,8 +130,7 @@ export default class Lexer { // Yes... if (match.groups) { token = new LineToken(r.type, this.pos, indent, match.groups["attr"]); - } - else { + } else { token = new LineToken(r.type, this.pos, indent); } @@ -148,8 +146,7 @@ export default class Lexer { if (/^\s*(#.*)?$/.test(line)) { // "empty" line token = new LineToken(Symbol.EMPTY, this.pos, 999999); - } - else { + } else { // This is an INDENT token token = new LineToken(Symbol.INDENT, this.pos, indent); } @@ -218,8 +215,7 @@ export default class Lexer { if (tabFmt.hard) { // used tabs indent = leadingSpace; - } - else { + } else { // use spaces indent = Math.ceil(leadingSpace / tabFmt.size!); } From 09b4d41054ad426550e000012495460a1fdbf6d0 Mon Sep 17 00:00:00 2001 From: tel0065 <77864718+tel0065@users.noreply.github.com> Date: Thu, 5 May 2022 11:59:42 -0500 Subject: [PATCH 17/19] Code cleaned Removed commented out code --- src/commands/nav.ts | 92 --------------------------------------------- 1 file changed, 92 deletions(-) diff --git a/src/commands/nav.ts b/src/commands/nav.ts index a9be064..a33775b 100755 --- a/src/commands/nav.ts +++ b/src/commands/nav.ts @@ -1,6 +1,4 @@ import * as vscode from "vscode"; -// import * as fs from "fs"; -// import * as os from 'os'; import { CommandEntry } from "./commandEntry"; @@ -89,10 +87,6 @@ function openWebview(): void { panel.webview.html = getWebviewContent(); } -// function getWebviewContent(filepath: string) { -// return fs.readFileSync(filepath, {encoding: 'utf-8'}); -// } - function getWebviewContent() { return ` @@ -138,89 +132,3 @@ function getWebviewContent() { `; } - -// export function getPlatform(): 'windows' | 'mac' | 'linux' | undefined { -// let platform: 'windows' | 'mac' | 'linux' | undefined; - -// 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'); From b51507b76f95c8cc73e389b862507f9214d5affc Mon Sep 17 00:00:00 2001 From: tel0065 <77864718+tel0065@users.noreply.github.com> Date: Thu, 5 May 2022 12:07:13 -0500 Subject: [PATCH 18/19] Version increase Major version increase: 1.0.0 -> 2.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 23a4863..3b9af28 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "email" : "PedroAlvarez3@my.unt.edu" } ], - "version": "1.0.0", + "version": "2.0.0", "engines": { "vscode": "^1.60.0" }, From be60f884fee676e810e05cfbc4a80b539503d8d2 Mon Sep 17 00:00:00 2001 From: tel0065 <77864718+tel0065@users.noreply.github.com> Date: Thu, 5 May 2022 12:15:39 -0500 Subject: [PATCH 19/19] naming scheme changed mindReader to mind-reader to be consistent with other parts of the extension --- src/commands/nav.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/nav.ts b/src/commands/nav.ts index a33775b..57f8ef7 100755 --- a/src/commands/nav.ts +++ b/src/commands/nav.ts @@ -78,7 +78,7 @@ export const navCommands: CommandEntry[] = [ // COMMAND CALLBACK IMPLEMENTATIONS function openWebview(): void { const panel = vscode.window.createWebviewPanel( - "mindReader", // Identifies the type of the webview. Used internally + "mind-reader", // 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. {}