FIRE-30892: Pressing the Home key in the script editor should go to the first non-whitespace character on a line; Contribution by Testicular Slingshot

meow-7.2.2
Ansariel 2021-04-03 09:59:07 +02:00
parent a072cd4db0
commit 6d26efe266
4 changed files with 32 additions and 4 deletions

View File

@ -2882,7 +2882,7 @@ void LLTextBase::updateCursorXPos()
mDesiredXPixel = getLocalRectFromDocIndex(mCursorPos).mLeft;
}
//virtual
void LLTextBase::startOfLine()
{
S32 offset = getLineOffsetFromDocIndex(mCursorPos);

View File

@ -497,7 +497,7 @@ public:
S32 getCursorPos() { return mCursorPos; }
// [/SL:KB
bool setCursorPos(S32 cursor_pos, bool keep_cursor_offset = false);
void startOfLine();
virtual void startOfLine(); // <FS> Added virtual modifier
void endOfLine();
void startOfDoc();
void endOfDoc();

View File

@ -322,3 +322,26 @@ void LLScriptEditor::drawSelectionBackground()
}
}
}
// <FS> Improved Home-key behavior
//virtual
void LLScriptEditor::startOfLine()
{
const LLWString text = getWText();
const S32 line_start_pos = mCursorPos - getLineOffsetFromDocIndex(mCursorPos);
S32 trimmed_line_start_pos = line_start_pos;
while (trimmed_line_start_pos < mCursorPos && LLStringOps::isSpace(text[trimmed_line_start_pos]))
{
++trimmed_line_start_pos;
}
if (mCursorPos != trimmed_line_start_pos)
{
setCursorPos(trimmed_line_start_pos);
}
else if (mCursorPos != line_start_pos)
{
setCursorPos(line_start_pos);
}
}
// </FS>

View File

@ -45,6 +45,10 @@ public:
// LLView override
virtual void draw();
// <FS> Improved Home-key behavior
// LLTextBase override
virtual void startOfLine();
void initKeywords();
void loadKeywords();
@ -67,8 +71,9 @@ private:
void drawLineNumbers();
/* virtual */ void updateSegments();
/* virtual */ void drawSelectionBackground();
void loadKeywords(const std::string& filename_keywords,
const std::string& filename_colors);
// <FS:Ansariel> Doesn't exist
//void loadKeywords(const std::string& filename_keywords,
// const std::string& filename_colors);
LLKeywords mKeywords;
bool mShowLineNumbers;