summaryrefslogtreecommitdiff
path: root/examples/apps
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graemeg@gmail.com>2013-03-14 13:36:34 +0000
committerGraeme Geldenhuys <graemeg@gmail.com>2013-03-14 13:36:34 +0000
commit9a282af6037f84ff36af4aa81da9a462a05a2eb7 (patch)
tree68c0705ab6de18710a1f452045974a5f1f8ec4f1 /examples/apps
parent1909941bcf11b4bcd0f57a168e291d00e9449e1a (diff)
downloadfpGUI-9a282af6037f84ff36af4aa81da9a462a05a2eb7.tar.xz
textedit: minor optimisation in DEL key handling
If we know the current line is empty, we can simply delete that line, without having to worry about concatenation with the next line.
Diffstat (limited to 'examples/apps')
-rw-r--r--examples/apps/ide/src/fpg_textedit.pas25
1 files changed, 16 insertions, 9 deletions
diff --git a/examples/apps/ide/src/fpg_textedit.pas b/examples/apps/ide/src/fpg_textedit.pas
index d793cf66..b68c78b3 100644
--- a/examples/apps/ide/src/fpg_textedit.pas
+++ b/examples/apps/ide/src/fpg_textedit.pas
@@ -1674,19 +1674,26 @@ begin
if CaretPos.Y > pred(FLines.Count) then
Exit;
SLine := FLines[CaretPos.Y];
- if Length(SLine) >= CaretPos.X + 1 then
+ if SLine = '' then // short circut the code block
begin
- X := CaretPos.X + 1;
- Delete(SLine, X, 1);
- FLines[CaretPos.Y] := SLine;
+ FLines.Delete(CaretPos.Y);
end
else
begin
- if CaretPos.Y + 1 > pred(FLines.Count) then
- Exit;
- AddS := FLines[CaretPos.Y + 1];
- FLines[CaretPos.Y] := SLine + AddS;
- FLines.Delete(CaretPos.Y + 1);
+ if Length(SLine) >= CaretPos.X + 1 then
+ begin
+ X := CaretPos.X + 1;
+ Delete(SLine, X, 1);
+ FLines[CaretPos.Y] := SLine;
+ end
+ else
+ begin
+ if CaretPos.Y + 1 > pred(FLines.Count) then
+ Exit;
+ AddS := FLines[CaretPos.Y + 1];
+ FLines[CaretPos.Y] := SLine + AddS;
+ FLines.Delete(CaretPos.Y + 1);
+ end;
end;
consumed := True;
end;