@@ -139,32 +139,47 @@ void AnnotateCommentOffset(ANNOTATOR_PARAMS)
139
139
void AnnotateColor (ANNOTATOR_PARAMS)
140
140
{
141
141
pugi::xml_attribute attr = node.attribute (" color" );
142
- if (attr.empty ())
142
+ if (attr.empty ())
143
143
return ;
144
144
145
- std::string color = attr.as_string ( );
146
- if (color == " " )
145
+ int color = attr.as_int (- 1 );
146
+ if (color < 0 )
147
147
return ;
148
148
149
149
RSyntaxHighlightType type;
150
- if (color == " keyword" )
151
- type = RZ_SYNTAX_HIGHLIGHT_TYPE_KEYWORD;
152
- else if (color == " comment" )
153
- type = RZ_SYNTAX_HIGHLIGHT_TYPE_COMMENT;
154
- else if (color == " type" )
155
- type = RZ_SYNTAX_HIGHLIGHT_TYPE_DATATYPE;
156
- else if (color == " funcname" )
157
- type = RZ_SYNTAX_HIGHLIGHT_TYPE_FUNCTION_NAME;
158
- else if (color == " param" )
159
- type = RZ_SYNTAX_HIGHLIGHT_TYPE_FUNCTION_PARAMETER;
160
- else if (color == " var" )
161
- type = RZ_SYNTAX_HIGHLIGHT_TYPE_LOCAL_VARIABLE;
162
- else if (color == " const" )
163
- type = RZ_SYNTAX_HIGHLIGHT_TYPE_CONSTANT_VARIABLE;
164
- else if (color == " global" )
165
- type = RZ_SYNTAX_HIGHLIGHT_TYPE_GLOBAL_VARIABLE;
166
- else
167
- return ;
150
+ switch (color)
151
+ {
152
+ case Emit::syntax_highlight::keyword_color:
153
+ type = RZ_SYNTAX_HIGHLIGHT_TYPE_KEYWORD;
154
+ break ;
155
+ case Emit::syntax_highlight::comment_color:
156
+ type = RZ_SYNTAX_HIGHLIGHT_TYPE_COMMENT;
157
+ break ;
158
+ case Emit::syntax_highlight::type_color:
159
+ type = RZ_SYNTAX_HIGHLIGHT_TYPE_DATATYPE;
160
+ break ;
161
+ case Emit::syntax_highlight::funcname_color:
162
+ type = RZ_SYNTAX_HIGHLIGHT_TYPE_FUNCTION_NAME;
163
+ break ;
164
+ case Emit::syntax_highlight::var_color:
165
+ type = RZ_SYNTAX_HIGHLIGHT_TYPE_LOCAL_VARIABLE;
166
+ break ;
167
+ case Emit::syntax_highlight::const_color:
168
+ type = RZ_SYNTAX_HIGHLIGHT_TYPE_CONSTANT_VARIABLE;
169
+ break ;
170
+ case Emit::syntax_highlight::param_color:
171
+ type = RZ_SYNTAX_HIGHLIGHT_TYPE_FUNCTION_PARAMETER;
172
+ break ;
173
+ case Emit::syntax_highlight::global_color:
174
+ type = RZ_SYNTAX_HIGHLIGHT_TYPE_GLOBAL_VARIABLE;
175
+ break ;
176
+ case Emit::syntax_highlight::no_color:
177
+ case Emit::syntax_highlight::error_color:
178
+ case Emit::syntax_highlight::special_color:
179
+ default :
180
+ return ;
181
+ }
182
+
168
183
RzCodeAnnotation annotation = {};
169
184
annotation.type = RZ_CODE_ANNOTATION_TYPE_SYNTAX_HIGHLIGHT;
170
185
annotation.syntax_highlight .type = type;
0 commit comments