mirror of
https://github.com/mistralai/mistral-vibe
synced 2026-04-26 01:24:55 +02:00
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>
29 lines
727 B
Python
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()
|