summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorMarcos Paulo de Souza <marcos.souza.org@gmail.com>2013-08-13 11:22:47 -0300
committerTor Lillqvist <tml@iki.fi>2013-08-14 06:36:34 +0000
commit2ebe64ba90cf35d2744519d6b3a033375715614e (patch)
tree398419336e2028cb83e8b591c524fc02e140c27f /starmath
parente32a74ca1ba5c89f97b5741f376ae6a2c2ee32d4 (diff)
fdo#43090: Improve auto close brackets
Now it works this way: * Auto close in end of current line of formula * Auto close when we have "<?>" selected * Auto close when we're in the beginning of current line. We're adding a space between the brakets, like this: "[ ]" and putting the cursor in the center of these brackets. Change-Id: I8d77bfd7c33f875e7f4070343e634c2b6c45d33c Reviewed-on: https://gerrit.libreoffice.org/5388 Reviewed-by: Tor Lillqvist <tml@iki.fi> Tested-by: Tor Lillqvist <tml@iki.fi>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/source/edit.cxx28
1 files changed, 28 insertions, 0 deletions
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index 2a7cb9395e9e..045986623db4 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -425,6 +425,34 @@ void SmEditWindow::KeyInput(const KeyEvent& rKEvt)
if (selected.trim() == "<?>")
autoClose = true;
+ else if (selected.isEmpty() && !aSelection.HasRange())
+ {
+ selected = pEditView->GetEditEngine()->GetText(aSelection.nEndPara);
+ if (!selected.isEmpty())
+ {
+ sal_Int32 index = selected.indexOf("\n", aSelection.nEndPos);
+ if (index != -1)
+ {
+ selected = selected.copy(index, sal_Int32(aSelection.nEndPos));
+ if (selected.trim().isEmpty())
+ autoClose = true;
+ }
+ else
+ {
+ sal_Int32 length = selected.getLength();
+ if (aSelection.nEndPos == length)
+ autoClose = true;
+ else
+ {
+ selected = selected.copy(aSelection.nEndPos, length);
+ if (selected.trim().isEmpty())
+ autoClose = true;
+ }
+ }
+ }
+ else
+ autoClose = true;
+ }
if (!pEditView)
CreateEditView();