[Libreoffice-commits] core.git: starmath/source

Marcos Paulo de Souza marcos.souza.org at gmail.com
Wed Jun 26 05:09:34 PDT 2013


 starmath/source/edit.cxx |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

New commits:
commit d12980ce0b86549028ddaac3192f14456dde25c6
Author: Marcos Paulo de Souza <marcos.souza.org at gmail.com>
Date:   Thu Jun 20 00:23:29 2013 -0300

    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 at suse.com>
    Tested-by: Michael Meeks <michael.meeks at suse.com>

diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index f68e0fb..45d27ce 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();
     }
 }


More information about the Libreoffice-commits mailing list