Match the terminal's colours: auto from its background, and a terminal theme
auto now reads the background through OpenTUI's palette detector (OSC 11) and falls back to dark. The new terminal theme builds the palette from the detected background, foreground and ANSI colours, and shows in settings.
This commit is contained in:
1 parent
c1a7376aa8
commit
f18fc9c68d
7 files changed
+143
-12
No files matched your search
+8
-3
@@ -162,9 +162,14 @@ async function runUi(attachNeedle?: string) {
|
||||
setInterval(() => {
|
||||
if (Date.now() - lastInput > 5_000) Bun.gc(true);
|
||||
}, 30_000).unref();
|
||||
const { applyTheme } = await import("./ui/theme.ts");
|
||||
// Terminals that don't say what their background is get the dark palette.
|
||||
applyTheme(config.theme === "auto" ? ((await renderer.waitForThemeMode(300)) ?? "dark") : config.theme);
|
||||
const { applyTheme, terminalPalette, themeModeOf } = await import("./ui/theme.ts");
|
||||
if (config.theme === "dark" || config.theme === "light") applyTheme(config.theme);
|
||||
else {
|
||||
// The terminal's colours through OSC 4, 10 and 11; terminals that don't answer get the dark palette.
|
||||
const detected = await renderer.getPalette({ timeout: 300, size: 16 }).catch(() => null);
|
||||
const mode = themeModeOf(detected) ?? renderer.themeMode ?? "dark";
|
||||
applyTheme(config.theme === "terminal" ? (terminalPalette(detected) ?? mode) : mode);
|
||||
}
|
||||
createRoot(renderer).render(createElement(App, { session, config, layout, ...(attachThreadId ? { attachThreadId } : {}) }));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user