summaryrefslogtreecommitdiff
path: root/src/fpg_textedit.pas
diff options
context:
space:
mode:
Diffstat (limited to 'src/fpg_textedit.pas')
-rw-r--r--src/fpg_textedit.pas43
1 files changed, 25 insertions, 18 deletions
diff --git a/src/fpg_textedit.pas b/src/fpg_textedit.pas
index 749b3d7c..e6aab639 100644
--- a/src/fpg_textedit.pas
+++ b/src/fpg_textedit.pas
@@ -136,8 +136,8 @@ type
procedure HandleKeyChar(var AText: TfpgChar; var shiftstate: TShiftState; var consumed: boolean); override;
{ -- local widget functions -- }
procedure DrawVisible; virtual;
- procedure DrawLine(const I, Y: Integer); virtual;
- procedure FormatLine(const I, X, Y: Integer);
+ procedure DrawLine(const ALineIndex, Y: Integer); virtual;
+ procedure FormatLine(const ALineIndex, X, Y: Integer);
procedure DrawCaret(const X, Y: Integer); virtual;
{ -- to be published --}
property FontDesc: string read GetFontDesc write SetFontDesc;
@@ -1391,7 +1391,7 @@ begin
end;
end;
-procedure TfpgBaseTextEdit.DrawLine(const I, Y: Integer);
+procedure TfpgBaseTextEdit.DrawLine(const ALineIndex, Y: Integer);
var
X: Integer;
GSz: Integer;
@@ -1408,14 +1408,14 @@ begin
else
GSz := GetClientRect.Left + 1; // gutter size if no gutter panel
- if I < FLines.Count then
+ if ALineIndex < FLines.Count then
begin
X := -(HPos * FChrW) + GSz;
- FormatLine(I, X, Y);
+ FormatLine(ALineIndex, X, Y);
end;
end;
-procedure TfpgBaseTextEdit.FormatLine(const I, X, Y: Integer);
+procedure TfpgBaseTextEdit.FormatLine(const ALineIndex, X, Y: Integer);
var
S, CorrectS, SS: TfpgString;
TI, Si, Ei, T: Integer;
@@ -1424,9 +1424,9 @@ var
begin
if FLines.Count = 0 then
Exit; //==>
- if (I < 0) or (I > FLines.Count-1) then
+ if (ALineIndex < 0) or (ALineIndex > FLines.Count-1) then
Exit; //==>
- S := FLines[I];
+ S := FLines[ALineIndex];
if Pos(#9, S) > 0 then
begin
CorrectS := '';
@@ -1448,23 +1448,27 @@ begin
AllowDraw := True;
{ end-user can hook in here to do syntax highlighting and other custom drawing }
if Assigned(FOnDrawLine) then
- FOnDrawLine(self, S, I, Canvas, R, AllowDraw);
+ FOnDrawLine(self, S, ALineIndex, Canvas, R, AllowDraw);
{ Draw simple text line... }
if AllowDraw then
begin
Canvas.DrawText(R, S);
+ end;
if FSelected then
begin
- if (I > StartNo) and (I < EndNo) then // whole line is selected
+ Canvas.TextColor := clWhite;
+ Canvas.Color := fpgColorToRGB(clSelection);
+ if (ALineIndex > StartNo) and (ALineIndex < EndNo) then // whole line is selected
begin
R.SetRect(X, Y, UTF8Length(S) * FChrW, FChrH);
- Canvas.XORFillRectangle(fpgColorToRGB(clSelection) xor $FFFFFF, R);
+ Canvas.FillRectangle(R);
+ Canvas.DrawText(R, S);
end
else
begin
Ei := EndOffs;
Si := StartOffs;
- if (I = StartNo) and (I = EndNo) then // start/end selection on same line
+ if (ALineIndex = StartNo) and (ALineIndex = EndNo) then // start/end selection on same line
begin
SS := UTF8Copy(S, Si + 1, UTF8Length(S) - Si);
if Ei > UTF8Length(S) then
@@ -1472,31 +1476,34 @@ begin
else
SS := UTF8Copy(S, Si + 1, Ei - Si);
R.SetRect(X+(Si * FChrW), Y, (UTF8Length(SS) * FChrW), FChrH);
- Canvas.XORFillRectangle(fpgColorToRGB(clSelection) xor $FFFFFF, R);
+ Canvas.FillRectangle(R);
+ Canvas.DrawText(R, SS);
end
else
begin
- if (I = StartNo) and (I < EndNo) then
+ if (ALineIndex = StartNo) and (ALineIndex < EndNo) then
begin
SS := UTF8Copy(S, Si + 1, UTF8Length(S) - Si);
R.SetRect(X+(Si * FChrW), Y, (UTF8Length(SS) * FChrW), FChrH);
- Canvas.XORFillRectangle(fpgColorToRGB(clSelection) xor $FFFFFF, R);
+ Canvas.FillRectangle(R);
+ Canvas.DrawText(R, SS);
end
else
begin
- if (I > StartNo) and (I = EndNo) then
+ if (ALineIndex > StartNo) and (ALineIndex = EndNo) then
begin
if Ei > UTF8Length(S) then
Ei := UTF8Length(S);
SS := UTF8Copy(S, 1, Ei);
R.SetRect(X, Y, (UTF8Length(SS) * FChrW), FChrH);
- Canvas.XORFillRectangle(fpgColorToRGB(clSelection) xor $FFFFFF, R);
+ Canvas.FillRectangle(R);
+ Canvas.DrawText(R, SS);
end;
end;
end;
end;
end; { if FSelected... }
- end; { if AllowDraw... }
+// end; { if AllowDraw... }
if UTF8Length(S) > FMaxScrollH then
begin