storm-1831 Fixing identificaton of label for highlighting.

master
Ima Mechanique 2014-03-09 04:55:46 +00:00
parent a2c084849f
commit 06bdcef531
3 changed files with 62 additions and 34 deletions

View File

@ -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";
}

View File

@ -407,52 +407,70 @@ BOOL LLScriptEdCore::postBuild()
initMenu();
mSyntaxIdLSL.addFileFetchedCallback(boost::bind(&LLScriptEdCore::onFileFetchedInitialiseKeywords, this));
mSyntaxIdLSL.addFileFetchedCallback(boost::bind(&LLScriptEdCore::processKeywords, 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));
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;
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;
}
processLoaded();
}
else
{
LL_INFOS("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;
}
void LLScriptEdCore::onFileFetchedInitialiseKeywords()
void LLScriptEdCore::updateKeywords()
{
if (mLive)
{
clearHighlights();
gAgent.removeRegionChangedCallback(mRegionChangedCallback);
}
else
{
processLoaded();
}
}
void LLScriptEdCore::processLoaded()
{
mSyntaxIdLSL.initialise();
if (mSyntaxIdLSL.isLoaded())
{
processKeywords();
}
else
{
LL_INFOS("SyntaxLSL")
<< "Hashes are different, waiting for the syntax file to be retrieved." << LL_ENDL;
}
}
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;
}

View File

@ -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;