aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden
diff options
context:
space:
mode:
Diffstat (limited to 'linden')
-rw-r--r--linden/indra/llui/llkeywords.cpp66
-rw-r--r--linden/indra/llui/llkeywords.h16
-rw-r--r--linden/indra/newview/app_settings/keywords.ini6
3 files changed, 69 insertions, 19 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 {
diff --git a/linden/indra/llui/llkeywords.h b/linden/indra/llui/llkeywords.h
index e3361f6..742383a 100644
--- a/linden/indra/llui/llkeywords.h
+++ b/linden/indra/llui/llkeywords.h
@@ -45,23 +45,27 @@ class LLTextSegment;
45class LLKeywordToken 45class LLKeywordToken
46{ 46{
47public: 47public:
48 enum TOKEN_TYPE { WORD, LINE, TWO_SIDED_DELIMITER, ONE_SIDED_DELIMITER }; 48 enum TOKEN_TYPE { WORD, LINE, TWO_SIDED_DELIMITER, ONE_SIDED_DELIMITER, TWO_SIDED_DELIMITER_ESC };
49 49
50 LLKeywordToken( TOKEN_TYPE type, const LLColor3& color, const LLWString& token, const LLWString& tool_tip ) 50 LLKeywordToken( TOKEN_TYPE type, const LLColor3& color, const LLWString& token, const LLWString& tool_tip, const LLWString& delimiter )
51 : 51 :
52 mType( type ), 52 mType( type ),
53 mToken( token ), 53 mToken( token ), // keyword or left delimiter
54 mColor( color ), 54 mColor( color ),
55 mToolTip( tool_tip ) 55 mToolTip( tool_tip ),
56 mDelimiter( delimiter ) // right delimiter
56 { 57 {
57 } 58 }
58 59
59 S32 getLength() const { return mToken.size(); } 60 S32 getLength() const { return mToken.size(); }
61 S32 getLength2() const { return mDelimiter.size(); }
60 BOOL isHead(const llwchar* s) const; 62 BOOL isHead(const llwchar* s) const;
63 BOOL isTail(const llwchar* s) const;
61 const LLWString& getToken() const { return mToken; } 64 const LLWString& getToken() const { return mToken; }
62 const LLColor3& getColor() const { return mColor; } 65 const LLColor3& getColor() const { return mColor; }
63 TOKEN_TYPE getType() const { return mType; } 66 TOKEN_TYPE getType() const { return mType; }
64 const LLWString& getToolTip() const { return mToolTip; } 67 const LLWString& getToolTip() const { return mToolTip; }
68 const LLWString& getDelimiter() const { return mDelimiter; }
65 69
66#ifdef _DEBUG 70#ifdef _DEBUG
67 void dump(); 71 void dump();
@@ -72,6 +76,7 @@ private:
72 LLWString mToken; 76 LLWString mToken;
73 LLColor3 mColor; 77 LLColor3 mColor;
74 LLWString mToolTip; 78 LLWString mToolTip;
79 LLWString mDelimiter;
75}; 80};
76 81
77class LLKeywords 82class LLKeywords
@@ -89,7 +94,8 @@ public:
89 void addToken(LLKeywordToken::TOKEN_TYPE type, 94 void addToken(LLKeywordToken::TOKEN_TYPE type,
90 const std::string& key, 95 const std::string& key,
91 const LLColor3& color, 96 const LLColor3& color,
92 const std::string& tool_tip = LLStringUtil::null); 97 const std::string& tool_tip = LLStringUtil::null,
98 const std::string& delimiter = LLStringUtil::null);
93 99
94 typedef std::map<LLWString, LLKeywordToken*> word_token_map_t; 100 typedef std::map<LLWString, LLKeywordToken*> word_token_map_t;
95 typedef word_token_map_t::const_iterator keyword_iterator_t; 101 typedef word_token_map_t::const_iterator keyword_iterator_t;
diff --git a/linden/indra/newview/app_settings/keywords.ini b/linden/indra/newview/app_settings/keywords.ini
index 3679c38..28ecb00 100644
--- a/linden/indra/newview/app_settings/keywords.ini
+++ b/linden/indra/newview/app_settings/keywords.ini
@@ -551,9 +551,11 @@ return Leave current function or event handler
551# Comment 551# Comment
552[one_sided_delimiter .8, .3, .15] 552[one_sided_delimiter .8, .3, .15]
553// Comment:Non-functional commentary or disabled code 553// Comment:Non-functional commentary or disabled code
554[two_sided_delimiter .8, .3, .15]
555/* */ Comment:Non-functional commentary or disabled code
554 556
555# String literals 557# String literals
556[two_sided_delimiter 0, .2, 0] 558[two_sided_delimiter_esc 0, .2, 0]
557" String literal 559" " String literal
558 560
559#functions are supplied by the program now. 561#functions are supplied by the program now.