aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llkeywords.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llui/llkeywords.cpp')
-rw-r--r--linden/indra/llui/llkeywords.cpp66
1 files changed, 54 insertions, 12 deletions
diff --git a/linden/indra/llui/llkeywords.cpp b/linden/indra/llui/llkeywords.cpp
index 35f032a..2d5f53d 100644
--- a/linden/indra/llui/llkeywords.cpp
+++ b/linden/indra/llui/llkeywords.cpp
@@ -58,6 +58,22 @@ inline BOOL LLKeywordToken::isHead(const llwchar* s) const
58 return res; 58 return res;
59} 59}
60 60
61inline BOOL LLKeywordToken::isTail(const llwchar* s) const
62{
63 BOOL res = TRUE;
64 const llwchar* t = mDelimiter.c_str();
65 S32 len = mDelimiter.size();
66 for (S32 i=0; i<len; i++)
67 {
68 if (s[i] != t[i])
69 {
70 res = FALSE;
71 break;
72 }
73 }
74 return res;
75}
76
61LLKeywords::LLKeywords() : mLoaded(FALSE) 77LLKeywords::LLKeywords() : mLoaded(FALSE)
62{ 78{
63} 79}
@@ -111,6 +127,7 @@ BOOL LLKeywords::loadFromFile( const std::string& filename )
111 std::string SOL_LINE("[line "); 127 std::string SOL_LINE("[line ");
112 std::string SOL_ONE_SIDED_DELIMITER("[one_sided_delimiter "); 128 std::string SOL_ONE_SIDED_DELIMITER("[one_sided_delimiter ");
113 std::string SOL_TWO_SIDED_DELIMITER("[two_sided_delimiter "); 129 std::string SOL_TWO_SIDED_DELIMITER("[two_sided_delimiter ");
130 std::string SOL_TWO_SIDED_DELIMITER_ESC("[two_sided_delimiter_esc ");
114 131
115 LLColor3 cur_color( 1, 0, 0 ); 132 LLColor3 cur_color( 1, 0, 0 );
116 LLKeywordToken::TOKEN_TYPE cur_type = LLKeywordToken::WORD; 133 LLKeywordToken::TOKEN_TYPE cur_type = LLKeywordToken::WORD;
@@ -142,6 +159,12 @@ BOOL LLKeywords::loadFromFile( const std::string& filename )
142 cur_type = LLKeywordToken::TWO_SIDED_DELIMITER; 159 cur_type = LLKeywordToken::TWO_SIDED_DELIMITER;
143 continue; 160 continue;
144 } 161 }
162 else if( line.find(SOL_TWO_SIDED_DELIMITER_ESC) == 0 )
163 {
164 cur_color = readColor( line.substr(SOL_TWO_SIDED_DELIMITER_ESC.size()) );
165 cur_type = LLKeywordToken::TWO_SIDED_DELIMITER_ESC;
166 continue;
167 }
145 else if( line.find(SOL_ONE_SIDED_DELIMITER) == 0 ) 168 else if( line.find(SOL_ONE_SIDED_DELIMITER) == 0 )
146 { 169 {
147 cur_color = readColor( line.substr(SOL_ONE_SIDED_DELIMITER.size()) ); 170 cur_color = readColor( line.substr(SOL_ONE_SIDED_DELIMITER.size()) );
@@ -163,6 +186,19 @@ BOOL LLKeywords::loadFromFile( const std::string& filename )
163 std::string keyword = (*token_word_iter); 186 std::string keyword = (*token_word_iter);
164 LLStringUtil::trim(keyword); 187 LLStringUtil::trim(keyword);
165 188
189 // second word may be right delimiter
190 std::string delimiter = "";
191
192 if (cur_type == LLKeywordToken::TWO_SIDED_DELIMITER ||
193 cur_type == LLKeywordToken::TWO_SIDED_DELIMITER_ESC)
194 {
195 while (delimiter.length() == 0 && ++token_word_iter != word_tokens.end())
196 {
197 delimiter = *token_word_iter;
198 LLStringUtil::trim(delimiter);
199 }
200 }
201
166 // following words are tooltip 202 // following words are tooltip
167 std::string tool_tip; 203 std::string tool_tip;
168 while (++token_word_iter != word_tokens.end()) 204 while (++token_word_iter != word_tokens.end())
@@ -175,11 +211,11 @@ BOOL LLKeywords::loadFromFile( const std::string& filename )
175 { 211 {
176 // Replace : with \n for multi-line tool tips. 212 // Replace : with \n for multi-line tool tips.
177 LLStringUtil::replaceChar( tool_tip, ':', '\n' ); 213 LLStringUtil::replaceChar( tool_tip, ':', '\n' );
178 addToken(cur_type, keyword, cur_color, tool_tip ); 214 addToken(cur_type, keyword, cur_color, tool_tip, delimiter );
179 } 215 }
180 else 216 else
181 { 217 {
182 addToken(cur_type, keyword, cur_color, LLStringUtil::null ); 218 addToken(cur_type, keyword, cur_color, LLStringUtil::null, delimiter );
183 } 219 }
184 } 220 }
185 } 221 }
@@ -194,24 +230,27 @@ BOOL LLKeywords::loadFromFile( const std::string& filename )
194void LLKeywords::addToken(LLKeywordToken::TOKEN_TYPE type, 230void LLKeywords::addToken(LLKeywordToken::TOKEN_TYPE type,
195 const std::string& key_in, 231 const std::string& key_in,
196 const LLColor3& color, 232 const LLColor3& color,
197 const std::string& tool_tip_in ) 233 const std::string& tool_tip_in,
234 const std::string& delimiter_in )
198{ 235{
199 LLWString key = utf8str_to_wstring(key_in); 236 LLWString key = utf8str_to_wstring(key_in);
200 LLWString tool_tip = utf8str_to_wstring(tool_tip_in); 237 LLWString tool_tip = utf8str_to_wstring(tool_tip_in);
238 LLWString delimiter = utf8str_to_wstring(delimiter_in);
201 switch(type) 239 switch(type)
202 { 240 {
203 case LLKeywordToken::WORD: 241 case LLKeywordToken::WORD:
204 mWordTokenMap[key] = new LLKeywordToken(type, color, key, tool_tip); 242 mWordTokenMap[key] = new LLKeywordToken(type, color, key, tool_tip, NULL);
205 break; 243 break;
206 244
207 case LLKeywordToken::LINE: 245 case LLKeywordToken::LINE:
208 mLineTokenList.push_front(new LLKeywordToken(type, color, key, tool_tip)); 246 mLineTokenList.push_front(new LLKeywordToken(type, color, key, tool_tip, NULL));
209 break; 247 break;
210 248
211 case LLKeywordToken::TWO_SIDED_DELIMITER: 249 case LLKeywordToken::TWO_SIDED_DELIMITER:
212 case LLKeywordToken::ONE_SIDED_DELIMITER: 250 case LLKeywordToken::ONE_SIDED_DELIMITER:
213 mDelimiterTokenList.push_front(new LLKeywordToken(type, color, key, tool_tip)); 251 case LLKeywordToken::TWO_SIDED_DELIMITER_ESC:
214 break; 252 mDelimiterTokenList.push_front(new LLKeywordToken(type, color, key, tool_tip, delimiter));
253 break;
215 254
216 default: 255 default:
217 llassert(0); 256 llassert(0);
@@ -341,12 +380,13 @@ void LLKeywords::findSegments(std::vector<LLTextSegment *>* seg_list, const LLWS
341 seg_start = cur - base; 380 seg_start = cur - base;
342 cur += cur_delimiter->getLength(); 381 cur += cur_delimiter->getLength();
343 382
344 if( cur_delimiter->getType() == LLKeywordToken::TWO_SIDED_DELIMITER ) 383 if( cur_delimiter->getType() == LLKeywordToken::TWO_SIDED_DELIMITER || LLKeywordToken::TWO_SIDED_DELIMITER_ESC)
345 { 384 {
346 while( *cur && !cur_delimiter->isHead(cur)) 385 llassert( cur_delimiter->getDelimiter() != NULL );
386 while( *cur && !cur_delimiter->isTail(cur))
347 { 387 {
348 // Check for an escape sequence. 388 // Check for an escape sequence.
349 if (*cur == '\\') 389 if (cur_delimiter->getType() == LLKeywordToken::TWO_SIDED_DELIMITER_ESC && *cur == '\\')
350 { 390 {
351 // Count the number of backslashes. 391 // Count the number of backslashes.
352 S32 num_backslashes = 0; 392 S32 num_backslashes = 0;
@@ -357,7 +397,7 @@ void LLKeywords::findSegments(std::vector<LLTextSegment *>* seg_list, const LLWS
357 cur++; 397 cur++;
358 } 398 }
359 // Is the next character the end delimiter? 399 // Is the next character the end delimiter?
360 if (cur_delimiter->isHead(cur)) 400 if (cur_delimiter->isTail(cur))
361 { 401 {
362 // Is there was an odd number of backslashes, then this delimiter 402 // Is there was an odd number of backslashes, then this delimiter
363 // does not end the sequence. 403 // does not end the sequence.
@@ -383,7 +423,9 @@ void LLKeywords::findSegments(std::vector<LLTextSegment *>* seg_list, const LLWS
383 if( *cur ) 423 if( *cur )
384 { 424 {
385 cur += cur_delimiter->getLength(); 425 cur += cur_delimiter->getLength();
386 seg_end = seg_start + between_delimiters + 2 * cur_delimiter->getLength(); 426 seg_end = seg_start + between_delimiters
427 + cur_delimiter->getLength()
428 + cur_delimiter->getLength2();
387 } 429 }
388 else 430 else
389 { 431 {