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.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/llpreviewscript.h') diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 9fb0a4fb63..21e33f30d5 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -35,6 +35,7 @@ #include "lliconctrl.h" #include "llframetimer.h" #include "llfloatergotoline.h" +#include "llsyntaxid.h" class LLLiveLSLFile; class LLMessageSystem; @@ -149,6 +150,7 @@ private: BOOL mEnableSave; BOOL mHasScriptData; LLLiveLSLFile* mLiveFile; + LLSyntaxIdLSL mSyntaxLSL; LLScriptEdContainer* mContainer; // parent view }; -- cgit v1.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 +--- indra/newview/llpreviewscript.h | 2 +- indra/newview/llsyntaxid.cpp | 113 +++++++++++++++++++++----------------- indra/newview/llsyntaxid.h | 63 ++++++++++----------- 4 files changed, 96 insertions(+), 92 deletions(-) (limited to 'indra/newview/llpreviewscript.h') 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; diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 21e33f30d5..73ccaab0b8 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -150,7 +150,7 @@ private: BOOL mEnableSave; BOOL mHasScriptData; LLLiveLSLFile* mLiveFile; - LLSyntaxIdLSL mSyntaxLSL; + LLSyntaxIdLSL mSyntaxIdLSL; LLScriptEdContainer* mContainer; // parent view }; diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index deaa64c0e7..442793bff1 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -41,14 +41,17 @@ //----------------------------------------------------------------------------- class fetchKeywordsFileResponder : public LLCurl::Responder { - std::string mFileSpec; public: + std::string mFileSpec; + fetchKeywordsFileResponder(std::string filespec) { mFileSpec = filespec; } - void errorWithContent(U32 status, const std::string& reason, const LLSD& content) + void errorWithContent(U32 status, + const std::string& reason, + const LLSD& content) { LL_WARNS("") << "fetchKeywordsFileResponder error [status:" @@ -58,15 +61,14 @@ public: << LL_ENDL; } - void result(LLSD& content_ref) + void result(const LLSD& content_ref) { - LLSyntaxIdLSL::setKeywordsXml(content_ref); + //LLSyntaxIdLSL::setKeywordsXml(content_ref); std::stringstream str; LLSDSerialize::toPrettyXML(content_ref, str); LL_WARNS("") - << "fetchKeywordsFileResponder result:" - << str.str() + << "fetchKeywordsFileResponder result:" << str.str() << "filename: '" << mFileSpec << "'" << LL_ENDL; @@ -80,20 +82,21 @@ public: //----------------------------------------------------------------------------- // LLSyntaxIdLSL //----------------------------------------------------------------------------- +/** + * @brief LLSyntaxIdLSL constructor + */ LLSyntaxIdLSL::LLSyntaxIdLSL() : // Move these to signature? - mFilenameDefault("keywords_lsl_default.xml"), + mFileNameDefault("keywords_lsl_default.xml"), mSimulatorFeature("LSLSyntaxId"), - mCapabilityName("LSLSyntax") + mCapabilityName("LSLSyntax"), + mFilePath(LL_PATH_APP_SETTINGS) { mCurrentSyntaxId = LLUUID(); - mFilenameCurrent = mFilenameDefault; - mFilenameLocation = LL_PATH_APP_SETTINGS; - checkSyntaxIdChange(); - //LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLSyntaxIdLSL::checkSyntaxIdChange(), this)); + mFileNameCurrent = mFileNameDefault; } -std::string LLSyntaxIdLSL::buildFilename(LLUUID& SyntaxId) +std::string LLSyntaxIdLSL::buildFileName(LLUUID& SyntaxId) { std::string filename = "keywords_lsl_" + SyntaxId.asString() + "_" + gLastVersionChannel + ".llsd.xml"; return filename; @@ -102,23 +105,24 @@ std::string LLSyntaxIdLSL::buildFilename(LLUUID& SyntaxId) //----------------------------------------------------------------------------- // checkSyntaxIdChange() //----------------------------------------------------------------------------- -bool LLSyntaxIdLSL::checkSyntaxIdChange() +bool LLSyntaxIdLSL::checkSyntaxIdChanged() { bool changed = false; - if (mRegion) + LLViewerRegion* region = gAgent.getRegion(); + + if (region) { + /* LL_WARNS("LSLSyntax") - << "REGION is '" - << mRegion->getName() - << "'" + << "REGION is '" << region->getName() << "'" << LL_ENDL; + */ - if (!mRegion->capabilitiesReceived()) + if (!region->capabilitiesReceived()) { // Shouldn't be possible, but experience shows that it's needed -// mRegion->setCapabilitiesReceivedCallback(boost::bind(&LLSyntaxIdLSL::checkSyntaxIdChange, this)); +// region->setCapabilitiesReceivedCallback(boost::bind(&LLSyntaxIdLSL::checkSyntaxIdChange, this)); LL_WARNS("LSLSyntax") - << "mRegion '" - << mRegion->getName() + << "region '" << region->getName() << "' has not received capabilities yet! Setting a callback for when they arrive." << LL_ENDL; } @@ -126,23 +130,21 @@ bool LLSyntaxIdLSL::checkSyntaxIdChange() { // get and check the hash LLSD simFeatures; - mRegion->getSimulatorFeatures(simFeatures); + region->getSimulatorFeatures(simFeatures); if (simFeatures.has("LSLSyntaxId")) { LLUUID SyntaxId = simFeatures["LSLSyntaxId"].asUUID(); if (mCurrentSyntaxId != SyntaxId) { // set the properties for the fetcher to use - mFilenameCurrent = buildFilename(SyntaxId); - mFilenameLocation = LL_PATH_CACHE; + mFileNameCurrent = buildFileName(SyntaxId); + mFilePath = LL_PATH_CACHE; mCurrentSyntaxId = SyntaxId; LL_WARNS("LSLSyntax") - << "Region changed to '" - << mRegion->getName() + << "Region changed to '" << region->getName() << "' it has LSLSyntaxId capability, and the new hash is '" - << SyntaxId - << "'" + << SyntaxId << "'" << LL_ENDL; changed = true; @@ -150,11 +152,9 @@ bool LLSyntaxIdLSL::checkSyntaxIdChange() else { LL_WARNS("LSLSyntax") - << "Region changed to '" - << mRegion->getName() + << "Region changed to '" << region->getName() << "' it has the same LSLSyntaxId! Leaving hash as '" - << mCurrentSyntaxId - << "'" + << mCurrentSyntaxId << "'" << LL_ENDL; } } @@ -164,17 +164,19 @@ bool LLSyntaxIdLSL::checkSyntaxIdChange() if ( mCurrentSyntaxId.isNull() ) { LL_WARNS("LSLSyntax") - << "Region does not have LSLSyntaxId capability, remaining with default keywords file!" + << "Region changed to '" << region->getName() + << " it does not have LSLSyntaxId capability, remaining with default keywords file!" << LL_ENDL; } else { mCurrentSyntaxId = LLUUID(); - mFilenameCurrent = mFilenameDefault; - mFilenameLocation = LL_PATH_APP_SETTINGS; + mFileNameCurrent = mFileNameDefault; + mFilePath = LL_PATH_APP_SETTINGS; LL_WARNS("LSLSyntax") - << "Region does not have LSLSyntaxId capability, using default keywords file!" + << "Region changed to '" << region->getName() + << " it does not have LSLSyntaxId capability, using default keywords file!" << LL_ENDL; changed = true; @@ -190,12 +192,13 @@ bool LLSyntaxIdLSL::checkSyntaxIdChange() //----------------------------------------------------------------------------- bool LLSyntaxIdLSL::fetchKeywordsFile() { + LLViewerRegion* region = gAgent.getRegion(); bool fetched = false; - std::string cap_url = mRegion->getCapability(mCapabilityName); -// mResponder->setFileSpec(mFilenameSpec); + + std::string cap_url = region->getCapability(mCapabilityName); if ( !cap_url.empty() ) { - LLHTTPClient::get(cap_url, new fetchKeywordsFileResponder(mFilenameSpec)); + LLHTTPClient::get(cap_url, new fetchKeywordsFileResponder(mFullFileSpec)); } return fetched; @@ -203,26 +206,34 @@ bool LLSyntaxIdLSL::fetchKeywordsFile() void LLSyntaxIdLSL::initialise() { - mRegion = gAgent.getRegion(); - if (checkSyntaxIdChange()) + if (checkSyntaxIdChanged()) { - mFilenameFull = gDirUtilp->getExpandedFilename( - mFilenameLocation, - mFilenameCurrent - ); + LL_WARNS("LSLSyntax") + << "Change to syntax, setting up new file." + << LL_ENDL; + + setFileNameNew(gDirUtilp->getExpandedFilename( + mFilePath, + mFileNameCurrent + )); if ( !mCurrentSyntaxId.isNull() ) { - bool success = true; - if (!gDirUtilp->fileExists(mFilenameSpec)) - { - //mResponder = new fetchKeywordsFileResponder(mFilenameSpec); + bool success = false; + if ( !gDirUtilp->fileExists(mFullFileSpec) ) + { // Does not exist, so fetch it from the capability success = fetchKeywordsFile(); } } // TODO add a signal here to tell the editor the hash has changed? } + else + { + LL_WARNS("LSLSyntax") + << "Apparently there is no change to Syntax!" + << LL_ENDL; - mRegion = NULL; + } + //LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLSyntaxIdLSL::checkSyntaxIdChange(), this)); } //----------------------------------------------------------------------------- diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index e32fcf209e..f7e3d6896e 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -12,9 +12,6 @@ #include "llviewerregion.h" -//class LLKeywords; - - /** * @file llsyntaxid.h * @brief The LLSyntaxIdLSL class @@ -22,45 +19,45 @@ class LLSyntaxIdLSL { public: - /** - * @brief LLSyntaxIdLSL constructor - */ LLSyntaxIdLSL(); - LLUUID getSyntaxId() const { return mCurrentSyntaxId; } + bool checkSyntaxIdChanged(); + std::string getFileNameCurrent() const { return mFileNameCurrent; } + ELLPath getFilePath() const { return mFilePath; } + LLUUID getSyntaxId() const { return mCurrentSyntaxId; } + + void initialise(); + + static void setKeywordsXml(const LLSD& content) { sKeywordsXml = content; } - bool checkSyntaxIdChange(); - std::string filenameCurrent() { return mFilenameCurrent; } - ELLPath filenamePath() { return mFilenameLocation; } - void initialise(); - static void setKeywordsXml(const LLSD& content) { LLSyntaxIdLSL::sKeywordsXml = content; } protected: - std::string buildFilename(LLUUID& SyntaxId); - bool fetchKeywordsFile(); - void openKeywordsFile(); - void setSyntaxId(LLUUID SyntaxId) { mCurrentSyntaxId = SyntaxId; } - void setFilenameCurrent(std::string& name) { mFilenameCurrent = name; } - void setFilenameDefault(std::string& name) { mFilenameDefault = name; } - void setSimulatorFeatureName(const std::string& name) { mSimulatorFeature = name; } + std::string buildFileName(LLUUID& SyntaxId); + bool fetchKeywordsFile(); + void openKeywordsFile(); + void setSyntaxId(LLUUID SyntaxId) { mCurrentSyntaxId = SyntaxId; } + void setFileNameCurrent(std::string& name) { mFileNameCurrent = name; } + void setFileNameDefault(std::string& name) { mFileNameDefault = name; } + void setFileNameNew(std::string& name) { mFileNameNew = name; } + void setSimulatorFeatureName(const std::string& name) { mSimulatorFeature = name; } -public: - static LLHTTPClient::ResponderPtr mResponder; + +//public: protected: -// LLKeywords& mKeywords; - LLViewerRegion* mRegion; + LLViewerRegion* region; + private: - std::string mCapabilityName; - LLUUID mCurrentSyntaxId; - std::string mFilenameCurrent; - std::string mFilenameDefault; - std::string mFilenameFull; - ELLPath mFilenameLocation; - std::string mFilenameSpec; - std::string mSimulatorFeature; - - static LLSD sKeywordsXml; + std::string mCapabilityName; + LLUUID mCurrentSyntaxId; + std::string mFileNameCurrent; + std::string mFileNameDefault; + std::string mFileNameNew; + ELLPath mFilePath; + std::string mFullFileSpec; + std::string mSimulatorFeature; + + static LLSD sKeywordsXml; }; -- cgit v1.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/llui/llkeywords.cpp | 12 +++++----- indra/llui/llkeywords.h | 20 ++++++++--------- indra/newview/llpreviewscript.cpp | 15 ++++++++----- indra/newview/llpreviewscript.h | 1 + indra/newview/llsyntaxid.cpp | 47 ++++++++++++++++++++++++++++++++------- indra/newview/llsyntaxid.h | 4 +++- 6 files changed, 69 insertions(+), 30 deletions(-) (limited to 'indra/newview/llpreviewscript.h') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 687c2fb31d..832264f074 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -34,7 +34,7 @@ #include "lltexteditor.h" #include "llstl.h" -inline BOOL LLKeywordToken::isHead(const llwchar* s) const +inline bool LLKeywordToken::isHead(const llwchar* s) const { // strncmp is much faster than string compare BOOL res = TRUE; @@ -51,7 +51,7 @@ inline BOOL LLKeywordToken::isHead(const llwchar* s) const return res; } -inline BOOL LLKeywordToken::isTail(const llwchar* s) const +inline bool LLKeywordToken::isTail(const llwchar* s) const { BOOL res = TRUE; const llwchar* t = mDelimiter.c_str(); @@ -198,7 +198,7 @@ LLColor4 LLKeywords::getColorGroup(const std::string key_in) return LLUIColorTable::instance().getColor(ColourGroup); } -BOOL LLKeywords::initialise(ELLPath path, const std::string filename) +bool LLKeywords::initialise(ELLPath path, const std::string filename) { mReady = false; setFilenameSyntax( gDirUtilp->getExpandedFilename(path, filename) ); @@ -214,7 +214,7 @@ BOOL LLKeywords::initialise(ELLPath path, const std::string filename) return mReady; } -BOOL LLKeywords::loadFromFile() +bool LLKeywords::loadFromFile() { processTokens(); return true; @@ -226,14 +226,14 @@ BOOL LLKeywords::loadFromFile() * contained data to the specified LLSD object. * @return Returns boolean true/false indicating success or failure. */ -BOOL LLKeywords::loadIntoLLSD(const std::string& filename, LLSD& data) +bool LLKeywords::loadIntoLLSD(const std::string& filename, LLSD& data) { mLoaded = false; llifstream file; file.open(filename); if(file.is_open()) { - mLoaded = (BOOL)LLSDSerialize::fromXML(data, file); + mLoaded = (bool)LLSDSerialize::fromXML(data, file); if (!mLoaded) { LL_WARNS("") << "Unable to deserialise file: " << filename << LL_ENDL; diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index 1bd23549d2..f98453405d 100755 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -83,8 +83,8 @@ public: S32 getLengthHead() const { return mToken.size(); } S32 getLengthTail() const { return mDelimiter.size(); } - BOOL isHead(const llwchar* s) const; - BOOL isTail(const llwchar* s) const; + bool isHead(const llwchar* s) const; + bool isTail(const llwchar* s) const; const LLWString& getToken() const { return mToken; } const LLColor4& getColor() const { return mColor; } TOKEN_TYPE getType() const { return mType; } @@ -111,13 +111,13 @@ public: void addColorGroup(const std::string key_in, const LLColor4 color); LLColor4 getColorGroup(const std::string key_in); - BOOL loadFromFile(); - BOOL loadFromFile(const std::string& filename); - BOOL isLoaded() const { return mLoaded; } + bool loadFromFile(); + bool loadFromFile(const std::string& filename); + bool isLoaded() const { return mLoaded; } void setFilenameSyntax(const std::string filename) { mFilenameSyntax = filename; } void findSegments(std::vector *seg_list, const LLWString& text, const LLColor4 &defaultColor, class LLTextEditor& editor ); - BOOL initialise(ELLPath path, const std::string filename); + bool initialise(ELLPath path, const std::string filename); std::string processColors(); std::string processColors(LLSD &data, const std::string strGroup); void processTokens(); @@ -176,10 +176,10 @@ protected: LLColor4 readColor(LLSD& sd); void insertSegment(std::vector& seg_list, LLTextSegmentPtr new_segment, S32 text_len, const LLColor4 &defaultColor, class LLTextEditor& editor); void insertSegments(const LLWString& wtext, std::vector& seg_list, LLKeywordToken* token, S32 text_len, S32 seg_start, S32 seg_end, const LLColor4 &defaultColor, LLTextEditor& editor); - BOOL loadIntoLLSD( const std::string& filename, LLSD& data ); + bool loadIntoLLSD( const std::string& filename, LLSD& data ); LLSD mColors; - BOOL mLoaded; + bool mLoaded; LLSD mSyntax; word_token_map_t mWordTokenMap; typedef std::deque token_list_t; @@ -194,8 +194,8 @@ protected: std::string getArguments(LLSD& args); private: - BOOL ready() { return mReady; } - BOOL mReady; + bool ready() { return mReady; } + bool mReady; std::string mFilenameSyntax; }; 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 diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 73ccaab0b8..149c27461e 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -78,6 +78,7 @@ public: ~LLScriptEdCore(); void initMenu(); + void initKeywords(); virtual void draw(); /*virtual*/ BOOL postBuild(); diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 0249607834..00e6086546 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -248,7 +248,7 @@ void LLSyntaxIdLSL::initialise() LL_WARNS("LSLSyntax") << "Filename is cached, no need to download!" << LL_ENDL; - openKeywordsFile(); + loadKeywordsFileIntoLLSD(); } } else @@ -256,27 +256,58 @@ void LLSyntaxIdLSL::initialise() LL_WARNS("LSLSyntax") << "ID is null so SyntaxID does not need to be processed!" << LL_ENDL; - openKeywordsFile(); + loadKeywordsFileIntoLLSD(); } - // TODO add a signal here to tell the editor the hash has changed? + mFileNameCurrent = mFileNameNew; + mSyntaxIdCurrent = mSyntaxIdNew; } else { LL_WARNS("LSLSyntax") << "No change to Syntax! Nothing to see here. Move along now!" << LL_ENDL; - } - //LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLSyntaxIdLSL::checkSyntaxIdChange(), this)); } //----------------------------------------------------------------------------- -// openKeywordsFile +// loadKeywordsFileIntoLLSD //----------------------------------------------------------------------------- -void LLSyntaxIdLSL::openKeywordsFile() +/** + * @brief Load xml serialised LLSD + * @desc Opens the specified filespec and attempts to deserialise the + * contained data to the specified LLSD object. + * @return Returns boolean true/false indicating success or failure. + */ +bool LLSyntaxIdLSL::loadKeywordsFileIntoLLSD() { LL_WARNS("LSLSyntax") << "Trying to open default or cached keyword file ;-)" << LL_ENDL; - // TODO Open the file and load LLSD into sKeywordsXml + + bool loaded = false; + LLSD content; + llifstream file; + file.open(mFullFileSpec); + if (file.is_open()) + { + loaded = (bool)LLSDSerialize::fromXML(content, file); + if (!loaded) + { + LL_WARNS("LSLSyntax") << "Unable to deserialise file: " << filename << LL_ENDL; + + // Is this the right thing to do, or should we leave the old content + // even if it isn't entirely accurate anymore? + sKeywordsXml = LLSD.emptyMap(); + } + else + { + sKeywordsXml = content; + LL_INFOS("LSLSyntax") << "Deserialised file: " << filename << LL_ENDL; + } + } + else + { + LL_WARNS("LSLSyntax") << "Unable to open file: " << filename << LL_ENDL; + } + return loaded; } diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index d9f2572863..50013a8380 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -39,6 +39,7 @@ public: bool checkSyntaxIdChanged(); std::string getFileNameCurrent() const { return mFileNameCurrent; } ELLPath getFilePath() const { return mFilePath; } + LLSD getKeywordsXML() const { return sKeywordsXml; } LLUUID getSyntaxId() const { return mSyntaxIdCurrent; } void initialise(); @@ -50,7 +51,8 @@ protected: std::string buildFileNameNew(); std::string buildFullFileSpec(); void fetchKeywordsFile(); - void openKeywordsFile(); + //void openKeywordsFile(); + bool loadKeywordsFileIntoLLSD(); void setSyntaxId(LLUUID SyntaxId) { mSyntaxIdCurrent = SyntaxId; } void setFileNameCurrent(std::string& name) { mFileNameCurrent = name; } void setFileNameDefault(std::string& name) { mFileNameDefault = name; } -- cgit v1.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/llui/llkeywords.cpp | 12 +++++----- indra/llui/llkeywords.h | 20 ++++++++--------- indra/newview/llpreviewscript.cpp | 15 +++++-------- indra/newview/llpreviewscript.h | 1 - indra/newview/llsyntaxid.cpp | 47 +++++++-------------------------------- indra/newview/llsyntaxid.h | 4 +--- 6 files changed, 30 insertions(+), 69 deletions(-) (limited to 'indra/newview/llpreviewscript.h') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 832264f074..687c2fb31d 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -34,7 +34,7 @@ #include "lltexteditor.h" #include "llstl.h" -inline bool LLKeywordToken::isHead(const llwchar* s) const +inline BOOL LLKeywordToken::isHead(const llwchar* s) const { // strncmp is much faster than string compare BOOL res = TRUE; @@ -51,7 +51,7 @@ inline bool LLKeywordToken::isHead(const llwchar* s) const return res; } -inline bool LLKeywordToken::isTail(const llwchar* s) const +inline BOOL LLKeywordToken::isTail(const llwchar* s) const { BOOL res = TRUE; const llwchar* t = mDelimiter.c_str(); @@ -198,7 +198,7 @@ LLColor4 LLKeywords::getColorGroup(const std::string key_in) return LLUIColorTable::instance().getColor(ColourGroup); } -bool LLKeywords::initialise(ELLPath path, const std::string filename) +BOOL LLKeywords::initialise(ELLPath path, const std::string filename) { mReady = false; setFilenameSyntax( gDirUtilp->getExpandedFilename(path, filename) ); @@ -214,7 +214,7 @@ bool LLKeywords::initialise(ELLPath path, const std::string filename) return mReady; } -bool LLKeywords::loadFromFile() +BOOL LLKeywords::loadFromFile() { processTokens(); return true; @@ -226,14 +226,14 @@ bool LLKeywords::loadFromFile() * contained data to the specified LLSD object. * @return Returns boolean true/false indicating success or failure. */ -bool LLKeywords::loadIntoLLSD(const std::string& filename, LLSD& data) +BOOL LLKeywords::loadIntoLLSD(const std::string& filename, LLSD& data) { mLoaded = false; llifstream file; file.open(filename); if(file.is_open()) { - mLoaded = (bool)LLSDSerialize::fromXML(data, file); + mLoaded = (BOOL)LLSDSerialize::fromXML(data, file); if (!mLoaded) { LL_WARNS("") << "Unable to deserialise file: " << filename << LL_ENDL; diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index f98453405d..1bd23549d2 100755 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -83,8 +83,8 @@ public: S32 getLengthHead() const { return mToken.size(); } S32 getLengthTail() const { return mDelimiter.size(); } - bool isHead(const llwchar* s) const; - bool isTail(const llwchar* s) const; + BOOL isHead(const llwchar* s) const; + BOOL isTail(const llwchar* s) const; const LLWString& getToken() const { return mToken; } const LLColor4& getColor() const { return mColor; } TOKEN_TYPE getType() const { return mType; } @@ -111,13 +111,13 @@ public: void addColorGroup(const std::string key_in, const LLColor4 color); LLColor4 getColorGroup(const std::string key_in); - bool loadFromFile(); - bool loadFromFile(const std::string& filename); - bool isLoaded() const { return mLoaded; } + BOOL loadFromFile(); + BOOL loadFromFile(const std::string& filename); + BOOL isLoaded() const { return mLoaded; } void setFilenameSyntax(const std::string filename) { mFilenameSyntax = filename; } void findSegments(std::vector *seg_list, const LLWString& text, const LLColor4 &defaultColor, class LLTextEditor& editor ); - bool initialise(ELLPath path, const std::string filename); + BOOL initialise(ELLPath path, const std::string filename); std::string processColors(); std::string processColors(LLSD &data, const std::string strGroup); void processTokens(); @@ -176,10 +176,10 @@ protected: LLColor4 readColor(LLSD& sd); void insertSegment(std::vector& seg_list, LLTextSegmentPtr new_segment, S32 text_len, const LLColor4 &defaultColor, class LLTextEditor& editor); void insertSegments(const LLWString& wtext, std::vector& seg_list, LLKeywordToken* token, S32 text_len, S32 seg_start, S32 seg_end, const LLColor4 &defaultColor, LLTextEditor& editor); - bool loadIntoLLSD( const std::string& filename, LLSD& data ); + BOOL loadIntoLLSD( const std::string& filename, LLSD& data ); LLSD mColors; - bool mLoaded; + BOOL mLoaded; LLSD mSyntax; word_token_map_t mWordTokenMap; typedef std::deque token_list_t; @@ -194,8 +194,8 @@ protected: std::string getArguments(LLSD& args); private: - bool ready() { return mReady; } - bool mReady; + BOOL ready() { return mReady; } + BOOL mReady; std::string mFilenameSyntax; }; 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 diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 149c27461e..73ccaab0b8 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -78,7 +78,6 @@ public: ~LLScriptEdCore(); void initMenu(); - void initKeywords(); virtual void draw(); /*virtual*/ BOOL postBuild(); diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 00e6086546..0249607834 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -248,7 +248,7 @@ void LLSyntaxIdLSL::initialise() LL_WARNS("LSLSyntax") << "Filename is cached, no need to download!" << LL_ENDL; - loadKeywordsFileIntoLLSD(); + openKeywordsFile(); } } else @@ -256,58 +256,27 @@ void LLSyntaxIdLSL::initialise() LL_WARNS("LSLSyntax") << "ID is null so SyntaxID does not need to be processed!" << LL_ENDL; - loadKeywordsFileIntoLLSD(); + openKeywordsFile(); } - mFileNameCurrent = mFileNameNew; - mSyntaxIdCurrent = mSyntaxIdNew; + // TODO add a signal here to tell the editor the hash has changed? } else { LL_WARNS("LSLSyntax") << "No change to Syntax! Nothing to see here. Move along now!" << LL_ENDL; + } + //LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLSyntaxIdLSL::checkSyntaxIdChange(), this)); } //----------------------------------------------------------------------------- -// loadKeywordsFileIntoLLSD +// openKeywordsFile //----------------------------------------------------------------------------- -/** - * @brief Load xml serialised LLSD - * @desc Opens the specified filespec and attempts to deserialise the - * contained data to the specified LLSD object. - * @return Returns boolean true/false indicating success or failure. - */ -bool LLSyntaxIdLSL::loadKeywordsFileIntoLLSD() +void LLSyntaxIdLSL::openKeywordsFile() { LL_WARNS("LSLSyntax") << "Trying to open default or cached keyword file ;-)" << LL_ENDL; - - bool loaded = false; - LLSD content; - llifstream file; - file.open(mFullFileSpec); - if (file.is_open()) - { - loaded = (bool)LLSDSerialize::fromXML(content, file); - if (!loaded) - { - LL_WARNS("LSLSyntax") << "Unable to deserialise file: " << filename << LL_ENDL; - - // Is this the right thing to do, or should we leave the old content - // even if it isn't entirely accurate anymore? - sKeywordsXml = LLSD.emptyMap(); - } - else - { - sKeywordsXml = content; - LL_INFOS("LSLSyntax") << "Deserialised file: " << filename << LL_ENDL; - } - } - else - { - LL_WARNS("LSLSyntax") << "Unable to open file: " << filename << LL_ENDL; - } - return loaded; + // TODO Open the file and load LLSD into sKeywordsXml } diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 50013a8380..d9f2572863 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -39,7 +39,6 @@ public: bool checkSyntaxIdChanged(); std::string getFileNameCurrent() const { return mFileNameCurrent; } ELLPath getFilePath() const { return mFilePath; } - LLSD getKeywordsXML() const { return sKeywordsXml; } LLUUID getSyntaxId() const { return mSyntaxIdCurrent; } void initialise(); @@ -51,8 +50,7 @@ protected: std::string buildFileNameNew(); std::string buildFullFileSpec(); void fetchKeywordsFile(); - //void openKeywordsFile(); - bool loadKeywordsFileIntoLLSD(); + void openKeywordsFile(); void setSyntaxId(LLUUID SyntaxId) { mSyntaxIdCurrent = SyntaxId; } void setFileNameCurrent(std::string& name) { mFileNameCurrent = name; } void setFileNameDefault(std::string& name) { mFileNameDefault = name; } -- cgit v1.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 +++++++++++++++++++++------------------ indra/newview/llpreviewscript.h | 1 + 2 files changed, 47 insertions(+), 41 deletions(-) (limited to 'indra/newview/llpreviewscript.h') 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() diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 73ccaab0b8..bc0256703e 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -78,6 +78,7 @@ public: ~LLScriptEdCore(); void initMenu(); + bool initKeywords(); virtual void draw(); /*virtual*/ BOOL postBuild(); -- cgit v1.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 +++++---------- indra/newview/llpreviewscript.h | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'indra/newview/llpreviewscript.h') 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() diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index bc0256703e..149c27461e 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -78,7 +78,7 @@ public: ~LLScriptEdCore(); void initMenu(); - bool initKeywords(); + void initKeywords(); virtual void draw(); /*virtual*/ BOOL postBuild(); -- cgit v1.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 +++++--- indra/newview/llpreviewscript.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'indra/newview/llpreviewscript.h') 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()); diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 149c27461e..2dd5a1b6a7 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -78,7 +78,7 @@ public: ~LLScriptEdCore(); void initMenu(); - void initKeywords(); + void onRegionChangeInitialiseKeywords(); virtual void draw(); /*virtual*/ BOOL postBuild(); -- cgit v1.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 ++++++++++++++++++++++++----------- indra/newview/llpreviewscript.h | 1 + 2 files changed, 25 insertions(+), 11 deletions(-) (limited to 'indra/newview/llpreviewscript.h') 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() diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 2dd5a1b6a7..67a4ca52fa 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -79,6 +79,7 @@ public: void initMenu(); void onRegionChangeInitialiseKeywords(); + void onFileFetchedInitialiseKeywords(); virtual void draw(); /*virtual*/ BOOL postBuild(); -- cgit v1.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/llui/llkeywords.cpp | 2 +- indra/newview/llpreviewscript.cpp | 72 ++++++++++++++++++++++++--------------- indra/newview/llpreviewscript.h | 18 +++++++--- 3 files changed, 60 insertions(+), 32 deletions(-) (limited to 'indra/newview/llpreviewscript.h') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 6a349f3916..a251c2e4f5 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -209,7 +209,7 @@ LLColor4 LLKeywords::getColorGroup(const std::string key_in) { ColourGroup = "SyntaxLslConstantVector"; } - else if (key_in == "controls") + else if (key_in == "misc-flow-label") { ColourGroup = "SyntaxLslControlFlow"; } 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; } diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 67a4ca52fa..0841c8188b 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -77,9 +77,12 @@ protected: public: ~LLScriptEdCore(); + void clearHighlights(); + void initialiseKeywords(); void initMenu(); - void onRegionChangeInitialiseKeywords(); - void onFileFetchedInitialiseKeywords(); + void processKeywords(); + void processLoaded(); + void updateKeywords(); virtual void draw(); /*virtual*/ BOOL postBuild(); @@ -133,6 +136,8 @@ protected: void addHelpItemToHistory(const std::string& help_string); static void onErrorList(LLUICtrl*, void* user_data); + bool mLive; + private: std::string mSampleText; LLTextEditor* mEditor; @@ -155,6 +160,10 @@ private: LLSyntaxIdLSL mSyntaxIdLSL; LLScriptEdContainer* mContainer; // parent view + +public: + boost::signals2::connection mRegionChangedCallback; + }; class LLScriptEdContainer : public LLPreview @@ -163,6 +172,7 @@ class LLScriptEdContainer : public LLPreview public: LLScriptEdContainer(const LLSD& key); + LLScriptEdContainer(const LLSD& key, const bool live); protected: std::string getTmpFileName(); @@ -172,7 +182,7 @@ protected: LLScriptEdCore* mScriptEd; }; -// Used to view and edit a LSL from your inventory. +// Used to view and edit an LSL script from your inventory. class LLPreviewLSL : public LLScriptEdContainer { public: @@ -217,7 +227,7 @@ protected: }; -// Used to view and edit an LSL that is attached to an object. +// Used to view and edit an LSL script that is attached to an object. class LLLiveLSLEditor : public LLScriptEdContainer { friend class LLLiveLSLFile; -- cgit v1.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 +++------ indra/newview/llpreviewscript.h | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'indra/newview/llpreviewscript.h') 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( diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 0841c8188b..dc4f828cf1 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -162,6 +162,7 @@ private: LLScriptEdContainer* mContainer; // parent view public: + boost::signals2::connection mFileFetchedCallback; boost::signals2::connection mRegionChangedCallback; }; -- cgit v1.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/llui/lltextbase.cpp | 1 - indra/llui/lltexteditor.cpp | 8 ---- indra/llui/lltexteditor.h | 1 - indra/newview/CMakeLists.txt | 2 + indra/newview/llfloatergotoline.cpp | 2 +- indra/newview/llpreviewscript.cpp | 4 +- indra/newview/llpreviewscript.h | 4 +- indra/newview/llscripteditor.cpp | 51 ++++++++++++++++++++++ indra/newview/llscripteditor.h | 51 ++++++++++++++++++++++ .../skins/default/xui/en/panel_script_ed.xml | 4 +- .../newview/skins/default/xui/en/script_editor.xml | 5 +++ 11 files changed, 116 insertions(+), 17 deletions(-) create mode 100644 indra/newview/llscripteditor.cpp create mode 100644 indra/newview/llscripteditor.h create mode 100644 indra/newview/skins/default/xui/en/script_editor.xml (limited to 'indra/newview/llpreviewscript.h') diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index ee16d3de7c..c4664d6fe0 100755 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -923,7 +923,6 @@ void LLTextBase::createDefaultSegment() // ensures that there is always at least one segment if (mSegments.empty()) { - LLStyleConstSP sp(new LLStyle(getStyleParams())); LLTextSegmentPtr default_segment = new LLNormalTextSegment( sp, 0, getLength() + 1, *this); mSegments.insert(default_segment); diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index df8d37e3aa..8120f3f9a1 100755 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -2529,14 +2529,6 @@ void LLTextEditor::loadKeywords() } } -void LLTextEditor::clearSegments() -{ - if (!mSegments.empty()) - { - mSegments.clear(); - } -} - void LLTextEditor::updateSegments() { if (mReflowIndex < S32_MAX && mKeywords.isLoaded() && mParseOnTheFly) diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index 698153587f..09c56fca5a 100755 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -208,7 +208,6 @@ public: const LLTextSegmentPtr getPreviousSegment() const; void getSelectedSegments(segment_vec_t& segments) const; - void clearSegments(); void setShowContextMenu(bool show) { mShowContextMenu = show; } bool getShowContextMenu() const { return mShowContextMenu; } diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 34eab9fa33..f4c1d0b151 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -494,6 +494,7 @@ set(viewer_SOURCE_FILES llsaveoutfitcombobtn.cpp llsceneview.cpp llscreenchannel.cpp + llscripteditor.cpp llscriptfloater.cpp llscrollingpanelparam.cpp llscrollingpanelparambase.cpp @@ -1074,6 +1075,7 @@ set(viewer_HEADER_FILES llsaveoutfitcombobtn.h llsceneview.h llscreenchannel.h + llscripteditor.h llscriptfloater.h llscrollingpanelparam.h llscrollingpanelparambase.h diff --git a/indra/newview/llfloatergotoline.cpp b/indra/newview/llfloatergotoline.cpp index d66e418926..3b34f03532 100644 --- a/indra/newview/llfloatergotoline.cpp +++ b/indra/newview/llfloatergotoline.cpp @@ -30,7 +30,7 @@ #include "llpreviewscript.h" #include "llfloaterreg.h" #include "lllineeditor.h" -#include "llviewertexteditor.h" +#include "llscripteditor.h" #include "llviewerwindow.h" LLFloaterGotoLine* LLFloaterGotoLine::sInstance = NULL; 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)); diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index dc4f828cf1..913303d57d 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -39,7 +39,7 @@ class LLLiveLSLFile; class LLMessageSystem; -class LLTextEditor; +class LLScriptEditor; class LLButton; class LLCheckBoxCtrl; class LLScrollListCtrl; @@ -140,7 +140,7 @@ protected: private: std::string mSampleText; - LLTextEditor* mEditor; + LLScriptEditor* mEditor; void (*mLoadCallback)(void* userdata); void (*mSaveCallback)(void* userdata, BOOL close_after_save); void (*mSearchReplaceCallback) (void* userdata); diff --git a/indra/newview/llscripteditor.cpp b/indra/newview/llscripteditor.cpp new file mode 100644 index 0000000000..7067f49fba --- /dev/null +++ b/indra/newview/llscripteditor.cpp @@ -0,0 +1,51 @@ +/** + * @file llecripteditor.cpp + * @author Cinder Roxley + * @brief Text editor widget used for viewing and editing scripts + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" +#include "llscripteditor.h" + +static LLDefaultChildRegistry::Register r("script_editor"); + +LLScriptEditor::LLScriptEditor::Params::Params() +{ + +} + + +LLScriptEditor::LLScriptEditor(const Params& p) +: LLTextEditor(p) +{ + +} + +void LLScriptEditor::clearSegments() +{ + if (!mSegments.empty()) + { + mSegments.clear(); + } +} diff --git a/indra/newview/llscripteditor.h b/indra/newview/llscripteditor.h new file mode 100644 index 0000000000..1e05e337c5 --- /dev/null +++ b/indra/newview/llscripteditor.h @@ -0,0 +1,51 @@ +/** + * @file llecripteditor.h + * @author Cinder Roxley + * @brief Text editor widget used for viewing and editing scripts + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_SCRIPTEDITOR_H +#define LL_SCRIPTEDITOR_H + +#include "lltexteditor.h" + +class LLScriptEditor : public LLTextEditor +{ + friend class LLUICtrlFactory; +public: + + struct Params : public LLInitParam::Block + { + Params(); + }; + + virtual ~LLScriptEditor() {}; + void clearSegments(); + +protected: + LLScriptEditor(const Params& p); + +}; + +#endif // LL_SCRIPTEDITOR_H 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 d1b35dce9d..3e88e2dc04 100755 --- a/indra/newview/skins/default/xui/en/panel_script_ed.xml +++ b/indra/newview/skins/default/xui/en/panel_script_ed.xml @@ -148,7 +148,7 @@ name="Keyword Help..." /> - Loading... - + + + -- cgit v1.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 ++------- indra/newview/llpreviewscript.h | 1 - 2 files changed, 2 insertions(+), 8 deletions(-) (limited to 'indra/newview/llpreviewscript.h') 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()) { diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 913303d57d..3ac48ae9c4 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -77,7 +77,6 @@ protected: public: ~LLScriptEdCore(); - void clearHighlights(); void initialiseKeywords(); void initMenu(); void processKeywords(); -- cgit v1.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/llui/llkeywords.cpp | 130 ++++++++++----------- indra/llui/llkeywords.h | 6 +- .../newview/app_settings/keywords_lsl_default.xml | 20 ++-- indra/newview/llpreviewscript.cpp | 79 ++++++------- indra/newview/llpreviewscript.h | 1 - indra/newview/llsyntaxid.cpp | 17 +-- indra/newview/llsyntaxid.h | 8 +- 7 files changed, 125 insertions(+), 136 deletions(-) (limited to 'indra/newview/llpreviewscript.h') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 07c84e57c0..bae604e270 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -82,7 +82,7 @@ LLKeywords::~LLKeywords() mDelimiterTokenList.clear(); } -void LLKeywords::addColorGroup(const std::string key_in, const LLColor4 color) +void LLKeywords::addColorGroup(const std::string& key_in, const LLColor4& color) { WStringMapIndex key ( utf8str_to_wstring(key_in) ); mColorGroupMap[key] = color; @@ -176,79 +176,79 @@ std::string LLKeywords::getAttribute(const std::string& key) return (it != mAttributes.end()) ? it->second : ""; } -LLColor4 LLKeywords::getColorGroup(const std::string key_in) +LLColor4 LLKeywords::getColorGroup(const std::string& key_in) { - std::string ColourGroup = "Black"; + std::string color_group = "Black"; if (key_in == "constants-float") { - ColourGroup = "SyntaxLslConstantFloat"; + color_group = "SyntaxLslConstantFloat"; } else if (key_in == "constants-integer") { - ColourGroup = "SyntaxLslConstantInteger"; + color_group = "SyntaxLslConstantInteger"; } else if (key_in == "constants-key") { - ColourGroup = "SyntaxLslConstantKey"; + color_group = "SyntaxLslConstantKey"; } else if (key_in == "constants-rotation") { - ColourGroup = "SyntaxLslConstantRotation"; + color_group = "SyntaxLslConstantRotation"; } else if (key_in == "constants-string") { - ColourGroup = "SyntaxLslConstantString"; + color_group = "SyntaxLslConstantString"; } else if (key_in == "constants-vector") { - ColourGroup = "SyntaxLslConstantVector"; + color_group = "SyntaxLslConstantVector"; } else if (key_in == "misc-flow-label") { - ColourGroup = "SyntaxLslControlFlow"; + color_group = "SyntaxLslControlFlow"; } else if (key_in =="deprecated") { - ColourGroup = "SyntaxLslDeprecated"; + color_group = "SyntaxLslDeprecated"; } else if (key_in == "events") { - ColourGroup = "SyntaxLslEvent"; + color_group = "SyntaxLslEvent"; } else if (key_in == "functions") { - ColourGroup = "SyntaxLslFunction"; + color_group = "SyntaxLslFunction"; } else if (key_in =="god-mode") { - ColourGroup = "SyntaxLslGodMode"; + color_group = "SyntaxLslGodMode"; } else if (key_in == "types") { - ColourGroup = "SyntaxLslDataType"; + color_group = "SyntaxLslDataType"; } else if (key_in == "sections") { - ColourGroup = "SyntaxLslSection"; + color_group = "SyntaxLslSection"; } else if (key_in == "misc-double_quotation_marks") { - ColourGroup = "SyntaxLslStringLiteral"; + color_group = "SyntaxLslStringLiteral"; } else if (key_in == "misc-comments_1_sided") { - ColourGroup = "SyntaxLslComment1Sided"; + color_group = "SyntaxLslComment1Sided"; } else if (key_in == "misc-comments_2_sided") { - ColourGroup = "SyntaxLslComment2Sided"; + color_group = "SyntaxLslComment2Sided"; } else { LL_WARNS("SyntaxLSL") << "Color key '" << key_in << "' not recognized!" << LL_ENDL; } - return LLUIColorTable::instance().getColor(ColourGroup); + return LLUIColorTable::instance().getColor(color_group); } void LLKeywords::initialise(LLSD SyntaxXML) @@ -271,107 +271,107 @@ void LLKeywords::processTokens() addToken(LLKeywordToken::TT_TWO_SIDED_DELIMITER, "/*", getColorGroup("misc-comments_2_sided"), "Comment (multi-line)\nNon-functional commentary or disabled code", "*/" ); addToken(LLKeywordToken::TT_DOUBLE_QUOTATION_MARKS, "\"", getColorGroup("misc-double_quotation_marks"), "String literal", "\"" ); - LLSD::map_iterator outerIt = mSyntax.beginMap(); - for ( ; outerIt != mSyntax.endMap(); ++outerIt) + LLSD::map_iterator itr = mSyntax.beginMap(); + for ( ; itr != mSyntax.endMap(); ++itr) { - if (outerIt->first == "llsd-lsl-syntax-version") + if (itr->first == "llsd-lsl-syntax-version") { // Skip over version key. } else { - if (outerIt->second.isMap()) + if (itr->second.isMap()) { - processTokensGroup(outerIt->second, outerIt->first); + processTokensGroup(itr->second, itr->first); } else { - LL_WARNS("LSL-Tokens-Processing") << "Map for " + outerIt->first + " entries is missing! Ignoring." << LL_ENDL; + LL_WARNS("LSL-Tokens-Processing") << "Map for " + itr->first + " entries is missing! Ignoring." << LL_ENDL; } } } LL_INFOS("SyntaxLSL") << "Finished processing tokens." << LL_ENDL; } -void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) +void LLKeywords::processTokensGroup(const LLSD& tokens, const std::string& group) { - LLColor4 Color; - LLColor4 ColorGroup; - LLColor4 ColorDeprecated = getColorGroup("deprecated"); - LLColor4 ColorGM = getColorGroup("god-mode"); + LLColor4 color; + LLColor4 color_group; + LLColor4 color_deprecated = getColorGroup("deprecated"); + LLColor4 color_god_mode = getColorGroup("god-mode"); LLKeywordToken::ETokenType token_type = LLKeywordToken::TT_UNKNOWN; // If a new token type is added here, it must also be added to the 'addToken' method - if (Group == "constants") + if (group == "constants") { token_type = LLKeywordToken::TT_CONSTANT; } - else if (Group == "controls") + else if (group == "controls") { token_type = LLKeywordToken::TT_CONTROL; } - else if (Group == "events") + else if (group == "events") { token_type = LLKeywordToken::TT_EVENT; } - else if (Group == "functions") + else if (group == "functions") { token_type = LLKeywordToken::TT_FUNCTION; } - else if (Group == "label") + else if (group == "label") { token_type = LLKeywordToken::TT_LABEL; } - else if (Group == "types") + else if (group == "types") { token_type = LLKeywordToken::TT_TYPE; } - ColorGroup = getColorGroup(Group); - LL_INFOS("Tokens") << "Group: '" << Group << "', using colour: '" << ColorGroup << "'" << LL_ENDL; + color_group = getColorGroup(group); + LL_INFOS("Tokens") << "Group: '" << group << "', using color: '" << color_group << "'" << LL_ENDL; - if (Tokens.isMap()) + if (tokens.isMap()) { - LLSD::map_iterator outerIt = Tokens.beginMap(); - for ( ; outerIt != Tokens.endMap(); ++outerIt) + LLSD::map_const_iterator outer_itr = tokens.beginMap(); + for ( ; outer_itr != tokens.endMap(); ++outer_itr) { - if (outerIt->second.isMap()) + if (outer_itr->second.isMap()) { mAttributes.clear(); - LLSD arguments = LLSD (); - LLSD::map_iterator innerIt = outerIt->second.beginMap(); - for ( ; innerIt != outerIt->second.endMap(); ++innerIt) + LLSD arguments = LLSD(); + LLSD::map_const_iterator inner_itr = outer_itr->second.beginMap(); + for ( ; inner_itr != outer_itr->second.endMap(); ++inner_itr) { - if (innerIt->first == "arguments") + if (inner_itr->first == "arguments") { - if (innerIt->second.isArray()) + if (inner_itr->second.isArray()) { - arguments = innerIt->second; + arguments = inner_itr->second; } } - else if (!innerIt->second.isMap() && !innerIt->second.isArray()) + else if (!inner_itr->second.isMap() && !inner_itr->second.isArray()) { - mAttributes[innerIt->first] = innerIt->second.asString(); + mAttributes[inner_itr->first] = inner_itr->second.asString(); } else { - LL_WARNS("SyntaxLSL") << "Not a valid attribute: " << innerIt->first << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Not a valid attribute: " << inner_itr->first << LL_ENDL; } } std::string tooltip = ""; if (token_type == LLKeywordToken::TT_CONSTANT) { - ColorGroup = getColorGroup(Group + "-" + getAttribute("type")); + color_group = getColorGroup(group + "-" + getAttribute("type")); tooltip = "Type: " + getAttribute("type") + ", Value: " + getAttribute("value"); } else if (token_type == LLKeywordToken::TT_EVENT) { - tooltip = outerIt->first + "(" + getArguments(arguments) + ")"; + tooltip = outer_itr->first + "(" + getArguments(arguments) + ")"; } else if (token_type == LLKeywordToken::TT_FUNCTION) { - tooltip = getAttribute("return") + " " + outerIt->first + "(" + getArguments(arguments) + ");"; + tooltip = getAttribute("return") + " " + outer_itr->first + "(" + getArguments(arguments) + ");"; tooltip += "\nEnergy: "; tooltip += getAttribute("energy") == "" ? "0.0" : getAttribute("energy"); if (getAttribute("sleep") != "") @@ -389,28 +389,28 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) tooltip += getAttribute("tooltip"); } - Color = getAttribute("deprecated") == "true" ? ColorDeprecated : ColorGroup; + color = getAttribute("deprecated") == "true" ? color_deprecated : color_group; if (getAttribute("god-mode") == "true") { - Color = ColorGM; + color = color_god_mode; } - addToken(token_type, outerIt->first, Color, tooltip); + addToken(token_type, outer_itr->first, color, tooltip); } } } - else if (Tokens.isArray()) // Currently nothing should need this, but it's here for completeness + else if (tokens.isArray()) // Currently nothing should need this, but it's here for completeness { - LL_INFOS("SyntaxLSL") << "Curious, shouldn't be an array here; adding all using color " << Color << LL_ENDL; - for (int count = 0; count < Tokens.size(); ++count) + LL_INFOS("SyntaxLSL") << "Curious, shouldn't be an array here; adding all using color " << color << LL_ENDL; + for (int count = 0; count < tokens.size(); ++count) { - addToken(token_type, Tokens[count], Color, ""); + addToken(token_type, tokens[count], color, ""); } } else { - LL_WARNS("Tokens") << "Invalid map/array passed: '" << Tokens << "'" << LL_ENDL; + LL_WARNS("Tokens") << "Invalid map/array passed: '" << tokens << "'" << LL_ENDL; } } @@ -511,11 +511,11 @@ LLColor4 LLKeywords::readColor(LLSD& sd) { if (sd.isArray()) { - return LLColor4 (sd, 1.f); + return LLColor4(sd, 1.f); } else if (sd.isMap()) { - return LLColor4 ( sd.get("x").asReal(), sd.get("y").asReal(), sd.get("z").asReal(), 1.f ); + return LLColor4( sd.get("x").asReal(), sd.get("y").asReal(), sd.get("z").asReal(), 1.f ); } else { diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index 69bc8919db..b17e9dd942 100755 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -109,9 +109,9 @@ public: LLKeywords(); ~LLKeywords(); - void addColorGroup(const std::string key_in, const LLColor4 color); + void addColorGroup(const std::string& key_in, const LLColor4& color); void clearLoaded() { mLoaded = false; } - LLColor4 getColorGroup(const std::string key_in); + LLColor4 getColorGroup(const std::string& key_in); bool isLoaded() const { return mLoaded; } void findSegments(std::vector *seg_list, const LLWString& text, const LLColor4 &defaultColor, class LLTextEditor& editor ); @@ -167,7 +167,7 @@ public: #endif protected: - void processTokensGroup(LLSD& Tokens, const std::string Group); + void processTokensGroup(const LLSD& Tokens, const std::string& Group); LLColor4 readColor(const std::string& s); LLColor4 readColor(LLSD& sd); void insertSegment(std::vector& seg_list, LLTextSegmentPtr new_segment, S32 text_len, const LLColor4 &defaultColor, class LLTextEditor& editor); diff --git a/indra/newview/app_settings/keywords_lsl_default.xml b/indra/newview/app_settings/keywords_lsl_default.xml index 83801a7e1e..53a89f0f09 100755 --- a/indra/newview/app_settings/keywords_lsl_default.xml +++ b/indra/newview/app_settings/keywords_lsl_default.xml @@ -89,7 +89,7 @@ vector tooltip - A vector is a data type that contains a set of three float values.\nVectors are used to represent colours (RGB), positions, and directions/velocities. + A vector is a data type that contains a set of three float values.\nVectors are used to represent colors (RGB), positions, and directions/velocities. constants @@ -852,7 +852,7 @@ value 0x2 tooltip - The object colour has changed. + The object color has changed. CHANGED_INVENTORY @@ -4372,7 +4372,7 @@ value 3 tooltip - A vector <r, g, b> which determines the ending colour of the object. + A vector <r, g, b> which determines the ending color of the object. PSYS_PART_END_GLOW @@ -4426,7 +4426,7 @@ value 0x1 tooltip - Interpolate both the colour and alpha from the start value to the end value. + Interpolate both the color and alpha from the start value to the end value. PSYS_PART_INTERP_SCALE_MASK @@ -4471,7 +4471,7 @@ value 1 tooltip - A vector <r.r, g.g, b.b> which determines the starting colour of the object. + A vector <r.r, g.g, b.b> which determines the starting color of the object. PSYS_PART_START_GLOW @@ -9032,7 +9032,7 @@ tooltip - Returns the color on Face.\nReturns the colour of Face as a vector of red, green, and blue values between 0 and 1. If face is ALL_SIDES the colour returned is the mean average of each channel. + Returns the color on Face.\nReturns the color of Face as a vector of red, green, and blue values between 0 and 1. If face is ALL_SIDES the color returned is the mean average of each channel. llGetCreator @@ -15304,7 +15304,7 @@ arguments - Colour + Color type vector @@ -15323,7 +15323,7 @@ tooltip - Sets the color, for the face.\nSets the colour of the side specified. If Face is ALL_SIDES, sets the colour on all faces. + Sets the color, for the face.\nSets the color of the side specified. If Face is ALL_SIDES, sets the color on all faces. llSetContentType @@ -15671,7 +15671,7 @@ - Colour + Color type vector @@ -15690,7 +15690,7 @@ tooltip - If a task exists in the link chain at LinkNumber, set the Face to color.\nSets the colour of the linked child's side, specified by LinkNumber. + If a task exists in the link chain at LinkNumber, set the Face to color.\nSets the color of the linked child's side, specified by LinkNumber. llSetLinkMedia 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); + } } } diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 3ac48ae9c4..966c149d3d 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -156,7 +156,6 @@ private: BOOL mEnableSave; BOOL mHasScriptData; LLLiveLSLFile* mLiveFile; - LLSyntaxIdLSL mSyntaxIdLSL; LLScriptEdContainer* mContainer; // parent view diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 14265fd3af..3f726fa8b5 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -127,13 +127,13 @@ LLSyntaxIdLSL::file_fetched_signal_t LLSyntaxIdLSL::sFileFetchedSignal; /** * @brief LLSyntaxIdLSL constructor */ -LLSyntaxIdLSL::LLSyntaxIdLSL(std::string filenameDefault, std::string simFeatureName, std::string capabilityName) : - mFilePath(LL_PATH_APP_SETTINGS) +LLSyntaxIdLSL::LLSyntaxIdLSL(const std::string& filename, const std::string& sim_feature, const std::string& capability) +: mFilePath(LL_PATH_APP_SETTINGS) { - mCapabilityName = capabilityName; - mFileNameCurrent = filenameDefault; - mFileNameDefault = filenameDefault; - mSimulatorFeature = simFeatureName; + mCapabilityName = capability; + mFileNameCurrent = filename; + mFileNameDefault = filename; + mSimulatorFeature = sim_feature; mSyntaxIdCurrent = LLUUID(); } @@ -321,6 +321,9 @@ void LLSyntaxIdLSL::initialise() //----------------------------------------------------------------------------- // isSupportedVersion //----------------------------------------------------------------------------- +const U32 LLSD_SYNTAX_LSL_VERSION_EXPECTED = 2; +const std::string LLSD_SYNTAX_LSL_VERSION_KEY("llsd-lsl-syntax-version"); + bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content) { bool isValid = false; @@ -328,8 +331,6 @@ bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content) * If the schema used to store LSL keywords and hints changes, this value is incremented * Note that it should _not_ be changed if the keywords and hints _content_ changes. */ - const U32 LLSD_SYNTAX_LSL_VERSION_EXPECTED = 2; - const std::string LLSD_SYNTAX_LSL_VERSION_KEY("llsd-lsl-syntax-version"); if (content.has(LLSD_SYNTAX_LSL_VERSION_KEY)) { diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 1f7e893b38..75cfc45380 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -75,7 +75,7 @@ private: public: LLSyntaxIdLSL(); - LLSyntaxIdLSL(std::string filenameDefault, std::string simFeatureName, std::string capabilityName); + LLSyntaxIdLSL(const std::string& filename, const std::string& sim_feature, const std::string& capability); bool checkSyntaxIdChanged(); bool fetching(); @@ -104,9 +104,9 @@ protected: void loadDefaultKeywordsIntoLLSD(); void loadKeywordsIntoLLSD(); void setSyntaxId(LLUUID SyntaxId) { mSyntaxIdCurrent = SyntaxId; } - void setFileNameCurrent(std::string& name) { mFileNameCurrent = name; } - void setFileNameDefault(std::string& name) { mFileNameDefault = name; } - void setFileNameNew(std::string name) { mFileNameNew = name; } + void setFileNameCurrent(const std::string& name) { mFileNameCurrent = name; } + void setFileNameDefault(const std::string& name) { mFileNameDefault = name; } + void setFileNameNew(const std::string name) { mFileNameNew = name; } }; -- cgit v1.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/llui/llkeywords.cpp | 2 +- indra/llui/llkeywords.h | 2 +- .../newview/app_settings/keywords_lsl_default.xml | 2 +- indra/newview/llpreviewscript.cpp | 4 +-- indra/newview/llpreviewscript.h | 2 +- indra/newview/llscripteditor.cpp | 2 +- indra/newview/llsyntaxid.cpp | 38 ++++++++-------------- indra/newview/llsyntaxid.h | 24 ++++---------- 8 files changed, 27 insertions(+), 49 deletions(-) (limited to 'indra/newview/llpreviewscript.h') diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index bae604e270..346b9a83bd 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -251,7 +251,7 @@ LLColor4 LLKeywords::getColorGroup(const std::string& key_in) return LLUIColorTable::instance().getColor(color_group); } -void LLKeywords::initialise(LLSD SyntaxXML) +void LLKeywords::initialize(LLSD SyntaxXML) { mSyntax = SyntaxXML; mLoaded = true; diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index b17e9dd942..eecb327fee 100755 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -115,7 +115,7 @@ public: bool isLoaded() const { return mLoaded; } void findSegments(std::vector *seg_list, const LLWString& text, const LLColor4 &defaultColor, class LLTextEditor& editor ); - void initialise(LLSD SyntaxXML); + void initialize(LLSD SyntaxXML); void processTokens(); // Add the token as described diff --git a/indra/newview/app_settings/keywords_lsl_default.xml b/indra/newview/app_settings/keywords_lsl_default.xml index 53a89f0f09..02823136ee 100755 --- a/indra/newview/app_settings/keywords_lsl_default.xml +++ b/indra/newview/app_settings/keywords_lsl_default.xml @@ -21,7 +21,7 @@ for tooltip - for loop\nfor (<initialiser>; <condition>; <post-iteration-statement>)\n{ ...\n} + for loop\nfor (<initializer>; <condition>; <post-iteration-statement>)\n{ ...\n} if 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(); diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 966c149d3d..69a72325fc 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -77,7 +77,7 @@ protected: public: ~LLScriptEdCore(); - void initialiseKeywords(); + void initializeKeywords(); void initMenu(); void processKeywords(); void processLoaded(); diff --git a/indra/newview/llscripteditor.cpp b/indra/newview/llscripteditor.cpp index 5d87f7ba0c..869368e72c 100644 --- a/indra/newview/llscripteditor.cpp +++ b/indra/newview/llscripteditor.cpp @@ -46,7 +46,7 @@ LLScriptEditor::LLScriptEditor(const Params& p) void LLScriptEditor::initKeywords() { - mKeywords.initialise(LLSyntaxIdLSL::getInstance()->getKeywordsXML()); + mKeywords.initialize(LLSyntaxIdLSL::getInstance()->getKeywordsXML()); } static LLFastTimer::DeclareTimer FTM_SYNTAX_HIGHLIGHTING("Syntax Highlighting"); diff --git a/indra/newview/llsyntaxid.cpp b/indra/newview/llsyntaxid.cpp index 3f726fa8b5..3582ac024d 100644 --- a/indra/newview/llsyntaxid.cpp +++ b/indra/newview/llsyntaxid.cpp @@ -70,7 +70,7 @@ void fetchKeywordsFileResponder::result(const LLSD& content_ref) << "Supported verson of syntax file." << LL_ENDL; LLSyntaxIdLSL::setKeywordsXml(content_ref); - LLSyntaxIdLSL::sInitialised = true; + LLSyntaxIdLSL::sInitialized = true; LLSyntaxIdLSL::sLoaded = true; LLSyntaxIdLSL::sLoadFailed = false; @@ -117,12 +117,12 @@ const std::string LLSyntaxIdLSL::CAPABILITY_NAME = "LSLSyntax"; const std::string LLSyntaxIdLSL::FILENAME_DEFAULT = "keywords_lsl_default.xml"; const std::string LLSyntaxIdLSL::SIMULATOR_FEATURE = "LSLSyntaxId"; -bool LLSyntaxIdLSL::sInitialised; +bool LLSyntaxIdLSL::sInitialized; LLSD LLSyntaxIdLSL::sKeywordsXml; bool LLSyntaxIdLSL::sLoaded; bool LLSyntaxIdLSL::sLoadFailed; bool LLSyntaxIdLSL::sVersionChanged; -LLSyntaxIdLSL::file_fetched_signal_t LLSyntaxIdLSL::sFileFetchedSignal; +LLSyntaxIdLSL::file_fetched_signal_t LLSyntaxIdLSL::sFileFetchedSignal; /** * @brief LLSyntaxIdLSL constructor @@ -207,7 +207,7 @@ bool LLSyntaxIdLSL::checkSyntaxIdChanged() } else { - if ( mSyntaxIdCurrent.isNull() && isInitialised()) + if ( mSyntaxIdCurrent.isNull() && isInitialized()) { LL_INFOS("SyntaxLSL") << "It does not have LSLSyntaxId capability, remaining with default keywords file!" @@ -255,9 +255,9 @@ void LLSyntaxIdLSL::fetchKeywordsFile() //----------------------------------------------------------------------------- -// initialise +// initialize //----------------------------------------------------------------------------- -void LLSyntaxIdLSL::initialise() +void LLSyntaxIdLSL::initialize() { mFileNameNew = mFileNameCurrent; mSyntaxIdNew = mSyntaxIdCurrent; @@ -309,7 +309,7 @@ void LLSyntaxIdLSL::initialise() loadDefaultKeywordsIntoLLSD(); } } - else if (!isInitialised()) + else if (!isInitialized()) { loadDefaultKeywordsIntoLLSD(); } @@ -355,8 +355,7 @@ bool LLSyntaxIdLSL::isSupportedVersion(const LLSD& content) //----------------------------------------------------------------------------- void LLSyntaxIdLSL::loadDefaultKeywordsIntoLLSD() { - LL_INFOS("SyntaxLSL") - << "LSLSyntaxId is null so we will use the default file!" << LL_ENDL; + LL_INFOS("SyntaxLSL") << "LSLSyntaxId is null so we will use the default file!" << LL_ENDL; mSyntaxIdNew = LLUUID(); buildFullFileSpec(); loadKeywordsIntoLLSD(); @@ -373,9 +372,7 @@ void LLSyntaxIdLSL::loadDefaultKeywordsIntoLLSD() */ void LLSyntaxIdLSL::loadKeywordsIntoLLSD() { - LL_INFOS("SyntaxLSL") - << "Trying to open cached or default keyword file ;-)" - << LL_ENDL; + LL_INFOS("SyntaxLSL") << "Trying to open cached or default keyword file" << LL_ENDL; // Is this the right thing to do, or should we leave the old content // even if it isn't entirely accurate anymore? @@ -389,9 +386,7 @@ void LLSyntaxIdLSL::loadKeywordsIntoLLSD() sLoaded = (bool)LLSDSerialize::fromXML(content, file); if (!sLoaded) { - LL_WARNS("SyntaxLSL") - << "Unable to deserialise file: " - << mFullFileSpec << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Unable to deserialise file: " << mFullFileSpec << LL_ENDL; } else { @@ -399,15 +394,13 @@ void LLSyntaxIdLSL::loadKeywordsIntoLLSD() { sKeywordsXml = content; sLoaded = true; - sInitialised = true; - LL_INFOS("SyntaxLSL") - << "Deserialised file: " << mFullFileSpec << LL_ENDL; + sInitialized = true; + LL_INFOS("SyntaxLSL") << "Deserialised file: " << mFullFileSpec << LL_ENDL; } else { sLoaded = false; - LL_WARNS("SyntaxLSL") - << "Unknown or unsupported version of syntax file." << LL_ENDL; + LL_WARNS("SyntaxLSL") << "Unknown or unsupported version of syntax file." << LL_ENDL; } } } @@ -422,8 +415,3 @@ boost::signals2::connection LLSyntaxIdLSL::addFileFetchedCallback(const file_fet { return sFileFetchedSignal.connect(cb); } - -void LLSyntaxIdLSL::removeFileFetchedCallback(boost::signals2::connection callback) -{ - sFileFetchedSignal.disconnect(callback); -} diff --git a/indra/newview/llsyntaxid.h b/indra/newview/llsyntaxid.h index 75cfc45380..b68f3f4237 100644 --- a/indra/newview/llsyntaxid.h +++ b/indra/newview/llsyntaxid.h @@ -36,23 +36,18 @@ #include "llsingleton.h" #include "llviewerregion.h" - -/** - * @file llsyntaxid.h - * @brief Tracks the file needed to decorate the current sim's version of LSL. - */ -class LLSyntaxIdLSL: public LLSingleton +class LLSyntaxIdLSL : public LLSingleton { friend class fetchKeywordsFileResponder; public: typedef boost::signals2::signal file_fetched_signal_t; - static const std::string CAPABILITY_NAME; - static const std::string FILENAME_DEFAULT; - static const std::string SIMULATOR_FEATURE; + static const std::string CAPABILITY_NAME; + static const std::string FILENAME_DEFAULT; + static const std::string SIMULATOR_FEATURE; protected: - static bool sInitialised; + static bool sInitialized; static LLSD sKeywordsXml; static bool sLoaded; static bool sLoadFailed; @@ -85,16 +80,15 @@ public: LLSD getKeywordsXML() const { return sKeywordsXml; } LLUUID getSyntaxId() const { return mSyntaxIdCurrent; } bool isDifferentVersion() const { return sVersionChanged; } - bool isInitialised() const { return sInitialised; } + bool isInitialized() const { return sInitialized; } - void initialise(); + void initialize(); bool isLoaded() { return sLoaded; } static bool isSupportedVersion(const LLSD& content); static void setKeywordsXml(const LLSD& content) { sKeywordsXml = content; } boost::signals2::connection addFileFetchedCallback(const file_fetched_signal_t::slot_type& cb); - void removeFileFetchedCallback(boost::signals2::connection callback); protected: @@ -110,10 +104,6 @@ protected: }; -/** - * @file llsyntaxid.h - * @brief Handles responses for the LSLSyntax capability's get call. Is a friend of LLSyntaxIdLSL - */ class fetchKeywordsFileResponder : public LLHTTPClient::Responder { public: -- cgit v1.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 +++++--- indra/newview/llpreviewscript.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'indra/newview/llpreviewscript.h') 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; } diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 8b98b908e1..e19a87ec0a 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -72,6 +72,7 @@ protected: void (*save_callback)(void* userdata, BOOL close_after_save), void (*search_replace_callback)(void* userdata), void* userdata, + bool live, S32 bottom_pad = 0); // pad below bottom row of buttons public: ~LLScriptEdCore(); -- cgit v1.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 ++++++++++++-------------- indra/newview/llpreviewscript.h | 1 - 2 files changed, 12 insertions(+), 15 deletions(-) (limited to 'indra/newview/llpreviewscript.h') 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() diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index e19a87ec0a..5aab3ed938 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -81,7 +81,6 @@ public: void initMenu(); void processKeywords(); void processLoaded(); - void updateKeywords(); virtual void draw(); /*virtual*/ BOOL postBuild(); -- cgit v1.3