Initial commit
Co-Authored-By: Quentin Torroba <quentin.torroba@mistral.ai> Co-Authored-By: Laure Hugo <laure.hugo@mistral.ai> Co-Authored-By: Benjamin Trom <benjamin.trom@mistral.ai> Co-Authored-By: Mathias Gesbert <mathias.gesbert@ext.mistral.ai> Co-Authored-By: Michel Thomazo <michel.thomazo@mistral.ai> Co-Authored-By: Clément Drouin <clement.drouin@mistral.ai> Co-Authored-By: Vincent Guilloux <vincent.guilloux@mistral.ai> Co-Authored-By: Valentin Berard <val@mistral.ai> Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
commit
fa15fc977b
200 changed files with 30484 additions and 0 deletions
67
vibe/cli/textual_ui/widgets/blinking_message.py
Normal file
67
vibe/cli/textual_ui/widgets/blinking_message.py
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from textual.app import ComposeResult
|
||||
from textual.containers import Horizontal
|
||||
from textual.widgets import Static
|
||||
|
||||
|
||||
class BlinkingMessage(Static):
|
||||
def __init__(self, initial_text: str = "", **kwargs: Any) -> None:
|
||||
self.blink_state = False
|
||||
self._blink_timer = None
|
||||
self._is_blinking = True
|
||||
self.success = True
|
||||
self._initial_text = initial_text
|
||||
self._dot_widget: Static | None = None
|
||||
self._text_widget: Static | None = None
|
||||
super().__init__(**kwargs)
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
with Horizontal():
|
||||
self._dot_widget = Static("● ", classes="blink-dot")
|
||||
yield self._dot_widget
|
||||
self._text_widget = Static("", markup=False, classes="blink-text")
|
||||
yield self._text_widget
|
||||
|
||||
def on_mount(self) -> None:
|
||||
self.update_display()
|
||||
self._blink_timer = self.set_interval(0.5, self.toggle_blink)
|
||||
|
||||
def toggle_blink(self) -> None:
|
||||
if not self._is_blinking:
|
||||
return
|
||||
self.blink_state = not self.blink_state
|
||||
self.update_display()
|
||||
|
||||
def update_display(self) -> None:
|
||||
if not self._dot_widget or not self._text_widget:
|
||||
return
|
||||
|
||||
content = self.get_content()
|
||||
|
||||
if self._is_blinking:
|
||||
dot = "● " if self.blink_state else "○ "
|
||||
self._dot_widget.update(dot)
|
||||
self._dot_widget.remove_class("success")
|
||||
self._dot_widget.remove_class("error")
|
||||
else:
|
||||
self._dot_widget.update("● ")
|
||||
if self.success:
|
||||
self._dot_widget.add_class("success")
|
||||
self._dot_widget.remove_class("error")
|
||||
else:
|
||||
self._dot_widget.add_class("error")
|
||||
self._dot_widget.remove_class("success")
|
||||
|
||||
self._text_widget.update(content)
|
||||
|
||||
def get_content(self) -> str:
|
||||
return self._initial_text
|
||||
|
||||
def stop_blinking(self, success: bool = True) -> None:
|
||||
self._is_blinking = False
|
||||
self.blink_state = True
|
||||
self.success = success
|
||||
self.update_display()
|
||||
Loading…
Add table
Add a link
Reference in a new issue