mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 20:50:18 +02:00
win32: avoid redundant call for GetRealCount and GetLineStart in TWin32MemoStrings.Insert
git-svn-id: trunk@53294 -
This commit is contained in:
parent
d99fe899e7
commit
f43e1bfde6
@ -140,24 +140,25 @@ end;
|
||||
|
||||
procedure TWin32MemoStrings.Insert(Index: integer; const S: string);
|
||||
var
|
||||
LineStart: Integer;
|
||||
LineStart, RealCount: Integer;
|
||||
NewLine: String;
|
||||
begin
|
||||
LineStart := GetLineStart(Index);
|
||||
if Index < GetRealCount then
|
||||
RealCount := GetRealCount;
|
||||
if Index < RealCount then
|
||||
begin
|
||||
//insert with LineEnding
|
||||
LineStart := GetLineStart(Index);
|
||||
NewLine := S+LineEnding;
|
||||
SendMessageW(FHandle, EM_SETSEL, LineStart, LineStart);
|
||||
SendMessageW(FHandle, EM_REPLACESEL, 0, lparam(PWideChar(UTF8ToUTF16(NewLine))))
|
||||
SendMessageW(FHandle, EM_REPLACESEL, 0, lparam(PWideChar(UTF8ToUTF16(NewLine))));
|
||||
end
|
||||
else
|
||||
begin
|
||||
//append with a preceding LineEnding
|
||||
LineStart := GetLineStart(Index-1)+GetLineLength(Index-1);
|
||||
SendMessageW(FHandle, EM_SETSEL, LineStart, LineStart);
|
||||
if GetRealCount = Count then
|
||||
//check if last line is empty
|
||||
if Get(RealCount - 1) <> '' then
|
||||
NewLine := LineEnding+S+LineEnding
|
||||
else
|
||||
NewLine := S+LineEnding;
|
||||
|
Loading…
Reference in New Issue
Block a user