Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added options to change background and border colors of highlighting #17

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -185,6 +187,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
Expand Down
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)."
}
}
},
Expand Down
27 changes: 18 additions & 9 deletions src/trailing-spaces/trailing-spaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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; };
Expand Down Expand Up @@ -65,12 +61,25 @@ export class TrailingSpaces {
deleteModifiedLinesOnly: this.config.get<boolean>("deleteModifiedLinesOnly"),
syntaxIgnore: this.config.get<string[]>("syntaxIgnore"),
trimOnSave: this.config.get<boolean>("trimOnSave"),
saveAfterTrim: this.config.get<boolean>("saveAfterTrim")
saveAfterTrim: this.config.get<boolean>("saveAfterTrim"),
backgroundColor: this.config.get<string>("backgroundColor"),
borderColor: this.config.get<string>("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) => {
Expand Down