diff options
author | Marcos Paulo de Souza <marcos.souza.org@gmail.com> | 2013-07-21 14:34:53 -0300 |
---|---|---|
committer | Fridrich Strba <fridrich@documentfoundation.org> | 2013-07-24 17:52:52 +0000 |
commit | f583a199b3a0812523ed75e1d2099325edad24f7 (patch) | |
tree | 83d5c150fc6e47bad7329a14d4ffd1c1a9d6cd3f /starmath | |
parent | 3c15edaed5b11e13843081d22ef637f03a7c8d73 (diff) |
fdo#43090: Improvement: Just auto close when found placeholder
Another verification needs to be done, auto close when it's in the end of line.
Change-Id: I675ac6b6a0477fc9b5747860df8dff2866189433
Reviewed-on: https://gerrit.libreoffice.org/5008
Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org>
Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/source/edit.cxx | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx index 45d27cebe26c..ec9680fdf3e5 100644 --- a/starmath/source/edit.cxx +++ b/starmath/source/edit.cxx @@ -419,6 +419,13 @@ void SmEditWindow::KeyInput(const KeyEvent& rKEvt) { StartCursorMove(); + bool autoClose = false; + ESelection aSelection = pEditView->GetSelection(); + OUString selected = pEditView->GetEditEngine()->GetText(aSelection); + + if (selected.trim() == "<?>") + autoClose = true; + if (!pEditView) CreateEditView(); if ( !pEditView->PostKeyEvent(rKEvt) ) @@ -466,13 +473,13 @@ void SmEditWindow::KeyInput(const KeyEvent& rKEvt) else if (charCode == '(') close = " )"; - // auto close the current character - if (!close.isEmpty()) + // auto close the current character only when needed + if (!close.isEmpty() && autoClose) { pEditView->InsertText(close); // position it at center of brackets - ESelection aSelection = pEditView->GetSelection(); - aSelection.nStartPos = aSelection.nEndPos = aSelection.nEndPos - 2; + aSelection.nStartPos += 2; + aSelection.nEndPos = aSelection.nStartPos; pEditView->SetSelection(aSelection); } |