summaryrefslogtreecommitdiff
path: root/indra/newview/llpreviewscript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llpreviewscript.cpp')
-rwxr-xr-xindra/newview/llpreviewscript.cpp163
1 files changed, 96 insertions, 67 deletions
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index e533be7f24..4c6f4fd3ba 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"
@@ -50,11 +51,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"
@@ -396,7 +395,7 @@ BOOL LLScriptEdCore::postBuild()
{
mErrorList = getChild<LLScrollListCtrl>("lsl errors");
- mFunctions = getChild<LLComboBox>( "Insert...");
+ mFunctions = getChild<LLComboBox>("Insert...");
childSetCommitCallback("Insert...", &LLScriptEdCore::onBtnInsertFunction, this);
@@ -408,77 +407,107 @@ BOOL LLScriptEdCore::postBuild()
initMenu();
+ mSyntaxIdLSL.addFileFetchedCallback(boost::bind(&LLScriptEdCore::processKeywords, this));
+
+ // Intialise keyword highlighting for the current simulator's version of LSL
+ mSyntaxIdLSL.initialise();
- std::vector<std::string> funcs;
- std::vector<std::string> tooltips;
- for (std::vector<LLScriptLibraryFunction>::const_iterator i = gScriptLibrary.mFunctions.begin();
- i != gScriptLibrary.mFunctions.end(); ++i)
+ if (mSyntaxIdLSL.isDifferentVersion())
{
- // 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);
- }
+ processLoaded();
}
-
- LLColor3 color(0.5f, 0.0f, 0.15f);
- mEditor->loadKeywords(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"keywords.ini"), funcs, tooltips, color);
-
- std::vector<std::string> primary_keywords;
- std::vector<std::string> secondary_keywords;
- LLKeywordToken *token;
- LLKeywords::keyword_iterator_t token_it;
- for (token_it = mEditor->keywordsBegin(); token_it != mEditor->keywordsEnd(); ++token_it)
+ else
{
- token = token_it->second;
- 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()) );
- }
+ LL_INFOS("SyntaxLSL")
+ << "Hashes are the same, no need to update highlighter." << LL_ENDL;
}
- // 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<std::string>::const_iterator iter= primary_keywords.begin();
- iter!= primary_keywords.end(); ++iter)
+ // Set up a callback for region changes
+ mRegionChangedCallback = gAgent.addRegionChangedCallback(boost::bind(&LLScriptEdCore::updateKeywords, this));
+
+ return TRUE;
+}
+
+void LLScriptEdCore::updateKeywords()
+{
+ if (mLive)
+ {
+ clearHighlights();
+ gAgent.removeRegionChangedCallback(mRegionChangedCallback);
+ }
+ else
{
- mFunctions->add(*iter);
+ processLoaded();
}
+}
- for (std::vector<std::string>::const_iterator iter= secondary_keywords.begin();
- iter!= secondary_keywords.end(); ++iter)
+void LLScriptEdCore::processLoaded()
+{
+ mSyntaxIdLSL.initialise();
+ if (mSyntaxIdLSL.isLoaded())
+ {
+ processKeywords();
+ }
+ else
{
- mFunctions->add(*iter);
+ LL_INFOS("SyntaxLSL")
+ << "Hashes are different, waiting for the syntax file to be retrieved." << LL_ENDL;
}
+}
- return TRUE;
+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;
+
+ clearHighlights();
+
+ if (mSyntaxIdLSL.isLoaded())
+ {
+ mEditor->mKeywords.initialise(mSyntaxIdLSL.getKeywordsXML());
+
+ mEditor->loadKeywords();
+
+ std::vector<std::string> primary_keywords;
+ std::vector<std::string> 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 (std::vector<std::string>::const_iterator iter= primary_keywords.begin();
+ iter!= primary_keywords.end(); ++iter)
+ {
+ mFunctions->add(*iter);
+ }
+
+ for (std::vector<std::string>::const_iterator iter= secondary_keywords.begin();
+ iter!= secondary_keywords.end(); ++iter)
+ {
+ mFunctions->add(*iter);
+ }
+ }
+ }
}
void LLScriptEdCore::initMenu()
@@ -680,7 +709,7 @@ void LLScriptEdCore::updateDynamicHelp(BOOL immediate)
std::vector<LLTextSegmentPtr>::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;
@@ -691,7 +720,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;
}
@@ -1216,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)
{
}
@@ -1739,7 +1768,7 @@ void* LLLiveLSLEditor::createScriptEdPanel(void* userdata)
&LLLiveLSLEditor::onSearchReplace,
self,
0);
-
+ self->mScriptEd->mLive = true;
return self->mScriptEd;
}