From 23d9d7679b1dc6537c0bdbd42ba21f3e24a46621 Mon Sep 17 00:00:00 2001 From: Nikita Yustovskiy Date: Fri, 1 Jun 2018 15:55:10 +0300 Subject: [PATCH 1/2] Added an option to change background and border colors of highlighting --- README.md | 20 +++++++++++++++++++ package.json | 10 ++++++++++ src/trailing-spaces/trailing-spaces.ts | 27 +++++++++++++++++--------- 3 files changed, 48 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 724f8e8..590b9a8 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,26 @@ bat, c, clojure, coffeescript, cpp, css, dockerfile, fsharp, go, groovy, handleb For the most recent list of langauges, please use the `languages.getLanguages()` function (details [here](https://code.visualstudio.com/docs/extensionAPI/vscode-api#languages.getLanguages)). +### Background Color + +*Default: rgba(255,0,0,0.3)* + +Trailing spaces highlighting has a background color. To set up another color change the setting: + +``` js +{ "trailing-spaces.backgroundColor": "rgba(255,0,0,0.3)" } +``` + +### Border Color + +*Default: rgba(255,100,100,0.15)* + +Trailing spaces highlighting has a border color. To set up another color change the setting: + +``` js +{ "trailing-spaces.backgroundColor": "rgba(255,100,100,0.15)" } +``` + ### For power-users only! #### The matching pattern diff --git a/package.json b/package.json index 5550579..8e6602f 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,16 @@ "type": "boolean", "default": false, "description": "By default, deleting trailing spaces does not cause the document to be saved. Set to true to force saving after trailing spaces have been deleted. This setting is irrelevant and will be ignored if trimOnSave is true." + }, + "trailing-spaces.backgroundColor": { + "type": "string", + "default": "rgba(255,0,0,0.3)", + "description": "By default, rgba(255,0,0,0.3)." + }, + "trailing-spaces.borderColor": { + "type": "string", + "default": "rgba(255,100,100,0.15)", + "description": "By default, rgba(255,100,100,0.15)." } } }, diff --git a/src/trailing-spaces/trailing-spaces.ts b/src/trailing-spaces/trailing-spaces.ts index 0916ffd..635ad02 100644 --- a/src/trailing-spaces/trailing-spaces.ts +++ b/src/trailing-spaces/trailing-spaces.ts @@ -22,20 +22,16 @@ export interface TralingSpacesSettings { deleteModifiedLinesOnly: boolean, syntaxIgnore: string[], trimOnSave: boolean, - saveAfterTrim: boolean + saveAfterTrim: boolean, + backgroundColor: string, + borderColor: string } export class TrailingSpaces { private logger: ILogger; private config: Config; - private decorationOptions: vscode.DecorationRenderOptions = { - borderRadius: "3px", - borderWidth: "1px", - borderStyle: "solid", - backgroundColor: "rgba(255,0,0,0.3)", - borderColor: "rgba(255,100,100,0.15)" - }; + private decorationOptions: vscode.DecorationRenderOptions; private decorationType: vscode.TextEditorDecorationType; private matchedRegions: { [id: string]: TrailingRegions; }; private onDisk: { [id: string]: string; }; @@ -65,12 +61,25 @@ export class TrailingSpaces { deleteModifiedLinesOnly: this.config.get("deleteModifiedLinesOnly"), syntaxIgnore: this.config.get("syntaxIgnore"), trimOnSave: this.config.get("trimOnSave"), - saveAfterTrim: this.config.get("saveAfterTrim") + saveAfterTrim: this.config.get("saveAfterTrim"), + backgroundColor: this.config.get("backgroundColor"), + borderColor: this.config.get("borderColor") } + this.decorationOptions = this.getDecorationOptions(); this.matchedRegions = {}; this.refreshLanguagesToIgnore(); } + private getDecorationOptions() { + return { + borderRadius: "3px", + borderWidth: "1px", + borderStyle: "solid", + backgroundColor: this.settings.backgroundColor, + borderColor: this.settings.borderColor + } + } + private refreshLanguagesToIgnore() { this.languagesToIgnore = {}; this.settings.syntaxIgnore.map((language: string) => { From eb68f7e862febafeb5971d5a3d75e81a49bcd604 Mon Sep 17 00:00:00 2001 From: Nikita Yustovskiy Date: Fri, 8 Jun 2018 16:09:22 +0300 Subject: [PATCH 2/2] Added new items to the readme menu --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 590b9a8..37e9e02 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ This extension is a port of the popular [Sublime Text](https://www.sublimetext.c - [Save After Trim](#save-after-trim) - [Live Matching vs On-demand Matching](#live-matching-vs-on-demand-matching) - [Ignore Syntax](#ignore-syntax) + - [Background Color](#background-color) + - [Border Color](#border-color) - [For power-users only!](#for-power-users-only) - [The matching pattern](#the-matching-pattern)