summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorMarcos Paulo de Souza <marcos.souza.org@gmail.com>2013-09-03 09:09:19 -0300
committerThomas Arnhold <thomas@arnhold.org>2013-09-03 12:32:26 +0000
commit9e9693b91acb747cf53f819099a78f7ed4de9f40 (patch)
tree4becff90d44d0d373bd7bae5e7a7ec176fa31cd5 /starmath
parent7c032aa60eaccde88a9064a80bb69fe8076a040b (diff)
fdo#68877: Select "<?>" as Elements window do
Elements Dock needs to have the same behavior of Elements window. After insert some symbol, if this symbol have some placeholder, select the first placehold to user put some data. This increases usability of Elements Dock. Change-Id: Idc57cc6817d94f698632eb938600a55c8f9afbd8 Reviewed-on: https://gerrit.libreoffice.org/5780 Reviewed-by: Thomas Arnhold <thomas@arnhold.org> Tested-by: Thomas Arnhold <thomas@arnhold.org>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/source/edit.cxx24
1 files changed, 22 insertions, 2 deletions
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index 5ccdd754bdee..ce3dd4b91a68 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -1025,11 +1025,31 @@ void SmEditWindow::InsertText(const OUString& rText)
nEndIndex += aSelection.nEndPos;
+ // TODO: unify this function with the InsertCommand: The do the same thing for different
+ // callers
+ OUString string(rText);
+
// put a space before a new command if not in the beginning of a line
if (aSelection.nStartPos > 0 && aCurrentFormula[nStartIndex - 1] != ' ')
- pEditView->InsertText(" " + rText);
+ string = " " + string;
+
+ pEditView->InsertText(string);
+
+ // Remember start of the selection and move the cursor there afterwards.
+ aSelection.nEndPara = aSelection.nStartPara;
+ if (HasMark(string))
+ {
+ aSelection.nEndPos = aSelection.nStartPos;
+ pEditView->SetSelection(aSelection);
+ SelNextMark();
+ }
else
- pEditView->InsertText(rText);
+ { // set selection after inserted text
+ aSelection.nEndPos = aSelection.nStartPos + string.getLength();
+ aSelection.nStartPos = aSelection.nEndPos;
+ pEditView->SetSelection(aSelection);
+ }
+
aModifyTimer.Start();
StartCursorMove();
GrabFocus();