@@ -2,6 +2,7 @@ import { closeBrackets, deleteBracketPair } from "@codemirror/autocomplete";
22import { indentUnit } from "@codemirror/language" ;
33import { Compartment , EditorState , Extension } from "@codemirror/state" ;
44import { EditorView , highlightSpecialChars , highlightTrailingWhitespace , highlightWhitespace , keymap } from "@codemirror/view" ;
5+ import { debugHighlightTagsTooltip } from "./views/debug" ;
56import { insertTabKeymap , spacesSpacesKeymap } from "./views/tabs" ;
67
78declare var bootbox ;
@@ -13,6 +14,7 @@ export const highlightTrailingWhitespaceCompartment = new Compartment();
1314export const tabSizeCompartment = new Compartment ( ) ;
1415export const closeBracketsCompartment = new Compartment ( ) ;
1516export const tabsToSpacesCompartment = new Compartment ( ) ;
17+ export const debugHighlightTagsCompartment = new Compartment ( ) ;
1618
1719export interface EditorSettings {
1820 tabSize : number ;
@@ -21,6 +23,7 @@ export interface EditorSettings {
2123 highlightWhitespace : boolean ;
2224 highlightTrailingWhitespace : boolean ;
2325 closeBrackets : boolean ;
26+ debugHighlightTags : boolean ;
2427}
2528
2629const SETTINGS_KEY = "8bitworkshop/editorSettings" ;
@@ -32,6 +35,7 @@ const defaultSettings: EditorSettings = {
3235 highlightWhitespace : true ,
3336 highlightTrailingWhitespace : true ,
3437 closeBrackets : true ,
38+ debugHighlightTags : false ,
3539} ;
3640
3741export function loadSettings ( ) : EditorSettings {
@@ -55,6 +59,7 @@ const compartmentValues: [Compartment, (s: EditorSettings) => Extension][] = [
5559 [ highlightWhitespaceCompartment , s => s . highlightWhitespace ? highlightWhitespace ( ) : [ ] ] ,
5660 [ highlightTrailingWhitespaceCompartment , s => s . highlightTrailingWhitespace ? highlightTrailingWhitespace ( ) : [ ] ] ,
5761 [ closeBracketsCompartment , s => s . closeBrackets ? [ closeBrackets ( ) , keymap . of ( [ { key : "Backspace" , run : deleteBracketPair } ] ) ] : [ ] ] ,
62+ [ debugHighlightTagsCompartment , s => s . debugHighlightTags ? debugHighlightTagsTooltip : [ ] ] ,
5863] ;
5964
6065export function settingsExtensions ( settings : EditorSettings ) : Extension [ ] {
@@ -84,12 +89,16 @@ export function openSettings() {
8489 bootbox . dialog ( {
8590 title : "Settings" ,
8691 message : `<form id="settingsForm" onsubmit="return false">
92+ <h5>Editor preferences</h5>
8793 <div class="form-group"><label>Tab size: <input type="number" id="setting_tabSize" min="1" max="40" value="${ settings . tabSize } " style="width:4em"></label></div>
8894 <div class="checkbox"><label><input type="checkbox" id="setting_tabsToSpaces" ${ settings . tabsToSpaces ? 'checked' : '' } > Insert spaces when pressing TAB</label></div>
8995 <div class="checkbox"><label><input type="checkbox" id="setting_highlightSpecialChars" ${ settings . highlightSpecialChars ? 'checked' : '' } > Highlight special characters</label></div>
9096 <div class="checkbox"><label><input type="checkbox" id="setting_highlightWhitespace" ${ settings . highlightWhitespace ? 'checked' : '' } > Highlight whitespace</label></div>
9197 <div class="checkbox"><label><input type="checkbox" id="setting_highlightTrailingWhitespace" ${ settings . highlightTrailingWhitespace ? 'checked' : '' } > Highlight unwanted trailing whitespace</label></div>
9298 <div class="checkbox"><label><input type="checkbox" id="setting_closeBrackets" ${ settings . closeBrackets ? 'checked' : '' } > Automatically add and remove closing brackets</label></div>
99+ <hr>
100+ <h5>8bitworkshop IDE internal settings</h5>
101+ <div class="checkbox"><label><input type="checkbox" id="setting_debugHighlightTags" ${ settings . debugHighlightTags ? 'checked' : '' } > Debug editor syntax highlighting tags</label></div>
93102 </form>` ,
94103 buttons : {
95104 cancel : {
@@ -106,6 +115,7 @@ export function openSettings() {
106115 settings . highlightWhitespace = $ ( '#setting_highlightWhitespace' ) . is ( ':checked' ) ;
107116 settings . highlightTrailingWhitespace = $ ( '#setting_highlightTrailingWhitespace' ) . is ( ':checked' ) ;
108117 settings . closeBrackets = $ ( '#setting_closeBrackets' ) . is ( ':checked' ) ;
118+ settings . debugHighlightTags = $ ( '#setting_debugHighlightTags' ) . is ( ':checked' ) ;
109119 saveSettings ( settings ) ;
110120 applySettingsToAll ( settings ) ;
111121 }
0 commit comments