diff options
Diffstat (limited to 'linden/indra/llui/llkeywords.h')
-rw-r--r-- | linden/indra/llui/llkeywords.h | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/linden/indra/llui/llkeywords.h b/linden/indra/llui/llkeywords.h new file mode 100644 index 0000000..dc2745e --- /dev/null +++ b/linden/indra/llui/llkeywords.h | |||
@@ -0,0 +1,110 @@ | |||
1 | /** | ||
2 | * @file llkeywords.h | ||
3 | * @brief Keyword list for LSL | ||
4 | * | ||
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #ifndef LL_LLKEYWORDS_H | ||
29 | #define LL_LLKEYWORDS_H | ||
30 | |||
31 | |||
32 | #include "llstring.h" | ||
33 | #include "v3color.h" | ||
34 | #include <map> | ||
35 | #include <list> | ||
36 | #include <deque> | ||
37 | |||
38 | class LLTextSegment; | ||
39 | |||
40 | |||
41 | class LLKeywordToken | ||
42 | { | ||
43 | public: | ||
44 | enum TOKEN_TYPE { WORD, LINE, TWO_SIDED_DELIMITER, ONE_SIDED_DELIMITER }; | ||
45 | |||
46 | LLKeywordToken( TOKEN_TYPE type, const LLColor3& color, const LLWString& token, const LLWString& tool_tip ) | ||
47 | : | ||
48 | mType( type ), | ||
49 | mToken( token ), | ||
50 | mColor( color ), | ||
51 | mToolTip( tool_tip ) | ||
52 | { | ||
53 | } | ||
54 | |||
55 | S32 getLength() { return mToken.size(); } | ||
56 | BOOL isHead(const llwchar* s); | ||
57 | const LLColor3& getColor() { return mColor; } | ||
58 | TOKEN_TYPE getType() { return mType; } | ||
59 | const LLWString& getToolTip() { return mToolTip; } | ||
60 | |||
61 | #ifdef _DEBUG | ||
62 | void dump(); | ||
63 | #endif | ||
64 | |||
65 | private: | ||
66 | TOKEN_TYPE mType; | ||
67 | public: | ||
68 | LLWString mToken; | ||
69 | LLColor3 mColor; | ||
70 | private: | ||
71 | LLWString mToolTip; | ||
72 | }; | ||
73 | |||
74 | class LLKeywords | ||
75 | { | ||
76 | public: | ||
77 | LLKeywords(); | ||
78 | ~LLKeywords(); | ||
79 | |||
80 | BOOL loadFromFile(const LLString& filename); | ||
81 | BOOL isLoaded() { return mLoaded; } | ||
82 | |||
83 | void findSegments(std::vector<LLTextSegment *> *seg_list, const LLWString& text ); | ||
84 | |||
85 | #ifdef _DEBUG | ||
86 | void dump(); | ||
87 | #endif | ||
88 | |||
89 | // Add the token as described | ||
90 | void addToken(LLKeywordToken::TOKEN_TYPE type, | ||
91 | const LLString& key, | ||
92 | const LLColor3& color, | ||
93 | const LLString& tool_tip = LLString::null); | ||
94 | |||
95 | private: | ||
96 | LLColor3 readColor(const LLString& s); | ||
97 | void insertSegment(std::vector<LLTextSegment *> *seg_list, LLTextSegment* new_segment, S32 text_len); | ||
98 | |||
99 | private: | ||
100 | BOOL mLoaded; | ||
101 | public: | ||
102 | typedef std::map<LLWString, LLKeywordToken*> word_token_map_t; | ||
103 | word_token_map_t mWordTokenMap; | ||
104 | private: | ||
105 | typedef std::deque<LLKeywordToken*> token_list_t; | ||
106 | token_list_t mLineTokenList; | ||
107 | token_list_t mDelimiterTokenList; | ||
108 | }; | ||
109 | |||
110 | #endif // LL_LLKEYWORDS_H | ||