MCPcopy Create free account
hub / github.com/SpartanJ/eepp / parseStyle

Function parseStyle

src/eepp/ui/doc/syntaxcolorscheme.cpp:89–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89SyntaxColorScheme::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 )

Callers 2

loadFromStreamMethod · 0.85

Calls 5

fromStringFunction · 0.85
toSyntaxStyleTypeFunction · 0.85
isEmptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected