diff options
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/llui/lltexteditor.cpp | 80 | ||||
| -rw-r--r-- | indra/llui/lltexteditor.h | 6 | ||||
| -rw-r--r-- | indra/llui/lltooltip.cpp | 18 | ||||
| -rw-r--r-- | indra/llui/lltooltip.h | 4 | ||||
| -rw-r--r-- | indra/newview/skins/default/xui/en/panel_script_ed.xml | 1 | 
5 files changed, 90 insertions, 19 deletions
| diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 9720dded6c..0ba17c36db 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -237,7 +237,8 @@ LLTextEditor::Params::Params()  	show_line_numbers("show_line_numbers", false),  	default_color("default_color"),      commit_on_focus_lost("commit_on_focus_lost", false), -	show_context_menu("show_context_menu") +	show_context_menu("show_context_menu"), +	enable_tooltip_paste("enable_tooltip_paste")  {  	addSynonym(prevalidate_callback, "text_type");  } @@ -256,7 +257,8 @@ LLTextEditor::LLTextEditor(const LLTextEditor::Params& p) :  	mTabsToNextField(p.ignore_tab),  	mPrevalidateFunc(p.prevalidate_callback()),  	mContextMenu(NULL), -	mShowContextMenu(p.show_context_menu) +	mShowContextMenu(p.show_context_menu), +	mEnableTooltipPaste(p.enable_tooltip_paste)  {  	mSourceID.generate(); @@ -1409,6 +1411,23 @@ void LLTextEditor::pasteHelper(bool is_primary)  	// Clean up string (replace tabs and remove characters that our fonts don't support).  	LLWString clean_string(paste); +	cleanStringForPaste(clean_string); + +	// Insert the new text into the existing text. + +	//paste text with linebreaks. +	pasteTextWithLinebreaks(clean_string); + +	deselect(); + +	onKeyStroke(); +	mParseOnTheFly = TRUE; +} + + +// Clean up string (replace tabs and remove characters that our fonts don't support). +void LLTextEditor::cleanStringForPaste(LLWString & clean_string) +{  	LLWStringUtil::replaceTabsWithSpaces(clean_string, SPACES_PER_TAB);  	if( mAllowEmbeddedItems )  	{ @@ -1427,10 +1446,11 @@ void LLTextEditor::pasteHelper(bool is_primary)  			}  		}  	} +} -	// Insert the new text into the existing text. -	//paste text with linebreaks. +void LLTextEditor::pasteTextWithLinebreaks(LLWString & clean_string) +{  	std::basic_string<llwchar>::size_type start = 0;  	std::basic_string<llwchar>::size_type pos = clean_string.find('\n',start); @@ -1449,15 +1469,8 @@ void LLTextEditor::pasteHelper(bool is_primary)  	std::basic_string<llwchar> str = std::basic_string<llwchar>(clean_string,start,clean_string.length()-start);  	setCursorPos(mCursorPos + insert(mCursorPos, str, FALSE, LLTextSegmentPtr())); - -	deselect(); - -	onKeyStroke(); -	mParseOnTheFly = TRUE;  } - -  // copy selection to primary  void LLTextEditor::copyPrimary()  { @@ -1678,19 +1691,50 @@ BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask )  	{  		return FALSE;  	} -		 +  	if (mReadOnly && mScroller)  	{  		handled = (mScroller && mScroller->handleKeyHere( key, mask ))  				|| handleSelectionKey(key, mask)  				|| handleControlKey(key, mask); +	} +	else  +	{ +		if (mEnableTooltipPaste && +			LLToolTipMgr::instance().toolTipVisible() &&  +			KEY_TAB == key) +		{	// Paste the first line of a tooltip into the editor +			std::string message; +			LLToolTipMgr::instance().getToolTipMessage(message); +			LLWString tool_tip_text(utf8str_to_wstring(message)); +
 +			if (tool_tip_text.size() > 0) +			{ +				// Delete any selected characters (the tooltip text replaces them) +				if(hasSelection()) +				{ +					deleteSelection(TRUE); +				} + +				std::basic_string<llwchar>::size_type pos = tool_tip_text.find('\n',0); +				if (pos != -1) +				{	// Extract the first line of the tooltip +					tool_tip_text = std::basic_string<llwchar>(tool_tip_text, 0, pos); +				} + +				// Add the text +				cleanStringForPaste(tool_tip_text);
 +				pasteTextWithLinebreaks(tool_tip_text);
 +				handled = TRUE;
 +			}
 +		} +		else +		{	// Normal key handling +			handled = handleNavigationKey( key, mask ) +					|| handleSelectionKey(key, mask) +					|| handleControlKey(key, mask) +					|| handleSpecialKey(key, mask);  		} -		else  -		{ -		handled = handleNavigationKey( key, mask ) -				|| handleSelectionKey(key, mask) -				|| handleControlKey(key, mask) -				|| handleSpecialKey(key, mask);  	}  	if( handled ) diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index 40821ae9fb..e60fe03e58 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -64,7 +64,8 @@ public:  								ignore_tab,  								show_line_numbers,  								commit_on_focus_lost, -								show_context_menu; +								show_context_menu, +								enable_tooltip_paste;  		//colors  		Optional<LLUIColor>		default_color; @@ -288,6 +289,8 @@ private:  	// Methods  	//  	void	        pasteHelper(bool is_primary); +	void			cleanStringForPaste(LLWString & clean_string); +	void			pasteTextWithLinebreaks(LLWString & clean_string);  	void			drawLineNumbers(); @@ -321,6 +324,7 @@ private:  	BOOL			mAllowEmbeddedItems;  	bool			mShowContextMenu;  	bool			mParseOnTheFly; +	bool			mEnableTooltipPaste;  	LLUUID			mSourceID; diff --git a/indra/llui/lltooltip.cpp b/indra/llui/lltooltip.cpp index f737d48abf..7f1566d64a 100644 --- a/indra/llui/lltooltip.cpp +++ b/indra/llui/lltooltip.cpp @@ -390,6 +390,15 @@ bool LLToolTip::hasClickCallback()  	return mHasClickCallback;   } +void LLToolTip::getToolTipMessage(std::string & message) +{ +	if (mTextBox) +	{ +		message = mTextBox->getText(); +	} +} + +  //  // LLToolTipMgr @@ -594,5 +603,14 @@ void LLToolTipMgr::updateToolTipVisibility()  } +// Return the current tooltip text +void LLToolTipMgr::getToolTipMessage(std::string & message) +{ +	if (toolTipVisible()) +	{ +		mToolTip->getToolTipMessage(message); +	} +} +  // EOF diff --git a/indra/llui/lltooltip.h b/indra/llui/lltooltip.h index d71a944c3d..fad127fc4c 100644 --- a/indra/llui/lltooltip.h +++ b/indra/llui/lltooltip.h @@ -105,6 +105,8 @@ public:  	LLToolTip(const Params& p);  	void initFromParams(const LLToolTip::Params& params); +	void getToolTipMessage(std::string & message); +  private:  	class LLTextBox*	mTextBox;  	class LLButton*     mInfoButton; @@ -142,6 +144,8 @@ public:  	LLRect getMouseNearRect();  	void updateToolTipVisibility(); +	void getToolTipMessage(std::string & message); +  private:  	void createToolTip(const LLToolTip::Params& params); 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 f6a8af0973..765b07ed8b 100644 --- a/indra/newview/skins/default/xui/en/panel_script_ed.xml +++ b/indra/newview/skins/default/xui/en/panel_script_ed.xml @@ -158,6 +158,7 @@       text_readonly_color="DkGray"       width="487"       show_line_numbers="true"  +     enable_tooltip_paste="true"       word_wrap="true">          Loading...      </text_editor> | 
