diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 3a10963424..f90e86e105 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -2882,7 +2882,7 @@ void LLTextBase::updateCursorXPos() mDesiredXPixel = getLocalRectFromDocIndex(mCursorPos).mLeft; } - +//virtual void LLTextBase::startOfLine() { S32 offset = getLineOffsetFromDocIndex(mCursorPos); diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index 160861d777..9421b69c65 100644 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -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(); // Added virtual modifier void endOfLine(); void startOfDoc(); void endOfDoc(); diff --git a/indra/newview/llscripteditor.cpp b/indra/newview/llscripteditor.cpp index 645d944fcc..b020d52c0b 100644 --- a/indra/newview/llscripteditor.cpp +++ b/indra/newview/llscripteditor.cpp @@ -322,3 +322,26 @@ void LLScriptEditor::drawSelectionBackground() } } } + +// 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); + } +} +// diff --git a/indra/newview/llscripteditor.h b/indra/newview/llscripteditor.h index 0f84dffb7c..795871ca45 100644 --- a/indra/newview/llscripteditor.h +++ b/indra/newview/llscripteditor.h @@ -45,6 +45,10 @@ public: // LLView override virtual void draw(); + + // 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); + // Doesn't exist + //void loadKeywords(const std::string& filename_keywords, + // const std::string& filename_colors); LLKeywords mKeywords; bool mShowLineNumbers;