| 87 | } |
| 88 | |
| 89 | SyntaxColorScheme::Style parseStyle( |
| 90 | const std::string& value, bool* colorWasSet = nullptr, |
| 91 | const UnorderedMap<SyntaxStyleType, SyntaxColorScheme::Style>* syntaxColors = nullptr ) { |
| 92 | static const std::string outline = "outline"; |
| 93 | auto values = String::split( value, ",", "", "()" ); |
| 94 | SyntaxColorScheme::Style style; |
| 95 | bool colorSet = false; |
| 96 | for ( auto& val : values ) { |
| 97 | String::toLowerInPlace( val ); |
| 98 | String::trimInPlace( val ); |
| 99 | if ( Color::isColorString( val ) ) { |
| 100 | if ( !colorSet ) { |
| 101 | style.color = Color::fromString( val ); |
| 102 | colorSet = true; |
| 103 | } else { |
| 104 | style.background = Color::fromString( val ); |
| 105 | } |
| 106 | } else { |
| 107 | if ( "regular" == val ) |
| 108 | style.style |= Text::Regular; |
| 109 | else if ( "bold" == val ) |
| 110 | style.style |= Text::Bold; |
| 111 | else if ( "italic" == val ) |
| 112 | style.style |= Text::Italic; |
| 113 | else if ( "underline" == val || "underlined" == val ) |
| 114 | style.style |= Text::Underlined; |
| 115 | else if ( "strikethrough" == val || "line-through" == val ) |
| 116 | style.style |= Text::StrikeThrough; |
| 117 | else if ( "shadow" == val ) |
| 118 | style.style |= Text::Shadow; |
| 119 | else if ( String::startsWith( val, outline ) ) { |
| 120 | auto res = FunctionString::parse( val ); |
| 121 | if ( !res.isEmpty() ) { |
| 122 | for ( const auto& param : res.getParameters() ) { |
| 123 | if ( Color::isColorString( param ) ) { |
| 124 | style.outlineColor = Color::fromString( param ); |
| 125 | } else if ( String::isNumber( param, true ) ) { |
| 126 | Float f; |
| 127 | if ( String::fromString( f, param ) ) |
| 128 | style.outlineThickness = f; |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | } else if ( syntaxColors && |
| 133 | ( "normal" == val || "symbol" == val || "comment" == val || |
| 134 | "keyword" == val || "keyword2" == val || "keyword3" == val || |
| 135 | "number" == val || "literal" == val || "string" == val || |
| 136 | "opetaror" == val || "function" == val || "link" == val || |
| 137 | "link_hover" == val || "type" == val || "parameter" == val ) ) { |
| 138 | auto styleIt = syntaxColors->find( toSyntaxStyleType( val ) ); |
| 139 | if ( styleIt != syntaxColors->end() ) { |
| 140 | style = styleIt->second; |
| 141 | colorSet = true; |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | if ( colorWasSet ) |
no test coverage detected