diff --git a/package.json b/package.json index eb0432b66..fe530a08d 100644 --- a/package.json +++ b/package.json @@ -417,11 +417,6 @@ "default": true, "description": "If enabled, will log spool files from command executed. You can find it under Output for 'IBM i Compile Log'." }, - "code-for-ibmi.showSeuColors": { - "type": "boolean", - "default": false, - "description": "If enabled, will colourise lines like SEU. Only supports source members. Requires restart if changed." - }, "code-for-ibmi.clearOutputEveryTime": { "type": "boolean", "default": true, diff --git a/src/filesystems/qsys/extendedContent.ts b/src/filesystems/qsys/extendedContent.ts index 42a55e996..c65ff4336 100644 --- a/src/filesystems/qsys/extendedContent.ts +++ b/src/filesystems/qsys/extendedContent.ts @@ -11,10 +11,6 @@ const writeFileAsync = util.promisify(fs.writeFile); const DEFAULT_RECORD_LENGTH = 80; -// Translate x'25' to x'2F' and back, or x'25' will become x'0A' (linefeed)! -const SEU_GREEN_UL_RI = `x'25'`; -const SEU_GREEN_UL_RI_temp = `x'2F'`; - export class ExtendedIBMiContent { constructor(readonly sourceDateHandler: SourceDateHandler) { @@ -33,7 +29,6 @@ export class ExtendedIBMiContent { const config = instance.getConfig(); const connection = instance.getConnection(); if (connection && config && content) { - const sourceColourSupport = IBMi.connectionManager.get(`showSeuColors`); const tempLib = config.tempLibrary; const alias = getAliasName(uri); const aliasPath = `${tempLib}.${alias}`; @@ -49,17 +44,10 @@ export class ExtendedIBMiContent { this.sourceDateHandler.recordLengths.set(alias, recordLength); } - let rows; - if (sourceColourSupport) - rows = await connection.runSQL( - `select srcdat, rtrim(translate(srcdta, ${SEU_GREEN_UL_RI_temp}, ${SEU_GREEN_UL_RI})) as srcdta from ${aliasPath}`, - {forceSafe: true} - ); - else - rows = await connection.runSQL( - `select srcdat, srcdta from ${aliasPath}`, - {forceSafe: true} - ); + let rows = await connection.runSQL( + `select srcdat, srcdta from ${aliasPath}`, + {forceSafe: true} + ); if (rows.length === 0) { rows.push({ @@ -133,7 +121,6 @@ export class ExtendedIBMiContent { const { library, file, name } = connection.parserMemberPath(uri.path); const tempRmt = connection.getTempRemote(library + file + name); if (tempRmt) { - const sourceColourSupport = IBMi.connectionManager.get(`showSeuColors`); const tmpobj = await tmpFile(); const sourceData = body.split(`\n`); @@ -150,16 +137,9 @@ export class ExtendedIBMiContent { sourceData[i] = sourceData[i].substring(0, recordLength); } - // We only want to do the translate when source colours at enabled. - // For large sources, translate adds a bunch of time to the saving process. - if (sourceColourSupport) - rows.push( - `(${sequence}, ${sourceDates[i] ? sourceDates[i].padEnd(6, `0`) : `0`}, translate('${escapeString(sourceData[i])}', ${SEU_GREEN_UL_RI}, ${SEU_GREEN_UL_RI_temp}))`, - ); - else - rows.push( - `(${sequence}, ${sourceDates[i] ? sourceDates[i].padEnd(6, `0`) : `0`}, '${escapeString(sourceData[i])}')`, - ); + rows.push( + `(${sequence}, ${sourceDates[i] ? sourceDates[i].padEnd(6, `0`) : `0`}, '${escapeString(sourceData[i])}')`, + ); } diff --git a/src/instantiate.ts b/src/instantiate.ts index 2944b6b13..e4cdff605 100644 --- a/src/instantiate.ts +++ b/src/instantiate.ts @@ -12,7 +12,6 @@ import { registerConnectionCommands } from './commands/connection'; import { registerOpenCommands } from './commands/open'; import { registerPasswordCommands } from './commands/password'; import { QSysFS } from "./filesystems/qsys/QSysFs"; -import { SEUColorProvider } from "./languages/general/SEUColorProvider"; import { ActionsUI } from './webviews/actions'; import { VariablesUI } from "./webviews/variables"; import IBMi from "./api/IBMi"; @@ -97,11 +96,6 @@ export async function loadAllofExtension(context: vscode.ExtensionContext) { }) ); - // Color provider - if (IBMi.connectionManager.get(`showSeuColors`)) { - SEUColorProvider.intitialize(context); - } - // Register git events based on workspace folders if (vscode.workspace.workspaceFolders) { setupGitEventHandler(context); diff --git a/src/languages/general/SEUColorProvider.ts b/src/languages/general/SEUColorProvider.ts deleted file mode 100644 index 1d08b6381..000000000 --- a/src/languages/general/SEUColorProvider.ts +++ /dev/null @@ -1,80 +0,0 @@ -import vscode from 'vscode'; - -import { SEUColors } from './SEUColors'; - -const hidden = vscode.window.createTextEditorDecorationType({ - letterSpacing: `-1em`, - opacity: `0`, -}); - -export namespace SEUColorProvider { - let _timeout: NodeJS.Timeout; - - export function intitialize(context: vscode.ExtensionContext) { - context.subscriptions.push( - vscode.workspace.onDidChangeTextDocument(event => { - clearTimeout(_timeout); - _timeout = setTimeout(() => { - refreshDocumentColors(event.document); - }, 2000); - }), - - vscode.window.onDidChangeActiveTextEditor(event => { - if (event?.document) { - refreshDocumentColors(event.document); - } - }) - - ); - } - - function refreshDocumentColors(document: vscode.TextDocument) { - if (document.uri.scheme === `member`) { - // This should only work for members. - // We don't want to support this everywhere because it's ugly. - - const activeEditor = vscode.window.activeTextEditor; - if (document.uri.path === activeEditor?.document.uri.path) { - const hiddenDecorations : vscode.DecorationOptions[] = []; - const colorDecorations : Record = {}; - - // Set up the arrays - SEUColors.forEach(name => { - colorDecorations[name] = []; - }); - - // Find the lines and the bytes and all that... - for (let lineIndex = 0; lineIndex < document.lineCount; lineIndex++) { - const line = document.lineAt(lineIndex); - - const lineBytes = Buffer.from(line.text); - - SEUColors.forEach((name, definition) => { - const byteIndex = lineBytes.indexOf(definition.bytes); - if (byteIndex >= 0) { - colorDecorations[name].push({ - range: new vscode.Range(lineIndex, byteIndex + definition.bytes.length - 1, lineIndex, line.text.length) - }); - - hiddenDecorations.push({ - range: new vscode.Range(lineIndex, byteIndex, lineIndex, byteIndex + 1), - renderOptions: { - after: { - contentText: ``.padEnd(definition.bytes.length), - } - } - }); - } - }) - } - - // Then set the decorations - SEUColors.forEach((name, definition) => { - activeEditor.setDecorations(definition.decoration, colorDecorations[name]); - }); - - activeEditor.setDecorations(hidden, hiddenDecorations); - } - } - } -} \ No newline at end of file diff --git a/src/languages/general/SEUColors.ts b/src/languages/general/SEUColors.ts deleted file mode 100644 index fa2130087..000000000 --- a/src/languages/general/SEUColors.ts +++ /dev/null @@ -1,222 +0,0 @@ -import vscode from 'vscode'; - -export namespace SEUColors { - interface Color { - bytes: Buffer - decoration: vscode.TextEditorDecorationType - } - - const ColorDefinitions: Record = { - blue: { - bytes: Buffer.from([194, 154]), - decoration: vscode.window.createTextEditorDecorationType({ - color: `#3565cc`, - rangeBehavior: vscode.DecorationRangeBehavior.ClosedOpen, - }) - }, - blue_ri: { - bytes: Buffer.from([194, 155]), - decoration: vscode.window.createTextEditorDecorationType({ - backgroundColor: `#3565cc`, - color: `white`, - rangeBehavior: vscode.DecorationRangeBehavior.ClosedOpen, - }) - }, - blue_ul: { - bytes: Buffer.from([194, 158]), - decoration: vscode.window.createTextEditorDecorationType({ - color: `#3565cc`, - textDecoration: `; border-bottom: 1px solid #3565cc;` - }) - }, - green: { - bytes: Buffer.from([194, 128]), - decoration: vscode.window.createTextEditorDecorationType({ - color: `#28d15d`, - }) - }, - green_ri: { - bytes: Buffer.from([194, 129]), - decoration: vscode.window.createTextEditorDecorationType({ - backgroundColor: `#28d15d`, - color: `black`, - }) - }, - green_ul: { - bytes: Buffer.from([194, 132]), - decoration: vscode.window.createTextEditorDecorationType({ - color: `#28d15d`, - textDecoration: `; border-bottom: 1px solid #28d15d;` - }) - }, - green_ul_ri: { - bytes: Buffer.from([7]), - decoration: vscode.window.createTextEditorDecorationType({ - backgroundColor: `#28d15d`, - color: `black`, - textDecoration: `; border-bottom: 1px solid black;` - }) - }, - pink: { - bytes: Buffer.from([194, 152]), - decoration: vscode.window.createTextEditorDecorationType({ - color: `#cf259c`, - }) - }, - pink_ri: { - bytes: Buffer.from([194, 153]), - decoration: vscode.window.createTextEditorDecorationType({ - backgroundColor: `#cf259c`, - color: `white`, - }) - }, - pink_ul: { - bytes: Buffer.from([20]), - decoration: vscode.window.createTextEditorDecorationType({ - color: `#cf259c`, - textDecoration: `; border-bottom: 1px solid #cf259c;` - }) - }, - pink_ul_ri: { - bytes: Buffer.from([21]), - decoration: vscode.window.createTextEditorDecorationType({ - backgroundColor: `#cf259c`, - color: `white`, - textDecoration: `; border-bottom: 1px solid white;` - }) - }, - red: { - bytes: Buffer.from([194, 136]), - decoration: vscode.window.createTextEditorDecorationType({ - color: `#cf2331`, - }) - }, - // red_bl and red are the same - red_bl: { - bytes: Buffer.from([194, 138]), - decoration: vscode.window.createTextEditorDecorationType({ - color: `#cf2331`, - }) - }, - red_ri: { - bytes: Buffer.from([194, 137]), - decoration: vscode.window.createTextEditorDecorationType({ - backgroundColor: `#cf2331`, - color: `white`, - }), - }, - // red_ri_bl and red_ri are the same - red_ri_bl: { - bytes: Buffer.from([194, 139]), - decoration: vscode.window.createTextEditorDecorationType({ - backgroundColor: `#cf2331`, - color: `white`, - }), - }, - red_ul: { - bytes: Buffer.from([194, 140]), - decoration: vscode.window.createTextEditorDecorationType({ - color: `#cf2331`, - textDecoration: `; border-bottom: 1px solid #cf2331;` - }) - }, - red_ri_ul: { - bytes: Buffer.from([5]), - decoration: vscode.window.createTextEditorDecorationType({ - backgroundColor: `#cf2331`, - color: `white`, - textDecoration: `; border-bottom: 1px solid white;` - }), - }, - turquoise: { - bytes: Buffer.from([194, 144]), - decoration: vscode.window.createTextEditorDecorationType({ - color: `#22c4d6`, - }) - }, - turquoise_ri: { - bytes: Buffer.from([194, 145]), - decoration: vscode.window.createTextEditorDecorationType({ - backgroundColor: `#22c4d6`, - color: `black`, - }) - }, - turquoise_ul: { - bytes: Buffer.from([194, 148]), - decoration: vscode.window.createTextEditorDecorationType({ - color: `#22c4d6`, - textDecoration: `; border-bottom: 1px solid #22c4d6;` - }) - }, - // turquoise_ul_ri is the same as turquoise_ri - turquoise_ul_ri: { - bytes: Buffer.from([194, 149]), - decoration: vscode.window.createTextEditorDecorationType({ - backgroundColor: `#22c4d6`, - color: `black`, - textDecoration: `; border-bottom: 1px solid black;` - }) - }, - white: { - bytes: Buffer.from([194, 130]), - decoration: vscode.window.createTextEditorDecorationType({ - light: { - color: `#000000`, - }, - dark: { - color: `#ffffff`, - } - }) - }, - white_ri: { - bytes: Buffer.from([194, 131]), - decoration: vscode.window.createTextEditorDecorationType({ - light: { - color: `#ffffff`, - backgroundColor: `#000000`, - }, - dark: { - color: `#000000`, - backgroundColor: `#ffffff`, - } - }) - }, - white_ul: { - bytes: Buffer.from([23]), - decoration: vscode.window.createTextEditorDecorationType({ - light: { - color: `#000000`, - textDecoration: `; border-bottom: 1px solid #000000;` - }, - dark: { - color: `#ffffff`, - textDecoration: `; border-bottom: 1px solid #ffffff;` - } - }) - }, - yellow: { - bytes: Buffer.from([22]), - decoration: vscode.window.createTextEditorDecorationType({ - color: `#f4c842`, - }) - }, - yellow_ri: { - bytes: Buffer.from([194, 147]), - decoration: vscode.window.createTextEditorDecorationType({ - color: `#000000`, - backgroundColor: `#f4c842` - }) - }, - yellow_ul: { - bytes: Buffer.from([194, 150]), - decoration: vscode.window.createTextEditorDecorationType({ - color: `#f4c842`, - textDecoration: `; border-bottom: 1px solid #f4c842;` - }) - } - }; - - export function forEach(cb: (name: string, color: Color) => void) { - Object.entries(ColorDefinitions).forEach(c => cb(c[0], c[1])); - } -} \ No newline at end of file