about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2026-07-04 19:18:45 +0300
committerAndrew Dolgov <fox@fakecake.org>2026-07-04 19:18:45 +0300
commit3b8d30d74695d596b42911bdd65c0474f4a843db (patch)
treed19961a34d7eeb0cb06b3ee1965d6f0e4f0ccf2b
parentecd6b555d957ebfc2717364399d8bbb3f29b6673 (diff)
downloadfungus-launcher-3b8d30d74695d596b42911bdd65c0474f4a843db.tar.gz
fungus-launcher-3b8d30d74695d596b42911bdd65c0474f4a843db.tar.xz
show stdout/stderr in different colors instead of prefixes and remove previous accumulated stderr thing
-rw-r--r--fungus/game_launcher.py11
-rw-r--r--fungus/run_manager.py10
-rw-r--r--fungus/splash_window.py36
3 files changed, 34 insertions, 23 deletions
diff --git a/fungus/game_launcher.py b/fungus/game_launcher.py
index 3e88161..fb0806d 100644
--- a/fungus/game_launcher.py
+++ b/fungus/game_launcher.py
@@ -102,14 +102,13 @@ class GameLauncher:
         on_proton_missing: Callable[[], None] | None = None,
         on_proton_path_missing: Callable[[str], None] | None = None,
         on_spawn_error: Callable[[str], None] | None = None,
-        on_process_fail: Callable[[int, list[str]], None] | None = None,
+        on_process_fail: Callable[[int], None] | None = None,
         on_splash_close: Callable[[], None] | None = None,
         on_process_started: Callable[[], None] | None = None,
     ):
         self.game = game
         self.igpu = igpu
         self.process: subprocess.Popen | None = None
-        self.error_output: list[str] = []
         self._cleanup_event = Event()
         self._on_output_line = on_output_line
         self._on_error = on_error
@@ -291,7 +290,7 @@ class GameLauncher:
 
         # ── Inner command ───────────────────────────────────────────
         inner_cmd: list[str] = [umu_run, game.path]
-        # inner_cmd: list[str] = ["/bin/bash", "-c", f"{umu_run} \"{game.path}\" ; exit 100"]
+        # inner_cmd: list[str] = ["/bin/bash", "-c", f"{umu_run} \"{game.path}\" 2>&1 ; exit 100"]
         if game.game_arguments:
             inner_cmd.append(game.game_arguments)
 
@@ -478,7 +477,7 @@ class GameLauncher:
         else:
             log.warning("Process exited with code %d", exit_code)
             if self._on_process_fail:
-                self._on_process_fail(exit_code, self.error_output)
+                self._on_process_fail(exit_code)
 
     # ── Watchdog ──────────────────────────────────────────────────────
 
@@ -579,9 +578,7 @@ class GameLauncher:
 
         log.debug("_on_io_line: [%s] %s", "err" if is_stderr else "out", clean_line)
 
-        # Accumulate stderr for error reporting
-        if is_stderr:
-            self.error_output.append(clean_line)
+
 
         # Dispatch to callback
         if self._on_output_line:
diff --git a/fungus/run_manager.py b/fungus/run_manager.py
index 851aa15..03df048 100644
--- a/fungus/run_manager.py
+++ b/fungus/run_manager.py
@@ -108,10 +108,12 @@ def handle_command(
     splash_container: list[SplashWindow | None] = [None]  # mutable container for forward reference
 
     def on_output_line(line: str, is_stderr: bool) -> None:
-        prefix = "[err] " if is_stderr else "[out] "
+        color = "#e06c75" if is_stderr else None  # soft red for stderr
         s = splash_container[0]
         if s is not None:
-            GLib.idle_add(s.append_output, f"{prefix}{line}")
+            GLib.idle_add(
+                lambda: s.append_output(f"{line}", color=color)
+            )
 
     def on_error(msg: str) -> None:
         log.error("GameLauncher error: %s", msg)
@@ -123,12 +125,12 @@ def handle_command(
             GLib.idle_add(s._destroy)
         GLib.idle_add(Gtk.main_quit)
 
-    def on_process_fail(exit_code: int, error_output: list[str]) -> None:
+    def on_process_fail(exit_code: int) -> None:
         """Handle a non-zero process exit — show error in the splash."""
         log.debug("on_process_fail: exit_code=%d", exit_code)
         s = splash_container[0]
         if s is not None:
-            GLib.idle_add(s.show_error, exit_code, error_output)
+            GLib.idle_add(s.show_error, exit_code)
         else:
             log.warning("Splash unavailable for error display (exit_code=%d)", exit_code)
             # Splash was already destroyed — quit GTK so the app doesn't hang.
diff --git a/fungus/splash_window.py b/fungus/splash_window.py
index cf8a7bc..a65e19a 100644
--- a/fungus/splash_window.py
+++ b/fungus/splash_window.py
@@ -96,34 +96,52 @@ class SplashWindow:
 
     # ── Public API ────────────────────────────────────────────────────────
 
-    def append_output(self, line: str) -> None:
+    def append_output(
+        self, line: str, *, color: str | None = None, bold: bool = False,
+    ) -> None:
         """Append a line of output to the text view.
 
         Parameters
         ----------
         line : str
             Text line to append.
+        color : str, optional
+            Pango color name (e.g. ``"red"``, ``"#888888"``).
+        bold : bool, default False
+            Whether to render the line in bold.
         """
         if self._buffer is None or self._text_view is None:
             return
 
+        # Wrap in Pango markup if styling is requested.
+        if color or bold:
+            attrs: list[str] = []
+            if color:
+                attrs.append(f"foreground=\"{color}\"")
+            if bold:
+                attrs.append("weight=bold")
+            markup = f"<span {' '.join(attrs)}>{line}</span>"
+        else:
+            markup = line
+
         end = self._buffer.get_end_iter()
-        self._buffer.insert(end, line + "\n")
+        self._buffer.insert_markup(end, markup + "\n", -1)
         self._text_view.scroll_to_iter(end, 0.0, True, 0.0, 1.0)
 
         # Reveal output view on first output
         if self._scrolled is not None:
             self._scrolled.set_visible(True)
 
-    def show_error(self, exit_code: int, stderr_lines: list[str]) -> None:
-        """Show error information in the splash window.
+    def show_error(self, exit_code: int) -> None:
+        """Re-show the splash after a failed process exit.
+
+        The live stream already displayed stderr, so we just update the
+        title and reveal the Close button.
 
         Parameters
         ----------
         exit_code : int
             Non-zero process exit code.
-        stderr_lines : list[str]
-            Accumulated stderr output.
         """
         assert self._window is not None
 
@@ -134,12 +152,6 @@ class SplashWindow:
         current_title = self._window.get_title() or ""
         self._window.set_title(f"{current_title} — exited with code {exit_code}")
 
-        # Show accumulated stderr in the text view
-        if stderr_lines and self._buffer is not None:
-            error_text = "\n".join(stderr_lines)
-            self.append_output(f"\n--- stderr ({len(stderr_lines)} lines) ---")
-            self.append_output(error_text)
-
         # Reveal output view and close button
         if self._scrolled is not None:
             self._scrolled.set_visible(True)