From 3a5a46253df244b5c0d2ff05ddcb511c04077805 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 8 May 2025 15:57:56 -0700 Subject: [PATCH] feat: redesign spinner animation with tail --- aider/utils.py | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/aider/utils.py b/aider/utils.py index 0ec5ad5cc..b8b1e7b15 100644 --- a/aider/utils.py +++ b/aider/utils.py @@ -267,36 +267,43 @@ class Spinner: # Pre-render the animation frames using pure ASCII so they will # always display, even on very limited terminals. - ascii_forward = """ -[#------] -[-#-----] -[--#----] -[---#---] -[----#--] -[-----#-] -[------#] + ascii_frames = """ +[#=-----] +[=#-----] +[-=#----] +[--=#---] +[---=#--] +[----=#-] +[-----=#] +[-----#=] +[----#=-] +[---#=--] +[---#=--] +[---#=--] +[--#=---] +[-#=----] """.strip().splitlines() # If unicode is supported, swap the ASCII chars for nicer glyphs. if self._supports_unicode(): - scan_char, trail_char = "≡", "─" - forward = [f.replace("#", scan_char).replace("-", trail_char) for f in ascii_forward] + scan_char, tail_char, trail_char = "≡", "=", "─" + frames = [f.replace("#", scan_char).replace("-", trail_char) for f in ascii_frames] else: - scan_char, trail_char = "#", "-" - forward = ascii_forward + scan_char, tail_char, trail_char = "#", "=", "-" + frames = ascii_frames # Bounce the scanner back and forth. - self.frames = forward + forward[-2:0:-1] + self.frames = frames self.frame_idx = 0 self.scan_char = scan_char - self.width = len(forward[0]) - 2 # number of chars between the brackets - self.animation_len = len(forward[0]) + self.width = len(frames[0]) - 2 # number of chars between the brackets + self.animation_len = len(frames[0]) def _supports_unicode(self) -> bool: if not self.is_tty: return False try: - sys.stdout.write("∎\b \b") + sys.stdout.write("≡\b─\b") sys.stdout.flush() return True except UnicodeEncodeError: