mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
feat: Hide cursor when spinner is active
This commit is contained in:
parent
edb3bf84cc
commit
81b86441fd
1 changed files with 5 additions and 0 deletions
|
@ -7,6 +7,7 @@ import time
|
|||
from pathlib import Path
|
||||
|
||||
import oslex
|
||||
from rich.console import Console
|
||||
|
||||
from aider.dump import dump # noqa: F401
|
||||
|
||||
|
@ -266,6 +267,7 @@ class Spinner:
|
|||
self.last_update = 0.0
|
||||
self.visible = False
|
||||
self.is_tty = sys.stdout.isatty()
|
||||
self.console = Console()
|
||||
|
||||
# Pre-render the animation frames using pure ASCII so they will
|
||||
# always display, even on very limited terminals.
|
||||
|
@ -338,6 +340,8 @@ class Spinner:
|
|||
if not self.visible and now - self.start_time >= 0.5:
|
||||
self.visible = True
|
||||
self.last_update = 0.0
|
||||
if self.is_tty:
|
||||
self.console.show_cursor(False)
|
||||
|
||||
if not self.visible or now - self.last_update < 0.1:
|
||||
return
|
||||
|
@ -359,6 +363,7 @@ class Spinner:
|
|||
clear_len = len(self.text) + 1 + self.animation_len
|
||||
sys.stdout.write("\r" + " " * clear_len + "\r")
|
||||
sys.stdout.flush()
|
||||
self.console.show_cursor(True)
|
||||
self.visible = False
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue