mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-03 03:05:00 +00:00
feat: redesign spinner animation with tail
This commit is contained in:
parent
5bb891b2bb
commit
3a5a46253d
1 changed files with 23 additions and 16 deletions
|
@ -267,36 +267,43 @@ class Spinner:
|
||||||
|
|
||||||
# Pre-render the animation frames using pure ASCII so they will
|
# Pre-render the animation frames using pure ASCII so they will
|
||||||
# always display, even on very limited terminals.
|
# always display, even on very limited terminals.
|
||||||
ascii_forward = """
|
ascii_frames = """
|
||||||
[#------]
|
[#=-----]
|
||||||
[-#-----]
|
[=#-----]
|
||||||
[--#----]
|
[-=#----]
|
||||||
[---#---]
|
[--=#---]
|
||||||
[----#--]
|
[---=#--]
|
||||||
[-----#-]
|
[----=#-]
|
||||||
[------#]
|
[-----=#]
|
||||||
|
[-----#=]
|
||||||
|
[----#=-]
|
||||||
|
[---#=--]
|
||||||
|
[---#=--]
|
||||||
|
[---#=--]
|
||||||
|
[--#=---]
|
||||||
|
[-#=----]
|
||||||
""".strip().splitlines()
|
""".strip().splitlines()
|
||||||
|
|
||||||
# If unicode is supported, swap the ASCII chars for nicer glyphs.
|
# If unicode is supported, swap the ASCII chars for nicer glyphs.
|
||||||
if self._supports_unicode():
|
if self._supports_unicode():
|
||||||
scan_char, trail_char = "≡", "─"
|
scan_char, tail_char, trail_char = "≡", "=", "─"
|
||||||
forward = [f.replace("#", scan_char).replace("-", trail_char) for f in ascii_forward]
|
frames = [f.replace("#", scan_char).replace("-", trail_char) for f in ascii_frames]
|
||||||
else:
|
else:
|
||||||
scan_char, trail_char = "#", "-"
|
scan_char, tail_char, trail_char = "#", "=", "-"
|
||||||
forward = ascii_forward
|
frames = ascii_frames
|
||||||
|
|
||||||
# Bounce the scanner back and forth.
|
# Bounce the scanner back and forth.
|
||||||
self.frames = forward + forward[-2:0:-1]
|
self.frames = frames
|
||||||
self.frame_idx = 0
|
self.frame_idx = 0
|
||||||
self.scan_char = scan_char
|
self.scan_char = scan_char
|
||||||
self.width = len(forward[0]) - 2 # number of chars between the brackets
|
self.width = len(frames[0]) - 2 # number of chars between the brackets
|
||||||
self.animation_len = len(forward[0])
|
self.animation_len = len(frames[0])
|
||||||
|
|
||||||
def _supports_unicode(self) -> bool:
|
def _supports_unicode(self) -> bool:
|
||||||
if not self.is_tty:
|
if not self.is_tty:
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
sys.stdout.write("∎\b \b")
|
sys.stdout.write("≡\b─\b")
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
return True
|
return True
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue