diff options
| -rwxr-xr-x | indra/llui/llkeywords.cpp | 2 | ||||
| -rwxr-xr-x | indra/newview/llpreviewscript.cpp | 72 | ||||
| -rwxr-xr-x | indra/newview/llpreviewscript.h | 18 | 
3 files changed, 60 insertions, 32 deletions
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;  | 
