diff options
author | McCabe Maxsted | 2010-01-14 08:40:36 -0700 |
---|---|---|
committer | McCabe Maxsted | 2010-01-14 08:40:36 -0700 |
commit | 0ddfef6798dd28268d7784bac26e7b6e4574a9d6 (patch) | |
tree | 7e94b0ad14a988b0bac1b7887b536ae728ce080a | |
parent | Applied patch for VWR-14267 by Aimee Trescothick: Clicking send in an IM wind... (diff) | |
download | meta-impy-0ddfef6798dd28268d7784bac26e7b6e4574a9d6.zip meta-impy-0ddfef6798dd28268d7784bac26e7b6e4574a9d6.tar.gz meta-impy-0ddfef6798dd28268d7784bac26e7b6e4574a9d6.tar.bz2 meta-impy-0ddfef6798dd28268d7784bac26e7b6e4574a9d6.tar.xz |
Applied patch for VWR-14278 by Aimee Trescothick: Gesture auto-completion adds uncommitted suggestions to the line editor history
-rw-r--r-- | ChangeLog.txt | 7 | ||||
-rw-r--r-- | linden/indra/llui/lllineeditor.cpp | 52 | ||||
-rw-r--r-- | linden/indra/llui/lllineeditor.h | 5 |
3 files changed, 40 insertions, 24 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt index 48cc5bd..ea81074 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt | |||
@@ -1,5 +1,12 @@ | |||
1 | 2010-01-14 McCabe Maxsted <hakushakukun@gmail.com> | 1 | 2010-01-14 McCabe Maxsted <hakushakukun@gmail.com> |
2 | 2 | ||
3 | * Applied patch for VWR-14278 by Aimee Trescothick: | ||
4 | Gesture auto-completion adds uncommitted suggestions to the line editor history. | ||
5 | |||
6 | modified: linden/indra/llui/lllineeditor.cpp | ||
7 | modified: linden/indra/llui/lllineeditor.h | ||
8 | |||
9 | |||
3 | * Applied patch for VWR-14267 by Aimee Trescothick: | 10 | * Applied patch for VWR-14267 by Aimee Trescothick: |
4 | Clicking send in an IM window does not add the sent text to the line editor history. | 11 | Clicking send in an IM window does not add the sent text to the line editor history. |
5 | 12 | ||
diff --git a/linden/indra/llui/lllineeditor.cpp b/linden/indra/llui/lllineeditor.cpp index fc33dcf..6994f0b 100644 --- a/linden/indra/llui/lllineeditor.cpp +++ b/linden/indra/llui/lllineeditor.cpp | |||
@@ -135,18 +135,14 @@ LLLineEditor::LLLineEditor(const std::string& name, const LLRect& rect, | |||
135 | mSelectAllonCommit( TRUE ), | 135 | mSelectAllonCommit( TRUE ), |
136 | mPassDelete(FALSE), | 136 | mPassDelete(FALSE), |
137 | mReadOnly(FALSE), | 137 | mReadOnly(FALSE), |
138 | mHaveHistory(FALSE), | ||
138 | mImage( sImage ), | 139 | mImage( sImage ), |
139 | mReplaceNewlinesWithSpaces( TRUE ) | 140 | mReplaceNewlinesWithSpaces( TRUE ) |
140 | { | 141 | { |
141 | llassert( max_length_bytes > 0 ); | 142 | llassert( max_length_bytes > 0 ); |
142 | 143 | ||
143 | // line history support: | 144 | // Initialize current history line iterator |
144 | // - initialize line history list | 145 | mCurrentHistoryLine = mLineHistory.begin(); |
145 | mLineHistory.insert( mLineHistory.end(), "" ); | ||
146 | // - disable line history by default | ||
147 | mHaveHistory = FALSE; | ||
148 | // - reset current history line pointer | ||
149 | mCurrentHistoryLine = 0; | ||
150 | 146 | ||
151 | if (font) | 147 | if (font) |
152 | { | 148 | { |
@@ -244,16 +240,31 @@ void LLLineEditor::updateHistory() | |||
244 | // reset current history line number. | 240 | // reset current history line number. |
245 | // Be sure only to remember lines that are not empty and that are | 241 | // Be sure only to remember lines that are not empty and that are |
246 | // different from the last on the list. | 242 | // different from the last on the list. |
247 | if( mHaveHistory && mText.length() && ( mLineHistory.empty() || getText() != mLineHistory.back() ) ) | 243 | if( mHaveHistory && getLength() ) |
248 | { | 244 | { |
249 | // discard possible empty line at the end of the history | 245 | if( !mLineHistory.empty() ) |
250 | // inserted by setText() | ||
251 | if( !mLineHistory.back().length() ) | ||
252 | { | 246 | { |
253 | mLineHistory.pop_back(); | 247 | // When not empty, last line of history should always be blank. |
248 | if( mLineHistory.back().empty() ) | ||
249 | { | ||
250 | // discard the empty line | ||
251 | mLineHistory.pop_back(); | ||
252 | } | ||
253 | else | ||
254 | { | ||
255 | LL_WARNS("") << "Last line of history was not blank." << LL_ENDL; | ||
256 | } | ||
254 | } | 257 | } |
255 | mLineHistory.insert( mLineHistory.end(), getText() ); | 258 | |
256 | mCurrentHistoryLine = mLineHistory.size() - 1; | 259 | // Add text to history, ignoring duplicates |
260 | if( mLineHistory.empty() || getText() != mLineHistory.back() ) | ||
261 | { | ||
262 | mLineHistory.push_back( getText() ); | ||
263 | } | ||
264 | |||
265 | // Restore the blank line and set mCurrentHistoryLine to point at it | ||
266 | mLineHistory.push_back( "" ); | ||
267 | mCurrentHistoryLine = mLineHistory.end() - 1; | ||
257 | } | 268 | } |
258 | } | 269 | } |
259 | 270 | ||
@@ -324,11 +335,8 @@ void LLLineEditor::setText(const LLStringExplicit &new_text) | |||
324 | } | 335 | } |
325 | setCursor(llmin((S32)mText.length(), getCursor())); | 336 | setCursor(llmin((S32)mText.length(), getCursor())); |
326 | 337 | ||
327 | // Newly set text goes always in the last line of history. | ||
328 | // Possible empty strings (as with chat line) will be deleted later. | ||
329 | mLineHistory.insert( mLineHistory.end(), new_text ); | ||
330 | // Set current history line to end of history. | 338 | // Set current history line to end of history. |
331 | mCurrentHistoryLine = mLineHistory.size() - 1; | 339 | mCurrentHistoryLine = mLineHistory.end() - 1; |
332 | 340 | ||
333 | mPrevText = mText; | 341 | mPrevText = mText; |
334 | } | 342 | } |
@@ -1200,9 +1208,9 @@ BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask) | |||
1200 | case KEY_UP: | 1208 | case KEY_UP: |
1201 | if( mHaveHistory && ( MASK_CONTROL == mask ) ) | 1209 | if( mHaveHistory && ( MASK_CONTROL == mask ) ) |
1202 | { | 1210 | { |
1203 | if( mCurrentHistoryLine > 0 ) | 1211 | if( mCurrentHistoryLine > mLineHistory.begin() ) |
1204 | { | 1212 | { |
1205 | mText.assign( mLineHistory[ --mCurrentHistoryLine ] ); | 1213 | mText.assign( *(--mCurrentHistoryLine) ); |
1206 | setCursor(llmin((S32)mText.length(), getCursor())); | 1214 | setCursor(llmin((S32)mText.length(), getCursor())); |
1207 | } | 1215 | } |
1208 | else | 1216 | else |
@@ -1217,9 +1225,9 @@ BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask) | |||
1217 | case KEY_DOWN: | 1225 | case KEY_DOWN: |
1218 | if( mHaveHistory && ( MASK_CONTROL == mask ) ) | 1226 | if( mHaveHistory && ( MASK_CONTROL == mask ) ) |
1219 | { | 1227 | { |
1220 | if( !mLineHistory.empty() && mCurrentHistoryLine < mLineHistory.size() - 1 ) | 1228 | if( !mLineHistory.empty() && mCurrentHistoryLine < mLineHistory.end() - 1 ) |
1221 | { | 1229 | { |
1222 | mText.assign( mLineHistory[ ++mCurrentHistoryLine ] ); | 1230 | mText.assign( *(++mCurrentHistoryLine) ); |
1223 | setCursor(llmin((S32)mText.length(), getCursor())); | 1231 | setCursor(llmin((S32)mText.length(), getCursor())); |
1224 | } | 1232 | } |
1225 | else | 1233 | else |
diff --git a/linden/indra/llui/lllineeditor.h b/linden/indra/llui/lllineeditor.h index a670b21..f7cff8f 100644 --- a/linden/indra/llui/lllineeditor.h +++ b/linden/indra/llui/lllineeditor.h | |||
@@ -259,8 +259,9 @@ protected: | |||
259 | 259 | ||
260 | // line history support: | 260 | // line history support: |
261 | BOOL mHaveHistory; // flag for enabled line history | 261 | BOOL mHaveHistory; // flag for enabled line history |
262 | std::vector<std::string> mLineHistory; // line history storage | 262 | typedef std::vector<std::string> line_history_t; |
263 | U32 mCurrentHistoryLine; // currently browsed history line | 263 | line_history_t mLineHistory; // line history storage |
264 | line_history_t::iterator mCurrentHistoryLine; // currently browsed history line | ||
264 | 265 | ||
265 | LLViewBorder* mBorder; | 266 | LLViewBorder* mBorder; |
266 | const LLFontGL* mGLFont; | 267 | const LLFontGL* mGLFont; |