summaryrefslogtreecommitdiff
path: root/examples/apps
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2011-08-29 22:10:08 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2011-08-29 22:19:03 +0200
commit89aabaace7ebd7dd0519529d23bbcc776833a526 (patch)
tree2b4bc2bfedc127f6f43979607e4bc13e1fb40cec /examples/apps
parent66199125fd59b24277a8c40a2b55af71306a7d77 (diff)
downloadfpGUI-89aabaace7ebd7dd0519529d23bbcc776833a526.tar.xz
textedit: improved text selection via keyboard support
Diffstat (limited to 'examples/apps')
-rw-r--r--examples/apps/ide/src/fpg_textedit.pas64
1 files changed, 32 insertions, 32 deletions
diff --git a/examples/apps/ide/src/fpg_textedit.pas b/examples/apps/ide/src/fpg_textedit.pas
index 58789664..06345b46 100644
--- a/examples/apps/ide/src/fpg_textedit.pas
+++ b/examples/apps/ide/src/fpg_textedit.pas
@@ -1611,64 +1611,64 @@ begin
{ start drawing formatted text }
R.SetRect(X, Y, UTF8Length(S) * FChrW, FChrH);
AllowDraw := True;
+
{ end-user can hook in here to do syntax highlighting and other custom drawing }
if Assigned(FOnDrawLine) then
FOnDrawLine(self, S, ALineIndex, Canvas, R, AllowDraw);
+
{ Draw simple text line... }
if AllowDraw then
- begin
Canvas.DrawText(R, S);
- end;
- if FSelected then
+
+ if FSelected then
+ begin
+ 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.FillRectangle(R);
+ Canvas.DrawText(R, S);
+ end
+ else
begin
- Canvas.TextColor := clWhite;
- Canvas.Color := fpgColorToRGB(clSelection);
- if (ALineIndex > StartNo) and (ALineIndex < EndNo) then // whole line is selected
+ Ei := EndOffs;
+ Si := StartOffs;
+ if (ALineIndex = StartNo) and (ALineIndex = EndNo) then // start/end selection on same line
begin
- R.SetRect(X, Y, UTF8Length(S) * FChrW, FChrH);
+ SS := UTF8Copy(S, Si + 1, UTF8Length(S) - Si);
+ if Ei > UTF8Length(S) then
+ SS := UTF8Copy(S, Si + 1, UTF8Length(S) - Si)
+ else
+ SS := UTF8Copy(S, Si + 1, Ei - Si);
+ R.SetRect(X+(Si * FChrW), Y, (UTF8Length(SS) * FChrW), FChrH);
Canvas.FillRectangle(R);
- Canvas.DrawText(R, S);
+ Canvas.DrawText(R, SS);
end
else
begin
- Ei := EndOffs;
- Si := StartOffs;
- if (ALineIndex = StartNo) and (ALineIndex = EndNo) then // start/end selection on same line
+ if (ALineIndex = StartNo) and (ALineIndex < EndNo) then
begin
SS := UTF8Copy(S, Si + 1, UTF8Length(S) - Si);
- if Ei > UTF8Length(S) then
- SS := UTF8Copy(S, Si + 1, UTF8Length(S) - Si)
- else
- SS := UTF8Copy(S, Si + 1, Ei - Si);
R.SetRect(X+(Si * FChrW), Y, (UTF8Length(SS) * FChrW), FChrH);
Canvas.FillRectangle(R);
Canvas.DrawText(R, SS);
end
else
begin
- if (ALineIndex = StartNo) and (ALineIndex < 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);
+ if Ei > UTF8Length(S) then
+ Ei := UTF8Length(S);
+ SS := UTF8Copy(S, 1, Ei);
+ R.SetRect(X, Y, (UTF8Length(SS) * FChrW), FChrH);
Canvas.FillRectangle(R);
Canvas.DrawText(R, SS);
- end
- else
- begin
- 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.FillRectangle(R);
- Canvas.DrawText(R, SS);
- end;
end;
end;
end;
- end; { if FSelected... }
-// end; { if AllowDraw... }
+ end;
+ end; { if FSelected... }
if UTF8Length(S) > FMaxScrollH then
begin