import type { Ghostty } from 'ghostty-web'; export interface TerminalTheme { background: string; foreground: string; cursor: string; cursorAccent: string; selectionBackground: string; selectionForeground?: string; selectionInactiveBackground?: string; black: string; red: string; green: string; yellow: string; blue: string; magenta: string; cyan: string; white: string; brightBlack: string; brightRed: string; brightGreen: string; brightYellow: string; brightBlue: string; brightMagenta: string; brightCyan: string; brightWhite: string; } // Default dark theme const defaultTheme: TerminalTheme = { background: '#1e1e1e', foreground: '#d4d4d4', cursor: '#ffffff', cursorAccent: '#1e1e1e', selectionBackground: '#264f78', selectionForeground: '#ffffff', selectionInactiveBackground: '#264f7850', black: '#000000', red: '#cd3131', green: '#0dbc79', yellow: '#e5e510', blue: '#2472c8', magenta: '#bc3fbc', cyan: '#11a8cd', white: '#e5e5e5', brightBlack: '#666666', brightRed: '#f14c4c', brightGreen: '#23d18b', brightYellow: '#f5f543', brightBlue: '#3b8eea', brightMagenta: '#d670d6', brightCyan: '#29b8db', brightWhite: '#ffffff', }; export function getDefaultTheme(): TerminalTheme { return { ...defaultTheme }; } export function getTerminalOptions( fontFamily: string, fontSize: number, theme: TerminalTheme ) { const powerlineFallbacks = '"JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace'; const augmentedFontFamily = `${fontFamily}, ${powerlineFallbacks}`; return { fontFamily: augmentedFontFamily, fontSize, lineHeight: 1, cursorBlink: false, cursorStyle: 'bar' as const, theme, allowTransparency: false, scrollback: 10_000, minimumContrastRatio: 1, fastScrollModifier: 'shift' as const, fastScrollSensitivity: 5, scrollSensitivity: 3, macOptionIsMeta: true, macOptionClickForcesSelection: false, rightClickSelectsWord: true, }; } /** * Get terminal options for Ghostty Web terminal */ export function getGhosttyTerminalOptions( fontFamily: string, fontSize: number, theme: TerminalTheme, ghostty: Ghostty, disableStdin = false ) { const powerlineFallbacks = '"JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace'; const augmentedFontFamily = `${fontFamily}, ${powerlineFallbacks}`; return { cursorBlink: false, cursorStyle: 'bar' as const, fontSize, lineHeight: 1.15, fontFamily: augmentedFontFamily, allowTransparency: false, theme: { background: theme.background, foreground: theme.foreground, cursor: theme.cursor, cursorAccent: theme.cursorAccent, selectionBackground: theme.selectionBackground, selectionForeground: theme.selectionForeground, black: theme.black, red: theme.red, green: theme.green, yellow: theme.yellow, blue: theme.blue, magenta: theme.magenta, cyan: theme.cyan, white: theme.white, brightBlack: theme.brightBlack, brightRed: theme.brightRed, brightGreen: theme.brightGreen, brightYellow: theme.brightYellow, brightBlue: theme.brightBlue, brightMagenta: theme.brightMagenta, brightCyan: theme.brightCyan, brightWhite: theme.brightWhite, }, scrollback: 10_000, ghostty, disableStdin, }; }