From 7183cecd14fbdc3cd31e1482248fabec7b23b1fb Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Tue, 5 Feb 2013 16:37:37 +0000 Subject: STORM-1831 merging in previous work --- indra/newview/llpreviewscript.cpp | 41 ++++++--------------------------------- 1 file changed, 6 insertions(+), 35 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 9c25e69db0..45d92e6be0 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -50,11 +50,9 @@ #include "llscrolllistctrl.h" #include "llscrolllistitem.h" #include "llscrolllistcell.h" +#include "llsdserialize.h" #include "llslider.h" #include "lscript_rt_interface.h" -#include "lscript_library.h" -#include "lscript_export.h" -#include "lltextbox.h" #include "lltooldraganddrop.h" #include "llvfile.h" @@ -386,39 +384,11 @@ BOOL LLScriptEdCore::postBuild() initMenu(); + mEditor->mKeywords.initialise(); + // FIX: Refactor LLTextEditor::loadKeywords so these can be removed. std::vector funcs; std::vector tooltips; - for (std::vector::const_iterator i = gScriptLibrary.mFunctions.begin(); - i != gScriptLibrary.mFunctions.end(); ++i) - { - // Make sure this isn't a god only function, or the agent is a god. - if (!i->mGodOnly || gAgent.isGodlike()) - { - std::string name = i->mName; - funcs.push_back(name); - - std::string desc_name = "LSLTipText_"; - desc_name += name; - std::string desc = LLTrans::getString(desc_name); - - F32 sleep_time = i->mSleepTime; - if( sleep_time ) - { - desc += "\n"; - - LLStringUtil::format_map_t args; - args["[SLEEP_TIME]"] = llformat("%.1f", sleep_time ); - desc += LLTrans::getString("LSLTipSleepTime", args); - } - - // A \n linefeed is not part of xml. Let's add one to keep all - // the tips one-per-line in strings.xml - LLStringUtil::replaceString( desc, "\\n", "\n" ); - - tooltips.push_back(desc); - } - } LLColor3 color(0.5f, 0.0f, 0.15f); mEditor->loadKeywords(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"keywords.ini"), funcs, tooltips, color); @@ -430,6 +400,7 @@ BOOL LLScriptEdCore::postBuild() for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) { token = token_it->second; + // FIX: change this to use the new Token Type enum entries. if (token->getColor() == color) // Wow, what a disgusting hack. { primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); @@ -655,7 +626,7 @@ void LLScriptEdCore::updateDynamicHelp(BOOL immediate) std::vector::iterator segment_iter; for (segment_iter = selected_segments.begin(); segment_iter != selected_segments.end(); ++segment_iter) { - if((*segment_iter)->getToken() && (*segment_iter)->getToken()->getType() == LLKeywordToken::WORD) + if((*segment_iter)->getToken() && (*segment_iter)->getToken()->getType() == LLKeywordToken::TT_WORD) { segment = *segment_iter; break; @@ -666,7 +637,7 @@ void LLScriptEdCore::updateDynamicHelp(BOOL immediate) if (!segment) { const LLTextSegmentPtr test_segment = mEditor->getPreviousSegment(); - if(test_segment->getToken() && test_segment->getToken()->getType() == LLKeywordToken::WORD) + if(test_segment->getToken() && test_segment->getToken()->getType() == LLKeywordToken::TT_WORD) { segment = test_segment; } -- cgit v1.2.3 From 79645e6981a97224024c5226d8713dce9569d54a Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Mon, 21 Oct 2013 04:09:20 +0100 Subject: STORM-1831 First attempt at using SyntaxIdLSL capability. (incomplete) --- indra/newview/llpreviewscript.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 2e9907fcd2..62e1d765b3 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -406,7 +406,15 @@ BOOL LLScriptEdCore::postBuild() initMenu(); - mEditor->mKeywords.initialise(); +// Make this work ;-) + mSyntaxLSL = LLSyntaxIdLSL(); + +// mSyntaxLSL.initialise(); +// mSyntaxLSL.mKeywords = &mEditor->mKeywords; + // ... +// mSyntaxLSL->mKeywords.initialise(); +// Move into the SyntaxIdLSL class + mEditor->mKeywords.initialise(mSyntaxLSL.filenamePath(), mSyntaxLSL.filenameCurrent()); // FIX: Refactor LLTextEditor::loadKeywords so these can be removed. std::vector funcs; -- cgit v1.2.3 From bad5179f276f6913bfb9a313d25d02d0e883d678 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Fri, 25 Oct 2013 14:42:04 +0100 Subject: storm-1831 Fixing viewer crash and clean up. No idea why storing the region pointer in mRegion causes crashes, when doing it locally in each method doesn't. --- indra/newview/llpreviewscript.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 62e1d765b3..5f23249c8d 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -407,14 +407,10 @@ BOOL LLScriptEdCore::postBuild() initMenu(); // Make this work ;-) - mSyntaxLSL = LLSyntaxIdLSL(); - -// mSyntaxLSL.initialise(); -// mSyntaxLSL.mKeywords = &mEditor->mKeywords; + mSyntaxIdLSL.initialise(); // ... -// mSyntaxLSL->mKeywords.initialise(); -// Move into the SyntaxIdLSL class - mEditor->mKeywords.initialise(mSyntaxLSL.filenamePath(), mSyntaxLSL.filenameCurrent()); + mEditor->mKeywords.initialise(LL_PATH_APP_SETTINGS, "keywords_lsl_default.xml"); +// mEditor->mKeywords.initialise(mSyntaxIdLSL.getFullFileSpec()); // FIX: Refactor LLTextEditor::loadKeywords so these can be removed. std::vector funcs; -- cgit v1.2.3 From 4af21580297dd85727ffdc5d4eee89ad58ead271 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sat, 9 Nov 2013 11:31:32 +0000 Subject: Adding method to load cached/default syntax file and method to access sKeyWordsXML. --- indra/newview/llpreviewscript.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 5f23249c8d..705872328a 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -406,11 +406,7 @@ BOOL LLScriptEdCore::postBuild() initMenu(); -// Make this work ;-) - mSyntaxIdLSL.initialise(); - // ... - mEditor->mKeywords.initialise(LL_PATH_APP_SETTINGS, "keywords_lsl_default.xml"); -// mEditor->mKeywords.initialise(mSyntaxIdLSL.getFullFileSpec()); + LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLScriptEdCore::initKeywords(), this)); // FIX: Refactor LLTextEditor::loadKeywords so these can be removed. std::vector funcs; @@ -456,6 +452,15 @@ BOOL LLScriptEdCore::postBuild() return TRUE; } +void LLScriptEdCore::initKeywords() +{ + // Make this work ;-) + mSyntaxIdLSL.initialise(); + // ... + mEditor->mKeywords.initialise(LL_PATH_APP_SETTINGS, "keywords_lsl_default.xml"); + // mEditor->mKeywords.initialise(mSyntaxIdLSL.getKeywordsXML()); +} + void LLScriptEdCore::initMenu() { // *TODO: Skinning - make these callbacks data driven -- cgit v1.2.3 From 29b2129e1eec0dbbb909422e82766a58f14c5da3 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sat, 9 Nov 2013 11:32:08 +0000 Subject: Backed out changeset: e82d9467bec8 --- indra/newview/llpreviewscript.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 705872328a..5f23249c8d 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -406,7 +406,11 @@ BOOL LLScriptEdCore::postBuild() initMenu(); - LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLScriptEdCore::initKeywords(), this)); +// Make this work ;-) + mSyntaxIdLSL.initialise(); + // ... + mEditor->mKeywords.initialise(LL_PATH_APP_SETTINGS, "keywords_lsl_default.xml"); +// mEditor->mKeywords.initialise(mSyntaxIdLSL.getFullFileSpec()); // FIX: Refactor LLTextEditor::loadKeywords so these can be removed. std::vector funcs; @@ -452,15 +456,6 @@ BOOL LLScriptEdCore::postBuild() return TRUE; } -void LLScriptEdCore::initKeywords() -{ - // Make this work ;-) - mSyntaxIdLSL.initialise(); - // ... - mEditor->mKeywords.initialise(LL_PATH_APP_SETTINGS, "keywords_lsl_default.xml"); - // mEditor->mKeywords.initialise(mSyntaxIdLSL.getKeywordsXML()); -} - void LLScriptEdCore::initMenu() { // *TODO: Skinning - make these callbacks data driven -- cgit v1.2.3 From 5e27952ee4698006c86ebdca60c4eab305ddebac Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sun, 10 Nov 2013 20:24:13 +0000 Subject: storm-1831 Switch to use the llsyntaxid keywords LLSD directly --- indra/newview/llpreviewscript.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 5f23249c8d..b464845256 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -409,8 +409,7 @@ BOOL LLScriptEdCore::postBuild() // Make this work ;-) mSyntaxIdLSL.initialise(); // ... - mEditor->mKeywords.initialise(LL_PATH_APP_SETTINGS, "keywords_lsl_default.xml"); -// mEditor->mKeywords.initialise(mSyntaxIdLSL.getFullFileSpec()); + mEditor->mKeywords.initialise(mSyntaxIdLSL.getKeywordsXML()); // FIX: Refactor LLTextEditor::loadKeywords so these can be removed. std::vector funcs; -- cgit v1.2.3 From 488964157cb02b44ac9c72bb6c57e47c2b21ee53 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sun, 10 Nov 2013 21:57:29 +0000 Subject: Moving keywords code into its own method. --- indra/newview/llpreviewscript.cpp | 87 +++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 41 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index b464845256..0cf8dbe9c5 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -406,53 +406,58 @@ BOOL LLScriptEdCore::postBuild() initMenu(); -// Make this work ;-) - mSyntaxIdLSL.initialise(); - // ... - mEditor->mKeywords.initialise(mSyntaxIdLSL.getKeywordsXML()); - - // FIX: Refactor LLTextEditor::loadKeywords so these can be removed. - std::vector funcs; - std::vector tooltips; - - LLColor3 color(0.5f, 0.0f, 0.15f); - mEditor->loadKeywords(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"keywords.ini"), funcs, tooltips, color); - - std::vector primary_keywords; - std::vector secondary_keywords; - LLKeywordToken *token; - LLKeywords::keyword_iterator_t token_it; - for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) - { - token = token_it->second; - // FIX: change this to use the new Token Type enum entries. - if (token->getColor() == color) // Wow, what a disgusting hack. - { - primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); - } - else + return initKeywords(); +} + +bool LLScriptEdCore::initKeywords() +{ + // Make this work ;-) + mSyntaxIdLSL.initialise(); + // ... + mEditor->mKeywords.initialise(mSyntaxIdLSL.getKeywordsXML()); + + // FIX: Refactor LLTextEditor::loadKeywords so these can be removed. + //std::vector funcs; + //std::vector tooltips; + + LLColor3 color(0.5f, 0.0f, 0.15f); + mEditor->loadKeywords(); + + std::vector primary_keywords; + std::vector secondary_keywords; + LLKeywordToken *token; + LLKeywords::keyword_iterator_t token_it; + for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) { - secondary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); + token = token_it->second; + // FIX: change this to use the new Token Type enum entries. + if (token->getColor() == color) // Wow, what a disgusting hack. + { + primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); + } + else + { + secondary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); + } } - } - // Case-insensitive dictionary sort for primary keywords. We don't sort the secondary - // keywords. They're intelligently grouped in keywords.ini. - std::stable_sort( primary_keywords.begin(), primary_keywords.end(), LLSECKeywordCompare() ); + // Case-insensitive dictionary sort for primary keywords. We don't sort the secondary + // keywords. They're intelligently grouped in keywords.ini. + std::stable_sort( primary_keywords.begin(), primary_keywords.end(), LLSECKeywordCompare() ); - for (std::vector::const_iterator iter= primary_keywords.begin(); - iter!= primary_keywords.end(); ++iter) - { - mFunctions->add(*iter); - } + for (std::vector::const_iterator iter= primary_keywords.begin(); + iter!= primary_keywords.end(); ++iter) + { + mFunctions->add(*iter); + } - for (std::vector::const_iterator iter= secondary_keywords.begin(); - iter!= secondary_keywords.end(); ++iter) - { - mFunctions->add(*iter); - } + for (std::vector::const_iterator iter= secondary_keywords.begin(); + iter!= secondary_keywords.end(); ++iter) + { + mFunctions->add(*iter); + } - return TRUE; + return TRUE; } void LLScriptEdCore::initMenu() -- cgit v1.2.3 From 1cf2acf6d70c5ce68d6faedffbbf2b070f2a6fd7 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sun, 10 Nov 2013 22:47:34 +0000 Subject: Fixing some small discrepencies. --- indra/newview/llpreviewscript.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 0cf8dbe9c5..143703f60e 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -406,20 +406,16 @@ BOOL LLScriptEdCore::postBuild() initMenu(); - return initKeywords(); + initKeywords(); + + return TRUE; } -bool LLScriptEdCore::initKeywords() +void LLScriptEdCore::initKeywords() { - // Make this work ;-) mSyntaxIdLSL.initialise(); - // ... mEditor->mKeywords.initialise(mSyntaxIdLSL.getKeywordsXML()); - // FIX: Refactor LLTextEditor::loadKeywords so these can be removed. - //std::vector funcs; - //std::vector tooltips; - LLColor3 color(0.5f, 0.0f, 0.15f); mEditor->loadKeywords(); @@ -443,6 +439,7 @@ bool LLScriptEdCore::initKeywords() // Case-insensitive dictionary sort for primary keywords. We don't sort the secondary // keywords. They're intelligently grouped in keywords.ini. + // As we don't use keywords.ini, this is no longer true. Do we need to sort now? std::stable_sort( primary_keywords.begin(), primary_keywords.end(), LLSECKeywordCompare() ); for (std::vector::const_iterator iter= primary_keywords.begin(); @@ -456,8 +453,6 @@ bool LLScriptEdCore::initKeywords() { mFunctions->add(*iter); } - - return TRUE; } void LLScriptEdCore::initMenu() -- cgit v1.2.3 From f6d8e55eb9e9ec377e3a9ce9b25de702c3239090 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Mon, 11 Nov 2013 13:36:33 +0000 Subject: Fixing indentation of LLScriptEdCore::initKeywords --- indra/newview/llpreviewscript.cpp | 66 +++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 143703f60e..34ad95e228 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -413,46 +413,46 @@ BOOL LLScriptEdCore::postBuild() void LLScriptEdCore::initKeywords() { - mSyntaxIdLSL.initialise(); - mEditor->mKeywords.initialise(mSyntaxIdLSL.getKeywordsXML()); + mSyntaxIdLSL.initialise(); + mEditor->mKeywords.initialise(mSyntaxIdLSL.getKeywordsXML()); - LLColor3 color(0.5f, 0.0f, 0.15f); - mEditor->loadKeywords(); + LLColor3 color(0.5f, 0.0f, 0.15f); + mEditor->loadKeywords(); - std::vector primary_keywords; - std::vector secondary_keywords; - LLKeywordToken *token; - LLKeywords::keyword_iterator_t token_it; - for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) + std::vector primary_keywords; + std::vector secondary_keywords; + LLKeywordToken *token; + LLKeywords::keyword_iterator_t token_it; + for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) + { + token = token_it->second; + // FIX: change this to use the new Token Type enum entries. + if (token->getColor() == color) // Wow, what a disgusting hack. { - token = token_it->second; - // FIX: change this to use the new Token Type enum entries. - if (token->getColor() == color) // Wow, what a disgusting hack. - { - primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); - } - else - { - secondary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); - } + primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); } - - // Case-insensitive dictionary sort for primary keywords. We don't sort the secondary - // keywords. They're intelligently grouped in keywords.ini. - // As we don't use keywords.ini, this is no longer true. Do we need to sort now? - std::stable_sort( primary_keywords.begin(), primary_keywords.end(), LLSECKeywordCompare() ); - - for (std::vector::const_iterator iter= primary_keywords.begin(); - iter!= primary_keywords.end(); ++iter) + else { - mFunctions->add(*iter); + secondary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); } + } - for (std::vector::const_iterator iter= secondary_keywords.begin(); - iter!= secondary_keywords.end(); ++iter) - { - mFunctions->add(*iter); - } + // Case-insensitive dictionary sort for primary keywords. We don't sort the secondary + // keywords. They're intelligently grouped in keywords.ini. + // As we don't use keywords.ini, this is no longer true. Do we need to sort now? + std::stable_sort( primary_keywords.begin(), primary_keywords.end(), LLSECKeywordCompare() ); + + for (std::vector::const_iterator iter= primary_keywords.begin(); + iter!= primary_keywords.end(); ++iter) + { + mFunctions->add(*iter); + } + + for (std::vector::const_iterator iter= secondary_keywords.begin(); + iter!= secondary_keywords.end(); ++iter) + { + mFunctions->add(*iter); + } } void LLScriptEdCore::initMenu() -- cgit v1.2.3 From 377eb5561f885902585830226fd82c4ceeec4e05 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Mon, 11 Nov 2013 16:34:16 +0000 Subject: Renaming initKeywords to better reflect its intended use (onRegionChangeInitialiseKeywords) --- indra/newview/llpreviewscript.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 34ad95e228..19aab8f383 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -34,6 +34,7 @@ #include "llcheckboxctrl.h" #include "llcombobox.h" #include "lldir.h" +#include "llenvmanager.h" #include "llexternaleditor.h" #include "llfilepicker.h" #include "llfloaterreg.h" @@ -406,13 +407,14 @@ BOOL LLScriptEdCore::postBuild() initMenu(); - initKeywords(); - + onRegionChangeInitialiseKeywords(); + //LLEnvManagerNew::getInstance()->setRegionChangeCallback(boost::bind(&LLScriptEdCore::onRegionChangeInitialiseKeywords(), this)); return TRUE; } -void LLScriptEdCore::initKeywords() +void LLScriptEdCore::onRegionChangeInitialiseKeywords() { + mEditor->mKeywords.clearLoaded(); mSyntaxIdLSL.initialise(); mEditor->mKeywords.initialise(mSyntaxIdLSL.getKeywordsXML()); -- cgit v1.2.3 From df78262f0ac19c888bb3416da0df37ece77729dc Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Fri, 15 Nov 2013 23:17:06 +0000 Subject: Fixing the stupid mistake that prevented this from compiling. Thanks to Jonathan Yap for spotting it. --- indra/newview/llpreviewscript.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 19aab8f383..c662343238 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -407,8 +407,11 @@ BOOL LLScriptEdCore::postBuild() initMenu(); + // Intialise keyword highlighting for the current simulator's version of LSL onRegionChangeInitialiseKeywords(); - //LLEnvManagerNew::getInstance()->setRegionChangeCallback(boost::bind(&LLScriptEdCore::onRegionChangeInitialiseKeywords(), this)); + // Set up a callback for region changes, so that highlighting is updated to the new region's version of LSL + LLEnvManagerNew::getInstance()->setRegionChangeCallback(boost::bind(&LLScriptEdCore::onRegionChangeInitialiseKeywords, this)); + return TRUE; } -- cgit v1.2.3 From 25c7ea0532b6316639b7efbbfb9f10bfe7e38635 Mon Sep 17 00:00:00 2001 From: "niel@mint-32" Date: Thu, 21 Nov 2013 00:02:15 +0000 Subject: storm-1831 Replacing old region changed callback setup with the shiny new one. --- indra/newview/llpreviewscript.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index c662343238..362836b5b9 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -410,7 +410,7 @@ BOOL LLScriptEdCore::postBuild() // Intialise keyword highlighting for the current simulator's version of LSL onRegionChangeInitialiseKeywords(); // Set up a callback for region changes, so that highlighting is updated to the new region's version of LSL - LLEnvManagerNew::getInstance()->setRegionChangeCallback(boost::bind(&LLScriptEdCore::onRegionChangeInitialiseKeywords, this)); + gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::onRegionChangeInitialiseKeywords, this)); return TRUE; } -- cgit v1.2.3 From 7563fb0b5181fa7223cb08f79e2710f9d44aded3 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Fri, 22 Nov 2013 01:01:29 +0000 Subject: storm-1831 Replacing old hack with an ENUM check. --- indra/newview/llpreviewscript.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 362836b5b9..41c172e629 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -421,7 +421,6 @@ void LLScriptEdCore::onRegionChangeInitialiseKeywords() mSyntaxIdLSL.initialise(); mEditor->mKeywords.initialise(mSyntaxIdLSL.getKeywordsXML()); - LLColor3 color(0.5f, 0.0f, 0.15f); mEditor->loadKeywords(); std::vector primary_keywords; @@ -431,8 +430,7 @@ void LLScriptEdCore::onRegionChangeInitialiseKeywords() for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) { token = token_it->second; - // FIX: change this to use the new Token Type enum entries. - if (token->getColor() == color) // Wow, what a disgusting hack. + if (token->getType() == LLKeywordToken::TT_FUNCTION) { primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); } -- cgit v1.2.3 From fd643f07c8a3e3f1cfb146684f2d68db4b4126e7 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sat, 4 Jan 2014 01:27:57 +0000 Subject: storm-1831 In the LLSD, functions are in a which makes sorting unnecessary (loading sorts them). --- indra/newview/llpreviewscript.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 41c172e629..aedf687f0d 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -440,11 +440,6 @@ void LLScriptEdCore::onRegionChangeInitialiseKeywords() } } - // Case-insensitive dictionary sort for primary keywords. We don't sort the secondary - // keywords. They're intelligently grouped in keywords.ini. - // As we don't use keywords.ini, this is no longer true. Do we need to sort now? - std::stable_sort( primary_keywords.begin(), primary_keywords.end(), LLSECKeywordCompare() ); - for (std::vector::const_iterator iter= primary_keywords.begin(); iter!= primary_keywords.end(); ++iter) { -- cgit v1.2.3 From 4bcb67c704098d30f0969cc4791018ce136e49e7 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 30 Jan 2014 13:01:19 +0000 Subject: Making initialisation of mKeywords conditional on mSyntaxIdLSL having loaded an XML file. --- indra/newview/llpreviewscript.cpp | 53 +++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 24 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index aedf687f0d..979074b453 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -395,7 +395,7 @@ BOOL LLScriptEdCore::postBuild() { mErrorList = getChild("lsl errors"); - mFunctions = getChild( "Insert..."); + mFunctions = getChild("Insert..."); childSetCommitCallback("Insert...", &LLScriptEdCore::onBtnInsertFunction, this); @@ -419,37 +419,42 @@ void LLScriptEdCore::onRegionChangeInitialiseKeywords() { mEditor->mKeywords.clearLoaded(); mSyntaxIdLSL.initialise(); - mEditor->mKeywords.initialise(mSyntaxIdLSL.getKeywordsXML()); - mEditor->loadKeywords(); - std::vector primary_keywords; - std::vector secondary_keywords; - LLKeywordToken *token; - LLKeywords::keyword_iterator_t token_it; - for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) + if (mSyntaxIdLSL.isLoaded()) { - token = token_it->second; - if (token->getType() == LLKeywordToken::TT_FUNCTION) + mEditor->mKeywords.initialise(mSyntaxIdLSL.getKeywordsXML()); + + mEditor->loadKeywords(); + + std::vector primary_keywords; + std::vector secondary_keywords; + LLKeywordToken *token; + LLKeywords::keyword_iterator_t token_it; + for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) { - primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); + token = token_it->second; + if (token->getType() == LLKeywordToken::TT_FUNCTION) + { + primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); + } + else + { + secondary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); + } } - else + + for (std::vector::const_iterator iter= primary_keywords.begin(); + iter!= primary_keywords.end(); ++iter) { - secondary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); + mFunctions->add(*iter); } - } - for (std::vector::const_iterator iter= primary_keywords.begin(); - iter!= primary_keywords.end(); ++iter) - { - mFunctions->add(*iter); - } - - for (std::vector::const_iterator iter= secondary_keywords.begin(); - iter!= secondary_keywords.end(); ++iter) - { - mFunctions->add(*iter); + for (std::vector::const_iterator iter= secondary_keywords.begin(); + iter!= secondary_keywords.end(); ++iter) + { + mFunctions->add(*iter); + } } } -- cgit v1.2.3 From 4514d8c5c3bd5e16ba8d84214ecd164cd0740864 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 6 Feb 2014 16:48:22 +0000 Subject: Refactoring to better check state of loading and to allow clearing of highlighting if we don't have a valid keywords file. --- indra/newview/llpreviewscript.cpp | 71 +++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 25 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 979074b453..904b56b436 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -417,45 +417,66 @@ BOOL LLScriptEdCore::postBuild() void LLScriptEdCore::onRegionChangeInitialiseKeywords() { - mEditor->mKeywords.clearLoaded(); + LL_DEBUGS("SyntaxLSL") << "Pre Initialise!" << LL_ENDL; mSyntaxIdLSL.initialise(); + LL_DEBUGS("SyntaxLSL") << "Post Initialise!" << LL_ENDL; + // Nasty Hack to get started, needs to replaced with a callback or similar. + if (mSyntaxIdLSL.fetching()) + { + LL_WARNS("SyntaxLSL") << "No Response in Time, still fetching!" << LL_ENDL; + } - if (mSyntaxIdLSL.isLoaded()) + if (mSyntaxIdLSL.isDifferentVersion()) { - mEditor->mKeywords.initialise(mSyntaxIdLSL.getKeywordsXML()); + LL_INFOS("SyntaxLSL") + << "Hashes are different, updating highlighter." << LL_ENDL; - mEditor->loadKeywords(); + mEditor->mKeywords.clearLoaded(); + mEditor->clearSegments(); + mEditor->mKeywords.clear(); - std::vector primary_keywords; - std::vector secondary_keywords; - LLKeywordToken *token; - LLKeywords::keyword_iterator_t token_it; - for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) + if (mSyntaxIdLSL.isLoaded()) { - token = token_it->second; - if (token->getType() == LLKeywordToken::TT_FUNCTION) + mEditor->mKeywords.initialise(mSyntaxIdLSL.getKeywordsXML()); + + mEditor->loadKeywords(); + + std::vector primary_keywords; + std::vector secondary_keywords; + LLKeywordToken *token; + LLKeywords::keyword_iterator_t token_it; + for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) { - primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); + token = token_it->second; + if (token->getType() == LLKeywordToken::TT_FUNCTION) + { + primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); + } + else + { + secondary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); + } } - else + + for (std::vector::const_iterator iter= primary_keywords.begin(); + iter!= primary_keywords.end(); ++iter) { - secondary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); + mFunctions->add(*iter); } - } - - for (std::vector::const_iterator iter= primary_keywords.begin(); - iter!= primary_keywords.end(); ++iter) - { - mFunctions->add(*iter); - } - for (std::vector::const_iterator iter= secondary_keywords.begin(); - iter!= secondary_keywords.end(); ++iter) - { - mFunctions->add(*iter); + for (std::vector::const_iterator iter= secondary_keywords.begin(); + iter!= secondary_keywords.end(); ++iter) + { + mFunctions->add(*iter); + } } } + else + { + LL_INFOS("SyntaxLSL") + << "Hashes are the same, no need to update highlighter." << LL_ENDL; + } } void LLScriptEdCore::initMenu() -- cgit v1.2.3 From 76aa75974f25ffe3837fd5789a00e9dd194903e4 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 6 Mar 2014 13:24:52 +0000 Subject: storm-1831 Changes in postBuild to use onFileFetchedCallback --- indra/newview/llpreviewscript.cpp | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 904b56b436..0ca4718250 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -407,27 +407,45 @@ BOOL LLScriptEdCore::postBuild() initMenu(); - // Intialise keyword highlighting for the current simulator's version of LSL + mSyntaxIdLSL.addFileFetchedCallback(boost::bind(&LLScriptEdCore::onFileFetchedInitialiseKeywords, this)); + onRegionChangeInitialiseKeywords(); + // Set up a callback for region changes, so that highlighting is updated to the new region's version of LSL - gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::onRegionChangeInitialiseKeywords, this)); + //gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::onRegionChangeInitialiseKeywords, this)); return TRUE; } void LLScriptEdCore::onRegionChangeInitialiseKeywords() { + // Intialise keyword highlighting for the current simulator's version of LSL LL_DEBUGS("SyntaxLSL") << "Pre Initialise!" << LL_ENDL; mSyntaxIdLSL.initialise(); LL_DEBUGS("SyntaxLSL") << "Post Initialise!" << LL_ENDL; - // Nasty Hack to get started, needs to replaced with a callback or similar. - if (mSyntaxIdLSL.fetching()) + if (mSyntaxIdLSL.isDifferentVersion()) + { + if (mSyntaxIdLSL.isLoaded()) + { + onFileFetchedInitialiseKeywords(); + } + else + { + LL_INFOS("SyntaxLSL") + << "Hashes are the different, waiting for the syntax file to be retrieved." << LL_ENDL; + } + } + else { - LL_WARNS("SyntaxLSL") << "No Response in Time, still fetching!" << LL_ENDL; + LL_INFOS("SyntaxLSL") + << "Hashes are the same, no need to update highlighter." << LL_ENDL; } +} - if (mSyntaxIdLSL.isDifferentVersion()) +void LLScriptEdCore::onFileFetchedInitialiseKeywords() +{ + if (mSyntaxIdLSL.isLoaded()) { LL_INFOS("SyntaxLSL") << "Hashes are different, updating highlighter." << LL_ENDL; @@ -472,11 +490,6 @@ void LLScriptEdCore::onRegionChangeInitialiseKeywords() } } } - else - { - LL_INFOS("SyntaxLSL") - << "Hashes are the same, no need to update highlighter." << LL_ENDL; - } } void LLScriptEdCore::initMenu() -- cgit v1.2.3 From 06bdcef531c79db7f6901e2c5f5f63b2f75ad4e5 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sun, 9 Mar 2014 04:55:46 +0000 Subject: storm-1831 Fixing identificaton of label for highlighting. --- indra/newview/llpreviewscript.cpp | 72 ++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 27 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 0ca4718250..4c6f4fd3ba 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -407,52 +407,70 @@ BOOL LLScriptEdCore::postBuild() initMenu(); - mSyntaxIdLSL.addFileFetchedCallback(boost::bind(&LLScriptEdCore::onFileFetchedInitialiseKeywords, this)); + mSyntaxIdLSL.addFileFetchedCallback(boost::bind(&LLScriptEdCore::processKeywords, this)); + + // Intialise keyword highlighting for the current simulator's version of LSL + mSyntaxIdLSL.initialise(); + + if (mSyntaxIdLSL.isDifferentVersion()) + { + processLoaded(); + } + else + { + LL_INFOS("SyntaxLSL") + << "Hashes are the same, no need to update highlighter." << LL_ENDL; + } - onRegionChangeInitialiseKeywords(); - // Set up a callback for region changes, so that highlighting is updated to the new region's version of LSL - //gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::onRegionChangeInitialiseKeywords, this)); + // Set up a callback for region changes + mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::updateKeywords, this)); return TRUE; } -void LLScriptEdCore::onRegionChangeInitialiseKeywords() +void LLScriptEdCore::updateKeywords() { - // Intialise keyword highlighting for the current simulator's version of LSL - LL_DEBUGS("SyntaxLSL") << "Pre Initialise!" << LL_ENDL; - mSyntaxIdLSL.initialise(); - LL_DEBUGS("SyntaxLSL") << "Post Initialise!" << LL_ENDL; + if (mLive) + { + clearHighlights(); + gAgent.removeRegionChangedCallback(mRegionChangedCallback); + } + else + { + processLoaded(); + } +} - if (mSyntaxIdLSL.isDifferentVersion()) +void LLScriptEdCore::processLoaded() +{ + mSyntaxIdLSL.initialise(); + if (mSyntaxIdLSL.isLoaded()) { - if (mSyntaxIdLSL.isLoaded()) - { - onFileFetchedInitialiseKeywords(); - } - else - { - LL_INFOS("SyntaxLSL") - << "Hashes are the different, waiting for the syntax file to be retrieved." << LL_ENDL; - } + processKeywords(); } else { LL_INFOS("SyntaxLSL") - << "Hashes are the same, no need to update highlighter." << LL_ENDL; + << "Hashes are different, waiting for the syntax file to be retrieved." << LL_ENDL; } } -void LLScriptEdCore::onFileFetchedInitialiseKeywords() +void LLScriptEdCore::clearHighlights() +{ + mEditor->mKeywords.clearLoaded(); + mEditor->clearSegments(); + mEditor->mKeywords.clear(); +} + +void LLScriptEdCore::processKeywords() { if (mSyntaxIdLSL.isLoaded()) { LL_INFOS("SyntaxLSL") << "Hashes are different, updating highlighter." << LL_ENDL; - mEditor->mKeywords.clearLoaded(); - mEditor->clearSegments(); - mEditor->mKeywords.clear(); + clearHighlights(); if (mSyntaxIdLSL.isLoaded()) { @@ -1227,8 +1245,8 @@ bool LLScriptEdCore::enableLoadFromFileMenu(void* userdata) /// LLScriptEdContainer /// --------------------------------------------------------------------------- -LLScriptEdContainer::LLScriptEdContainer(const LLSD& key) -: LLPreview(key) +LLScriptEdContainer::LLScriptEdContainer(const LLSD& key) : + LLPreview(key) , mScriptEd(NULL) { } @@ -1750,7 +1768,7 @@ void* LLLiveLSLEditor::createScriptEdPanel(void* userdata) &LLLiveLSLEditor::onSearchReplace, self, 0); - + self->mScriptEd->mLive = true; return self->mScriptEd; } -- cgit v1.2.3 From 8e53c5bfb0e9feffa0450b362f21f56036b9b75c Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Wed, 26 Mar 2014 20:31:05 +0000 Subject: storm-1831 Removing the callback after first region crossing. Prevents repeated callbacks after highlighting has been removed for live script. --- indra/newview/llpreviewscript.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 4c6f4fd3ba..84e7a1650d 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -434,7 +434,7 @@ void LLScriptEdCore::updateKeywords() if (mLive) { clearHighlights(); - gAgent.removeRegionChangedCallback(mRegionChangedCallback); + mRegionChangedCallback.disconnect(); } else { @@ -458,9 +458,7 @@ void LLScriptEdCore::processLoaded() void LLScriptEdCore::clearHighlights() { - mEditor->mKeywords.clearLoaded(); mEditor->clearSegments(); - mEditor->mKeywords.clear(); } void LLScriptEdCore::processKeywords() @@ -1309,7 +1307,7 @@ void* LLPreviewLSL::createScriptEdPanel(void* userdata) LLPreviewLSL::onSearchReplace, self, 0); - + self->mScriptEd->mLive = false; return self->mScriptEd; } @@ -1324,7 +1322,7 @@ LLPreviewLSL::LLPreviewLSL(const LLSD& key ) // virtual BOOL LLPreviewLSL::postBuild() { - const LLInventoryItem* item = getItem(); + const LLInventoryItem* item = getItem(); llassert(item); if (item) @@ -1756,7 +1754,6 @@ void LLPreviewLSL::onLoadComplete( LLVFS *vfs, const LLUUID& asset_uuid, LLAsset //static void* LLLiveLSLEditor::createScriptEdPanel(void* userdata) { - LLLiveLSLEditor *self = (LLLiveLSLEditor*)userdata; self->mScriptEd = new LLScriptEdCore( -- cgit v1.2.3 From 8c39617c9ac469a8635d511142148ad5a38de836 Mon Sep 17 00:00:00 2001 From: Cinder Date: Fri, 18 Apr 2014 12:52:07 -0600 Subject: Begin moving script editor portions of LLTextEditor to their own derived class. This should fix the run off segment bugs by not overriding LLTextBase::clearSegments() in LLTextEditor TODO: Move the rest of the script stuff out of LLTextEditor for simplicity sake --- indra/newview/llpreviewscript.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 84e7a1650d..0d95874406 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -69,6 +69,7 @@ #include "llkeyboard.h" #include "llscrollcontainer.h" #include "llcheckboxctrl.h" +#include "llscripteditor.h" #include "llselectmgr.h" #include "lltooldraganddrop.h" #include "llscrolllistctrl.h" @@ -77,7 +78,6 @@ #include "lldir.h" #include "llcombobox.h" #include "llviewerstats.h" -#include "llviewertexteditor.h" #include "llviewerwindow.h" #include "lluictrlfactory.h" #include "llmediactrl.h" @@ -399,7 +399,7 @@ BOOL LLScriptEdCore::postBuild() childSetCommitCallback("Insert...", &LLScriptEdCore::onBtnInsertFunction, this); - mEditor = getChild("Script Editor"); + mEditor = getChild("Script Editor"); childSetCommitCallback("lsl errors", &LLScriptEdCore::onErrorList, this); childSetAction("Save_btn", boost::bind(&LLScriptEdCore::doSave,this,FALSE)); -- cgit v1.2.3 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 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') 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; -- cgit v1.2.3 From 46627b4eb2218babbc94421f9b93c03e2951cc6c Mon Sep 17 00:00:00 2001 From: Cinder Date: Fri, 18 Apr 2014 23:20:33 -0600 Subject: Remove clearHighlights() --- indra/newview/llpreviewscript.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index e778015965..1d95276c51 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -433,7 +433,7 @@ void LLScriptEdCore::updateKeywords() { if (mLive) { - clearHighlights(); + mEditor->clearSegments(); mRegionChangedCallback.disconnect(); } else @@ -456,11 +456,6 @@ void LLScriptEdCore::processLoaded() } } -void LLScriptEdCore::clearHighlights() -{ - mEditor->clearSegments(); -} - void LLScriptEdCore::processKeywords() { if (mSyntaxIdLSL.isLoaded()) @@ -468,7 +463,7 @@ void LLScriptEdCore::processKeywords() LL_INFOS("SyntaxLSL") << "Hashes are different, updating highlighter." << LL_ENDL; - clearHighlights(); + mEditor->clearSegments(); if (mSyntaxIdLSL.isLoaded()) { -- cgit v1.2.3 From e8422e5bed6c593c8a26b533f33103911a1d3da6 Mon Sep 17 00:00:00 2001 From: Cinder Date: Tue, 6 May 2014 11:09:50 -0600 Subject: Let's get started: some code policy cleanup, reference arguments where we can, correct spelling --- indra/newview/llpreviewscript.cpp | 79 +++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 45 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 1d95276c51..fae4aeb7bc 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -374,6 +374,7 @@ LLScriptEdCore::LLScriptEdCore( setXMLFilename("panel_script_ed.xml"); llassert_always(mContainer != NULL); + mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::updateKeywords, this)); } LLScriptEdCore::~LLScriptEdCore() @@ -389,6 +390,7 @@ LLScriptEdCore::~LLScriptEdCore() } delete mLiveFile; + mRegionChangedCallback.disconnect(); } BOOL LLScriptEdCore::postBuild() @@ -407,25 +409,20 @@ BOOL LLScriptEdCore::postBuild() initMenu(); - mSyntaxIdLSL.addFileFetchedCallback(boost::bind(&LLScriptEdCore::processKeywords, this)); + LLSyntaxIdLSL::getInstance()->addFileFetchedCallback(boost::bind(&LLScriptEdCore::processKeywords, this)); // Intialise keyword highlighting for the current simulator's version of LSL - mSyntaxIdLSL.initialise(); + LLSyntaxIdLSL::getInstance()->initialise(); - if (mSyntaxIdLSL.isDifferentVersion()) + if (LLSyntaxIdLSL::getInstance()->isDifferentVersion()) { processLoaded(); } else { - LL_INFOS("SyntaxLSL") - << "Hashes are the same, no need to update highlighter." << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "Hashes are the same, no need to update highlighter." << LL_ENDL; } - - // Set up a callback for region changes - mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::updateKeywords, this)); - return TRUE; } @@ -434,7 +431,6 @@ void LLScriptEdCore::updateKeywords() if (mLive) { mEditor->clearSegments(); - mRegionChangedCallback.disconnect(); } else { @@ -444,61 +440,54 @@ void LLScriptEdCore::updateKeywords() void LLScriptEdCore::processLoaded() { - mSyntaxIdLSL.initialise(); - if (mSyntaxIdLSL.isLoaded()) + LLSyntaxIdLSL::getInstance()->initialise(); + if (LLSyntaxIdLSL::getInstance()->isLoaded()) { processKeywords(); } else { - LL_INFOS("SyntaxLSL") - << "Hashes are different, waiting for the syntax file to be retrieved." << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "Hashes are different, waiting for the syntax file to be retrieved." << LL_ENDL; } } void LLScriptEdCore::processKeywords() { - if (mSyntaxIdLSL.isLoaded()) + if (LLSyntaxIdLSL::getInstance()->isLoaded()) { - LL_INFOS("SyntaxLSL") - << "Hashes are different, updating highlighter." << LL_ENDL; + LL_DEBUGS("SyntaxLSL") << "Hashes are different, updating highlighter." << LL_ENDL; mEditor->clearSegments(); - if (mSyntaxIdLSL.isLoaded()) - { - mEditor->initKeywords(); - mEditor->loadKeywords(); - - std::vector primary_keywords; - std::vector secondary_keywords; - LLKeywordToken *token; - LLKeywords::keyword_iterator_t token_it; - for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) - { - token = token_it->second; - if (token->getType() == LLKeywordToken::TT_FUNCTION) - { - primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); - } - else - { - secondary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); - } - } + mEditor->initKeywords(); + mEditor->loadKeywords(); - for (std::vector::const_iterator iter= primary_keywords.begin(); - iter!= primary_keywords.end(); ++iter) + string_vec_t primary_keywords; + string_vec_t secondary_keywords; + LLKeywordToken *token; + LLKeywords::keyword_iterator_t token_it; + for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) + { + token = token_it->second; + if (token->getType() == LLKeywordToken::TT_FUNCTION) { - mFunctions->add(*iter); + primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); } - - for (std::vector::const_iterator iter= secondary_keywords.begin(); - iter!= secondary_keywords.end(); ++iter) + else { - mFunctions->add(*iter); + secondary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); } } + for (string_vec_t::const_iterator iter = primary_keywords.begin(); + iter!= primary_keywords.end(); ++iter) + { + mFunctions->add(*iter); + } + for (string_vec_t::const_iterator iter = secondary_keywords.begin(); + iter!= secondary_keywords.end(); ++iter) + { + mFunctions->add(*iter); + } } } -- cgit v1.2.3 From 8501d6494bceeea962d7251d882ddc244a8daa7f Mon Sep 17 00:00:00 2001 From: Cinder Date: Wed, 7 May 2014 19:58:56 -0600 Subject: Code policy --- indra/newview/llpreviewscript.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index fae4aeb7bc..73dc19dd81 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -412,7 +412,7 @@ BOOL LLScriptEdCore::postBuild() LLSyntaxIdLSL::getInstance()->addFileFetchedCallback(boost::bind(&LLScriptEdCore::processKeywords, this)); // Intialise keyword highlighting for the current simulator's version of LSL - LLSyntaxIdLSL::getInstance()->initialise(); + LLSyntaxIdLSL::getInstance()->initialize(); if (LLSyntaxIdLSL::getInstance()->isDifferentVersion()) { @@ -440,7 +440,7 @@ void LLScriptEdCore::updateKeywords() void LLScriptEdCore::processLoaded() { - LLSyntaxIdLSL::getInstance()->initialise(); + LLSyntaxIdLSL::getInstance()->initialize(); if (LLSyntaxIdLSL::getInstance()->isLoaded()) { processKeywords(); -- cgit v1.2.3 From 059a29e976a41c30ec9fb346ae53bbc51aa682fc Mon Sep 17 00:00:00 2001 From: Cinder Date: Sun, 11 May 2014 23:17:31 -0600 Subject: Fix callback signal, Eliminate some unnecessary statics --- indra/newview/llpreviewscript.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index befec98849..d83a2bc3a6 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -374,7 +374,6 @@ LLScriptEdCore::LLScriptEdCore( setXMLFilename("panel_script_ed.xml"); llassert_always(mContainer != NULL); - mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::updateKeywords, this)); } LLScriptEdCore::~LLScriptEdCore() @@ -391,6 +390,7 @@ LLScriptEdCore::~LLScriptEdCore() delete mLiveFile; mRegionChangedCallback.disconnect(); + mFileFetchedCallback.disconnect(); } BOOL LLScriptEdCore::postBuild() @@ -409,7 +409,7 @@ BOOL LLScriptEdCore::postBuild() initMenu(); - LLSyntaxIdLSL::getInstance()->addFileFetchedCallback(boost::bind(&LLScriptEdCore::processKeywords, this)); + mFileFetchedCallback = LLSyntaxIdLSL::getInstance()->addFileFetchedCallback(boost::bind(&LLScriptEdCore::processKeywords, this)); // Intialise keyword highlighting for the current simulator's version of LSL LLSyntaxIdLSL::getInstance()->initialize(); @@ -422,6 +422,7 @@ BOOL LLScriptEdCore::postBuild() { LL_DEBUGS("SyntaxLSL") << "Hashes are the same, no need to update highlighter." << LL_ENDL; } + mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::updateKeywords, this)); return TRUE; } -- cgit v1.2.3 From 6141aa44d0f2aa2662a536c9d3ce9312dd57bd99 Mon Sep 17 00:00:00 2001 From: Cinder Date: Mon, 12 May 2014 06:54:04 -0600 Subject: STORM-2027 - Fix syntax highlighting on subsequent opening of scripts. This could use more refactoring, but it fixes it. --- indra/newview/llpreviewscript.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index d83a2bc3a6..b300f3a39c 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -352,6 +352,7 @@ LLScriptEdCore::LLScriptEdCore( void (*save_callback)(void*, BOOL), void (*search_replace_callback) (void* userdata), void* userdata, + bool live, S32 bottom_pad) : LLPanel(), @@ -366,6 +367,7 @@ LLScriptEdCore::LLScriptEdCore( mLiveHelpHistorySize(0), mEnableSave(FALSE), mLiveFile(NULL), + mLive(live), mContainer(container), mHasScriptData(FALSE) { @@ -420,7 +422,7 @@ BOOL LLScriptEdCore::postBuild() } else { - LL_DEBUGS("SyntaxLSL") << "Hashes are the same, no need to update highlighter." << LL_ENDL; + processKeywords(); } mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::updateKeywords, this)); @@ -1289,8 +1291,8 @@ void* LLPreviewLSL::createScriptEdPanel(void* userdata) LLPreviewLSL::onSave, LLPreviewLSL::onSearchReplace, self, + false, 0); - self->mScriptEd->mLive = false; return self->mScriptEd; } @@ -1745,8 +1747,8 @@ void* LLLiveLSLEditor::createScriptEdPanel(void* userdata) &LLLiveLSLEditor::onSave, &LLLiveLSLEditor::onSearchReplace, self, + true, 0); - self->mScriptEd->mLive = true; return self->mScriptEd; } -- cgit v1.2.3 From 70aff2154b910afd9a8bdc14c72c4e058c8b1076 Mon Sep 17 00:00:00 2001 From: Cinder Date: Mon, 12 May 2014 07:23:52 -0600 Subject: Eliminate updateKeywords() --- indra/newview/llpreviewscript.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index b300f3a39c..5e7b148101 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -391,8 +391,14 @@ LLScriptEdCore::~LLScriptEdCore() } delete mLiveFile; - mRegionChangedCallback.disconnect(); - mFileFetchedCallback.disconnect(); + if (mRegionChangedCallback.connected()) + { + mRegionChangedCallback.disconnect(); + } + if (mFileFetchedCallback.connected()) + { + mFileFetchedCallback.disconnect(); + } } BOOL LLScriptEdCore::postBuild() @@ -424,21 +430,13 @@ BOOL LLScriptEdCore::postBuild() { processKeywords(); } - mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::updateKeywords, this)); - - return TRUE; -} - -void LLScriptEdCore::updateKeywords() -{ + if (mLive) { - mEditor->clearSegments(); - } - else - { - processLoaded(); + mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::processLoaded, this)); } + + return TRUE; } void LLScriptEdCore::processLoaded() -- cgit v1.2.3 From 41f6c5ce4899b3ae57aefa564ee22ff84fa698ce Mon Sep 17 00:00:00 2001 From: Cinder Date: Mon, 9 Jun 2014 15:14:09 -0600 Subject: Greatly simplify LLSyntaxIdLSL: * Move file fetched callback to the singleton and handle all syntax id changes within the singleton * Remove a fair number of bool checks and method relying more on callbacks to drive syntax changes. * Don't pretty print the cache file to conserve space and to speed up xml to llsd parsing * Clean up includes --- indra/newview/llpreviewscript.cpp | 95 +++++++++++++-------------------------- 1 file changed, 30 insertions(+), 65 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 76cb1c1ebc..9ff0ece7d9 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -399,13 +399,9 @@ LLScriptEdCore::~LLScriptEdCore() } delete mLiveFile; - if (mRegionChangedCallback.connected()) + if (mSyntaxIDConnection.connected()) { - mRegionChangedCallback.disconnect(); - } - if (mFileFetchedCallback.connected()) - { - mFileFetchedCallback.disconnect(); + mSyntaxIDConnection.disconnect(); } } @@ -425,79 +421,48 @@ BOOL LLScriptEdCore::postBuild() initMenu(); - mFileFetchedCallback = LLSyntaxIdLSL::getInstance()->addFileFetchedCallback(boost::bind(&LLScriptEdCore::processKeywords, this)); + mSyntaxIDConnection = LLSyntaxIdLSL::getInstance()->addSyntaxIDCallback(boost::bind(&LLScriptEdCore::processKeywords, this)); // Intialise keyword highlighting for the current simulator's version of LSL LLSyntaxIdLSL::getInstance()->initialize(); - - if (LLSyntaxIdLSL::getInstance()->isDifferentVersion()) - { - processLoaded(); - } - else - { - processKeywords(); - } - - if (mLive) - { - mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::processLoaded, this)); - } + processKeywords(); return TRUE; } -void LLScriptEdCore::processLoaded() -{ - LLSyntaxIdLSL::getInstance()->initialize(); - if (LLSyntaxIdLSL::getInstance()->isLoaded()) - { - processKeywords(); - } - else - { - LL_DEBUGS("SyntaxLSL") << "Hashes are different, waiting for the syntax file to be retrieved." << LL_ENDL; - } -} - void LLScriptEdCore::processKeywords() { - if (LLSyntaxIdLSL::getInstance()->isLoaded()) - { - LL_DEBUGS("SyntaxLSL") << "Hashes are different, updating highlighter." << LL_ENDL; - - mEditor->clearSegments(); - - mEditor->initKeywords(); - mEditor->loadKeywords(); - - string_vec_t primary_keywords; - string_vec_t secondary_keywords; - LLKeywordToken *token; - LLKeywords::keyword_iterator_t token_it; - for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) - { - token = token_it->second; - if (token->getType() == LLKeywordToken::TT_FUNCTION) - { - primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); - } - else - { - secondary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); - } - } - for (string_vec_t::const_iterator iter = primary_keywords.begin(); - iter!= primary_keywords.end(); ++iter) + LL_DEBUGS("SyntaxLSL") << "Processing keywords" << LL_ENDL; + mEditor->clearSegments(); + mEditor->initKeywords(); + mEditor->loadKeywords(); + + string_vec_t primary_keywords; + string_vec_t secondary_keywords; + LLKeywordToken *token; + LLKeywords::keyword_iterator_t token_it; + for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it) + { + token = token_it->second; + if (token->getType() == LLKeywordToken::TT_FUNCTION) { - mFunctions->add(*iter); + primary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); } - for (string_vec_t::const_iterator iter = secondary_keywords.begin(); - iter!= secondary_keywords.end(); ++iter) + else { - mFunctions->add(*iter); + secondary_keywords.push_back( wstring_to_utf8str(token->getToken()) ); } } + for (string_vec_t::const_iterator iter = primary_keywords.begin(); + iter!= primary_keywords.end(); ++iter) + { + mFunctions->add(*iter); + } + for (string_vec_t::const_iterator iter = secondary_keywords.begin(); + iter!= secondary_keywords.end(); ++iter) + { + mFunctions->add(*iter); + } } void LLScriptEdCore::initMenu() -- cgit v1.2.3