mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 20:55:59 +02:00
TCDEdit: Implements ENTER key handling in multiline mode
git-svn-id: trunk@36935 -
This commit is contained in:
parent
18fb5b9362
commit
98541475a5
@ -1778,6 +1778,27 @@ begin
|
||||
VK_RETURN:
|
||||
begin
|
||||
if not MultiLine then Exit;
|
||||
// Selection delete
|
||||
if IsSomethingSelected() then
|
||||
DoDeleteSelection();
|
||||
// If the are no contents at the moment, add two lines, because the first one always exists for the user
|
||||
if FLines.Count = 0 then
|
||||
begin
|
||||
FLines.Add('');
|
||||
FLines.Add('');
|
||||
FEditState.CaretPos := Point(0, 1);
|
||||
end
|
||||
else
|
||||
begin
|
||||
// Get the two halves of the text separated by the cursor
|
||||
lLeftText := UTF8Copy(lOldText, 1, FEditState.CaretPos.X);
|
||||
lRightText := UTF8Copy(lOldText, FEditState.CaretPos.X+1, lOldTextLength);
|
||||
// Move the right part to a new line
|
||||
SetCurrentLine(lLeftText);
|
||||
FLines.Insert(FEditState.CaretPos.Y+1, lRightText);
|
||||
FEditState.CaretPos := Point(0, FEditState.CaretPos.Y+1);
|
||||
end;
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user