Kaydet (Commit) d12980ce authored tarafından Marcos Paulo de Souza's avatar Marcos Paulo de Souza Kaydeden (comit) Michael Meeks

Fix fdo#43090: Auto Closing of brackets

Check if we hit the left bracket, left parenthesis or left braces, insert the right close character
and set the current position to center the characters.

Change-Id: If1ee8a00799ef0933d5dfd51c32f669a2a27b2a7
Reviewed-on: https://gerrit.libreoffice.org/4374Reviewed-by: 's avatarMichael Meeks <michael.meeks@suse.com>
Tested-by: 's avatarMichael Meeks <michael.meeks@suse.com>
üst 1365a4d2
...@@ -455,6 +455,27 @@ void SmEditWindow::KeyInput(const KeyEvent& rKEvt) ...@@ -455,6 +455,27 @@ void SmEditWindow::KeyInput(const KeyEvent& rKEvt)
aModifyTimer.Start(); aModifyTimer.Start();
} }
// get the current char of the key event
sal_Unicode charCode = rKEvt.GetCharCode();
OUString close;
if (charCode == '{')
close = " }";
else if (charCode == '[')
close = " ]";
else if (charCode == '(')
close = " )";
// auto close the current character
if (!close.isEmpty())
{
pEditView->InsertText(close);
// position it at center of brackets
ESelection aSelection = pEditView->GetSelection();
aSelection.nStartPos = aSelection.nEndPos = aSelection.nEndPos - 2;
pEditView->SetSelection(aSelection);
}
InvalidateSlots(); InvalidateSlots();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment