summaryrefslogtreecommitdiff
path: root/indra/newview/llscripteditor.cpp
diff options
context:
space:
mode:
authorCinder <cinder.roxley@phoenixviewer.com>2014-04-18 23:13:57 -0600
committerCinder <cinder.roxley@phoenixviewer.com>2014-04-18 23:13:57 -0600
commitdcffb97518cb2888489c93b90862518f761967dd (patch)
tree5d4afbda134d7c0f63c48abcd6aa211f8d4fb782 /indra/newview/llscripteditor.cpp
parent54c7b96bf19efd28cc7ce81c0864ee7bbb7d6b1d (diff)
Move some more script editor functions from LLTextEditor to LLScriptEditor
Diffstat (limited to 'indra/newview/llscripteditor.cpp')
-rw-r--r--indra/newview/llscripteditor.cpp44
1 files changed, 44 insertions, 0 deletions
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<LLScriptEditor> 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())