irongit

A Regex file extension that makes it way easier to edit large regex.

regex-file/src/decorationSelector.ts
68 lines2.0 KBJavaScript
1import * as vscode from "vscode";
2
3const BACKGROUND_COLORS = [
4 "rgba(255, 255, 255, 0.2)", // White (For outer group)
5 "rgba(255, 99, 71, 0.5)", // Light Coral
6 "rgba(255, 140, 0, 0.5)", // Dark Orange
7 "rgba(255, 215, 0, 0.5)", // Gold
8 "rgba(240, 230, 140, 0.5)", // Khaki
9 "rgba(144, 238, 144, 0.5)", // Light Green
10 "rgba(152, 251, 152, 0.5)", // Pale Green
11 "rgba(60, 179, 113, 0.5)", // Medium Sea Green
12 "rgba(135, 206, 250, 0.5)", // Light Sky Blue
13 "rgba(173, 216, 230, 0.5)", // Light Blue
14 "rgba(135, 206, 235, 0.5)", // Sky Blue
15 "rgba(221, 160, 221, 0.5)", // Plum
16 "rgba(216, 191, 216, 0.5)", // Thistle
17 "rgba(240, 128, 128, 0.5)", // Light Salmon
18 "rgba(245, 222, 179, 0.5)", // Wheat
19 "rgba(255, 192, 203, 0.5)", // Pink
20 "rgba(255, 182, 193, 0.5)", // Light Pink
21 "rgba(238, 232, 170, 0.5)", // Pale Goldenrod
22 "rgba(255, 228, 196, 0.5)", // Bisque
23 "rgba(255, 218, 185, 0.5)", // Peach Puff
24 "rgba(175, 238, 238, 0.5)", // Pale Turquoise
25 "rgba(224, 255, 255, 0.5)", // Light Cyan
26 "rgba(240, 255, 240, 0.5)", // Honeydew
27 "rgba(250, 250, 210, 0.5)", // Light Goldenrod Yellow
28 "rgba(245, 245, 220, 0.5)", // Beige
29 "rgba(255, 250, 205, 0.5)", // Lemon Chiffon
30];
31
32class DecorationSelector {
33 decorations: vscode.TextEditorDecorationType[] = [];
34 currentIndex = 0;
35
36 constructor() {
37 for (const color of BACKGROUND_COLORS) {
38 this.decorations.push(
39 vscode.window.createTextEditorDecorationType({
40 backgroundColor: color,
41 color: "black",
42 fontWeight: "900",
43 })
44 );
45 }
46 }
47
48 reset() {
49 this.currentIndex = 0;
50 for (const decoration of this.decorations) {
51 }
52 }
53
54 select() {
55 const decoration = this.decorations[this.currentIndex];
56 this.currentIndex = (this.currentIndex + 1) % this.decorations.length;
57 return decoration;
58 }
59
60 dispose() {
61 for (const decoration of this.decorations) {
62 decoration.dispose();
63 }
64 }
65}
66
67const decorationSelector = new DecorationSelector();
68export default decorationSelector;