mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 20:00:16 +08:00
Add background color feature to SQL highlighting via preferences
This commit is contained in:
@ -69,7 +69,8 @@ const
|
||||
REGNAME_LOGSQLWIDTH = 'logsqlwidth';
|
||||
DEFAULT_LOGSQLWIDTH = 2000;
|
||||
REGPREFIX_SQLATTRI = 'SQL Attr ';
|
||||
REGPOSTFIX_SQL_COLOR = ' Color';
|
||||
REGPOSTFIX_SQL_FG = ' Foreground';
|
||||
REGPOSTFIX_SQL_BG = ' Background';
|
||||
REGPOSTFIX_SQL_STYLE = ' Style';
|
||||
REGNAME_SQLCOLACTIVELINE = 'SQLColActiveLine';
|
||||
DEFAULT_SQLCOLACTIVELINE = $00FFFFFF; // clWhite
|
||||
|
@ -2997,7 +2997,8 @@ begin
|
||||
// Default colors defined and used from highlighter on main form
|
||||
for i := 0 to Highlighter.AttrCount - 1 do begin
|
||||
Attri := Highlighter.Attribute[i];
|
||||
Attri.Foreground := GetRegValue(REGPREFIX_SQLATTRI+Attri.FriendlyName+REGPOSTFIX_SQL_COLOR, Mainform.SynSQLSyn1.Attribute[i].Foreground);
|
||||
Attri.Foreground := GetRegValue(REGPREFIX_SQLATTRI+Attri.FriendlyName+REGPOSTFIX_SQL_FG, Mainform.SynSQLSyn1.Attribute[i].Foreground);
|
||||
Attri.Background := GetRegValue(REGPREFIX_SQLATTRI+Attri.FriendlyName+REGPOSTFIX_SQL_BG, Mainform.SynSQLSyn1.Attribute[i].Background);
|
||||
Attri.IntegerStyle := GetRegValue(REGPREFIX_SQLATTRI+Attri.FriendlyName+REGPOSTFIX_SQL_STYLE, Mainform.SynSQLSyn1.Attribute[i].IntegerStyle)
|
||||
end;
|
||||
end;
|
||||
|
@ -244,33 +244,40 @@ object optionsform: Toptionsform
|
||||
Caption = 'Syntax'
|
||||
TabOrder = 1
|
||||
object lblSQLColElement: TLabel
|
||||
Left = 19
|
||||
Top = 18
|
||||
Left = 15
|
||||
Top = 17
|
||||
Width = 42
|
||||
Height = 13
|
||||
Caption = 'Element:'
|
||||
end
|
||||
object lblSQLColColor: TLabel
|
||||
Left = 188
|
||||
Top = 18
|
||||
Width = 29
|
||||
object lblSQLColForeground: TLabel
|
||||
Left = 213
|
||||
Top = 16
|
||||
Width = 60
|
||||
Height = 13
|
||||
Caption = 'Color:'
|
||||
Caption = 'Foreground:'
|
||||
end
|
||||
object lblSQLColBackground: TLabel
|
||||
Left = 213
|
||||
Top = 42
|
||||
Width = 60
|
||||
Height = 13
|
||||
Caption = 'Background:'
|
||||
end
|
||||
object comboSQLColElement: TComboBox
|
||||
Left = 16
|
||||
Top = 33
|
||||
Width = 161
|
||||
Left = 67
|
||||
Top = 13
|
||||
Width = 130
|
||||
Height = 21
|
||||
Style = csDropDownList
|
||||
ItemHeight = 13
|
||||
TabOrder = 0
|
||||
OnChange = comboSQLColElementChange
|
||||
end
|
||||
object cboxSQLColColor: TColorBox
|
||||
Left = 188
|
||||
Top = 33
|
||||
Width = 124
|
||||
object cboxSQLColForeground: TColorBox
|
||||
Left = 284
|
||||
Top = 13
|
||||
Width = 110
|
||||
Height = 22
|
||||
Style = [cbStandardColors, cbExtendedColors, cbIncludeNone, cbCustomColor, cbPrettyNames, cbCustomColors]
|
||||
ItemHeight = 16
|
||||
@ -278,23 +285,33 @@ object optionsform: Toptionsform
|
||||
OnChange = SQLFontChange
|
||||
end
|
||||
object chkSQLBold: TCheckBox
|
||||
Left = 322
|
||||
Top = 26
|
||||
Width = 72
|
||||
Left = 67
|
||||
Top = 41
|
||||
Width = 57
|
||||
Height = 17
|
||||
Caption = 'Bold'
|
||||
TabOrder = 2
|
||||
OnClick = SQLFontChange
|
||||
end
|
||||
object chkSQLItalic: TCheckBox
|
||||
Left = 322
|
||||
Top = 45
|
||||
Width = 65
|
||||
Left = 130
|
||||
Top = 41
|
||||
Width = 57
|
||||
Height = 17
|
||||
Caption = 'Italic'
|
||||
TabOrder = 3
|
||||
OnClick = SQLFontChange
|
||||
end
|
||||
object cboxSQLColBackground: TColorBox
|
||||
Left = 284
|
||||
Top = 39
|
||||
Width = 110
|
||||
Height = 22
|
||||
Style = [cbStandardColors, cbExtendedColors, cbIncludeNone, cbCustomColor, cbPrettyNames, cbCustomColors]
|
||||
ItemHeight = 16
|
||||
TabOrder = 4
|
||||
OnChange = SQLFontChange
|
||||
end
|
||||
end
|
||||
object grpSQLSample: TGroupBox
|
||||
Left = 0
|
||||
|
@ -85,8 +85,8 @@ type
|
||||
grpSQLColors: TGroupBox;
|
||||
comboSQLColElement: TComboBox;
|
||||
lblSQLColElement: TLabel;
|
||||
lblSQLColColor: TLabel;
|
||||
cboxSQLColColor: TColorBox;
|
||||
lblSQLColForeground: TLabel;
|
||||
cboxSQLColForeground: TColorBox;
|
||||
grpSQLSample: TGroupBox;
|
||||
SynMemoSQLSample: TSynMemo;
|
||||
SynSQLSynSQLSample: TSynSQLSyn;
|
||||
@ -95,6 +95,8 @@ type
|
||||
updownCopyDataMaxSize: TUpDown;
|
||||
chkSQLBold: TCheckBox;
|
||||
chkSQLItalic: TCheckBox;
|
||||
lblSQLColBackground: TLabel;
|
||||
cboxSQLColBackground: TColorBox;
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure Modified(Sender: TObject);
|
||||
procedure Apply(Sender: TObject);
|
||||
@ -170,7 +172,8 @@ begin
|
||||
MainReg.WriteInteger(REGNAME_LOGSQLWIDTH, updownLogSnip.Position);
|
||||
for i:=0 to SynSQLSynSQLSample.AttrCount - 1 do begin
|
||||
Attri := SynSQLSynSQLSample.Attribute[i];
|
||||
MainReg.WriteInteger(REGPREFIX_SQLATTRI+Attri.FriendlyName+REGPOSTFIX_SQL_COLOR, Attri.Foreground);
|
||||
MainReg.WriteInteger(REGPREFIX_SQLATTRI+Attri.FriendlyName+REGPOSTFIX_SQL_FG, Attri.Foreground);
|
||||
MainReg.WriteInteger(REGPREFIX_SQLATTRI+Attri.FriendlyName+REGPOSTFIX_SQL_BG, Attri.Background);
|
||||
MainReg.WriteInteger(REGPREFIX_SQLATTRI+Attri.FriendlyName+REGPOSTFIX_SQL_STYLE, Attri.IntegerStyle);
|
||||
end;
|
||||
MainReg.WriteString(REGNAME_SQLCOLACTIVELINE, ColorToString(SynMemoSQLSample.ActiveLineColor));
|
||||
@ -355,17 +358,19 @@ procedure Toptionsform.SQLFontChange(Sender: TObject);
|
||||
var
|
||||
AttriIdx: Integer;
|
||||
Attri: TSynHighlighterAttributes;
|
||||
col: TColor;
|
||||
Foreground, Background: TColor;
|
||||
begin
|
||||
SynMemoSQLSample.Font.Name := comboSQLFontName.Items[comboSQLFontName.ItemIndex];
|
||||
SynMemoSQLSample.Font.Size := updownSQLFontSize.Position;
|
||||
AttriIdx := comboSQLColElement.ItemIndex;
|
||||
col := cboxSQLColColor.Selected;
|
||||
Foreground := cboxSQLColForeground.Selected;
|
||||
Background := cboxSQLColBackground.Selected;
|
||||
if AttriIdx = comboSQLColElement.Items.Count-1 then begin
|
||||
SynMemoSQLSample.ActiveLineColor := col;
|
||||
SynMemoSQLSample.ActiveLineColor := Foreground;
|
||||
end else begin
|
||||
Attri := SynSqlSynSQLSample.Attribute[AttriIdx];
|
||||
Attri.Foreground := col;
|
||||
Attri.Foreground := Foreground;
|
||||
Attri.Background := Background;
|
||||
if chkSQLBold.Checked then Attri.Style := Attri.Style + [fsBold]
|
||||
else Attri.Style := Attri.Style - [fsBold];
|
||||
if chkSQLItalic.Checked then Attri.Style := Attri.Style + [fsItalic]
|
||||
@ -417,16 +422,18 @@ procedure Toptionsform.comboSQLColElementChange(Sender: TObject);
|
||||
var
|
||||
AttriIdx: Integer;
|
||||
Attri: TSynHighlighterAttributes;
|
||||
col: TColor;
|
||||
Foreground, Background: TColor;
|
||||
begin
|
||||
AttriIdx := comboSQLColElement.ItemIndex;
|
||||
if AttriIdx = comboSQLColElement.Items.Count-1 then begin
|
||||
col := SynMemoSQLSample.ActiveLineColor;
|
||||
Foreground := SynMemoSQLSample.ActiveLineColor;
|
||||
Background := clNone;
|
||||
chkSQLBold.Enabled := False;
|
||||
chkSQLItalic.Enabled := False;
|
||||
end else begin
|
||||
Attri := SynSqlSynSQLSample.Attribute[AttriIdx];
|
||||
col := Attri.Foreground;
|
||||
Foreground := Attri.Foreground;
|
||||
Background := Attri.Background;
|
||||
chkSQLBold.Enabled := True;
|
||||
chkSQLItalic.Enabled := True;
|
||||
chkSQLBold.OnClick := nil;
|
||||
@ -436,7 +443,8 @@ begin
|
||||
chkSQLBold.OnClick := SQLFontChange;
|
||||
chkSQLItalic.OnClick := SQLFontChange;
|
||||
end;
|
||||
cboxSQLColColor.Selected := col;
|
||||
cboxSQLColForeground.Selected := Foreground;
|
||||
cboxSQLColBackground.Selected := Background;
|
||||
end;
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user