From 6c2a890c2d66f41375cfaf01ca3db797693878b5 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Thu, 15 Jan 2009 07:45:10 -0700 Subject: Added viewer support for multiline comments --- linden/indra/llui/llkeywords.cpp | 66 ++++++++++++++++++++++++++++++++-------- linden/indra/llui/llkeywords.h | 16 +++++++--- 2 files changed, 65 insertions(+), 17 deletions(-) (limited to 'linden/indra/llui') 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 return res; } +inline BOOL LLKeywordToken::isTail(const llwchar* s) const +{ + BOOL res = TRUE; + const llwchar* t = mDelimiter.c_str(); + S32 len = mDelimiter.size(); + for (S32 i=0; i* seg_list, const LLWS seg_start = cur - base; cur += cur_delimiter->getLength(); - if( cur_delimiter->getType() == LLKeywordToken::TWO_SIDED_DELIMITER ) + if( cur_delimiter->getType() == LLKeywordToken::TWO_SIDED_DELIMITER || LLKeywordToken::TWO_SIDED_DELIMITER_ESC) { - while( *cur && !cur_delimiter->isHead(cur)) + llassert( cur_delimiter->getDelimiter() != NULL ); + while( *cur && !cur_delimiter->isTail(cur)) { // Check for an escape sequence. - if (*cur == '\\') + if (cur_delimiter->getType() == LLKeywordToken::TWO_SIDED_DELIMITER_ESC && *cur == '\\') { // Count the number of backslashes. S32 num_backslashes = 0; @@ -357,7 +397,7 @@ void LLKeywords::findSegments(std::vector* seg_list, const LLWS cur++; } // Is the next character the end delimiter? - if (cur_delimiter->isHead(cur)) + if (cur_delimiter->isTail(cur)) { // Is there was an odd number of backslashes, then this delimiter // does not end the sequence. @@ -383,7 +423,9 @@ void LLKeywords::findSegments(std::vector* seg_list, const LLWS if( *cur ) { cur += cur_delimiter->getLength(); - seg_end = seg_start + between_delimiters + 2 * cur_delimiter->getLength(); + seg_end = seg_start + between_delimiters + + cur_delimiter->getLength() + + cur_delimiter->getLength2(); } else { 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; class LLKeywordToken { public: - enum TOKEN_TYPE { WORD, LINE, TWO_SIDED_DELIMITER, ONE_SIDED_DELIMITER }; + enum TOKEN_TYPE { WORD, LINE, TWO_SIDED_DELIMITER, ONE_SIDED_DELIMITER, TWO_SIDED_DELIMITER_ESC }; - LLKeywordToken( TOKEN_TYPE type, const LLColor3& color, const LLWString& token, const LLWString& tool_tip ) + LLKeywordToken( TOKEN_TYPE type, const LLColor3& color, const LLWString& token, const LLWString& tool_tip, const LLWString& delimiter ) : mType( type ), - mToken( token ), + mToken( token ), // keyword or left delimiter mColor( color ), - mToolTip( tool_tip ) + mToolTip( tool_tip ), + mDelimiter( delimiter ) // right delimiter { } S32 getLength() const { return mToken.size(); } + S32 getLength2() const { return mDelimiter.size(); } BOOL isHead(const llwchar* s) const; + BOOL isTail(const llwchar* s) const; const LLWString& getToken() const { return mToken; } const LLColor3& getColor() const { return mColor; } TOKEN_TYPE getType() const { return mType; } const LLWString& getToolTip() const { return mToolTip; } + const LLWString& getDelimiter() const { return mDelimiter; } #ifdef _DEBUG void dump(); @@ -72,6 +76,7 @@ private: LLWString mToken; LLColor3 mColor; LLWString mToolTip; + LLWString mDelimiter; }; class LLKeywords @@ -89,7 +94,8 @@ public: void addToken(LLKeywordToken::TOKEN_TYPE type, const std::string& key, const LLColor3& color, - const std::string& tool_tip = LLStringUtil::null); + const std::string& tool_tip = LLStringUtil::null, + const std::string& delimiter = LLStringUtil::null); typedef std::map word_token_map_t; typedef word_token_map_t::const_iterator keyword_iterator_t; -- cgit v1.1