mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 01:04:59 +00:00
fix: add fallback to ASCII spinner when Unicode is not supported
This commit is contained in:
parent
4c2bc47bf3
commit
d87f9fbd79
1 changed files with 11 additions and 1 deletions
|
@ -268,7 +268,8 @@ def run_install(cmd):
|
||||||
|
|
||||||
|
|
||||||
class Spinner:
|
class Spinner:
|
||||||
spinner_chars = itertools.cycle(["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"])
|
unicode_spinner = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]
|
||||||
|
ascii_spinner = ["|", "/", "-", "\\"]
|
||||||
|
|
||||||
def __init__(self, text):
|
def __init__(self, text):
|
||||||
self.text = text
|
self.text = text
|
||||||
|
@ -276,6 +277,15 @@ class Spinner:
|
||||||
self.last_update = 0
|
self.last_update = 0
|
||||||
self.visible = False
|
self.visible = False
|
||||||
self.is_tty = sys.stdout.isatty()
|
self.is_tty = sys.stdout.isatty()
|
||||||
|
|
||||||
|
# Try unicode first, fall back to ascii if needed
|
||||||
|
try:
|
||||||
|
# Test if we can print unicode characters
|
||||||
|
print(self.unicode_spinner[0], end="", flush=True)
|
||||||
|
print("\r", end="", flush=True)
|
||||||
|
self.spinner_chars = itertools.cycle(self.unicode_spinner)
|
||||||
|
except UnicodeEncodeError:
|
||||||
|
self.spinner_chars = itertools.cycle(self.ascii_spinner)
|
||||||
|
|
||||||
def step(self):
|
def step(self):
|
||||||
if not self.is_tty:
|
if not self.is_tty:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue