From 2ebe64ba90cf35d2744519d6b3a033375715614e Mon Sep 17 00:00:00 2001 From: Marcos Paulo de Souza Date: Tue, 13 Aug 2013 11:22:47 -0300 Subject: 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 Tested-by: Tor Lillqvist --- starmath/source/edit.cxx | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'starmath/source') 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(); -- cgit v1.2.3