diff options
Diffstat (limited to 'indra/newview/llpreviewscript.cpp')
-rwxr-xr-x | indra/newview/llpreviewscript.cpp | 61 |
1 files changed, 20 insertions, 41 deletions
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index e533be7f24..c662343238 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" @@ -408,42 +407,22 @@ BOOL LLScriptEdCore::postBuild() initMenu(); + // 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)); + + return TRUE; +} + +void LLScriptEdCore::onRegionChangeInitialiseKeywords() +{ + mEditor->mKeywords.clearLoaded(); + mSyntaxIdLSL.initialise(); + mEditor->mKeywords.initialise(mSyntaxIdLSL.getKeywordsXML()); - 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) - { - // 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); + mEditor->loadKeywords(); std::vector<std::string> primary_keywords; std::vector<std::string> secondary_keywords; @@ -452,6 +431,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()) ); @@ -464,6 +444,7 @@ BOOL LLScriptEdCore::postBuild() // 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<std::string>::const_iterator iter= primary_keywords.begin(); @@ -477,8 +458,6 @@ BOOL LLScriptEdCore::postBuild() { mFunctions->add(*iter); } - - return TRUE; } void LLScriptEdCore::initMenu() @@ -680,7 +659,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 +670,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; } |