fix: handle inverse video rendering for nano's white bar

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 <noreply@anthropic.com>
This commit is contained in:
Mario Zechner 2025-06-20 22:50:27 +02:00
parent 5593ee39ef
commit dc2e72e052

View file

@ -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