Files
mistral-vibe/vibe/cli/textual_ui/widgets/path_display.py
Quentin Torroba fa15fc977b 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>
2025-12-09 13:13:22 +01:00

29 lines
727 B
Python

from __future__ import annotations
from pathlib import Path
from textual.widgets import Static
class PathDisplay(Static):
def __init__(self, path: Path | str) -> None:
super().__init__()
self.can_focus = False
self._path = Path(path)
self._update_display()
def _update_display(self) -> None:
path_str = str(self._path)
try:
home = Path.home()
if self._path.is_relative_to(home):
path_str = f"~/{self._path.relative_to(home)}"
except (ValueError, OSError):
pass
self.update(path_str)
def set_path(self, path: Path | str) -> None:
self._path = Path(path)
self._update_display()