mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-25 11:19:40 +02:00
IDE: identifier completion window: use editor settings to (dis)allow font highlighting
git-svn-id: trunk@57105 -
This commit is contained in:
parent
afa1c5c035
commit
3164be0b8b
@ -2355,6 +2355,7 @@ var
|
|||||||
MaxX: Integer;
|
MaxX: Integer;
|
||||||
t: TCompletionType;
|
t: TCompletionType;
|
||||||
hl: TSynCustomHighlighter;
|
hl: TSynCustomHighlighter;
|
||||||
|
Colors: TPaintCompletionItemColors;
|
||||||
begin
|
begin
|
||||||
with ACanvas do begin
|
with ACanvas do begin
|
||||||
if (Editor<>nil) then
|
if (Editor<>nil) then
|
||||||
@ -2364,11 +2365,9 @@ begin
|
|||||||
Font.Name:=EditorOpts.EditorFont;
|
Font.Name:=EditorOpts.EditorFont;
|
||||||
end;
|
end;
|
||||||
Font.Style:=[];
|
Font.Style:=[];
|
||||||
if not ItemSelected then
|
|
||||||
Font.Color := FActiveEditDefaultFGColor
|
|
||||||
else
|
|
||||||
Font.Color := FActiveEditSelectedFGColor;
|
|
||||||
end;
|
end;
|
||||||
|
Colors.FontColor := FActiveEditDefaultFGColor;
|
||||||
|
Colors.SelectedFontColor := FActiveEditSelectedFGColor;
|
||||||
MaxX:=TheForm.ClientWidth;
|
MaxX:=TheForm.ClientWidth;
|
||||||
t:=CurrentCompletionType;
|
t:=CurrentCompletionType;
|
||||||
if Manager.ActiveCompletionPlugin<>nil then
|
if Manager.ActiveCompletionPlugin<>nil then
|
||||||
@ -2383,7 +2382,7 @@ begin
|
|||||||
hl := nil;
|
hl := nil;
|
||||||
if Editor <> nil then
|
if Editor <> nil then
|
||||||
hl := Editor.Highlighter;
|
hl := Editor.Highlighter;
|
||||||
PaintCompletionItem(AKey, ACanvas, X, Y, MaxX, ItemSelected, Index, self, t, hl);
|
PaintCompletionItem(AKey, ACanvas, X, Y, MaxX, ItemSelected, Index, self, t, hl, @Colors);
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2418,7 +2417,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
Result := PaintCompletionItem(AKey,ACanvas,0,0,MaxX,ItemSelected,Index,
|
Result := PaintCompletionItem(AKey,ACanvas,0,0,MaxX,ItemSelected,Index,
|
||||||
self,t,nil,True);
|
self,t,nil,nil,True);
|
||||||
Result.Y:=FontHeight;
|
Result.Y:=FontHeight;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -97,11 +97,18 @@ type
|
|||||||
icvNone
|
icvNone
|
||||||
);
|
);
|
||||||
|
|
||||||
|
TPaintCompletionItemColors = record
|
||||||
|
FontColor: TColor;
|
||||||
|
SelectedFontColor: TColor;
|
||||||
|
end;
|
||||||
|
PPaintCompletionItemColors = ^TPaintCompletionItemColors;
|
||||||
|
|
||||||
// completion form and functions
|
// completion form and functions
|
||||||
function PaintCompletionItem(const AKey: string; ACanvas: TCanvas;
|
function PaintCompletionItem(const AKey: string; ACanvas: TCanvas;
|
||||||
X, Y, MaxX: integer; ItemSelected: boolean; Index: integer;
|
X, Y, MaxX: integer; ItemSelected: boolean; Index: integer;
|
||||||
{%H-}aCompletion : TSynCompletion; CurrentCompletionType: TCompletionType;
|
{%H-}aCompletion : TSynCompletion; CurrentCompletionType: TCompletionType;
|
||||||
Highlighter: TSrcIDEHighlighter; MeasureOnly: Boolean = False): TPoint;
|
Highlighter: TSrcIDEHighlighter; Colors: PPaintCompletionItemColors;
|
||||||
|
MeasureOnly: Boolean = False): TPoint;
|
||||||
|
|
||||||
function GetIdentCompletionValue(aCompletion : TSynCompletion;
|
function GetIdentCompletionValue(aCompletion : TSynCompletion;
|
||||||
AddChar: TUTF8Char;
|
AddChar: TUTF8Char;
|
||||||
@ -124,10 +131,11 @@ begin
|
|||||||
FreeAndNil(TextConverterToolClasses);
|
FreeAndNil(TextConverterToolClasses);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function PaintCompletionItem(const AKey: string; ACanvas: TCanvas;
|
function PaintCompletionItem(const AKey: string; ACanvas: TCanvas; X, Y,
|
||||||
X, Y, MaxX: integer; ItemSelected: boolean; Index: integer;
|
MaxX: integer; ItemSelected: boolean; Index: integer;
|
||||||
aCompletion : TSynCompletion; CurrentCompletionType: TCompletionType;
|
aCompletion: TSynCompletion; CurrentCompletionType: TCompletionType;
|
||||||
Highlighter: TSrcIDEHighlighter; MeasureOnly: Boolean): TPoint;
|
Highlighter: TSrcIDEHighlighter; Colors: PPaintCompletionItemColors;
|
||||||
|
MeasureOnly: Boolean): TPoint;
|
||||||
|
|
||||||
const
|
const
|
||||||
HintModifierImage: array[TPascalHintModifier] of String = (
|
HintModifierImage: array[TPascalHintModifier] of String = (
|
||||||
@ -145,6 +153,7 @@ var
|
|||||||
TokenStart: Integer;
|
TokenStart: Integer;
|
||||||
BackgroundColor: TColorRef;
|
BackgroundColor: TColorRef;
|
||||||
ForegroundColor: TColorRef;
|
ForegroundColor: TColorRef;
|
||||||
|
AllowFontColor: Boolean;
|
||||||
|
|
||||||
procedure SetFontColor(NewColor: TColor);
|
procedure SetFontColor(NewColor: TColor);
|
||||||
|
|
||||||
@ -171,6 +180,9 @@ var
|
|||||||
GreenDiff: integer;
|
GreenDiff: integer;
|
||||||
BlueDiff: integer;
|
BlueDiff: integer;
|
||||||
begin
|
begin
|
||||||
|
if not AllowFontColor then
|
||||||
|
Exit;
|
||||||
|
|
||||||
NewColor := TColor(ColorToRGB(NewColor));
|
NewColor := TColor(ColorToRGB(NewColor));
|
||||||
FGRed:=(NewColor shr 16) and $ff;
|
FGRed:=(NewColor shr 16) and $ff;
|
||||||
FGGreen:=(NewColor shr 8) and $ff;
|
FGGreen:=(NewColor shr 8) and $ff;
|
||||||
@ -216,7 +228,7 @@ var
|
|||||||
Inc(Result.X,ACanvas.TextWidth(s));
|
Inc(Result.X,ACanvas.TextWidth(s));
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
if (Highlighter<>nil) and (not ItemSelected) then begin
|
if (Highlighter<>nil) and AllowFontColor then begin
|
||||||
Highlighter.ResetRange;
|
Highlighter.ResetRange;
|
||||||
Highlighter.SetLine(s,0);
|
Highlighter.SetLine(s,0);
|
||||||
while not Highlighter.GetEol do begin
|
while not Highlighter.GetEol do begin
|
||||||
@ -256,7 +268,28 @@ var
|
|||||||
HintModifier: TPascalHintModifier;
|
HintModifier: TPascalHintModifier;
|
||||||
HelperForNode: TCodeTreeNode;
|
HelperForNode: TCodeTreeNode;
|
||||||
begin
|
begin
|
||||||
ForegroundColor := ColorToRGB(ACanvas.Font.Color);
|
if (Colors<>nil) or MeasureOnly then
|
||||||
|
begin
|
||||||
|
if ItemSelected then
|
||||||
|
begin
|
||||||
|
ForegroundColor := Colors^.SelectedFontColor;
|
||||||
|
AllowFontColor := ForegroundColor=clNone;
|
||||||
|
if ForegroundColor=clNone then
|
||||||
|
ForegroundColor := Colors^.FontColor;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
ForegroundColor := Colors^.FontColor;
|
||||||
|
AllowFontColor := True;
|
||||||
|
end;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
ForegroundColor := clBlack;
|
||||||
|
AllowFontColor := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
ForegroundColor := ColorToRGB(ForegroundColor);
|
||||||
|
ACanvas.Font.Color := ForegroundColor;
|
||||||
|
|
||||||
Result.X := 0;
|
Result.X := 0;
|
||||||
Result.Y := ACanvas.TextHeight('W');
|
Result.Y := ACanvas.TextHeight('W');
|
||||||
if CurrentCompletionType=ctIdentCompletion then begin
|
if CurrentCompletionType=ctIdentCompletion then begin
|
||||||
|
Loading…
Reference in New Issue
Block a user