mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-19 05:30:59 +02:00
IDE, SourceEditor: refactor / clean up - Colors for completion drop down.
This commit is contained in:
parent
6a0efcb8c0
commit
a8b95b354c
@ -7689,44 +7689,9 @@ begin
|
||||
begin
|
||||
IDESynEdit := TIDESynEditor(ASynEdit);
|
||||
|
||||
Attri := GetUsedAttr(ahaIdentComplWindow);
|
||||
if Attri<>nil then
|
||||
begin
|
||||
IDESynEdit.MarkupIdentComplWindow.TextColor := Attri.Foreground;
|
||||
IDESynEdit.MarkupIdentComplWindow.WindowColor:= Attri.Background;
|
||||
end else
|
||||
begin
|
||||
IDESynEdit.MarkupIdentComplWindow.TextColor := clNone;
|
||||
IDESynEdit.MarkupIdentComplWindow.WindowColor:= clNone;
|
||||
end;
|
||||
|
||||
Attri := GetUsedAttr(ahaIdentComplWindowBorder);
|
||||
if Attri<>nil then
|
||||
IDESynEdit.MarkupIdentComplWindow.BorderColor:= Attri.Foreground
|
||||
else
|
||||
IDESynEdit.MarkupIdentComplWindow.BorderColor:= clNone;
|
||||
|
||||
Attri := GetUsedAttr(ahaIdentComplRecent);
|
||||
if Attri<>nil then
|
||||
IDESynEdit.MarkupIdentComplWindow.HistoryTextColor := Attri.Foreground
|
||||
else
|
||||
IDESynEdit.MarkupIdentComplWindow.HistoryTextColor := clNone;
|
||||
|
||||
Attri := GetUsedAttr(ahaIdentComplWindowHighlight);
|
||||
if Attri<>nil then
|
||||
IDESynEdit.MarkupIdentComplWindow.HighlightColor:= Attri.Foreground
|
||||
else
|
||||
IDESynEdit.MarkupIdentComplWindow.HighlightColor:= clNone;
|
||||
|
||||
Attri := GetUsedAttr(ahaIdentComplWindowSelection);
|
||||
if Attri<>nil then
|
||||
begin
|
||||
IDESynEdit.MarkupIdentComplWindow.TextSelectedColor:= Attri.Foreground;
|
||||
IDESynEdit.MarkupIdentComplWindow.BackgroundSelectedColor:= Attri.Background;
|
||||
end else
|
||||
begin
|
||||
IDESynEdit.MarkupIdentComplWindow.TextSelectedColor := clNone;
|
||||
IDESynEdit.MarkupIdentComplWindow.BackgroundSelectedColor:= clNone;
|
||||
for aha := low(TIdentWindowAhaColorRange) to high(TIdentWindowAhaColorRange) do begin
|
||||
Attri := GetUsedAttr(aha);
|
||||
Attri.ApplyTo(IDESynEdit.MarkupIdentComplWindow.Color[aha]);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -129,6 +129,7 @@ type
|
||||
FIdentCompletionJumpToError: boolean;
|
||||
ccSelection: String;
|
||||
// colors for the completion form (popup form, e.g. word completion)
|
||||
FColors: TSynMarkupIdentComplWindow;
|
||||
|
||||
FActiveEditBackgroundColor: TColor;
|
||||
FActiveEditBackgroundSelectedColor: TColor;
|
||||
@ -167,6 +168,7 @@ type
|
||||
function GetCompletionFormClass: TSynBaseCompletionFormClass; override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
property IdentCompletionJumpToError: Boolean
|
||||
read FIdentCompletionJumpToError write FIdentCompletionJumpToError;
|
||||
end;
|
||||
@ -2443,7 +2445,6 @@ var
|
||||
Prefix: String;
|
||||
I: Integer;
|
||||
NewStr: String;
|
||||
SynEditor: TIDESynEditor;
|
||||
Template: TTemplate;
|
||||
A: TIdentComplSortMethod;
|
||||
Begin
|
||||
@ -2478,13 +2479,12 @@ Begin
|
||||
A=CodeToolBoss.IdentifierList.SortMethodForCompletion;
|
||||
end;
|
||||
|
||||
FActiveHistoryTextColor := clNone;
|
||||
FActiveEditTextColor := Editor.Font.Color;
|
||||
FActiveEditBorderColor := RGBToColor(200, 200, 200);
|
||||
FActiveEditBackgroundColor := Editor.Color;
|
||||
FActiveEditTextSelectedColor := TSynEdit(Editor).SelectedColor.Foreground;
|
||||
FActiveEditBackgroundSelectedColor := TSynEdit(Editor).SelectedColor.Background;
|
||||
FActiveEditTextHighLightColor := clNone;
|
||||
FColors.Clear;
|
||||
FColors.Color[ahaIdentComplWindow].Foreground := Editor.Font.Color;
|
||||
FColors.Color[ahaIdentComplWindow].Background := Editor.Color;
|
||||
FColors.Color[ahaIdentComplWindowBorder].Foreground := RGBToColor(200, 200, 200);
|
||||
FColors.Color[ahaIdentComplWindowSelection].Foreground := TSynEdit(Editor).SelectedColor.Foreground;
|
||||
FColors.Color[ahaIdentComplWindowSelection].Background := TSynEdit(Editor).SelectedColor.Background;
|
||||
|
||||
if Editor.Highlighter<>nil
|
||||
then begin
|
||||
@ -2492,30 +2492,16 @@ Begin
|
||||
if IdentifierAttribute<>nil
|
||||
then begin
|
||||
if IdentifierAttribute.ForeGround<>clNone then
|
||||
FActiveEditTextColor:=IdentifierAttribute.ForeGround;
|
||||
FColors.Color[ahaIdentComplWindow].Foreground := IdentifierAttribute.ForeGround;
|
||||
if IdentifierAttribute.BackGround<>clNone then
|
||||
FActiveEditBackgroundColor:=IdentifierAttribute.BackGround;
|
||||
FColors.Color[ahaIdentComplWindow].Background := IdentifierAttribute.BackGround;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
if Editor is TIDESynEditor then
|
||||
begin
|
||||
SynEditor := TIDESynEditor(Editor);
|
||||
if SynEditor.MarkupIdentComplWindow.TextColor<>clNone then
|
||||
FActiveEditTextColor := SynEditor.MarkupIdentComplWindow.TextColor;
|
||||
if SynEditor.MarkupIdentComplWindow.BorderColor<>clNone then
|
||||
FActiveEditBorderColor := SynEditor.MarkupIdentComplWindow.BorderColor;
|
||||
if SynEditor.MarkupIdentComplWindow.WindowColor<>clNone then
|
||||
FActiveEditBackgroundColor := SynEditor.MarkupIdentComplWindow.WindowColor;
|
||||
if SynEditor.MarkupIdentComplWindow.TextSelectedColor<>clNone then
|
||||
FActiveEditTextSelectedColor := SynEditor.MarkupIdentComplWindow.TextSelectedColor;
|
||||
if SynEditor.MarkupIdentComplWindow.BackgroundSelectedColor<>clNone then
|
||||
FActiveEditBackgroundSelectedColor := SynEditor.MarkupIdentComplWindow.BackgroundSelectedColor;
|
||||
if SynEditor.MarkupIdentComplWindow.HighlightColor<>clNone then
|
||||
FActiveEditTextHighLightColor := SynEditor.MarkupIdentComplWindow.HighlightColor;
|
||||
if SynEditor.MarkupIdentComplWindow.HistoryTextColor<>clNone then
|
||||
FActiveHistoryTextColor:=SynEditor.MarkupIdentComplWindow.HistoryTextColor;
|
||||
FColors.Merge(TIDESynEditor(Editor).MarkupIdentComplWindow);
|
||||
end;
|
||||
|
||||
SL := TStringList.Create;
|
||||
@ -2563,12 +2549,12 @@ Begin
|
||||
// set colors
|
||||
if (Editor<>nil) and (TheForm<>nil) then begin
|
||||
with TheForm as TSourceEditCompletionForm do begin
|
||||
DrawBorderColor := FActiveEditBorderColor;
|
||||
BackgroundColor := FActiveEditBackgroundColor;
|
||||
clSelect := FActiveEditBackgroundSelectedColor;
|
||||
TextColor := FActiveEditTextColor;
|
||||
TextSelectedColor := FActiveEditTextSelectedColor;
|
||||
TextHighLightColor:= FActiveEditTextHighLightColor;
|
||||
DrawBorderColor := FColors[ahaIdentComplWindowBorder].Foreground;
|
||||
BackgroundColor := FColors[ahaIdentComplWindow].Background;
|
||||
clSelect := FColors[ahaIdentComplWindowSelection].Background;
|
||||
TextColor := FColors[ahaIdentComplWindow].Foreground;
|
||||
TextSelectedColor := FColors[ahaIdentComplWindowSelection].Foreground;
|
||||
TextHighLightColor:= FColors[ahaIdentComplWindowHighlight].Foreground;
|
||||
//debugln('TSourceEditCompletion.ccExecute A Color=',DbgS(Color),
|
||||
// ' clSelect=',DbgS(clSelect),
|
||||
// ' TextColor=',DbgS(TextColor),
|
||||
@ -2766,7 +2752,6 @@ var
|
||||
MaxX: Integer;
|
||||
t: TCompletionType;
|
||||
hl: TSynCustomHighlighter;
|
||||
Colors: TPaintCompletionItemColors;
|
||||
begin
|
||||
try
|
||||
with ACanvas do begin
|
||||
@ -2779,20 +2764,12 @@ begin
|
||||
Font.Style:=[];
|
||||
end;
|
||||
|
||||
if (CurrentCompletionType = ctIdentCompletion) and
|
||||
FColors.UseRecent :=
|
||||
(CurrentCompletionType = ctIdentCompletion) and
|
||||
(CodeToolBoss.IdentifierList.SortForHistory) and
|
||||
(iliIsRecentItem in CodeToolBoss.IdentifierList.FilteredItems[Index].Flags) and
|
||||
(FActiveHistoryTextColor <> clNone)
|
||||
then begin
|
||||
Colors.TextColor := FActiveHistoryTextColor; // - to display history items
|
||||
end else begin
|
||||
Colors.TextColor := FActiveEditTextColor;
|
||||
end;
|
||||
(FColors[ahaIdentComplRecent].Foreground <> clNone);
|
||||
|
||||
Colors.BackgroundColor := FActiveEditBackgroundColor;
|
||||
Colors.BackgroundSelectedColor := FActiveEditBackgroundSelectedColor;
|
||||
Colors.TextSelectedColor := FActiveEditTextSelectedColor;
|
||||
Colors.TextHilightColor := FActiveEditTextHighLightColor;
|
||||
MaxX:=TheForm.ClientWidth;
|
||||
t:=CurrentCompletionType;
|
||||
if Manager.ActiveCompletionPlugin<>nil then
|
||||
@ -2807,7 +2784,7 @@ begin
|
||||
hl := nil;
|
||||
if Editor <> nil then
|
||||
hl := Editor.Highlighter;
|
||||
PaintCompletionItem(AKey, ACanvas, X, Y, MaxX, ItemSelected, Index, self, t, hl, @Colors);
|
||||
PaintCompletionItem(AKey, ACanvas, X, Y, MaxX, ItemSelected, Index, self, t, hl, FColors);
|
||||
Result:=true;
|
||||
except
|
||||
DebugLn('OnSynCompletionPaintItem failed');
|
||||
@ -3122,6 +3099,7 @@ end;
|
||||
constructor TSourceEditCompletion.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited;
|
||||
FColors := TSynMarkupIdentComplWindow.Create;
|
||||
EndOfTokenChr:='()[].,;:-+=^*<>/';
|
||||
Width:=400;
|
||||
OnExecute := @ccExecute;
|
||||
@ -3143,6 +3121,12 @@ begin
|
||||
TheForm.OnDragResized := @CompletionFormResized;
|
||||
end;
|
||||
|
||||
destructor TSourceEditCompletion.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
FColors.Free;
|
||||
end;
|
||||
|
||||
{ TSourceEditorSharedValues }
|
||||
|
||||
function TSourceEditorSharedValues.GetSharedEditors(Index: Integer): TSourceEditor;
|
||||
|
@ -50,7 +50,7 @@ uses
|
||||
// IdeIntf
|
||||
LazIDEIntf, IDEImagesIntf, TextTools, IDETextConverter,
|
||||
// IDE
|
||||
DialogProcs, EditorOptions, CodeToolsOptions;
|
||||
DialogProcs, EditorOptions, CodeToolsOptions, SourceSynEditor;
|
||||
|
||||
type
|
||||
|
||||
@ -110,20 +110,11 @@ type
|
||||
icvNone
|
||||
);
|
||||
|
||||
TPaintCompletionItemColors = record
|
||||
BackgroundColor: TColor;
|
||||
BackgroundSelectedColor: TColor;
|
||||
TextColor: TColor;
|
||||
TextSelectedColor: TColor;
|
||||
TextHilightColor: TColor;
|
||||
end;
|
||||
PPaintCompletionItemColors = ^TPaintCompletionItemColors;
|
||||
|
||||
// completion form and functions
|
||||
function PaintCompletionItem(const AKey: string; ACanvas: TCanvas;
|
||||
X, Y, MaxX: integer; ItemSelected: boolean; Index: integer;
|
||||
{%H-}aCompletion : TSynCompletion; CurrentCompletionType: TCompletionType;
|
||||
Highlighter: TSrcIDEHighlighter; Colors: PPaintCompletionItemColors;
|
||||
Highlighter: TSrcIDEHighlighter; Colors: TSynMarkupIdentComplWindow;
|
||||
MeasureOnly: Boolean = False): TPoint;
|
||||
|
||||
function GetIdentCompletionValue(aCompletion : TSynCompletion;
|
||||
@ -155,11 +146,10 @@ begin
|
||||
FreeAndNil(TextConverterToolClasses);
|
||||
end;
|
||||
|
||||
function PaintCompletionItem(const AKey: string; ACanvas: TCanvas; X, Y,
|
||||
MaxX: integer; ItemSelected: boolean; Index: integer;
|
||||
aCompletion: TSynCompletion; CurrentCompletionType: TCompletionType;
|
||||
Highlighter: TSrcIDEHighlighter; Colors: PPaintCompletionItemColors;
|
||||
MeasureOnly: Boolean): TPoint;
|
||||
function PaintCompletionItem(const AKey: string; ACanvas: TCanvas; X, Y, MaxX: integer;
|
||||
ItemSelected: boolean; Index: integer; aCompletion: TSynCompletion;
|
||||
CurrentCompletionType: TCompletionType; Highlighter: TSrcIDEHighlighter;
|
||||
Colors: TSynMarkupIdentComplWindow; MeasureOnly: Boolean): TPoint;
|
||||
|
||||
const
|
||||
HintModifierImage: array[TPascalHintModifier] of String = (
|
||||
@ -343,19 +333,26 @@ begin
|
||||
begin
|
||||
if ItemSelected then
|
||||
begin
|
||||
AllowFontColor := Colors^.TextSelectedColor=clNone;
|
||||
if AllowFontColor then
|
||||
ForegroundColor := ColorToRGB(Colors^.TextColor)
|
||||
AllowFontColor := Colors.TextSelectedColor=clNone;
|
||||
if AllowFontColor then begin
|
||||
if Colors.UseRecent then
|
||||
ForegroundColor := ColorToRGB(Colors.RecentColor)
|
||||
else
|
||||
ForegroundColor := ColorToRGB(Colors.TextColor);
|
||||
end
|
||||
else
|
||||
ForegroundColor := ColorToRGB(Colors^.TextSelectedColor);
|
||||
BackgroundColor:=ColorToRGB(Colors^.BackgroundSelectedColor);
|
||||
ForegroundColor := ColorToRGB(Colors.TextSelectedColor);
|
||||
BackgroundColor:=ColorToRGB(Colors.BackgroundSelectedColor);
|
||||
end else
|
||||
begin
|
||||
ForegroundColor := ColorToRGB(Colors^.TextColor);
|
||||
if Colors.UseRecent then
|
||||
ForegroundColor := ColorToRGB(Colors.RecentColor)
|
||||
else
|
||||
ForegroundColor := ColorToRGB(Colors.TextColor);
|
||||
AllowFontColor := True;
|
||||
BackgroundColor:=ColorToRGB(Colors^.BackgroundColor);
|
||||
BackgroundColor:=ColorToRGB(Colors.BackgroundColor);
|
||||
end;
|
||||
TextHilightColor:=ColorToRGB(Colors^.TextHilightColor);
|
||||
TextHilightColor:=ColorToRGB(Colors.TextHilightColor);
|
||||
end else
|
||||
begin
|
||||
ForegroundColor := clBlack;
|
||||
|
@ -62,7 +62,7 @@ uses
|
||||
SynEditMarkupHighAll, SynEditKeyCmds, SynEditMarkupIfDef, SynEditMiscProcs,
|
||||
SynPluginMultiCaret, SynEditPointClasses,
|
||||
SynEditMarkupFoldColoring, SynEditTextTabExpander, SynEditMouseCmds,
|
||||
etSrcEditMarks, LazarusIDEStrConsts;
|
||||
etSrcEditMarks, LazarusIDEStrConsts, SourceMarks;
|
||||
|
||||
type
|
||||
|
||||
@ -220,25 +220,33 @@ type
|
||||
property IfDefTree;
|
||||
end;
|
||||
|
||||
TIdentWindowAhaColorRange = ahaIdentComplWindow..ahaIdentComplWindowHighlight;
|
||||
|
||||
{ TSynMarkupIdentComplWindow }
|
||||
|
||||
TSynMarkupIdentComplWindow = class // don't inherit from TSynEditMarkup, no regular markup
|
||||
private
|
||||
FBackgroundSelectedColor: TColor;
|
||||
FBorderColor: TColor;
|
||||
FHighlightColor: TColor;
|
||||
FTextColor: TColor;
|
||||
FHistoryTextColor: TColor;
|
||||
FTextSelectedColor: TColor;
|
||||
FWindowColor: TColor;
|
||||
FColor: array[TIdentWindowAhaColorRange] of TSynHighlighterAttributes;
|
||||
FUseRecent: boolean;
|
||||
|
||||
function GetColor(AnIndex: TIdentWindowAhaColorRange): TSynHighlighterAttributes;
|
||||
function GetForegroundColor(AnIndex: TAdditionalHilightAttribute): TColor;
|
||||
function GetBackgroundColor(AnIndex: TAdditionalHilightAttribute): TColor;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure Clear;
|
||||
procedure Merge(AColors: TSynMarkupIdentComplWindow);
|
||||
public
|
||||
property WindowColor: TColor read FWindowColor write FWindowColor;
|
||||
property TextColor: TColor read FTextColor write FTextColor;
|
||||
property HistoryTextColor: TColor read FHistoryTextColor write FHistoryTextColor;
|
||||
property BorderColor: TColor read FBorderColor write FBorderColor;
|
||||
property HighlightColor: TColor read FHighlightColor write FHighlightColor;
|
||||
property TextSelectedColor: TColor read FTextSelectedColor write FTextSelectedColor;
|
||||
property BackgroundSelectedColor: TColor read FBackgroundSelectedColor write FBackgroundSelectedColor;
|
||||
property Color [AnIndex: TIdentWindowAhaColorRange]: TSynHighlighterAttributes read GetColor; default;
|
||||
|
||||
property TextColor: TColor index ahaIdentComplWindow read GetForegroundColor;
|
||||
property BackgroundColor: TColor index ahaIdentComplWindow read GetBackgroundColor;
|
||||
property TextSelectedColor: TColor index ahaIdentComplWindowSelection read GetForegroundColor;
|
||||
property BackgroundSelectedColor: TColor index ahaIdentComplWindowSelection read GetBackgroundColor;
|
||||
property TextHilightColor : TColor index ahaIdentComplWindowHighlight read GetForegroundColor;
|
||||
property RecentColor: TColor index ahaIdentComplRecent read GetForegroundColor;
|
||||
property UseRecent: boolean read FUseRecent write FUseRecent;
|
||||
end;
|
||||
|
||||
{ TIDESynEditor }
|
||||
@ -543,21 +551,69 @@ type
|
||||
|
||||
implementation
|
||||
|
||||
uses SourceMarks;
|
||||
|
||||
{ TSynMarkupIdentComplWindow }
|
||||
|
||||
function TSynMarkupIdentComplWindow.GetColor(AnIndex: TIdentWindowAhaColorRange
|
||||
): TSynHighlighterAttributes;
|
||||
begin
|
||||
Result := FColor[AnIndex];
|
||||
end;
|
||||
|
||||
function TSynMarkupIdentComplWindow.GetForegroundColor(AnIndex: TAdditionalHilightAttribute
|
||||
): TColor;
|
||||
begin
|
||||
Result := FColor[AnIndex].Foreground;
|
||||
end;
|
||||
|
||||
function TSynMarkupIdentComplWindow.GetBackgroundColor(AnIndex: TAdditionalHilightAttribute
|
||||
): TColor;
|
||||
begin
|
||||
Result := FColor[AnIndex].Background
|
||||
end;
|
||||
|
||||
constructor TSynMarkupIdentComplWindow.Create;
|
||||
var
|
||||
i: TIdentWindowAhaColorRange;
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FBackgroundSelectedColor := clNone;
|
||||
FBorderColor := clNone;
|
||||
FHighlightColor := clNone;
|
||||
FTextColor := clNone;
|
||||
FHistoryTextColor := clNone;
|
||||
FTextSelectedColor := clNone;
|
||||
FWindowColor := clNone;
|
||||
for i := low(TIdentWindowAhaColorRange) to high(TIdentWindowAhaColorRange) do
|
||||
FColor[i] := TSynHighlighterAttributes.Create;
|
||||
Clear;
|
||||
end;
|
||||
|
||||
destructor TSynMarkupIdentComplWindow.Destroy;
|
||||
var
|
||||
i: TIdentWindowAhaColorRange;
|
||||
begin
|
||||
inherited Destroy;
|
||||
|
||||
for i := low(TIdentWindowAhaColorRange) to high(TIdentWindowAhaColorRange) do
|
||||
FColor[i].Free;
|
||||
end;
|
||||
|
||||
procedure TSynMarkupIdentComplWindow.Clear;
|
||||
var
|
||||
i: TIdentWindowAhaColorRange;
|
||||
begin
|
||||
FUseRecent := False;
|
||||
for i := low(TIdentWindowAhaColorRange) to high(TIdentWindowAhaColorRange) do begin
|
||||
FColor[i].Foreground := clNone;
|
||||
FColor[i].Background := clNone;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynMarkupIdentComplWindow.Merge(AColors: TSynMarkupIdentComplWindow);
|
||||
var
|
||||
i: TIdentWindowAhaColorRange;
|
||||
begin
|
||||
for i := low(TIdentWindowAhaColorRange) to high(TIdentWindowAhaColorRange) do begin
|
||||
if AColors[i].Foreground <> clNone then
|
||||
FColor[i].Foreground := AColors.FColor[i].Foreground;
|
||||
if AColors[i].Background <> clNone then
|
||||
FColor[i].Background := AColors.FColor[i].Background;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TSourceSynSearchTermDict }
|
||||
|
Loading…
Reference in New Issue
Block a user