TCDEdit: Implements ENTER key handling in multiline mode

git-svn-id: trunk@36935 -
This commit is contained in:
sekelsenmat 2012-04-20 15:22:53 +00:00
parent 18fb5b9362
commit 98541475a5

View File

@ -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