summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcos Paulo de Souza <marcos.souza.org@gmail.com>2013-06-20 00:23:29 -0300
committerMichael Meeks <michael.meeks@suse.com>2013-06-26 12:09:14 +0000
commitd12980ce0b86549028ddaac3192f14456dde25c6 (patch)
tree586c3595da346eedfafb6e6c0dc7cee72a5b38fb
parent1365a4d281f969e8cd3833422b2d771621d40245 (diff)
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/4374 Reviewed-by: Michael Meeks <michael.meeks@suse.com> Tested-by: Michael Meeks <michael.meeks@suse.com>
-rw-r--r--starmath/source/edit.cxx21
1 files changed, 21 insertions, 0 deletions
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index f68e0fb36d8f..45d27cebe26c 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -455,6 +455,27 @@ void SmEditWindow::KeyInput(const KeyEvent& rKEvt)
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();
}
}