Files
vscode-extension-samples/decorator-sample/README.md

32 lines
1.5 KiB
Markdown
Raw Permalink Normal View History

2018-10-28 22:29:18 +01:00
# Decorator Sample
2015-11-05 17:33:07 +01:00
2018-10-28 22:29:18 +01:00
This folder contains a sample VS code extension that demonstrates the editor decorator API.
2015-11-05 17:33:07 +01:00
The sample creates a decoration for each number that appears in the active editor. It
demonstrates some of the decorator features such as borders, background colors, cursors
2018-10-28 22:29:18 +01:00
and hovers.
2018-10-29 08:34:37 +01:00
The sample also shows the use of a user defined themeable color. Instead of hardcoding a color value this allows users (and themes) to redefine the color in the user settings.
2015-11-05 17:33:07 +01:00
2016-12-30 12:05:24 +01:00
![sample](preview.png)
2018-10-28 22:29:18 +01:00
## VSCode API
The sample code show the usage of the vscode.[`TextEditor.setDecorations`](https://code.visualstudio.com/api/references/vscode-api#TextEditor.setDecorations) and [`vscode.window.createTextEditorDecorationType`](https://code.visualstudio.com/api/references/vscode-api#window.createTextEditorDecorationType) APIs as well as the `colors` contribution point.
2018-10-28 22:29:18 +01:00
2018-10-28 22:31:00 +01:00
## Running the Sample
2018-10-28 22:29:18 +01:00
* `npm install` to initialize the project
* `npm run watch` to start the compiler in watch mode
2016-12-30 12:05:24 +01:00
* open this folder in VS Code and press `F5`
2018-10-28 22:29:18 +01:00
* this will open the `[Extension Development Host]` window, running the extension:
* Open any document that contains single and multi-digit numbers.
* The extension will decorate single and multiple-digit numbers as shown in the screenshot above.
* In the user settings, add
```
"workbench.colorCustomizations": {
"myextension.largeNumberBackground": "#ff00ff"
}
```
to customize the large number decoration color.