@@ -154,10 +154,6 @@ TfrmPreferences = class(TExtForm)
154154 comboTheme: TComboBox;
155155 lblEditorColorsPreset: TLabel;
156156 comboEditorColorsPreset: TComboBox;
157- SynSQLSyn_Dark: TSynSQLSyn;
158- SynSQLSyn_Light: TSynSQLSyn;
159- SynSQLSyn_Black: TSynSQLSyn;
160- SynSQLSyn_White: TSynSQLSyn;
161157 comboGridTextColorsPreset: TComboBox;
162158 lblIconPack: TLabel;
163159 comboIconPack: TComboBox;
@@ -259,7 +255,7 @@ TfrmPreferences = class(TExtForm)
259255
260256implementation
261257
262- uses main, apphelpers, extfiledialog;
258+ uses main, apphelpers, extfiledialog, generic_types ;
263259
264260{ $R *.lfm}
265261
@@ -297,8 +293,6 @@ procedure TfrmPreferences.pagecontrolMainChange(Sender: TObject);
297293}
298294procedure TfrmPreferences.Apply (Sender: TObject);
299295var
300- i: Integer;
301- Attri: TSynHighlighterAttributes;
302296 CatNode, ItemNode: PVirtualNode;
303297 Data: PShortcutItemData;
304298 LangCode: String;
@@ -325,12 +319,7 @@ procedure TfrmPreferences.Apply(Sender: TObject);
325319 AppSettings.WriteInt(asQueryHistoryKeepDays, MakeInt(editQueryHistoryKeepDays.Text));
326320 AppSettings.WriteBool(asLogHorizontalScrollbar, chkHorizontalScrollbar.Checked);
327321 AppSettings.WriteBool(asLogTimestamp, chkLogTimestamp.Checked);
328- for i:=0 to SynSQLSynSQLSample.AttrCount - 1 do begin
329- Attri := SynSQLSynSQLSample.Attribute [i];
330- AppSettings.WriteInt(asHighlighterForeground, Attri.Foreground, Attri.Name );
331- AppSettings.WriteInt(asHighlighterBackground, Attri.Background, Attri.Name );
332- AppSettings.WriteInt(asHighlighterStyle, Attri.IntegerStyle, Attri.Name );
333- end ;
322+ SQLSynSchemes.ApplyScheme(SynSQLSynSQLSample);
334323 AppSettings.WriteString(asSQLColActiveLine, ColorToString(SynMemoSQLSample.LineHighlightColor.Background));
335324 AppSettings.WriteString(asSQLColMatchingBraceForeground, ColorToString(MainForm.MatchingBraceForegroundColor));
336325 AppSettings.WriteString(asSQLColMatchingBraceBackground, ColorToString(MainForm.MatchingBraceBackgroundColor));
@@ -537,7 +526,6 @@ procedure TfrmPreferences.FormCreate(Sender: TObject);
537526 dtc: TDBDatatypeCategoryIndex;
538527 // Styles: TArray<String>;
539528 Highlighter: TSynSQLSyn;
540- Name : String;
541529 GridColorsPreset: TGridColorsPreset;
542530 IconPack: String;
543531 Reformatter: TfrmReformatter;
@@ -605,17 +593,8 @@ procedure TfrmPreferences.FormCreate(Sender: TObject);
605593 comboSQLColElement.Items.Add(_(' Brace matching color' ));
606594 comboSQLColElement.ItemIndex := 0 ;
607595 // Enumerate highlighter presets
608- for i:=0 to ComponentCount-1 do begin
609- if (Components[i] is TSynSQLSyn)
610- and (Components[i] <> SynMemoSQLSample.Highlighter)
611- then begin
612- Highlighter := Components[i] as TSynSQLSyn;
613- Name := Highlighter.Name ;
614- Name := RegExprGetMatch(' _([^_]+)$' , Name , 1 );
615- if Name <> ' ' then begin
616- comboEditorColorsPreset.Items.Add(_(Name ));
617- end ;
618- end ;
596+ for Highlighter in SQLSynSchemes do begin
597+ comboEditorColorsPreset.Items.Add(_(Highlighter.Name ));
619598 end ;
620599
621600 // Grid formatting
@@ -970,40 +949,29 @@ procedure TfrmPreferences.comboEditorColorsPresetChange(Sender: TObject);
970949 i, j: Integer;
971950 Highlighter: TSynSQLSyn;
972951 FoundHighlighter: Boolean;
973- rx: TRegExpr;
974952 TranslatedHighlighterName: String;
975953begin
976954 // Color preset selected
977955 FoundHighlighter := False;
978- rx := TRegExpr.Create;
979- rx.Expression := ' .+_([a-zA-Z0-9]+)$' ;
980- for i:=0 to ComponentCount-1 do begin
981- if (Components[i] is TSynSQLSyn) and (Components[i] <> SynMemoSQLSample.Highlighter) then begin
982- Highlighter := Components[i] as TSynSQLSyn;
983-
984- // Translate highlighter postfix after last underscore: SynSQLSyn_White, SynSQLSyn_Black, ...
985- TranslatedHighlighterName := ' ' ;
986- if rx.Exec(Highlighter.Name ) then begin
987- TranslatedHighlighterName := _(rx.Match[1 ]);
956+ for Highlighter in SQLSynSchemes do begin
957+ TranslatedHighlighterName := _(Highlighter.Name );
958+ // ... so we can compare that with the selected dropdown text
959+ if TranslatedHighlighterName = comboEditorColorsPreset.Text then begin
960+ FoundHighlighter := True;
961+ for j:=0 to SynSQLSynSQLSample.AttrCount - 1 do begin
962+ SynSQLSynSQLSample.Attribute [j].AssignColorAndStyle(Highlighter.Attribute [j]);
988963 end ;
989- // ... so we can compare that with the selected dropdown text
990- if TranslatedHighlighterName = comboEditorColorsPreset.Text then begin
991- FoundHighlighter := True;
992- for j:=0 to SynSQLSynSQLSample.AttrCount - 1 do begin
993- SynSQLSynSQLSample.Attribute [j].AssignColorAndStyle(Highlighter.Attribute [j]);
994- end ;
995- // Use 3 hardcoded default values for additional colors, which are not part
996- // of the highlighter's attributes
997- SynMemoSQLSample.LineHighlightColor.Background := StringToColor(AppSettings.GetDefaultString(asSQLColActiveLine));
998- if IsDarkModeEnabled then begin // This is yet wrong, and should be based on the selected but not yet saved theme setting
999- MainForm.MatchingBraceForegroundColor := $0028EFFF;
1000- MainForm.MatchingBraceBackgroundColor := $004D513B;
1001- end else begin
1002- MainForm.MatchingBraceForegroundColor := StringToColor(AppSettings.GetDefaultString(asSQLColMatchingBraceForeground));
1003- MainForm.MatchingBraceBackgroundColor := StringToColor(AppSettings.GetDefaultString(asSQLColMatchingBraceBackground));
1004- end ;
1005- Break;
964+ // Use 3 hardcoded default values for additional colors, which are not part
965+ // of the highlighter's attributes
966+ SynMemoSQLSample.LineHighlightColor.Background := StringToColor(AppSettings.GetDefaultString(asSQLColActiveLine));
967+ if IsDarkModeEnabled then begin // This is yet wrong, and should be based on the selected but not yet saved theme setting
968+ MainForm.MatchingBraceForegroundColor := $0028EFFF;
969+ MainForm.MatchingBraceBackgroundColor := $004D513B;
970+ end else begin
971+ MainForm.MatchingBraceForegroundColor := StringToColor(AppSettings.GetDefaultString(asSQLColMatchingBraceForeground));
972+ MainForm.MatchingBraceBackgroundColor := StringToColor(AppSettings.GetDefaultString(asSQLColMatchingBraceBackground));
1006973 end ;
974+ Break;
1007975 end ;
1008976 end ;
1009977 if not FoundHighlighter then begin
0 commit comments