A Regex file extension that makes it way easier to edit large regex.
hides buttons when regex file doesnt exist
2 files changed, +33 -0
+2-0src/extension.ts
| @@ -13,11 +13,13 @@ export function activate(context: vscode.ExtensionContext) { | ||
| 13 | 13 | if (editor && editor.document.uri.scheme === "file") { |
| 14 | 14 | if (editor.document.languageId === "regex") { |
| 15 | 15 | // output.log("Regex file opened"); |
| 16 | + regexButtons.show(); | |
| 16 | 17 | highlighter.run(); |
| 17 | 18 | } |
| 18 | 19 | } |
| 19 | 20 | if (!editorsContainRegexFile()) { |
| 20 | 21 | highlighter.reset(); |
| 22 | + regexButtons.hide(); | |
| 21 | 23 | output.log("No regex file opened"); |
| 22 | 24 | } |
| 23 | 25 | }); |
+31-0src/regexButtons.ts
| @@ -132,6 +132,37 @@ class RegexButtons { | ||
| 132 | 132 | |
| 133 | 133 | disposeButtons() { |
| 134 | 134 | // output.log("Disposing buttons"); |
| 135 | + for (const flag of Object.values(this.flags)) { | |
| 136 | + if (flag.button) { | |
| 137 | + flag.button.dispose(); | |
| 138 | + } | |
| 139 | + } | |
| 140 | + } | |
| 141 | + | |
| 142 | + hideButtons() { | |
| 143 | + // output.log("Hiding buttons"); | |
| 144 | + for (const flag of Object.values(this.flags)) { | |
| 145 | + if (flag.button) { | |
| 146 | + flag.button.hide(); | |
| 147 | + } | |
| 148 | + } | |
| 149 | + } | |
| 150 | + | |
| 151 | + hide() { | |
| 152 | + this.hideButtons(); | |
| 153 | + } | |
| 154 | + | |
| 155 | + showFlagButtons() { | |
| 156 | + // output.log("Showing buttons"); | |
| 157 | + for (const flag of Object.values(this.flags)) { | |
| 158 | + if (flag.button) { | |
| 159 | + flag.button.show(); | |
| 160 | + } | |
| 161 | + } | |
| 162 | + } | |
| 163 | + | |
| 164 | + show() { | |
| 165 | + this.showFlagButtons(); | |
| 135 | 166 | } |
| 136 | 167 | |
| 137 | 168 | dispose() { |