mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 02:05:00 +00:00
refactor: Use str.translate for spinner unicode mapping
This commit is contained in:
parent
aad6838e15
commit
647f556582
1 changed files with 6 additions and 6 deletions
|
@ -284,20 +284,20 @@ class Spinner:
|
||||||
[ #=- ]
|
[ #=- ]
|
||||||
""".strip().splitlines()
|
""".strip().splitlines()
|
||||||
|
|
||||||
xlate = ("-=#", "≈≋≣")
|
xlate_from, xlate_to = ("-=#", "≈≋≣")
|
||||||
|
|
||||||
# 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 = "≣", ""
|
translation_table = str.maketrans(xlate_from, xlate_to)
|
||||||
frames = [f.replace("#", scan_char).replace("-", trail_char) for f in ascii_frames]
|
frames = [f.translate(translation_table) for f in ascii_frames]
|
||||||
|
self.scan_char = xlate_to[xlate_from.find("#")]
|
||||||
else:
|
else:
|
||||||
scan_char, _ = "#", "-"
|
|
||||||
frames = ascii_frames
|
frames = ascii_frames
|
||||||
|
self.scan_char = "#"
|
||||||
|
|
||||||
# Bounce the scanner back and forth.
|
# Bounce the scanner back and forth.
|
||||||
self.frames = frames
|
self.frames = frames
|
||||||
self.frame_idx = Spinner.last_frame_idx # Initialize from class variable
|
self.frame_idx = Spinner.last_frame_idx # Initialize from class variable
|
||||||
self.scan_char = scan_char
|
|
||||||
self.width = len(frames[0]) - 2 # number of chars between the brackets
|
self.width = len(frames[0]) - 2 # number of chars between the brackets
|
||||||
self.animation_len = len(frames[0])
|
self.animation_len = len(frames[0])
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue