mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 12:12:25 +02:00
SynEdit: Caret, reduce calculation overhead
git-svn-id: trunk@39694 -
This commit is contained in:
parent
b3f15ac258
commit
cdadce87e0
@ -654,31 +654,40 @@ end;
|
|||||||
|
|
||||||
procedure TSynEditCaret.InternalSetLineCharPos(NewLine, NewCharPos: Integer;
|
procedure TSynEditCaret.InternalSetLineCharPos(NewLine, NewCharPos: Integer;
|
||||||
KeepLastCharPos: Boolean = False; ForceSet: Boolean = False);
|
KeepLastCharPos: Boolean = False; ForceSet: Boolean = False);
|
||||||
|
|
||||||
|
function GetMaxLeftPastEOL: Integer;
|
||||||
|
begin
|
||||||
|
if FMaxLeftChar <> nil then
|
||||||
|
Result := FMaxLeftChar()
|
||||||
|
else
|
||||||
|
Result := MaxInt;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
nMaxX, i: Integer;
|
nMaxX, i: Integer;
|
||||||
Line: string;
|
|
||||||
begin
|
begin
|
||||||
Lock;
|
Lock;
|
||||||
FTouched := True;
|
FTouched := True;
|
||||||
try
|
try
|
||||||
if (fCharPos <> NewCharPos) or (fLinePos <> NewLine) or ForceSet then begin
|
if (fCharPos <> NewCharPos) or (fLinePos <> NewLine) or ForceSet then begin
|
||||||
if FMaxLeftChar <> nil then
|
|
||||||
nMaxX := FMaxLeftChar()
|
|
||||||
else
|
|
||||||
nMaxX := MaxInt;
|
|
||||||
if NewLine > FLines.Count then
|
if NewLine > FLines.Count then
|
||||||
NewLine := FLines.Count;
|
NewLine := FLines.Count;
|
||||||
|
|
||||||
if NewLine < 1 then begin
|
if NewLine < 1 then begin
|
||||||
|
nMaxX := 1;
|
||||||
|
if (NewCharPos > 1) and (FAllowPastEOL or (FForcePastEOL > 0)) then
|
||||||
|
nMaxX := GetMaxLeftPastEOL;
|
||||||
// this is just to make sure if Lines stringlist should be empty
|
// this is just to make sure if Lines stringlist should be empty
|
||||||
NewLine := 1;
|
NewLine := 1;
|
||||||
if (not FAllowPastEOL) and (FForcePastEOL = 0) then
|
|
||||||
nMaxX := 1;
|
|
||||||
end else begin
|
end else begin
|
||||||
Line := Lines[NewLine - 1];
|
i := Lines.LogPhysConvertor.LogicalToPhysical(NewLine-1, length(Lines[NewLine - 1])+1);
|
||||||
i := Lines.LogicalToPhysicalCol(Line, NewLine - 1, length(Line)+1);
|
nMaxX := i;
|
||||||
if ((not FAllowPastEOL) and (FForcePastEOL = 0)) or (nMaxX < i) then
|
if (NewCharPos > i) and (FAllowPastEOL or (FForcePastEOL > 0)) then
|
||||||
|
nMaxX := GetMaxLeftPastEOL;
|
||||||
|
if (nMaxX < i) then
|
||||||
nMaxX := i;
|
nMaxX := i;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if NewCharPos > nMaxX then
|
if NewCharPos > nMaxX then
|
||||||
NewCharPos := nMaxX;
|
NewCharPos := nMaxX;
|
||||||
if NewCharPos < 1 then
|
if NewCharPos < 1 then
|
||||||
|
Loading…
Reference in New Issue
Block a user