From f583a199b3a0812523ed75e1d2099325edad24f7 Mon Sep 17 00:00:00 2001 From: Marcos Paulo de Souza Date: Sun, 21 Jul 2013 14:34:53 -0300 Subject: 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 Tested-by: Fridrich Strba --- starmath/source/edit.cxx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'starmath') 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); } -- cgit