mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-20 17:39:43 +01:00
SynEdit: Refactor, LengthOfLongestLine
git-svn-id: trunk@25789 -
This commit is contained in:
parent
4ab9eaac1b
commit
0e98a5118a
@ -311,10 +311,8 @@ end;
|
||||
function TSynEditStringTabExpander.GetLengthOfLongestLine: integer;
|
||||
var
|
||||
Line: String;
|
||||
CharWidths: TPhysicalCharWidths;
|
||||
n, m: Integer;
|
||||
//var
|
||||
i, j: integer;
|
||||
CharWidths: PPhysicalCharWidth;
|
||||
i, j, n, m: Integer;
|
||||
begin
|
||||
if (fIndexOfLongestLine >= 0) and (fIndexOfLongestLine < Count) then begin
|
||||
Result := FTabData[fIndexOfLongestLine];
|
||||
@ -322,8 +320,10 @@ begin
|
||||
exit;
|
||||
end;
|
||||
|
||||
try
|
||||
Result := 0;
|
||||
m := 0;
|
||||
CharWidths := nil;
|
||||
for i := 0 to Count - 1 do begin
|
||||
j := FTabData[i];
|
||||
if j = LINE_LEN_UNKNOWN then begin
|
||||
@ -336,10 +336,10 @@ begin
|
||||
end else begin
|
||||
n := length(Line);
|
||||
if n > m then begin
|
||||
SetLength(CharWidths, n);
|
||||
ReAllocMem(CharWidths, n * SizeOf(TPhysicalCharWidth));
|
||||
m := n;
|
||||
end;
|
||||
DoGetPhysicalCharWidths(Pchar(Line), n, i, @CharWidths[0]);
|
||||
DoGetPhysicalCharWidths(Pchar(Line), n, i, CharWidths);
|
||||
for m := 0 to n-1 do
|
||||
j := j + CharWidths[m];
|
||||
|
||||
@ -357,6 +357,9 @@ begin
|
||||
fIndexOfLongestLine := i;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
ReAllocMem(CharWidths, 0);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user