summaryrefslogtreecommitdiff
path: root/indra/llui/llkeywords.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/llkeywords.cpp')
-rwxr-xr-xindra/llui/llkeywords.cpp147
1 files changed, 45 insertions, 102 deletions
diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp
index 2d8bd926c0..9c5a339b6d 100755
--- a/indra/llui/llkeywords.cpp
+++ b/indra/llui/llkeywords.cpp
@@ -67,8 +67,8 @@ inline bool LLKeywordToken::isTail(const llwchar* s) const
return res;
}
-LLKeywords::LLKeywords() :
- mLoaded(false)
+LLKeywords::LLKeywords()
+: mLoaded(false)
{
}
@@ -82,12 +82,6 @@ LLKeywords::~LLKeywords()
mDelimiterTokenList.clear();
}
-void LLKeywords::addColorGroup(const std::string& key_in, const LLColor4& color)
-{
- WStringMapIndex key ( utf8str_to_wstring(key_in) );
- mColorGroupMap[key] = color;
-}
-
// Add the token as described
void LLKeywords::addToken(LLKeywordToken::ETokenType type,
const std::string& key_in,
@@ -98,7 +92,7 @@ void LLKeywords::addToken(LLKeywordToken::ETokenType 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.empty())
{
tip_text = "[no info]";
}
@@ -167,7 +161,7 @@ std::string LLKeywords::getArguments(LLSD& arguments)
{
LL_WARNS("SyntaxLSL") << "Not an array! Invalid arguments LLSD passed to function." << arguments << LL_ENDL;
}
- return argString == "" ? "" : argString;
+ return argString;
}
std::string LLKeywords::getAttribute(const std::string& key)
@@ -178,30 +172,14 @@ std::string LLKeywords::getAttribute(const std::string& key)
LLColor4 LLKeywords::getColorGroup(const std::string& key_in)
{
- std::string color_group = "Black";
- if (key_in == "constants-float")
- {
- color_group = "SyntaxLslConstantFloat";
- }
- else if (key_in == "constants-integer")
- {
- color_group = "SyntaxLslConstantInteger";
- }
- else if (key_in == "constants-key")
- {
- color_group = "SyntaxLslConstantKey";
- }
- else if (key_in == "constants-rotation")
+ std::string color_group = "ScriptText";
+ if (key_in == "constants")
{
- color_group = "SyntaxLslConstantRotation";
+ color_group = "SyntaxLslConstant";
}
- else if (key_in == "constants-string")
+ else if (key_in == "controls")
{
- color_group = "SyntaxLslConstantString";
- }
- else if (key_in == "constants-vector")
- {
- color_group = "SyntaxLslConstantVector";
+ color_group = "SyntaxLslControlFlow";
}
else if (key_in == "misc-flow-label")
{
@@ -231,21 +209,9 @@ LLColor4 LLKeywords::getColorGroup(const std::string& key_in)
{
color_group = "SyntaxLslSection";
}
- else if (key_in == "misc-double_quotation_marks")
- {
- color_group = "SyntaxLslStringLiteral";
- }
- else if (key_in == "misc-comments_1_sided")
- {
- color_group = "SyntaxLslComment1Sided";
- }
- else if (key_in == "misc-comments_2_sided")
- {
- color_group = "SyntaxLslComment2Sided";
- }
else
{
- LL_WARNS("SyntaxLSL") << "Color key '" << key_in << "' not recognized!" << LL_ENDL;
+ LL_WARNS("SyntaxLSL") << "Color key '" << key_in << "' not recognized." << LL_ENDL;
}
return LLUIColorTable::instance().getColor(color_group);
@@ -267,9 +233,9 @@ void LLKeywords::processTokens()
// Add 'standard' stuff: Quotes, Comments, Strings, Labels, etc. before processing the LLSD
std::string delimiter;
addToken(LLKeywordToken::TT_LABEL, "@", getColorGroup("misc-flow-label"), "Label\nTarget for jump statement", delimiter );
- addToken(LLKeywordToken::TT_ONE_SIDED_DELIMITER, "//", getColorGroup("misc-comments_1_sided"), "Comment (single-line)\nNon-functional commentary or disabled code", delimiter );
- addToken(LLKeywordToken::TT_TWO_SIDED_DELIMITER, "/*", getColorGroup("misc-comments_2_sided"), "Comment (multi-line)\nNon-functional commentary or disabled code", "*/" );
- addToken(LLKeywordToken::TT_DOUBLE_QUOTATION_MARKS, "\"", getColorGroup("misc-double_quotation_marks"), "String literal", "\"" );
+ addToken(LLKeywordToken::TT_ONE_SIDED_DELIMITER, "//", LLUIColorTable::instance().getColor("SyntaxLslComment"), "Comment (single-line)\nNon-functional commentary or disabled code", delimiter );
+ addToken(LLKeywordToken::TT_TWO_SIDED_DELIMITER, "/*", LLUIColorTable::instance().getColor("SyntaxLslComment"), "Comment (multi-line)\nNon-functional commentary or disabled code", "*/" );
+ addToken(LLKeywordToken::TT_DOUBLE_QUOTATION_MARKS, "\"", LLUIColorTable::instance().getColor("SyntaxLslStringLiteral"), "String literal", "\"" );
LLSD::map_iterator itr = mSyntax.beginMap();
for ( ; itr != mSyntax.endMap(); ++itr)
@@ -333,14 +299,14 @@ void LLKeywords::processTokensGroup(const LLSD& tokens, const std::string& group
if (tokens.isMap())
{
LLSD::map_const_iterator outer_itr = tokens.beginMap();
- for ( ; outer_itr != tokens.endMap(); ++outer_itr)
+ for ( ; outer_itr != tokens.endMap(); ++outer_itr )
{
if (outer_itr->second.isMap())
{
mAttributes.clear();
LLSD arguments = LLSD();
LLSD::map_const_iterator inner_itr = outer_itr->second.beginMap();
- for ( ; inner_itr != outer_itr->second.endMap(); ++inner_itr)
+ for ( ; inner_itr != outer_itr->second.endMap(); ++inner_itr )
{
if (inner_itr->first == "arguments")
{
@@ -360,33 +326,34 @@ void LLKeywords::processTokensGroup(const LLSD& tokens, const std::string& group
}
std::string tooltip = "";
- if (token_type == LLKeywordToken::TT_CONSTANT)
+ switch (token_type)
{
- color_group = getColorGroup(group + "-" + getAttribute("type"));
- tooltip = "Type: " + getAttribute("type") + ", Value: " + getAttribute("value");
- }
- else if (token_type == LLKeywordToken::TT_EVENT)
- {
- tooltip = outer_itr->first + "(" + getArguments(arguments) + ")";
- }
- else if (token_type == LLKeywordToken::TT_FUNCTION)
- {
- tooltip = getAttribute("return") + " " + outer_itr->first + "(" + getArguments(arguments) + ");";
- tooltip += "\nEnergy: ";
- tooltip += getAttribute("energy") == "" ? "0.0" : getAttribute("energy");
- if (getAttribute("sleep") != "")
- {
- tooltip += ", Sleep: " + getAttribute("sleep");
- }
+ case LLKeywordToken::TT_CONSTANT:
+ color_group = getColorGroup(group + "-" + getAttribute("type"));
+ tooltip = "Type: " + getAttribute("type") + ", Value: " + getAttribute("value");
+ break;
+ case LLKeywordToken::TT_EVENT:
+ tooltip = outer_itr->first + "(" + getArguments(arguments) + ")";
+ break;
+ case LLKeywordToken::TT_FUNCTION:
+ tooltip = getAttribute("return") + " " + outer_itr->first + "(" + getArguments(arguments) + ");";
+ tooltip.append("\nEnergy: ");
+ tooltip.append(getAttribute("energy").empty() ? "0.0" : getAttribute("energy"));
+ if (!getAttribute("sleep").empty())
+ {
+ tooltip += ", Sleep: " + getAttribute("sleep");
+ }
+ default:
+ break;
}
- if (getAttribute("tooltip") != "")
+ if (!getAttribute("tooltip").empty())
{
- if (tooltip != "")
+ if (!tooltip.empty())
{
- tooltip += "\n";
+ tooltip.append("\n");
}
- tooltip += getAttribute("tooltip");
+ tooltip.append(getAttribute("tooltip"));
}
color = getAttribute("deprecated") == "true" ? color_deprecated : color_group;
@@ -403,7 +370,7 @@ void LLKeywords::processTokensGroup(const LLSD& tokens, const std::string& group
else if (tokens.isArray()) // Currently nothing should need this, but it's here for completeness
{
LL_INFOS("SyntaxLSL") << "Curious, shouldn't be an array here; adding all using color " << color << LL_ENDL;
- for (int count = 0; count < tokens.size(); ++count)
+ for (S32 count = 0; count < tokens.size(); ++count)
{
addToken(token_type, tokens[count], color, "");
}
@@ -433,15 +400,19 @@ LLKeywords::WStringMapIndex::WStringMapIndex(const LLWString& str)
copyData(str.data(), str.size());
}
-LLKeywords::WStringMapIndex::WStringMapIndex(const llwchar *start, size_t length):
-mData(start), mLength(length), mOwner(false)
+LLKeywords::WStringMapIndex::WStringMapIndex(const llwchar *start, size_t length)
+: mData(start)
+, mLength(length)
+, mOwner(false)
{
}
LLKeywords::WStringMapIndex::~WStringMapIndex()
{
- if(mOwner)
+ if (mOwner)
+ {
delete[] mData;
+ }
}
void LLKeywords::WStringMapIndex::copyData(const llwchar *start, size_t length)
@@ -495,34 +466,6 @@ bool LLKeywords::WStringMapIndex::operator<(const LLKeywords::WStringMapIndex &o
return result;
}
-LLColor4 LLKeywords::readColor( const std::string& s )
-{
- F32 r, g, b;
- r = g = b = 0.0f;
- S32 values_read = sscanf(s.c_str(), "%f, %f, %f]", &r, &g, &b );
- if( values_read != 3 )
- {
- llinfos << " poorly formed color in keyword file" << llendl;
- }
- return LLColor4( r, g, b, 1.f);
-}
-
-LLColor4 LLKeywords::readColor(LLSD& sd)
-{
- if (sd.isArray())
- {
- return LLColor4(sd, 1.f);
- }
- else if (sd.isMap())
- {
- return LLColor4( sd.get("x").asReal(), sd.get("y").asReal(), sd.get("z").asReal(), 1.f );
- }
- else
- {
- return LLColor4::black;
- }
-}
-
LLTrace::BlockTimerStatHandle FTM_SYNTAX_COLORING("Syntax Coloring");
// Walk through a string, applying the rules specified by the keyword token list and