diff options
Diffstat (limited to 'indra/llui')
| -rw-r--r-- | indra/llui/lllineeditor.cpp | 64 | ||||
| -rw-r--r-- | indra/llui/lllineeditor.h | 5 | ||||
| -rw-r--r-- | indra/llui/llmenugl.cpp | 42 | ||||
| -rw-r--r-- | indra/llui/llresmgr.cpp | 8 | ||||
| -rw-r--r-- | indra/llui/lluistring.h | 4 | 
5 files changed, 53 insertions, 70 deletions
diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 693ea5bb45..0db515ab41 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -148,6 +148,7 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p)  	mBgImage( p.background_image ),  	mBgImageDisabled( p.background_image_disabled ),  	mBgImageFocused( p.background_image_focused ), +	mHaveHistory(FALSE),  	mReplaceNewlinesWithSpaces( TRUE ),  	mLabel(p.label),  	mCursorColor(p.cursor_color()), @@ -164,13 +165,8 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p)  	mTripleClickTimer.reset();  	setText(p.default_text()); -	// line history support: -	// - initialize line history list -	mLineHistory.insert( mLineHistory.end(), "" ); -	// - disable line history by default -	mHaveHistory = FALSE; -	// - reset current history line pointer -	mCurrentHistoryLine = 0; +	// Initialize current history line iterator +	mCurrentHistoryLine = mLineHistory.begin();  	LLRect border_rect(getLocalRect());  	// adjust for gl line drawing glitch @@ -278,16 +274,31 @@ void LLLineEditor::updateHistory()  	// reset current history line number.  	// Be sure only to remember lines that are not empty and that are  	// different from the last on the list. -	if( mHaveHistory && mText.length() && ( mLineHistory.empty() || getText() != mLineHistory.back() ) ) +	if( mHaveHistory && getLength() )  	{ -		// discard possible empty line at the end of the history -		// inserted by setText() -		if( !mLineHistory.back().length() ) +		if( !mLineHistory.empty() )  		{ -			mLineHistory.pop_back(); +			// When not empty, last line of history should always be blank. +			if( mLineHistory.back().empty() ) +			{ +				// discard the empty line +				mLineHistory.pop_back(); +			} +			else +			{ +				LL_WARNS("") << "Last line of history was not blank." << LL_ENDL; +			}  		} -		mLineHistory.insert( mLineHistory.end(), getText() ); -		mCurrentHistoryLine = mLineHistory.size() - 1; + +		// Add text to history, ignoring duplicates +		if( mLineHistory.empty() || getText() != mLineHistory.back() ) +		{ +			mLineHistory.push_back( getText() ); +		} + +		// Restore the blank line and set mCurrentHistoryLine to point at it +		mLineHistory.push_back( "" ); +		mCurrentHistoryLine = mLineHistory.end() - 1;  	}  } @@ -357,11 +368,8 @@ void LLLineEditor::setText(const LLStringExplicit &new_text)  	}  	setCursor(llmin((S32)mText.length(), getCursor())); -	// Newly set text goes always in the last line of history. -	// Possible empty strings (as with chat line) will be deleted later. -	mLineHistory.insert( mLineHistory.end(), new_text );  	// Set current history line to end of history. -	mCurrentHistoryLine = mLineHistory.size() - 1; +	mCurrentHistoryLine = mLineHistory.end() - 1;  	mPrevText = mText;  } @@ -1254,9 +1262,9 @@ BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask)  	case KEY_UP:  		if( mHaveHistory && ( MASK_CONTROL == mask ) )  		{ -			if( mCurrentHistoryLine > 0 ) +			if( mCurrentHistoryLine > mLineHistory.begin() )  			{ -				mText.assign( mLineHistory[ --mCurrentHistoryLine ] ); +				mText.assign( *(--mCurrentHistoryLine) );  				setCursor(llmin((S32)mText.length(), getCursor()));  			}  			else @@ -1271,9 +1279,9 @@ BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask)  	case KEY_DOWN:  		if( mHaveHistory  && ( MASK_CONTROL == mask ) )  		{ -			if( !mLineHistory.empty() && mCurrentHistoryLine < mLineHistory.size() - 1 ) +			if( !mLineHistory.empty() && mCurrentHistoryLine < mLineHistory.end() - 1 )  			{ -				mText.assign( mLineHistory[ ++mCurrentHistoryLine ] ); +				mText.assign( *(++mCurrentHistoryLine) );  				setCursor(llmin((S32)mText.length(), getCursor()));  			}  			else @@ -2291,14 +2299,20 @@ BOOL LLLineEditor::hasPreeditString() const  void LLLineEditor::resetPreedit()  { -	if (hasPreeditString()) +	if (hasSelection())  	{ -		if (hasSelection()) +		if (hasPreeditString())  		{  			llwarns << "Preedit and selection!" << llendl;  			deselect();  		} - +		else +		{ +			deleteSelection(); +		} +	} +	if (hasPreeditString()) +	{  		const S32 preedit_pos = mPreeditPositions.front();  		mText.erase(preedit_pos, mPreeditPositions.back() - preedit_pos);  		mText.insert(preedit_pos, mPreeditOverwrittenWString); diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index 48d68b9935..6e81969f00 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -286,8 +286,9 @@ protected:  	// line history support:  	BOOL		mHaveHistory;				// flag for enabled line history -	std::vector<std::string> mLineHistory;		// line history storage -	U32			mCurrentHistoryLine;		// currently browsed history line +	typedef std::vector<std::string>	line_history_t; +	line_history_t	mLineHistory;			// line history storage +	line_history_t::iterator	mCurrentHistoryLine;	// currently browsed history line  	LLViewBorder* mBorder;  	const LLFontGL*	mGLFont; diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index 14bee0465c..cf013efca0 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -279,47 +279,7 @@ BOOL LLMenuItemGL::addToAcceleratorList(std::list <LLKeyBinding*> *listp)  // the current accelerator key and mask to the provided string.  void LLMenuItemGL::appendAcceleratorString( std::string& st ) const  { -	// break early if this is a silly thing to do. -	if( KEY_NONE == mAcceleratorKey ) -	{ -		return; -	} - -	// Append any masks -#ifdef LL_DARWIN -	// Standard Mac names for modifier keys in menu equivalents -	// We could use the symbol characters, but they only exist in certain fonts. -	if( mAcceleratorMask & MASK_CONTROL ) -	{ -		if ( mAcceleratorMask & MASK_MAC_CONTROL ) -		{ -			st.append( "Ctrl-" ); -		} -		else -		{ -			st.append( "Cmd-" );		// Symbol would be "\xE2\x8C\x98" -		} -	} -	if( mAcceleratorMask & MASK_ALT ) -		st.append( "Opt-" );		// Symbol would be "\xE2\x8C\xA5" -	if( mAcceleratorMask & MASK_SHIFT ) -		st.append( "Shift-" );		// Symbol would be "\xE2\x8C\xA7" -#else -	if( mAcceleratorMask & MASK_CONTROL ) -		st.append( "Ctrl-" ); -	if( mAcceleratorMask & MASK_ALT ) -		st.append( "Alt-" ); -	if( mAcceleratorMask & MASK_SHIFT ) -		st.append( "Shift-" ); -#endif - -	std::string keystr = LLKeyboard::stringFromKey( mAcceleratorKey ); -	if ((mAcceleratorMask & MASK_NORMALKEYS) && -		(keystr[0] == '-' || keystr[0] == '=')) -	{ -		st.append( " " ); -	} -	st.append( keystr ); +	st = LLKeyboard::stringFromAccelerator( mAcceleratorMask, mAcceleratorKey );  	LL_DEBUGS("HotKeys") << "appendAcceleratorString: " << st << LL_ENDL;  } diff --git a/indra/llui/llresmgr.cpp b/indra/llui/llresmgr.cpp index a4e23a605b..ed870d46d5 100644 --- a/indra/llui/llresmgr.cpp +++ b/indra/llui/llresmgr.cpp @@ -279,6 +279,14 @@ std::string LLResMgr::getMonetaryString( S32 input ) const  void LLResMgr::getIntegerString( std::string& output, S32 input ) const  { +	// handle special case of input value being zero +	if (input == 0) +	{ +		output = "0"; +		return; +	} +	 +	// *NOTE: this method does not handle negative input integers correctly  	S32 fraction = 0;  	std::string fraction_string;  	S32 remaining_count = input; diff --git a/indra/llui/lluistring.h b/indra/llui/lluistring.h index aedeca27cb..195f21a6a7 100644 --- a/indra/llui/lluistring.h +++ b/indra/llui/lluistring.h @@ -51,9 +51,9 @@  // llinfos << mMessage.getString() << llendl; // outputs "Welcome Steve to Second Life"  // mMessage.setArg("[USERNAME]", "Joe");  // llinfos << mMessage.getString() << llendl; // outputs "Welcome Joe to Second Life" -// mMessage = "Recepcin a la [SECONDLIFE] [USERNAME]" +// mMessage = "Bienvenido a la [SECONDLIFE] [USERNAME]"  // mMessage.setArg("[SECONDLIFE]", "Segunda Vida"); -// llinfos << mMessage.getString() << llendl; // outputs "Recepcin a la Segunda Vida Joe" +// llinfos << mMessage.getString() << llendl; // outputs "Bienvenido a la Segunda Vida Joe"  // Implementation Notes:  // Attempting to have operator[](const std::string& s) return mArgs[s] fails because we have  | 
