@@ -73,6 +73,7 @@ class EsptoolLogger(TemplateLogger):
73
73
ansi_clear : str = ""
74
74
ansi_line_up : str = ""
75
75
ansi_line_clear : str = ""
76
+ ansi_line_up_pos1 : str = ""
76
77
77
78
_stage_active : bool = False
78
79
_newline_count : int = 0
@@ -115,7 +116,7 @@ def _set_smart_features(cls, override: bool | None = None):
115
116
116
117
# Determine if colors should be enabled
117
118
cls .instance ._smart_features = (
118
- is_tty and term_supports_color and not no_color
119
+ is_tty or term_supports_color and not no_color
119
120
)
120
121
# Handle Windows specifically
121
122
if sys .platform == "win32" and cls .instance ._smart_features :
@@ -134,6 +135,7 @@ def _set_smart_features(cls, override: bool | None = None):
134
135
cls .instance .ansi_clear = "\033 [K"
135
136
cls .instance .ansi_line_up = "\033 [1A"
136
137
cls .instance .ansi_line_clear = "\x1b [2K"
138
+ cls .instance .ansi_line_up_pos1 = "\033 [F"
137
139
else :
138
140
cls .instance .ansi_red = ""
139
141
cls .instance .ansi_yellow = ""
@@ -142,6 +144,7 @@ def _set_smart_features(cls, override: bool | None = None):
142
144
cls .instance .ansi_clear = ""
143
145
cls .instance .ansi_line_up = ""
144
146
cls .instance .ansi_line_clear = ""
147
+ cls .instance .ansi_line_up_pos1 = ""
145
148
146
149
def print (self , * args , ** kwargs ):
147
150
"""
@@ -228,18 +231,13 @@ def progress_bar(
228
231
Call in a loop to print a progress bar overwriting itself in place.
229
232
If terminal doesn't support ANSI escape codes, no overwriting happens.
230
233
"""
231
- filled = int (bar_length * cur_iter // total_iters )
232
- if filled == bar_length :
233
- bar = "=" * bar_length
234
- elif filled == 0 :
235
- bar = " " * bar_length
236
- else :
237
- bar = f"{ '=' * (filled - 1 )} >{ ' ' * (bar_length - filled )} "
238
-
239
234
percent = f"{ 100 * (cur_iter / float (total_iters )):.1f} "
235
+ filled_length = int (bar_length * cur_iter // total_iters )
236
+ bar = '█' * filled_length + '░' * (bar_length - filled_length )
237
+
240
238
self .print (
241
239
f"\r { self .ansi_clear } { prefix } [{ bar } ] { percent :>5} %{ suffix } " ,
242
- end = "\n " if not self ._smart_features or cur_iter == total_iters else " " ,
240
+ end = "\n " if not self ._smart_features or cur_iter == total_iters else f" { self . ansi_line_up_pos1 } " ,
243
241
flush = True ,
244
242
)
245
243
0 commit comments