From 7183cecd14fbdc3cd31e1482248fabec7b23b1fb Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Tue, 5 Feb 2013 16:37:37 +0000 Subject: STORM-1831 merging in previous work --- indra/llui/llkeywords.h | 81 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 62 insertions(+), 19 deletions(-) (limited to 'indra/llui/llkeywords.h') diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index ac34015393..87f65dc0bf 100644 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -1,25 +1,25 @@ -/** +/** * @file llkeywords.h * @brief Keyword list for LSL * * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -41,26 +41,35 @@ typedef LLPointer LLTextSegmentPtr; class LLKeywordToken { public: - /** + /** * @brief Types of tokens/delimters being parsed. * * @desc Tokens/delimiters that need to be identified/highlighted. All are terminated if an EOF is encountered. - * - WORD are keywords in the normal sense, i.e. constants, events, etc. - * - LINE are for entire lines (currently only flow control labels use this). - * - ONE_SIDED_DELIMITER are for open-ended delimiters which are terminated by EOL. - * - TWO_SIDED_DELIMITER are for delimiters that end with a different delimiter than they open with. - * - DOUBLE_QUOTATION_MARKS are for delimiting areas using the same delimiter to open and close. + * - TT_WORD are keywords in the normal sense, i.e. constants, events, etc. + * - TT_LINE are for entire lines (currently only flow control labels use this). + * - TT_ONE_SIDED_DELIMITER are for open-ended delimiters which are terminated by EOL. + * - TT_TWO_SIDED_DELIMITER are for delimiters that end with a different delimiter than they open with. + * - TT_DOUBLE_QUOTATION_MARKS are for delimiting areas using the same delimiter to open and close. */ enum TOKEN_TYPE { - WORD, - LINE, - TWO_SIDED_DELIMITER, - ONE_SIDED_DELIMITER, - DOUBLE_QUOTATION_MARKS + TT_UNKNOWN, + TT_WORD, + TT_LINE, + TT_TWO_SIDED_DELIMITER, + TT_ONE_SIDED_DELIMITER, + TT_DOUBLE_QUOTATION_MARKS, + // Following constants are more specific versions of the preceding ones + TT_CONSTANT, // WORD + TT_EVENT, // WORD + TT_FLOW, // WORD + TT_FUNCTION, // WORD + TT_LABEL, // LINE + TT_SECTION, // WORD + TT_TYPE // WORD }; - LLKeywordToken( TOKEN_TYPE type, const LLColor3& color, const LLWString& token, const LLWString& tool_tip, const LLWString& delimiter ) + LLKeywordToken( TOKEN_TYPE type, const LLColor3& color, const LLWString& token, const LLWString& tool_tip, const LLWString& delimiter ) : mType( type ), mToken( token ), @@ -98,10 +107,19 @@ public: LLKeywords(); ~LLKeywords(); + void addColorGroup(const std::string key_in, const LLColor3 color); + LLColor3 getColorGroup(const std::string key_in); + BOOL loadFromFile(); BOOL loadFromFile(const std::string& filename); BOOL isLoaded() const { return mLoaded; } + void setFilenameColors(const std::string filename) { mFilenameColors = filename; } + void setFilenameSyntax(const std::string filename) { mFilenameSyntax = filename; } void findSegments(std::vector *seg_list, const LLWString& text, const LLColor4 &defaultColor, class LLTextEditor& editor ); + BOOL initialise(); + std::string processColors(); + std::string processColors(LLSD &data, const std::string strGroup); + void processTokens(); // Add the token as described void addToken(LLKeywordToken::TOKEN_TYPE type, @@ -109,7 +127,7 @@ public: const LLColor3& color, const std::string& tool_tip = LLStringUtil::null, const std::string& delimiter = LLStringUtil::null); - + // This class is here as a performance optimization. // The word token map used to be defined as std::map. // This worked, but caused a performance bottleneck due to memory allocation and string copies @@ -133,6 +151,9 @@ public: const llwchar *mData; size_t mLength; bool mOwner; + + + LLColor3 mColor; }; typedef std::map word_token_map_t; @@ -140,20 +161,42 @@ public: keyword_iterator_t begin() const { return mWordTokenMap.begin(); } keyword_iterator_t end() const { return mWordTokenMap.end(); } + typedef std::map group_color_map_t; + typedef group_color_map_t::const_iterator color_iterator_t; + group_color_map_t mColorGroupMap; + #ifdef _DEBUG void dump(); #endif -private: +protected: + void processTokensGroup(LLSD& Tokens, const std::string Group); LLColor3 readColor(const std::string& s); + LLColor3 readColor(LLSD& sd); void insertSegment(std::vector& seg_list, LLTextSegmentPtr new_segment, S32 text_len, const LLColor4 &defaultColor, class LLTextEditor& editor); void insertSegments(const LLWString& wtext, std::vector& seg_list, LLKeywordToken* token, S32 text_len, S32 seg_start, S32 seg_end, const LLColor4 &defaultColor, LLTextEditor& editor); + BOOL loadIntoLLSD( const std::string& filename, LLSD& data ); + LLSD mColors; BOOL mLoaded; + LLSD mSyntax; word_token_map_t mWordTokenMap; typedef std::deque token_list_t; token_list_t mLineTokenList; token_list_t mDelimiterTokenList; + + typedef std::map element_attributes_t; + typedef element_attributes_t::const_iterator attribute_iterator_t; + element_attributes_t mAttributes; + std::string getAttribute(const std::string& key); + + std::string getArguments(LLSD& args); + +private: + BOOL ready() { return mReady; }; + BOOL mReady; + std::string mFilenameColors; + std::string mFilenameSyntax; }; #endif // LL_LLKEYWORDS_H -- cgit v1.2.3 From 582babac2f1acd7f558fa4bf13034c5f306fe115 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Mon, 11 Feb 2013 21:50:38 +0000 Subject: STORM-1831 Changes to LLSD structure and corresponding processing in llkeywords. Plus some formating clean ups. --- indra/llui/llkeywords.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui/llkeywords.h') diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index 87f65dc0bf..badbd2ae85 100644 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -61,8 +61,8 @@ public: TT_DOUBLE_QUOTATION_MARKS, // Following constants are more specific versions of the preceding ones TT_CONSTANT, // WORD + TT_CONTROL, // WORD TT_EVENT, // WORD - TT_FLOW, // WORD TT_FUNCTION, // WORD TT_LABEL, // LINE TT_SECTION, // WORD -- cgit v1.2.3 From 7d5ed4f7477c2c564f0e9dededf7131ed42d55b8 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Thu, 27 Jun 2013 21:28:52 +0100 Subject: Moving LSL highlighting colour info into .../skins/default/colors.xml where it makes more sense than its own xml file. Changing other functions to read it. --- indra/llui/llkeywords.h | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'indra/llui/llkeywords.h') diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index badbd2ae85..6889b95339 100755 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -30,6 +30,7 @@ #include "llstring.h" #include "v3color.h" +#include "v4color.h" #include #include #include @@ -69,7 +70,7 @@ public: TT_TYPE // WORD }; - LLKeywordToken( TOKEN_TYPE type, const LLColor3& color, const LLWString& token, const LLWString& tool_tip, const LLWString& delimiter ) + LLKeywordToken( TOKEN_TYPE type, const LLColor4& color, const LLWString& token, const LLWString& tool_tip, const LLWString& delimiter ) : mType( type ), mToken( token ), @@ -84,7 +85,7 @@ public: BOOL isHead(const llwchar* s) const; BOOL isTail(const llwchar* s) const; const LLWString& getToken() const { return mToken; } - const LLColor3& getColor() const { return mColor; } + const LLColor4& getColor() const { return mColor; } TOKEN_TYPE getType() const { return mType; } const LLWString& getToolTip() const { return mToolTip; } const LLWString& getDelimiter() const { return mDelimiter; } @@ -96,7 +97,7 @@ public: private: TOKEN_TYPE mType; LLWString mToken; - LLColor3 mColor; + LLColor4 mColor; LLWString mToolTip; LLWString mDelimiter; }; @@ -107,12 +108,11 @@ public: LLKeywords(); ~LLKeywords(); - void addColorGroup(const std::string key_in, const LLColor3 color); - LLColor3 getColorGroup(const std::string key_in); + void addColorGroup(const std::string key_in, const LLColor4 color); + LLColor4 getColorGroup(const std::string key_in); BOOL loadFromFile(); BOOL loadFromFile(const std::string& filename); BOOL isLoaded() const { return mLoaded; } - void setFilenameColors(const std::string filename) { mFilenameColors = filename; } void setFilenameSyntax(const std::string filename) { mFilenameSyntax = filename; } void findSegments(std::vector *seg_list, const LLWString& text, const LLColor4 &defaultColor, class LLTextEditor& editor ); @@ -124,7 +124,7 @@ public: // Add the token as described void addToken(LLKeywordToken::TOKEN_TYPE type, const std::string& key, - const LLColor3& color, + const LLColor4& color, const std::string& tool_tip = LLStringUtil::null, const std::string& delimiter = LLStringUtil::null); @@ -153,7 +153,7 @@ public: bool mOwner; - LLColor3 mColor; + LLColor4 mColor; }; typedef std::map word_token_map_t; @@ -161,7 +161,7 @@ public: keyword_iterator_t begin() const { return mWordTokenMap.begin(); } keyword_iterator_t end() const { return mWordTokenMap.end(); } - typedef std::map group_color_map_t; + typedef std::map group_color_map_t; typedef group_color_map_t::const_iterator color_iterator_t; group_color_map_t mColorGroupMap; @@ -171,8 +171,8 @@ public: protected: void processTokensGroup(LLSD& Tokens, const std::string Group); - LLColor3 readColor(const std::string& s); - LLColor3 readColor(LLSD& sd); + LLColor4 readColor(const std::string& s); + LLColor4 readColor(LLSD& sd); void insertSegment(std::vector& seg_list, LLTextSegmentPtr new_segment, S32 text_len, const LLColor4 &defaultColor, class LLTextEditor& editor); void insertSegments(const LLWString& wtext, std::vector& seg_list, LLKeywordToken* token, S32 text_len, S32 seg_start, S32 seg_end, const LLColor4 &defaultColor, LLTextEditor& editor); BOOL loadIntoLLSD( const std::string& filename, LLSD& data ); @@ -195,7 +195,6 @@ protected: private: BOOL ready() { return mReady; }; BOOL mReady; - std::string mFilenameColors; std::string mFilenameSyntax; }; -- cgit v1.2.3 From 0ffaf25e7599391841508fbac769bc3b544930a5 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Tue, 15 Oct 2013 21:46:24 +0100 Subject: STORM-1831 Removing unnecessary semi-colon --- indra/llui/llkeywords.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui/llkeywords.h') diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index 6889b95339..77a12bc1e5 100755 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -193,7 +193,7 @@ protected: std::string getArguments(LLSD& args); private: - BOOL ready() { return mReady; }; + BOOL ready() { return mReady; } BOOL mReady; std::string mFilenameSyntax; }; -- cgit v1.2.3 From 79645e6981a97224024c5226d8713dce9569d54a Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Mon, 21 Oct 2013 04:09:20 +0100 Subject: STORM-1831 First attempt at using SyntaxIdLSL capability. (incomplete) --- indra/llui/llkeywords.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/llui/llkeywords.h') diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index 77a12bc1e5..1bd23549d2 100755 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -28,6 +28,7 @@ #define LL_LLKEYWORDS_H +#include "lldir.h" #include "llstring.h" #include "v3color.h" #include "v4color.h" @@ -116,7 +117,7 @@ public: void setFilenameSyntax(const std::string filename) { mFilenameSyntax = filename; } void findSegments(std::vector *seg_list, const LLWString& text, const LLColor4 &defaultColor, class LLTextEditor& editor ); - BOOL initialise(); + BOOL initialise(ELLPath path, const std::string filename); std::string processColors(); std::string processColors(LLSD &data, const std::string strGroup); void processTokens(); -- cgit v1.2.3 From 4af21580297dd85727ffdc5d4eee89ad58ead271 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sat, 9 Nov 2013 11:31:32 +0000 Subject: Adding method to load cached/default syntax file and method to access sKeyWordsXML. --- indra/llui/llkeywords.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'indra/llui/llkeywords.h') diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index 1bd23549d2..f98453405d 100755 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -83,8 +83,8 @@ public: S32 getLengthHead() const { return mToken.size(); } S32 getLengthTail() const { return mDelimiter.size(); } - BOOL isHead(const llwchar* s) const; - BOOL isTail(const llwchar* s) const; + bool isHead(const llwchar* s) const; + bool isTail(const llwchar* s) const; const LLWString& getToken() const { return mToken; } const LLColor4& getColor() const { return mColor; } TOKEN_TYPE getType() const { return mType; } @@ -111,13 +111,13 @@ public: void addColorGroup(const std::string key_in, const LLColor4 color); LLColor4 getColorGroup(const std::string key_in); - BOOL loadFromFile(); - BOOL loadFromFile(const std::string& filename); - BOOL isLoaded() const { return mLoaded; } + bool loadFromFile(); + bool loadFromFile(const std::string& filename); + bool isLoaded() const { return mLoaded; } void setFilenameSyntax(const std::string filename) { mFilenameSyntax = filename; } void findSegments(std::vector *seg_list, const LLWString& text, const LLColor4 &defaultColor, class LLTextEditor& editor ); - BOOL initialise(ELLPath path, const std::string filename); + bool initialise(ELLPath path, const std::string filename); std::string processColors(); std::string processColors(LLSD &data, const std::string strGroup); void processTokens(); @@ -176,10 +176,10 @@ protected: LLColor4 readColor(LLSD& sd); void insertSegment(std::vector& seg_list, LLTextSegmentPtr new_segment, S32 text_len, const LLColor4 &defaultColor, class LLTextEditor& editor); void insertSegments(const LLWString& wtext, std::vector& seg_list, LLKeywordToken* token, S32 text_len, S32 seg_start, S32 seg_end, const LLColor4 &defaultColor, LLTextEditor& editor); - BOOL loadIntoLLSD( const std::string& filename, LLSD& data ); + bool loadIntoLLSD( const std::string& filename, LLSD& data ); LLSD mColors; - BOOL mLoaded; + bool mLoaded; LLSD mSyntax; word_token_map_t mWordTokenMap; typedef std::deque token_list_t; @@ -194,8 +194,8 @@ protected: std::string getArguments(LLSD& args); private: - BOOL ready() { return mReady; } - BOOL mReady; + bool ready() { return mReady; } + bool mReady; std::string mFilenameSyntax; }; -- cgit v1.2.3 From 29b2129e1eec0dbbb909422e82766a58f14c5da3 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sat, 9 Nov 2013 11:32:08 +0000 Subject: Backed out changeset: e82d9467bec8 --- indra/llui/llkeywords.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'indra/llui/llkeywords.h') diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index f98453405d..1bd23549d2 100755 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -83,8 +83,8 @@ public: S32 getLengthHead() const { return mToken.size(); } S32 getLengthTail() const { return mDelimiter.size(); } - bool isHead(const llwchar* s) const; - bool isTail(const llwchar* s) const; + BOOL isHead(const llwchar* s) const; + BOOL isTail(const llwchar* s) const; const LLWString& getToken() const { return mToken; } const LLColor4& getColor() const { return mColor; } TOKEN_TYPE getType() const { return mType; } @@ -111,13 +111,13 @@ public: void addColorGroup(const std::string key_in, const LLColor4 color); LLColor4 getColorGroup(const std::string key_in); - bool loadFromFile(); - bool loadFromFile(const std::string& filename); - bool isLoaded() const { return mLoaded; } + BOOL loadFromFile(); + BOOL loadFromFile(const std::string& filename); + BOOL isLoaded() const { return mLoaded; } void setFilenameSyntax(const std::string filename) { mFilenameSyntax = filename; } void findSegments(std::vector *seg_list, const LLWString& text, const LLColor4 &defaultColor, class LLTextEditor& editor ); - bool initialise(ELLPath path, const std::string filename); + BOOL initialise(ELLPath path, const std::string filename); std::string processColors(); std::string processColors(LLSD &data, const std::string strGroup); void processTokens(); @@ -176,10 +176,10 @@ protected: LLColor4 readColor(LLSD& sd); void insertSegment(std::vector& seg_list, LLTextSegmentPtr new_segment, S32 text_len, const LLColor4 &defaultColor, class LLTextEditor& editor); void insertSegments(const LLWString& wtext, std::vector& seg_list, LLKeywordToken* token, S32 text_len, S32 seg_start, S32 seg_end, const LLColor4 &defaultColor, LLTextEditor& editor); - bool loadIntoLLSD( const std::string& filename, LLSD& data ); + BOOL loadIntoLLSD( const std::string& filename, LLSD& data ); LLSD mColors; - bool mLoaded; + BOOL mLoaded; LLSD mSyntax; word_token_map_t mWordTokenMap; typedef std::deque token_list_t; @@ -194,8 +194,8 @@ protected: std::string getArguments(LLSD& args); private: - bool ready() { return mReady; } - bool mReady; + BOOL ready() { return mReady; } + BOOL mReady; std::string mFilenameSyntax; }; -- cgit v1.2.3 From 5e27952ee4698006c86ebdca60c4eab305ddebac Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sun, 10 Nov 2013 20:24:13 +0000 Subject: storm-1831 Switch to use the llsyntaxid keywords LLSD directly --- indra/llui/llkeywords.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui/llkeywords.h') diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index 1bd23549d2..24a0450912 100755 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -117,7 +117,7 @@ public: void setFilenameSyntax(const std::string filename) { mFilenameSyntax = filename; } void findSegments(std::vector *seg_list, const LLWString& text, const LLColor4 &defaultColor, class LLTextEditor& editor ); - BOOL initialise(ELLPath path, const std::string filename); + bool initialise(LLSD SyntaxXML); std::string processColors(); std::string processColors(LLSD &data, const std::string strGroup); void processTokens(); -- cgit v1.2.3 From 009245510149c26337ac1cca64a367cd2234725b Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Sun, 10 Nov 2013 22:35:49 +0000 Subject: Removing unused getter/setter and property for mFilenameSyntax, mReady. --- indra/llui/llkeywords.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'indra/llui/llkeywords.h') diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index 24a0450912..f14605157d 100755 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -113,8 +113,7 @@ public: LLColor4 getColorGroup(const std::string key_in); BOOL loadFromFile(); BOOL loadFromFile(const std::string& filename); - BOOL isLoaded() const { return mLoaded; } - void setFilenameSyntax(const std::string filename) { mFilenameSyntax = filename; } + bool isLoaded() const { return mLoaded; } void findSegments(std::vector *seg_list, const LLWString& text, const LLColor4 &defaultColor, class LLTextEditor& editor ); bool initialise(LLSD SyntaxXML); @@ -179,7 +178,7 @@ protected: BOOL loadIntoLLSD( const std::string& filename, LLSD& data ); LLSD mColors; - BOOL mLoaded; + bool mLoaded; LLSD mSyntax; word_token_map_t mWordTokenMap; typedef std::deque token_list_t; @@ -194,9 +193,6 @@ protected: std::string getArguments(LLSD& args); private: - BOOL ready() { return mReady; } - BOOL mReady; - std::string mFilenameSyntax; }; #endif // LL_LLKEYWORDS_H -- cgit v1.2.3 From 3e41917403fb3519adac2343ca21a1f289596621 Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Mon, 11 Nov 2013 16:33:04 +0000 Subject: Removing no longer used member variable, adding method to reset the mLoaded status --- indra/llui/llkeywords.h | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llui/llkeywords.h') diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index f14605157d..074cedfc63 100755 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -110,6 +110,7 @@ public: ~LLKeywords(); void addColorGroup(const std::string key_in, const LLColor4 color); + void clearLoaded() { mLoaded = false; } LLColor4 getColorGroup(const std::string key_in); BOOL loadFromFile(); BOOL loadFromFile(const std::string& filename); -- cgit v1.2.3