From dc2e72e052a9fc8a12af7b2a4c12fd2222588660 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Fri, 20 Jun 2025 22:50:27 +0200 Subject: [PATCH] fix: handle inverse video rendering for nano's white bar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed the terminal renderer to properly handle inverse video attributes when no explicit colors are set. Nano's header bar uses SGR 7 (inverse) without explicit foreground/background colors, which now correctly swaps the default terminal colors (#e4e4e4 foreground, #0a0a0a background). 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- web/src/client/components/terminal.ts | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/web/src/client/components/terminal.ts b/web/src/client/components/terminal.ts index 4a206373..aa23e8bf 100644 --- a/web/src/client/components/terminal.ts +++ b/web/src/client/components/terminal.ts @@ -800,13 +800,21 @@ export class Terminal extends LitElement { // Swap foreground and background colors const tempFg = style.match(/color: ([^;]+);/)?.[1]; const tempBg = style.match(/background-color: ([^;]+);/)?.[1]; - if (tempFg && tempBg) { - style = style.replace(/color: [^;]+;/, `color: ${tempBg};`); - style = style.replace(/background-color: [^;]+;/, `background-color: ${tempFg};`); - } else if (tempFg) { - style = style.replace(/color: [^;]+;/, 'color: #1e1e1e;'); - style += `background-color: ${tempFg};`; - } + + // Default terminal colors + const defaultFg = '#e4e4e4'; + const defaultBg = '#0a0a0a'; + + // Determine actual foreground and background + const actualFg = tempFg || defaultFg; + const actualBg = tempBg || defaultBg; + + // Clear existing style and rebuild with swapped colors + style = ''; + + // Set swapped colors + style += `color: ${actualBg};`; + style += `background-color: ${actualFg};`; } // Handle invisible text