Skip to content

Commit

Permalink
Switch from old/deprecated SCI_SETSELBACK to new SCI_SETELEMENTCOLOUR…
Browse files Browse the repository at this point in the history
… and also fix ugly color if the IDE window doesn't have focus.
  • Loading branch information
martijnlaan committed Jun 15, 2024
1 parent c426177 commit 62ffa99
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
11 changes: 7 additions & 4 deletions Components/ModernColors.pas
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface

type
TThemeType = (ttModernLight, ttModernDark, ttClassic);
TThemeColor = (tcFore, tcBack, tcToolBack, tcSelBack,
TThemeColor = (tcFore, tcBack, tcToolBack, tcSelBack, tcSelInactiveBack,
tcWordAtCursorOccurrenceBack, tcSelTextOccurrenceBack,
tcMarginFore, tcMarginBack, tcSplitterBack, tcBraceBack, tcIdentGuideFore,
tcRed, tcGreen, tcBlue, tcOrange, tcPurple, tcYellow, tcTeal, tcGray);
Expand Down Expand Up @@ -44,6 +44,7 @@ function TTheme.FGetColor(Color: TThemeColor): TColor;
DBack = $1F1F1F; { VSCode Modern Dark }
DToolBack = $413E40; { Monokai Pro }
DSelBack = $764F1D; { VSCode Modern Dark }
DSelInactiveBack = $51504F;{ VSCode Modern Dark }
DWACOBack = $4A4A4A; { VSCode Modern Dark }
DSTOBACK = $403A33; { VSCode Modern Dark }
DMarginFore = $716F71; { Monokai Pro }
Expand All @@ -57,6 +58,7 @@ function TTheme.FGetColor(Color: TThemeColor): TColor;
LBack = clWhite;
LToolBack = clBtnFace;
LSelBack = $FDD6A7; { VSCode Modern Light }
LSelInactiveBack = $F1EBE4;{ VSCode Modern Light }
LWACOBack = $ECECEC; { Inno Setup 5, 4 tints lightened using color-hex.com }
LSTOBACK = $FEEAD3; { VSCode Modern Light }
LMarginFore = $716F71; { Monokai Pro }
Expand All @@ -69,6 +71,7 @@ function TTheme.FGetColor(Color: TThemeColor): TColor;
CBack = clWhite;
CToolBack = clBtnFace;
CSelBack = $FDD6A7; { VSCode Modern Light }
CSelInactiveBack = $F1EBE4;{ VSCode Modern Light }
CWACOBack = $ECECEC; { Inno Setup 5, 4 tints lightened using color-hex.com }
CSTOBACK = $FEEAD3; { VSCode Modern Light }
CMarginFore = clWindowText;
Expand Down Expand Up @@ -99,9 +102,9 @@ function TTheme.FGetColor(Color: TThemeColor): TColor;
CGray = $707070; { Inno Setup 5 }

Colors: array [TThemeType, TThemeColor] of TColor = (
(LFore, LBack, LToolBack, LSelBack, LWACOBack, LSTOBack, LMarginFore, LMarginBack, LSplitterBack, LBraceBack, LIdentGuideFore, MRed, MGreen, MBlue, MOrange, MPurple, MYellow, MTeal, MGray),
(DFore, DBack, DToolBack, DSelBack, DWACOBack, DSTOBack, DMarginFore, DMarginBack, DSplitterBack, DBraceBack, DIdentGuideFore, MRed, MGreen, MBlue, MOrange, MPurple, MYellow, MTeal, MGray),
(CFore, CBack, CToolBack, CSelBack, CWACOBack, CSTOBack, CMarginFore, CMarginBack, CSplitterBack, CBraceBack, CIdentGuideFore, CRed, CGreen, CBlue, COrange, CPurple, CYellow, CTeal, CGray)
(LFore, LBack, LToolBack, LSelBack, LSelInactiveBack, LWACOBack, LSTOBack, LMarginFore, LMarginBack, LSplitterBack, LBraceBack, LIdentGuideFore, MRed, MGreen, MBlue, MOrange, MPurple, MYellow, MTeal, MGray),
(DFore, DBack, DToolBack, DSelBack, DSelInactiveBack, DWACOBack, DSTOBack, DMarginFore, DMarginBack, DSplitterBack, DBraceBack, DIdentGuideFore, MRed, MGreen, MBlue, MOrange, MPurple, MYellow, MTeal, MGray),
(CFore, CBack, CToolBack, CSelBack, CSelInactiveBack, CWACOBack, CSTOBack, CMarginFore, CMarginBack, CSplitterBack, CBraceBack, CIdentGuideFore, CRed, CGreen, CBlue, COrange, CPurple, CYellow, CTeal, CGray)
);

begin
Expand Down
13 changes: 12 additions & 1 deletion Projects/Src/CompScintEdit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,22 @@ procedure TCompScintEdit.UpdateThemeColorsAndStyleAttributes;
if FTheme <> nil then begin
Font.Color := FTheme.Colors[tcFore];
Color := FTheme.Colors[tcBack];
Call(SCI_SETSELBACK, 1, FTheme.Colors[tcSelBack]);

var SelBackColor := FTheme.Colors[tcSelBack];
Call(SCI_SETELEMENTCOLOUR, SC_ELEMENT_SELECTION_BACK, SelBackColor);
Call(SCI_SETELEMENTCOLOUR, SC_ELEMENT_SELECTION_ADDITIONAL_BACK, SelBackColor);

var SelInactiveBackColor := FTheme.Colors[tcSelInactiveBack];
Call(SCI_SETELEMENTCOLOUR, SC_ELEMENT_SELECTION_SECONDARY_BACK, SelInactiveBackColor);
Call(SCI_SETELEMENTCOLOUR, SC_ELEMENT_SELECTION_INACTIVE_BACK, SelInactiveBackColor);
Call(SCI_SETELEMENTCOLOUR, SC_ELEMENT_SELECTION_INACTIVE_ADDITIONAL_BACK, SelInactiveBackColor);

Call(SCI_INDICSETFORE, inSquiggly, FTheme.Colors[tcRed]);
Call(SCI_INDICSETFORE, inWordAtCursorOccurrence, FTheme.Colors[tcWordAtCursorOccurrenceBack]);
Call(SCI_INDICSETFORE, inSelTextOccurrence, FTheme.Colors[tcSelTextOccurrenceBack]);

Call(SCI_MARKERSETBACK, mmLineStep, FTheme.Colors[tcBlue]);

Call(SCI_MARKERSETFORE, SC_MARKNUM_HISTORY_REVERTED_TO_ORIGIN, FTheme.Colors[tcBlue]); { To reproduce: open a file, press enter, save, undo }
Call(SCI_MARKERSETBACK, SC_MARKNUM_HISTORY_REVERTED_TO_ORIGIN, FTheme.Colors[tcBlue]);
Call(SCI_MARKERSETFORE, SC_MARKNUM_HISTORY_SAVED, FTheme.Colors[tcGreen]);
Expand Down

0 comments on commit 62ffa99

Please sign in to comment.