diff options
Diffstat (limited to 'indra/llui')
-rwxr-xr-x | indra/llui/llkeywords.cpp | 121 | ||||
-rwxr-xr-x | indra/llui/llkeywords.h | 1 | ||||
-rwxr-xr-x | indra/llui/lltexteditor.cpp | 8 | ||||
-rwxr-xr-x | indra/llui/lltexteditor.h | 3 |
4 files changed, 92 insertions, 41 deletions
diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index b7de4d5224..c5e8f76a73 100755 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -76,8 +76,6 @@ LLKeywords::~LLKeywords() std::for_each(mDelimiterTokenList.begin(), mDelimiterTokenList.end(), DeletePointer()); } - - void LLKeywords::addColorGroup(const std::string key_in, const LLColor4 color) { WStringMapIndex key ( utf8str_to_wstring(key_in) ); @@ -94,7 +92,7 @@ void LLKeywords::addToken(LLKeywordToken::TOKEN_TYPE type, std::string tip_text = tool_tip_in; LLStringUtil::replaceString(tip_text, "\\n", "\n" ); LLStringUtil::replaceString(tip_text, "\t", " " ); - if (tip_text =="") + if (tip_text == "") { tip_text = "[no info]"; } @@ -130,13 +128,23 @@ void LLKeywords::addToken(LLKeywordToken::TOKEN_TYPE type, } } +void LLKeywords::clear() +{ + clearLoaded(); + mSyntax = LLSD(); + + std::for_each(mWordTokenMap.begin(), mWordTokenMap.end(), DeletePairedPointer()); + std::for_each(mLineTokenList.begin(), mLineTokenList.end(), DeletePointer()); + std::for_each(mDelimiterTokenList.begin(), mDelimiterTokenList.end(), DeletePointer()); +} + std::string LLKeywords::getArguments(LLSD& arguments) { std::string argString = ""; if (arguments.isArray()) { - int argsCount = arguments.size(); + U32 argsCount = arguments.size(); LLSD::array_iterator arrayIt = arguments.beginArray(); for ( ; arrayIt != arguments.endArray(); ++arrayIt) { @@ -165,7 +173,7 @@ std::string LLKeywords::getArguments(LLSD& arguments) LL_WARNS("SyntaxLSL") << "Not an array! Invalid arguments LLSD passed to function." << arguments << LL_ENDL; } - return argString == "" ? " void " : argString; + return argString == "" ? "" : argString; } std::string LLKeywords::getAttribute(const std::string& key) @@ -177,33 +185,68 @@ std::string LLKeywords::getAttribute(const std::string& key) LLColor4 LLKeywords::getColorGroup(const std::string key_in) { std::string ColourGroup = "Black"; - if (key_in == "constants-float") { + if (key_in == "constants-float") + { ColourGroup = "SyntaxLslConstantFloat"; - } else if (key_in == "constants-integer") { + } + else if (key_in == "constants-integer") + { ColourGroup = "SyntaxLslConstantInteger"; - } else if (key_in == "constants-key") { + } + else if (key_in == "constants-key") + { ColourGroup = "SyntaxLslConstantKey"; - } else if (key_in == "constants-string") { + } + else if (key_in == "constants-string") + { ColourGroup = "SyntaxLslConstantRotation"; - } else if (key_in == "constants-string") { + } + else if (key_in == "constants-string") + { ColourGroup = "SyntaxLslConstantString"; - } else if (key_in == "constants-vector") { + } + else if (key_in == "constants-vector") + { ColourGroup = "SyntaxLslConstantVector"; - } else if (key_in == "controls") { + } + else if (key_in == "controls") + { ColourGroup = "SyntaxLslControlFlow"; - } else if (key_in == "events") { + } + else if (key_in =="deprecated") + { + ColourGroup = "SyntaxLslDeprecated"; + } + else if (key_in == "events") + { ColourGroup = "SyntaxLslEvent"; - } else if (key_in == "functions") { + } + else if (key_in == "functions") + { ColourGroup = "SyntaxLslFunction"; - } else if (key_in == "types") { + } + else if (key_in =="god-mode") + { + ColourGroup = "SyntaxLslGodMode"; + } + else if (key_in == "types") + { ColourGroup = "SyntaxLslDataType"; - } else if (key_in == "sections") { + } + else if (key_in == "sections") + { ColourGroup = "SyntaxLslSection"; - } else if (key_in == "misc-double_quotation_marks") { + } + else if (key_in == "misc-double_quotation_marks") + { ColourGroup = "SyntaxLslStringLiteral"; - } else if (key_in == "misc-comments_1_sided") { + } + else if (key_in == "misc-comments_1_sided") + { ColourGroup = "SyntaxLslComment1Sided"; - } else if (key_in == "misc-comments_2_sided") { + } + else if (key_in == "misc-comments_2_sided") + { ColourGroup = "SyntaxLslComment2Sided"; } @@ -228,20 +271,9 @@ void LLKeywords::processTokens() LLSD::map_iterator outerIt = mSyntax.beginMap(); for ( ; outerIt != mSyntax.endMap(); ++outerIt) { - if (outerIt->first == "misc") + if (outerIt->first == "llsd-lsl-syntax-version") { - if (outerIt->second.isMap()) - { - LLSD::map_iterator innerIt = outerIt->second.beginMap(); - for ( ; innerIt != outerIt->second.endMap(); ++innerIt) - { - processTokensGroup(innerIt->second, "misc-" + innerIt->first); - } - } - else - { - LL_ERRS("LSL-Tokens-Processing") << "Map for misc entries is missing! Ignoring." << LL_ENDL; - } + LL_INFOS("SyntaxLSL") << "Skipping over version key." << LL_ENDL; } else { @@ -255,12 +287,15 @@ void LLKeywords::processTokens() } } } - LL_INFOS("") << LL_ENDL; + LL_INFOS("SyntaxLSL") << "Finished processing tokens." << LL_ENDL; } void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) { LLColor4 Color; + LLColor4 ColorGroup; + LLColor4 ColorDeprecated = getColorGroup("deprecated"); + LLColor4 ColorGM = getColorGroup("god-mode"); LLKeywordToken::TOKEN_TYPE token_type = LLKeywordToken::TT_UNKNOWN; // If a new token type is added here, it must also be added to the 'addToken' method @@ -289,8 +324,8 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) token_type = LLKeywordToken::TT_TYPE; } - Color = getColorGroup(Group); - LL_INFOS("Tokens") << "Group: '" << Group << "', using colour: '" << Color << "'" << LL_ENDL; + ColorGroup = getColorGroup(Group); + LL_INFOS("Tokens") << "Group: '" << Group << "', using colour: '" << ColorGroup << "'" << LL_ENDL; if (Tokens.isMap()) { @@ -299,8 +334,8 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) { if (outerIt->second.isMap()) { + Color = ColorGroup; mAttributes.clear(); - bool deprecated = false; LLSD arguments = LLSD (); LLSD::map_iterator innerIt = outerIt->second.beginMap(); for ( ; innerIt != outerIt->second.endMap(); ++innerIt) @@ -312,10 +347,14 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) arguments = innerIt->second; } } - else + else if (!innerIt->second.isMap() && !innerIt->second.isArray()) { mAttributes[innerIt->first] = innerIt->second.asString(); } + else + { + LL_ERRS("SyntaxLSL") << "Not a valid attribute" << LL_ENDL; + } } std::string tooltip = ""; @@ -348,11 +387,13 @@ void LLKeywords::processTokensGroup(LLSD& Tokens, const std::string Group) tooltip += getAttribute("tooltip"); } - deprecated = getAttribute("deprecated") == "true" ? true : false; - if (deprecated) + Color = getAttribute("deprecated") == "true" ? ColorDeprecated : ColorGroup; + + if (getAttribute("god-mode") == "true") { - Color = getColorGroup("deprecated"); + Color = ColorGM; } + addToken(token_type, outerIt->first, Color, tooltip); } } diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index 689fd75bcd..de7645a5d2 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 clear(); void clearLoaded() { mLoaded = false; } LLColor4 getColorGroup(const std::string key_in); bool isLoaded() const { return mLoaded; } diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 303bc48933..e11636682e 100755 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -2529,6 +2529,14 @@ void LLTextEditor::loadKeywords() } } +void LLTextEditor::clearSegments() +{ + if (!mSegments.empty()) + { + mSegments.clear(); + } +} + void LLTextEditor::updateSegments() { if (mReflowIndex < S32_MAX && mKeywords.isLoaded() && mParseOnTheFly) diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index d7f6c7f643..698153587f 100755 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -207,7 +207,8 @@ public: const LLUUID& getSourceID() const { return mSourceID; } const LLTextSegmentPtr getPreviousSegment() const; - void getSelectedSegments(segment_vec_t& segments) const; + void getSelectedSegments(segment_vec_t& segments) const; + void clearSegments(); void setShowContextMenu(bool show) { mShowContextMenu = show; } bool getShowContextMenu() const { return mShowContextMenu; } |