From 4e863744db8c66416f78fcc1ac9985643db5e596 Mon Sep 17 00:00:00 2001 From: WyattBlue Date: Sat, 22 Feb 2025 15:22:30 -0500 Subject: [PATCH] Fix progressbar being too small --- auto_editor/utils/bar.py | 26 ++++++++++++++++---------- pyproject.toml | 2 +- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/auto_editor/utils/bar.py b/auto_editor/utils/bar.py index d79d12561..5c3f71172 100644 --- a/auto_editor/utils/bar.py +++ b/auto_editor/utils/bar.py @@ -89,20 +89,26 @@ def tick(self, index: float) -> None: percent = round(progress * 100, 1) p_pad = " " * (4 - len(str(percent))) columns = get_terminal_size().columns - bar_len = max(1, columns - len_title - 32) + bar_len = max(1, columns - len_title - 35) bar_str = self._bar_str(progress, bar_len) - bar = f" {self.icon}{title} {bar_str} {p_pad}{percent}% ETA {new_time}" - - if len(bar) > columns - 2: - bar = bar[: columns - 2] - else: - bar += " " * (columns - len(bar) - 4) - - sys.stdout.write(bar + "\r") + bar = f" {self.icon}{title} {bar_str} {p_pad}{percent}% ETA {new_time} \r" + sys.stdout.write(bar) def start(self, total: float, title: str = "Please wait") -> None: - self.stack.append((title, len(title), total, time())) + len_title = 0 + in_escape = False + + for char in title: + if not in_escape: + if char == "\033": + in_escape = True + else: + len_title += 1 + elif char == "m": + in_escape = False + + self.stack.append((title, len_title, total, time())) try: self.tick(0) diff --git a/pyproject.toml b/pyproject.toml index 2116d15ba..e011629dd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ authors = [{ name = "WyattBlue", email = "wyattblue@auto-editor.com" }] requires-python = ">=3.10,<3.14" dependencies = [ "numpy>=1.24,<3.0", - "pyav==14.2.0", + "pyav==14.2.*", ] keywords = [ "video", "audio", "media", "editor", "editing",