File tree Expand file tree Collapse file tree
colcon_notification/event_handler Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222from colcon_core .subprocess import SIGINT_RESULT
2323
2424
25+ def _colorama_str_len (s ):
26+ in_code = False
27+ l = 1
28+ for c in s :
29+ if c == '\033 ' :
30+ in_code = True
31+ elif c == 'm' and in_code :
32+ in_code = False
33+ elif not in_code :
34+ l += 1
35+ return l
36+
37+
2538class StatusEventHandler (EventHandlerExtensionPoint ):
2639 """
2740 Continuously update a status line.
@@ -173,13 +186,13 @@ def __call__(self, event): # noqa: D102
173186 # append dots when skipping at least one block
174187 if i < len (blocks ) - 1 :
175188 msg += ' ...'
176- if len (msg ) < max_width :
189+ if _colorama_str_len (msg ) < max_width :
177190 break
178191 else :
179192 return
180193
181194 print (msg , end = '\r ' )
182- self ._last_status_line_length = len (msg )
195+ self ._last_status_line_length = _colorama_str_len (msg )
183196
184197 elif isinstance (data , EventReactorShutdown ):
185198 self ._clear_last_status_line ()
You can’t perform that action at this time.
0 commit comments