tdf#145764 - Change behaviour of BASIC IDE Home Key
Pressing the Home Key moves the cursor to the first non-space character
in the line, whereas pressing it at the first non-space character moves
it to the beginning of that line
Follow up of: I8eabb6d01b1a4de0d24bf064f82c83342ca91396
Change-Id: I9f4f0b2b602fa0158488959c2e2029f5da315771
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126702
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx
index b295b78..29dad16 100644
--- a/vcl/source/edit/textview.cxx
+++ b/vcl/source/edit/textview.cxx
@@ -1017,10 +1017,16 @@ TextSelection const & TextView::ImpMoveCursor( const KeyEvent& rKeyEvent )
case KEY_DOWN: aPaM = CursorDown( aPaM );
break;
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 );
if (bCtrl)
{
aPaM = CursorStartOfDoc();
}
else
{
// tdf#145764 - move cursor to the beginning or the first non-space character in the same line
const TextPaM aFirstWordPaM = CursorFirstWord(aPaM);
aPaM = aPaM.GetIndex() == aFirstWordPaM.GetIndex() ? CursorStartOfLine(aPaM) : aFirstWordPaM;
}
break;
case KEY_END: aPaM = bCtrl ? CursorEndOfDoc() : CursorEndOfLine( aPaM );
break;
@@ -1166,7 +1172,7 @@ TextPaM TextView::CursorFirstWord( const TextPaM& 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;
aPaM.GetIndex() = xBI->beginOfSentence(pNode->GetText(), 0, mpImpl->mpTextEngine->GetLocale());
return aPaM;
}