summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorAndreas Heinisch <andreas.heinisch@yahoo.de>2021-12-08 16:09:23 +0100
committerAndreas Heinisch <andreas.heinisch@yahoo.de>2021-12-11 16:57:57 +0100
commit809236ed826b67328409e008313dea87de6d5243 (patch)
tree0bafaa0aa49f257c2f77afc39b5b61e78df8faa7 /vcl
parent0040076af3e1f45f43435d83335ef8cee8e6ab0c (diff)
tdf#145764 - BASIC IDE Home Key: move cursor to the beginning/first character
Pressing the Home Key moves the cursor to the first character in the line, whereas pressing it at line start moves it to the first character in that line. Change-Id: I8eabb6d01b1a4de0d24bf064f82c83342ca91396 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126548 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/edit/textview.cxx17
1 files changed, 16 insertions, 1 deletions
diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx
index 3c94e6fa6e1e..b295b78af8b0 100644
--- a/vcl/source/edit/textview.cxx
+++ b/vcl/source/edit/textview.cxx
@@ -1016,7 +1016,11 @@ TextSelection const & TextView::ImpMoveCursor( const KeyEvent& rKeyEvent )
break;
case KEY_DOWN: aPaM = CursorDown( aPaM );
break;
- case KEY_HOME: aPaM = bCtrl ? CursorStartOfDoc() : CursorStartOfLine( aPaM );
+ case KEY_HOME:
+ // tdf#145764 - move cursor to the beginning or first character in the same line
+ aPaM = bCtrl ? CursorStartOfDoc()
+ : aPaM.GetIndex() == 0 ? CursorFirstWord( aPaM )
+ : CursorStartOfLine( aPaM );
break;
case KEY_END: aPaM = bCtrl ? CursorEndOfDoc() : CursorEndOfLine( aPaM );
break;
@@ -1156,6 +1160,17 @@ TextPaM TextView::CursorRight( const TextPaM& rPaM, sal_uInt16 nCharacterIterato
return aPaM;
}
+TextPaM TextView::CursorFirstWord( const TextPaM& rPaM )
+{
+ TextPaM aPaM(rPaM);
+ TextNode* pNode = mpImpl->mpTextEngine->mpDoc->GetNodes()[aPaM.GetPara()].get();
+
+ css::uno::Reference<css::i18n::XBreakIterator> xBI = mpImpl->mpTextEngine->GetBreakIterator();
+ aPaM.GetIndex() = xBI->nextWord(pNode->GetText(), 0, mpImpl->mpTextEngine->GetLocale(), css::i18n::WordType::ANYWORD_IGNOREWHITESPACES).startPos;
+
+ return aPaM;
+}
+
TextPaM TextView::CursorWordLeft( const TextPaM& rPaM )
{
TextPaM aPaM( rPaM );