@@ -271,23 +271,38 @@ def _handle_app_studio_traj(self, block, indent=0, arg_map=None):
271
271
272
272
def _handle_tool_message (self , block , indent = 0 , arg_map = None ):
273
273
fields = self ._get_nodes ('field' , block )
274
+ color = json .dumps (fields [0 ].text , ensure_ascii = False ) if len (fields ) > 1 else 'white'
274
275
msg = json .dumps (fields [1 ].text if fields [- 1 ].text is not None else '' , ensure_ascii = False )
275
- self ._append_main_code ('print({})' .format (msg ), indent + 2 )
276
+ if self ._highlight_callback is not None :
277
+ self ._append_main_code ('print({}, {})' .format (msg , color ), indent + 2 )
278
+ else :
279
+ self ._append_main_code ('print({})' .format (msg ), indent + 2 )
276
280
277
281
def _handle_tool_console (self , block , indent = 0 , arg_map = None ):
278
282
fields = self ._get_nodes ('field' , block )
283
+ color = json .dumps (fields [0 ].text , ensure_ascii = False ) if len (fields ) > 1 else 'white'
279
284
msg = json .dumps (fields [1 ].text if fields [- 1 ].text is not None else '' , ensure_ascii = False )
280
- self ._append_main_code ('print({})' .format (msg ), indent + 2 )
285
+ if self ._highlight_callback is not None :
286
+ self ._append_main_code ('print({}, {})' .format (msg , color ), indent + 2 )
287
+ else :
288
+ self ._append_main_code ('print({})' .format (msg ), indent + 2 )
281
289
282
290
def _handle_tool_console_with_variable (self , block , indent = 0 , arg_map = None ):
283
291
fields = self ._get_nodes ('field' , block )
292
+ color = json .dumps (fields [0 ].text , ensure_ascii = False )
284
293
msg = fields [1 ].text
285
294
value = self ._get_node ('value' , block )
286
295
expression = self ._get_condition_expression (value , arg_map = arg_map )
287
296
if msg :
288
- self ._append_main_code ('print({}.format({}))' .format (json .dumps (msg + '{}' , ensure_ascii = False ), expression ), indent + 2 )
297
+ if self ._highlight_callback is not None :
298
+ self ._append_main_code ('print({}.format({}), {})' .format (json .dumps (msg + '{}' , ensure_ascii = False ), expression , color ), indent + 2 )
299
+ else :
300
+ self ._append_main_code ('print({}.format({}))' .format (json .dumps (msg + '{}' , ensure_ascii = False ), expression ), indent + 2 )
289
301
else :
290
- self ._append_main_code ('print(\' {{}}\' .format({}))' .format (expression ), indent + 2 )
302
+ if self ._highlight_callback is not None :
303
+ self ._append_main_code ('print(\' {{}}\' .format({}), {})' .format (expression , color ), indent + 2 )
304
+ else :
305
+ self ._append_main_code ('print(\' {{}}\' .format({}))' .format (expression ), indent + 2 )
291
306
292
307
def _handle_wait (self , block , indent = 0 , arg_map = None ):
293
308
value = self ._get_node ('value' , root = block )
0 commit comments