| 1 | import * as vscode from "vscode"; |
| 2 | |
| 3 | const BACKGROUND_COLORS = [ |
| 4 | "rgba(255, 255, 255, 0.2)", |
| 5 | "rgba(255, 99, 71, 0.5)", |
| 6 | "rgba(255, 140, 0, 0.5)", |
| 7 | "rgba(255, 215, 0, 0.5)", |
| 8 | "rgba(240, 230, 140, 0.5)", |
| 9 | "rgba(144, 238, 144, 0.5)", |
| 10 | "rgba(152, 251, 152, 0.5)", |
| 11 | "rgba(60, 179, 113, 0.5)", |
| 12 | "rgba(135, 206, 250, 0.5)", |
| 13 | "rgba(173, 216, 230, 0.5)", |
| 14 | "rgba(135, 206, 235, 0.5)", |
| 15 | "rgba(221, 160, 221, 0.5)", |
| 16 | "rgba(216, 191, 216, 0.5)", |
| 17 | "rgba(240, 128, 128, 0.5)", |
| 18 | "rgba(245, 222, 179, 0.5)", |
| 19 | "rgba(255, 192, 203, 0.5)", |
| 20 | "rgba(255, 182, 193, 0.5)", |
| 21 | "rgba(238, 232, 170, 0.5)", |
| 22 | "rgba(255, 228, 196, 0.5)", |
| 23 | "rgba(255, 218, 185, 0.5)", |
| 24 | "rgba(175, 238, 238, 0.5)", |
| 25 | "rgba(224, 255, 255, 0.5)", |
| 26 | "rgba(240, 255, 240, 0.5)", |
| 27 | "rgba(250, 250, 210, 0.5)", |
| 28 | "rgba(245, 245, 220, 0.5)", |
| 29 | "rgba(255, 250, 205, 0.5)", |
| 30 | ]; |
| 31 | |
| 32 | class 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 | |
| 67 | const decorationSelector = new DecorationSelector(); |
| 68 | export default decorationSelector; |