From dcffb97518cb2888489c93b90862518f761967dd Mon Sep 17 00:00:00 2001 From: Cinder Date: Fri, 18 Apr 2014 23:13:57 -0600 Subject: Move some more script editor functions from LLTextEditor to LLScriptEditor --- indra/newview/llpreviewscript.cpp | 3 +- indra/newview/llscripteditor.cpp | 44 ++++++++++++++++++++++ indra/newview/llscripteditor.h | 14 ++++++- .../xui/en/floater_region_debug_console.xml | 1 - .../skins/default/xui/en/panel_script_ed.xml | 1 - .../newview/skins/default/xui/en/script_editor.xml | 4 +- 6 files changed, 60 insertions(+), 7 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 0d95874406..e778015965 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -472,8 +472,7 @@ void LLScriptEdCore::processKeywords() if (mSyntaxIdLSL.isLoaded()) { - mEditor->mKeywords.initialise(mSyntaxIdLSL.getKeywordsXML()); - + mEditor->initKeywords(); mEditor->loadKeywords(); std::vector primary_keywords; diff --git a/indra/newview/llscripteditor.cpp b/indra/newview/llscripteditor.cpp index 67a43c0ef0..61b5eec9fc 100644 --- a/indra/newview/llscripteditor.cpp +++ b/indra/newview/llscripteditor.cpp @@ -28,6 +28,8 @@ #include "linden_common.h" #include "llscripteditor.h" +#include "llsyntaxid.h" + static LLDefaultChildRegistry::Register r("script_editor"); LLScriptEditor::LLScriptEditor::Params::Params() @@ -42,6 +44,48 @@ LLScriptEditor::LLScriptEditor(const Params& p) } +void LLScriptEditor::initKeywords() +{ + mKeywords.initialise(LLSyntaxIdLSL::getInstance()->getKeywordsXML()); +} + +static LLFastTimer::DeclareTimer FTM_SYNTAX_HIGHLIGHTING("Syntax Highlighting"); + +void LLScriptEditor::loadKeywords() +{ + LLFastTimer ft(FTM_SYNTAX_HIGHLIGHTING); + mKeywords.processTokens(); + + segment_vec_t segment_list; + mKeywords.findSegments(&segment_list, getWText(), mDefaultColor.get(), *this); + + mSegments.clear(); + segment_set_t::iterator insert_it = mSegments.begin(); + for (segment_vec_t::iterator list_it = segment_list.begin(); list_it != segment_list.end(); ++list_it) + { + insert_it = mSegments.insert(insert_it, *list_it); + } +} + +void LLScriptEditor::updateSegments() +{ + if (mReflowIndex < S32_MAX && mKeywords.isLoaded() && mParseOnTheFly) + { + LLFastTimer ft(FTM_SYNTAX_HIGHLIGHTING); + // HACK: No non-ascii keywords for now + segment_vec_t segment_list; + mKeywords.findSegments(&segment_list, getWText(), mDefaultColor.get(), *this); + + clearSegments(); + for (segment_vec_t::iterator list_it = segment_list.begin(); list_it != segment_list.end(); ++list_it) + { + insertSegment(*list_it); + } + } + + LLTextBase::updateSegments(); +} + void LLScriptEditor::clearSegments() { if (!mSegments.empty()) diff --git a/indra/newview/llscripteditor.h b/indra/newview/llscripteditor.h index a0bee36a25..86c915d6a0 100644 --- a/indra/newview/llscripteditor.h +++ b/indra/newview/llscripteditor.h @@ -41,11 +41,21 @@ public: }; virtual ~LLScriptEditor() {}; - void clearSegments(); + void initKeywords(); + void loadKeywords(); + void clearSegments(); + LLKeywords::keyword_iterator_t keywordsBegin() { return mKeywords.begin(); } + LLKeywords::keyword_iterator_t keywordsEnd() { return mKeywords.end(); } protected: LLScriptEditor(const Params& p); - + +private: + void updateSegments(); + void loadKeywords(const std::string& filename_keywords, + const std::string& filename_colors); + + LLKeywords mKeywords; }; #endif // LL_SCRIPTEDITOR_H diff --git a/indra/newview/skins/default/xui/en/floater_region_debug_console.xml b/indra/newview/skins/default/xui/en/floater_region_debug_console.xml index 99b812a880..11172d8a3e 100755 --- a/indra/newview/skins/default/xui/en/floater_region_debug_console.xml +++ b/indra/newview/skins/default/xui/en/floater_region_debug_console.xml @@ -21,7 +21,6 @@ layout="topleft" max_length="65536" name="region_debug_console_output" - show_line_numbers="false" word_wrap="true" track_end="true" read_only="true"> diff --git a/indra/newview/skins/default/xui/en/panel_script_ed.xml b/indra/newview/skins/default/xui/en/panel_script_ed.xml index 3e88e2dc04..1a4f0aff73 100755 --- a/indra/newview/skins/default/xui/en/panel_script_ed.xml +++ b/indra/newview/skins/default/xui/en/panel_script_ed.xml @@ -161,7 +161,6 @@ name="Script Editor" text_readonly_color="DkGray" width="487" - show_line_numbers="true" enable_tooltip_paste="true" word_wrap="true"> Loading... diff --git a/indra/newview/skins/default/xui/en/script_editor.xml b/indra/newview/skins/default/xui/en/script_editor.xml index d24833e85c..b030a117fc 100644 --- a/indra/newview/skins/default/xui/en/script_editor.xml +++ b/indra/newview/skins/default/xui/en/script_editor.xml @@ -1,5 +1,7 @@ + parse_urls="false" + show_context_menu="true" + show_line_numbers="true"> -- cgit v1.2.3