diff options
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/source/edit.cxx | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx index f68e0fb36d8f..45d27cebe26c 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(); } } |