refactor: extract TerminalPane hooks and modularize terminal themes (#66)

Split the monolithic TerminalPane component into focused custom hooks
(lifecycle, context menu, global effects, dark mode detection) and break
the large terminal-themes-data file into organized modules.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jinjing
2026-03-23 16:31:29 -07:00
committed by GitHub
co-authored by Claude Opus 4.6
parent 3a650b4196
commit 5765791bb9
16 changed files with 1464 additions and 1216 deletions
@@ -1,33 +1,23 @@
import { useEffect, useRef, useState } from 'react'
import { createPortal } from 'react-dom'
import type { CSSProperties } from 'react'
import { TOGGLE_TERMINAL_PANE_EXPAND_EVENT } from '@/constants/terminal'
import { useAppStore } from '../../store'
import {
DEFAULT_TERMINAL_DIVIDER_DARK,
normalizeColor,
resolveEffectiveTerminalAppearance
} from '@/lib/terminal-theme'
import { PaneManager } from '@/lib/pane-manager/pane-manager'
import type { PaneManager } from '@/lib/pane-manager/pane-manager'
import TerminalSearch from '@/components/TerminalSearch'
import type { PtyTransport } from './pty-transport'
import {
EMPTY_LAYOUT,
buildFontFamily,
serializeTerminalLayout,
replayTerminalLayout
} from './layout-serialization'
import {
createExpandCollapseActions,
restoreExpandedLayoutFrom,
applyExpandedLayoutTo
} from './expand-collapse'
import { EMPTY_LAYOUT, serializeTerminalLayout } from './layout-serialization'
import { createExpandCollapseActions } from './expand-collapse'
import { useTerminalKeyboardShortcuts, useTerminalFontZoom } from './keyboard-handlers'
import { applyTerminalAppearance } from './terminal-appearance'
import { connectPanePty } from './pty-connection'
import TerminalContextMenu from './TerminalContextMenu'
const CLOSE_ALL_CONTEXT_MENUS_EVENT = 'orca-close-all-context-menus'
import { useSystemPrefersDark } from './use-system-prefers-dark'
import { useTerminalPaneGlobalEffects } from './use-terminal-pane-global-effects'
import { useTerminalPaneLifecycle } from './use-terminal-pane-lifecycle'
import { useTerminalPaneContextMenu } from './use-terminal-pane-context-menu'
type TerminalPaneProps = {
tabId: string
@@ -46,8 +36,6 @@ export default function TerminalPane({
}: TerminalPaneProps): React.JSX.Element {
const containerRef = useRef<HTMLDivElement>(null)
const managerRef = useRef<PaneManager | null>(null)
const contextPaneIdRef = useRef<number | null>(null)
const wasActiveRef = useRef(false)
const paneFontSizesRef = useRef<Map<number, number>>(new Map())
const expandedPaneIdRef = useRef<number | null>(null)
const expandedStyleSnapshotRef = useRef<Map<HTMLElement, { display: string; flex: string }>>(
@@ -57,31 +45,26 @@ export default function TerminalPane({
const pendingWritesRef = useRef<Map<number, string>>(new Map())
const isActiveRef = useRef(isActive)
isActiveRef.current = isActive
const [terminalMenuOpen, setTerminalMenuOpen] = useState(false)
const [terminalMenuPoint, setTerminalMenuPoint] = useState({ x: 0, y: 0 })
const menuOpenedAtRef = useRef(0)
const [expandedPaneId, setExpandedPaneId] = useState<number | null>(null)
const [searchOpen, setSearchOpen] = useState(false)
const setTabPaneExpanded = useAppStore((s) => s.setTabPaneExpanded)
const setTabCanExpandPane = useAppStore((s) => s.setTabCanExpandPane)
const savedLayout = useAppStore((s) => s.terminalLayoutsByTabId[tabId] ?? EMPTY_LAYOUT)
const setTabLayout = useAppStore((s) => s.setTabLayout)
const setTabPaneExpanded = useAppStore((store) => store.setTabPaneExpanded)
const setTabCanExpandPane = useAppStore((store) => store.setTabCanExpandPane)
const savedLayout = useAppStore((store) => store.terminalLayoutsByTabId[tabId] ?? EMPTY_LAYOUT)
const setTabLayout = useAppStore((store) => store.setTabLayout)
const initialLayoutRef = useRef(savedLayout)
const updateTabTitle = useAppStore((s) => s.updateTabTitle)
const updateTabPtyId = useAppStore((s) => s.updateTabPtyId)
const clearTabPtyId = useAppStore((s) => s.clearTabPtyId)
const markWorktreeUnreadFromBell = useAppStore((s) => s.markWorktreeUnreadFromBell)
const settings = useAppStore((s) => s.settings)
const updateTabTitle = useAppStore((store) => store.updateTabTitle)
const updateTabPtyId = useAppStore((store) => store.updateTabPtyId)
const clearTabPtyId = useAppStore((store) => store.clearTabPtyId)
const markWorktreeUnreadFromBell = useAppStore((store) => store.markWorktreeUnreadFromBell)
const settings = useAppStore((store) => store.settings)
const settingsRef = useRef(settings)
settingsRef.current = settings
const onPtyExitRef = useRef(onPtyExit)
onPtyExitRef.current = onPtyExit
const [systemPrefersDark, setSystemPrefersDark] = useState(() =>
typeof window !== 'undefined' && typeof window.matchMedia === 'function'
? window.matchMedia('(prefers-color-scheme: dark)').matches
: true
)
const systemPrefersDark = useSystemPrefersDark()
const persistLayoutSnapshot = (): void => {
const manager = managerRef.current
@@ -110,292 +93,36 @@ export default function TerminalPane({
persistLayoutSnapshot
})
const syncCanExpandState = (): void => {
const paneCount = managerRef.current?.getPanes().length ?? 1
setTabCanExpandPane(tabId, paneCount > 1)
}
const doApplyAppearance = (manager: PaneManager): void => {
const s = settingsRef.current
if (!s) {
return
}
applyTerminalAppearance(
manager,
s,
systemPrefersDark,
paneFontSizesRef.current,
paneTransportsRef.current
)
}
useEffect(() => {
const closeMenu = (): void => {
if (Date.now() - menuOpenedAtRef.current < 100) {
return
}
setTerminalMenuOpen(false)
}
window.addEventListener(CLOSE_ALL_CONTEXT_MENUS_EVENT, closeMenu)
return () => window.removeEventListener(CLOSE_ALL_CONTEXT_MENUS_EVENT, closeMenu)
}, [])
useEffect(() => {
const media = window.matchMedia('(prefers-color-scheme: dark)')
const handleChange = (event: MediaQueryListEvent): void => setSystemPrefersDark(event.matches)
setSystemPrefersDark(media.matches)
media.addEventListener('change', handleChange)
return () => media.removeEventListener('change', handleChange)
}, [])
// Initialize PaneManager instance once
useEffect(() => {
const container = containerRef.current
if (!container) {
return
}
let resizeRaf: number | null = null
const queueResizeAll = (focusActive: boolean): void => {
if (resizeRaf !== null) {
cancelAnimationFrame(resizeRaf)
}
resizeRaf = requestAnimationFrame(() => {
resizeRaf = null
const m = managerRef.current
if (!m) {
return
}
const panes = m.getPanes()
for (const p of panes) {
try {
p.fitAddon.fit()
} catch {
/* ignore */
}
}
if (focusActive) {
const active = m.getActivePane() ?? panes[0]
active?.terminal.focus()
}
})
}
let shouldPersistLayout = false
const ptyDeps = {
tabId,
worktreeId,
cwd,
paneTransportsRef,
pendingWritesRef,
isActiveRef,
onPtyExitRef,
clearTabPtyId,
updateTabTitle,
updateTabPtyId,
markWorktreeUnreadFromBell
}
const manager = new PaneManager(container, {
onPaneCreated: (pane) => {
doApplyAppearance(manager)
connectPanePty(pane, manager, ptyDeps)
queueResizeAll(true)
},
onPaneClosed: (paneId) => {
const transport = paneTransportsRef.current.get(paneId)
if (transport) {
transport.destroy?.()
paneTransportsRef.current.delete(paneId)
}
paneFontSizesRef.current.delete(paneId)
pendingWritesRef.current.delete(paneId)
},
onActivePaneChange: () => {
if (shouldPersistLayout) {
persistLayoutSnapshot()
}
},
onLayoutChanged: () => {
syncExpandedLayout()
syncCanExpandState()
queueResizeAll(false)
if (shouldPersistLayout) {
persistLayoutSnapshot()
}
},
terminalOptions: () => {
const cs = settingsRef.current
return {
fontSize: cs?.terminalFontSize ?? 14,
fontFamily: buildFontFamily(cs?.terminalFontFamily ?? 'SF Mono'),
scrollback: Math.min(
50_000,
Math.max(1000, Math.round((cs?.terminalScrollbackBytes ?? 10_000_000) / 200))
),
cursorStyle: cs?.terminalCursorStyle ?? 'bar',
cursorBlink: cs?.terminalCursorBlink ?? true
}
},
onLinkClick: (url) => {
window.api.shell.openExternal(url)
}
})
managerRef.current = manager
const restoredPaneByLeafId = replayTerminalLayout(manager, initialLayoutRef.current, isActive)
const restoredActivePaneId =
(initialLayoutRef.current.activeLeafId
? restoredPaneByLeafId.get(initialLayoutRef.current.activeLeafId)
: null) ??
manager.getActivePane()?.id ??
manager.getPanes()[0]?.id ??
null
if (restoredActivePaneId !== null) {
manager.setActivePane(restoredActivePaneId, { focus: isActive })
}
const restoredExpandedPaneId = initialLayoutRef.current.expandedLeafId
? (restoredPaneByLeafId.get(initialLayoutRef.current.expandedLeafId) ?? null)
: null
if (restoredExpandedPaneId !== null && manager.getPanes().length > 1) {
setExpandedPane(restoredExpandedPaneId)
applyExpandedLayoutTo(restoredExpandedPaneId, {
managerRef,
containerRef,
expandedStyleSnapshotRef
})
} else {
setExpandedPane(null)
}
shouldPersistLayout = true
syncCanExpandState()
doApplyAppearance(manager)
queueResizeAll(isActive)
persistLayoutSnapshot()
return () => {
if (resizeRaf !== null) {
cancelAnimationFrame(resizeRaf)
}
restoreExpandedLayoutFrom(expandedStyleSnapshotRef.current)
for (const transport of paneTransportsRef.current.values()) {
transport.destroy?.()
}
paneTransportsRef.current.clear()
pendingWritesRef.current.clear()
manager.destroy()
managerRef.current = null
setTabPaneExpanded(tabId, false)
setTabCanExpandPane(tabId, false)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [tabId, cwd])
useEffect(() => {
const manager = managerRef.current
if (!manager || !settings) {
return
}
doApplyAppearance(manager)
const fontFamily = buildFontFamily(settings.terminalFontFamily)
for (const pane of manager.getPanes()) {
pane.terminal.options.fontFamily = fontFamily
try {
pane.fitAddon.fit()
} catch {
/* ignore */
}
}
}, [settings, systemPrefersDark])
useTerminalPaneLifecycle({
tabId,
worktreeId,
cwd,
isActive,
systemPrefersDark,
settings,
settingsRef,
initialLayoutRef,
managerRef,
containerRef,
expandedStyleSnapshotRef,
paneFontSizesRef,
paneTransportsRef,
pendingWritesRef,
isActiveRef,
onPtyExitRef,
clearTabPtyId,
updateTabTitle,
updateTabPtyId,
markWorktreeUnreadFromBell,
setTabPaneExpanded,
setTabCanExpandPane,
setExpandedPane,
syncExpandedLayout,
persistLayoutSnapshot
})
useTerminalFontZoom({ isActive, managerRef, paneFontSizesRef, settingsRef })
useEffect(() => {
const manager = managerRef.current
if (!manager) {
return
}
if (isActive) {
manager.resumeRendering()
for (const [paneId, buf] of pendingWritesRef.current.entries()) {
if (buf.length > 0) {
const pane = manager.getPanes().find((p) => p.id === paneId)
if (pane) {
pane.terminal.write(buf)
}
pendingWritesRef.current.set(paneId, '')
}
}
requestAnimationFrame(() => {
const panes = manager.getPanes()
for (const p of panes) {
try {
p.fitAddon.fit()
} catch {
/* ignore */
}
}
const active = manager.getActivePane() ?? panes[0]
if (active) {
active.terminal.focus()
}
})
} else if (wasActiveRef.current) {
manager.suspendRendering()
}
wasActiveRef.current = isActive
}, [isActive])
useEffect(() => {
const onToggleExpand = (event: Event): void => {
const detail = (event as CustomEvent<{ tabId?: string }>).detail
if (!detail?.tabId || detail.tabId !== tabId) {
return
}
const manager = managerRef.current
if (!manager) {
return
}
const panes = manager.getPanes()
if (panes.length < 2) {
return
}
const pane = manager.getActivePane() ?? panes[0]
if (!pane) {
return
}
toggleExpandPane(pane.id)
}
window.addEventListener(TOGGLE_TERMINAL_PANE_EXPAND_EVENT, onToggleExpand)
return () => window.removeEventListener(TOGGLE_TERMINAL_PANE_EXPAND_EVENT, onToggleExpand)
}, [tabId])
useEffect(() => {
if (!isActive) {
return
}
const container = containerRef.current
if (!container) {
return
}
const ro = new ResizeObserver(() => {
const manager = managerRef.current
if (!manager) {
return
}
for (const p of manager.getPanes()) {
try {
p.fitAddon.fit()
} catch {
/* ignore */
}
}
})
ro.observe(container)
return () => ro.disconnect()
}, [isActive])
useTerminalKeyboardShortcuts({
isActive,
managerRef,
@@ -409,32 +136,16 @@ export default function TerminalPane({
setSearchOpen
})
useEffect(() => {
if (!isActive) {
return
}
const shellEscape = (p: string): string => {
if (/^[a-zA-Z0-9_./@:-]+$/.test(p)) {
return p
}
return `'${p.replace(/'/g, "'\\''")}'`
}
return window.api.ui.onFileDrop(({ path: filePath }) => {
const manager = managerRef.current
if (!manager) {
return
}
const pane = manager.getActivePane() ?? manager.getPanes()[0]
if (!pane) {
return
}
const transport = paneTransportsRef.current.get(pane.id)
if (!transport) {
return
}
transport.sendInput(shellEscape(filePath))
})
}, [isActive])
useTerminalPaneGlobalEffects({
tabId,
isActive,
managerRef,
containerRef,
pendingWritesRef,
paneTransportsRef,
isActiveRef,
toggleExpandPane
})
// Intercept paste events on the terminal to bypass Chromium's native
// clipboard pipeline. Chromium holds NSPasteboard references during format
@@ -479,79 +190,16 @@ export default function TerminalPane({
return () => container.removeEventListener('paste', onPaste, { capture: true })
}, [isActive])
const resolveMenuPane = () => {
const manager = managerRef.current
if (!manager) {
return null
}
const panes = manager.getPanes()
if (contextPaneIdRef.current !== null) {
const clickedPane = panes.find((p) => p.id === contextPaneIdRef.current) ?? null
if (clickedPane) {
return clickedPane
}
}
return manager.getActivePane() ?? panes[0] ?? null
}
const contextMenu = useTerminalPaneContextMenu({
managerRef,
paneTransportsRef,
toggleExpandPane
})
const handleCopy = async (): Promise<void> => {
const pane = resolveMenuPane()
if (!pane) {
return
}
const selection = pane.terminal.getSelection()
if (selection) {
await navigator.clipboard.writeText(selection)
}
}
const handlePaste = async (): Promise<void> => {
const pane = resolveMenuPane()
if (!pane) {
return
}
const text = await window.api.ui.readClipboardText()
if (text) {
pane.terminal.paste(text)
}
}
const handleSplitRight = (): void => {
const p = resolveMenuPane()
if (p) {
managerRef.current?.splitPane(p.id, 'vertical')
}
}
const handleSplitDown = (): void => {
const p = resolveMenuPane()
if (p) {
managerRef.current?.splitPane(p.id, 'horizontal')
}
}
const handleClosePane = (): void => {
const p = resolveMenuPane()
if (p && (managerRef.current?.getPanes().length ?? 0) > 1) {
managerRef.current?.closePane(p.id)
}
}
const handleClearScreen = (): void => {
const p = resolveMenuPane()
if (p) {
p.terminal.clear()
}
}
const handleToggleExpand = (): void => {
const p = resolveMenuPane()
if (p) {
toggleExpandPane(p.id)
}
}
const paneCount = managerRef.current?.getPanes().length ?? 1
const menuPaneId = resolveMenuPane()?.id ?? null
const effectiveAppearance = settings
? resolveEffectiveTerminalAppearance(settings, systemPrefersDark)
: null
const terminalContainerStyle: CSSProperties = {
display: isActive ? 'flex' : 'none',
['--orca-terminal-divider-color' as string]:
@@ -561,6 +209,7 @@ export default function TerminalPane({
DEFAULT_TERMINAL_DIVIDER_DARK
)
}
const activePane = managerRef.current?.getActivePane()
return (
@@ -569,27 +218,7 @@ export default function TerminalPane({
ref={containerRef}
className="absolute inset-0 min-h-0 min-w-0"
style={terminalContainerStyle}
onContextMenuCapture={(event) => {
event.preventDefault()
menuOpenedAtRef.current = Date.now()
window.dispatchEvent(new Event(CLOSE_ALL_CONTEXT_MENUS_EVENT))
const manager = managerRef.current
if (!manager) {
contextPaneIdRef.current = null
return
}
const target = event.target
if (!(target instanceof Node)) {
contextPaneIdRef.current = null
return
}
const clickedPane =
manager.getPanes().find((pane) => pane.container.contains(target)) ?? null
contextPaneIdRef.current = clickedPane?.id ?? null
const bounds = event.currentTarget.getBoundingClientRect()
setTerminalMenuPoint({ x: event.clientX - bounds.left, y: event.clientY - bounds.top })
setTerminalMenuOpen(true)
}}
onContextMenuCapture={contextMenu.onContextMenuCapture}
/>
{activePane?.container &&
createPortal(
@@ -601,20 +230,22 @@ export default function TerminalPane({
activePane.container
)}
<TerminalContextMenu
open={terminalMenuOpen}
onOpenChange={setTerminalMenuOpen}
menuPoint={terminalMenuPoint}
menuOpenedAtRef={menuOpenedAtRef}
canClosePane={paneCount > 1}
canExpandPane={paneCount > 1}
menuPaneIsExpanded={menuPaneId !== null && menuPaneId === expandedPaneId}
onCopy={() => void handleCopy()}
onPaste={() => void handlePaste()}
onSplitRight={handleSplitRight}
onSplitDown={handleSplitDown}
onClosePane={handleClosePane}
onClearScreen={handleClearScreen}
onToggleExpand={handleToggleExpand}
open={contextMenu.open}
onOpenChange={contextMenu.setOpen}
menuPoint={contextMenu.point}
menuOpenedAtRef={contextMenu.menuOpenedAtRef}
canClosePane={contextMenu.paneCount > 1}
canExpandPane={contextMenu.paneCount > 1}
menuPaneIsExpanded={
contextMenu.menuPaneId !== null && contextMenu.menuPaneId === expandedPaneId
}
onCopy={() => void contextMenu.onCopy()}
onPaste={() => void contextMenu.onPaste()}
onSplitRight={contextMenu.onSplitRight}
onSplitDown={contextMenu.onSplitDown}
onClosePane={contextMenu.onClosePane}
onClearScreen={contextMenu.onClearScreen}
onToggleExpand={contextMenu.onToggleExpand}
/>
</>
)
@@ -0,0 +1,29 @@
import type { PaneManager } from '@/lib/pane-manager/pane-manager'
export function fitPanes(manager: PaneManager): void {
for (const pane of manager.getPanes()) {
try {
pane.fitAddon.fit()
} catch {
/* ignore */
}
}
}
export function focusActivePane(manager: PaneManager): void {
const panes = manager.getPanes()
const activePane = manager.getActivePane() ?? panes[0]
activePane?.terminal.focus()
}
export function fitAndFocusPanes(manager: PaneManager): void {
fitPanes(manager)
focusActivePane(manager)
}
export function shellEscapePath(path: string): string {
if (/^[a-zA-Z0-9_./@:-]+$/.test(path)) {
return path
}
return `'${path.replace(/'/g, "'\\''")}'`
}
@@ -0,0 +1,22 @@
import { useEffect, useState } from 'react'
export function useSystemPrefersDark(): boolean {
const [systemPrefersDark, setSystemPrefersDark] = useState(() =>
typeof window !== 'undefined' && typeof window.matchMedia === 'function'
? window.matchMedia('(prefers-color-scheme: dark)').matches
: true
)
useEffect(() => {
if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') {
return
}
const media = window.matchMedia('(prefers-color-scheme: dark)')
const handleChange = (event: MediaQueryListEvent): void => setSystemPrefersDark(event.matches)
setSystemPrefersDark(media.matches)
media.addEventListener('change', handleChange)
return () => media.removeEventListener('change', handleChange)
}, [])
return systemPrefersDark
}
@@ -0,0 +1,163 @@
import { useEffect, useRef, useState } from 'react'
import type { ManagedPane, PaneManager } from '@/lib/pane-manager/pane-manager'
import type { PtyTransport } from './pty-transport'
const CLOSE_ALL_CONTEXT_MENUS_EVENT = 'orca-close-all-context-menus'
type UseTerminalPaneContextMenuDeps = {
managerRef: React.RefObject<PaneManager | null>
paneTransportsRef: React.RefObject<Map<number, PtyTransport>>
toggleExpandPane: (paneId: number) => void
}
type TerminalMenuState = {
open: boolean
setOpen: React.Dispatch<React.SetStateAction<boolean>>
point: { x: number; y: number }
menuOpenedAtRef: React.RefObject<number>
paneCount: number
menuPaneId: number | null
onContextMenuCapture: (event: React.MouseEvent<HTMLDivElement>) => void
onCopy: () => Promise<void>
onPaste: () => Promise<void>
onSplitRight: () => void
onSplitDown: () => void
onClosePane: () => void
onClearScreen: () => void
onToggleExpand: () => void
}
export function useTerminalPaneContextMenu({
managerRef,
paneTransportsRef,
toggleExpandPane
}: UseTerminalPaneContextMenuDeps): TerminalMenuState {
const contextPaneIdRef = useRef<number | null>(null)
const menuOpenedAtRef = useRef(0)
const [open, setOpen] = useState(false)
const [point, setPoint] = useState({ x: 0, y: 0 })
useEffect(() => {
const closeMenu = (): void => {
if (Date.now() - menuOpenedAtRef.current < 100) {
return
}
setOpen(false)
}
window.addEventListener(CLOSE_ALL_CONTEXT_MENUS_EVENT, closeMenu)
return () => window.removeEventListener(CLOSE_ALL_CONTEXT_MENUS_EVENT, closeMenu)
}, [])
const resolveMenuPane = (): ManagedPane | null => {
const manager = managerRef.current
if (!manager) {
return null
}
const panes = manager.getPanes()
if (contextPaneIdRef.current !== null) {
const clickedPane = panes.find((pane) => pane.id === contextPaneIdRef.current) ?? null
if (clickedPane) {
return clickedPane
}
}
return manager.getActivePane() ?? panes[0] ?? null
}
const onCopy = async (): Promise<void> => {
const pane = resolveMenuPane()
if (!pane) {
return
}
const selection = pane.terminal.getSelection()
if (selection) {
await navigator.clipboard.writeText(selection)
}
}
const onPaste = async (): Promise<void> => {
const pane = resolveMenuPane()
if (!pane) {
return
}
const text = await window.api.ui.readClipboardText()
if (text) {
pane.terminal.paste(text)
}
}
const onSplitRight = (): void => {
const pane = resolveMenuPane()
if (pane) {
managerRef.current?.splitPane(pane.id, 'vertical')
}
}
const onSplitDown = (): void => {
const pane = resolveMenuPane()
if (pane) {
managerRef.current?.splitPane(pane.id, 'horizontal')
}
}
const onClosePane = (): void => {
const pane = resolveMenuPane()
if (pane && (managerRef.current?.getPanes().length ?? 0) > 1) {
managerRef.current?.closePane(pane.id)
}
}
const onClearScreen = (): void => {
const pane = resolveMenuPane()
if (pane) {
pane.terminal.clear()
}
}
const onToggleExpand = (): void => {
const pane = resolveMenuPane()
if (pane) {
toggleExpandPane(pane.id)
}
}
const onContextMenuCapture = (event: React.MouseEvent<HTMLDivElement>): void => {
event.preventDefault()
menuOpenedAtRef.current = Date.now()
window.dispatchEvent(new Event(CLOSE_ALL_CONTEXT_MENUS_EVENT))
const manager = managerRef.current
if (!manager) {
contextPaneIdRef.current = null
return
}
const target = event.target
if (!(target instanceof Node)) {
contextPaneIdRef.current = null
return
}
const clickedPane = manager.getPanes().find((pane) => pane.container.contains(target)) ?? null
contextPaneIdRef.current = clickedPane?.id ?? null
const bounds = event.currentTarget.getBoundingClientRect()
setPoint({ x: event.clientX - bounds.left, y: event.clientY - bounds.top })
setOpen(true)
}
const paneCount = managerRef.current?.getPanes().length ?? 1
const menuPaneId = resolveMenuPane()?.id ?? null
return {
open,
setOpen,
point,
menuOpenedAtRef,
paneCount,
menuPaneId,
onContextMenuCapture,
onCopy,
onPaste,
onSplitRight,
onSplitDown,
onClosePane,
onClearScreen,
onToggleExpand
}
}
@@ -0,0 +1,121 @@
import { useEffect, useRef } from 'react'
import { TOGGLE_TERMINAL_PANE_EXPAND_EVENT } from '@/constants/terminal'
import type { PaneManager } from '@/lib/pane-manager/pane-manager'
import type { PtyTransport } from './pty-transport'
import { fitAndFocusPanes, fitPanes, shellEscapePath } from './pane-helpers'
type UseTerminalPaneGlobalEffectsArgs = {
tabId: string
isActive: boolean
managerRef: React.RefObject<PaneManager | null>
containerRef: React.RefObject<HTMLDivElement | null>
pendingWritesRef: React.RefObject<Map<number, string>>
paneTransportsRef: React.RefObject<Map<number, PtyTransport>>
isActiveRef: React.RefObject<boolean>
toggleExpandPane: (paneId: number) => void
}
export function useTerminalPaneGlobalEffects({
tabId,
isActive,
managerRef,
containerRef,
pendingWritesRef,
paneTransportsRef,
isActiveRef,
toggleExpandPane
}: UseTerminalPaneGlobalEffectsArgs): void {
const wasActiveRef = useRef(false)
useEffect(() => {
const manager = managerRef.current
if (!manager) {
return
}
if (isActive) {
manager.resumeRendering()
for (const [paneId, pendingBuffer] of pendingWritesRef.current.entries()) {
if (pendingBuffer.length > 0) {
const pane = manager.getPanes().find((existingPane) => existingPane.id === paneId)
if (pane) {
pane.terminal.write(pendingBuffer)
}
pendingWritesRef.current.set(paneId, '')
}
}
requestAnimationFrame(() => fitAndFocusPanes(manager))
} else if (wasActiveRef.current) {
manager.suspendRendering()
}
wasActiveRef.current = isActive
isActiveRef.current = isActive
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isActive])
useEffect(() => {
const onToggleExpand = (event: Event): void => {
const detail = (event as CustomEvent<{ tabId?: string }>).detail
if (!detail?.tabId || detail.tabId !== tabId) {
return
}
const manager = managerRef.current
if (!manager) {
return
}
const panes = manager.getPanes()
if (panes.length < 2) {
return
}
const pane = manager.getActivePane() ?? panes[0]
if (!pane) {
return
}
toggleExpandPane(pane.id)
}
window.addEventListener(TOGGLE_TERMINAL_PANE_EXPAND_EVENT, onToggleExpand)
return () => window.removeEventListener(TOGGLE_TERMINAL_PANE_EXPAND_EVENT, onToggleExpand)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [tabId])
useEffect(() => {
if (!isActive) {
return
}
const container = containerRef.current
if (!container) {
return
}
const resizeObserver = new ResizeObserver(() => {
const manager = managerRef.current
if (!manager) {
return
}
fitPanes(manager)
})
resizeObserver.observe(container)
return () => resizeObserver.disconnect()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isActive])
useEffect(() => {
if (!isActive) {
return
}
return window.api.ui.onFileDrop(({ path: filePath }) => {
const manager = managerRef.current
if (!manager) {
return
}
const pane = manager.getActivePane() ?? manager.getPanes()[0]
if (!pane) {
return
}
const transport = paneTransportsRef.current.get(pane.id)
if (!transport) {
return
}
transport.sendInput(shellEscapePath(filePath))
})
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isActive])
}
@@ -0,0 +1,250 @@
import { useEffect, useRef } from 'react'
import { PaneManager } from '@/lib/pane-manager/pane-manager'
import type { GlobalSettings, TerminalLayoutSnapshot } from '../../../../shared/types'
import { buildFontFamily, replayTerminalLayout } from './layout-serialization'
import { applyExpandedLayoutTo, restoreExpandedLayoutFrom } from './expand-collapse'
import { applyTerminalAppearance } from './terminal-appearance'
import { connectPanePty } from './pty-connection'
import type { PtyTransport } from './pty-transport'
import { fitAndFocusPanes, fitPanes } from './pane-helpers'
type UseTerminalPaneLifecycleDeps = {
tabId: string
worktreeId: string
cwd?: string
isActive: boolean
systemPrefersDark: boolean
settings: GlobalSettings | null | undefined
settingsRef: React.RefObject<GlobalSettings | null | undefined>
initialLayoutRef: React.RefObject<TerminalLayoutSnapshot>
managerRef: React.RefObject<PaneManager | null>
containerRef: React.RefObject<HTMLDivElement | null>
expandedStyleSnapshotRef: React.MutableRefObject<
Map<HTMLElement, { display: string; flex: string }>
>
paneFontSizesRef: React.RefObject<Map<number, number>>
paneTransportsRef: React.RefObject<Map<number, PtyTransport>>
pendingWritesRef: React.RefObject<Map<number, string>>
isActiveRef: React.RefObject<boolean>
onPtyExitRef: React.RefObject<(ptyId: string) => void>
clearTabPtyId: (tabId: string, ptyId: string) => void
updateTabTitle: (tabId: string, title: string) => void
updateTabPtyId: (tabId: string, ptyId: string) => void
markWorktreeUnreadFromBell: (worktreeId: string) => void
setTabPaneExpanded: (tabId: string, expanded: boolean) => void
setTabCanExpandPane: (tabId: string, canExpand: boolean) => void
setExpandedPane: (paneId: number | null) => void
syncExpandedLayout: () => void
persistLayoutSnapshot: () => void
}
export function useTerminalPaneLifecycle({
tabId,
worktreeId,
cwd,
isActive,
systemPrefersDark,
settings,
settingsRef,
initialLayoutRef,
managerRef,
containerRef,
expandedStyleSnapshotRef,
paneFontSizesRef,
paneTransportsRef,
pendingWritesRef,
isActiveRef,
onPtyExitRef,
clearTabPtyId,
updateTabTitle,
updateTabPtyId,
markWorktreeUnreadFromBell,
setTabPaneExpanded,
setTabCanExpandPane,
setExpandedPane,
syncExpandedLayout,
persistLayoutSnapshot
}: UseTerminalPaneLifecycleDeps): void {
const systemPrefersDarkRef = useRef(systemPrefersDark)
systemPrefersDarkRef.current = systemPrefersDark
const applyAppearance = (manager: PaneManager): void => {
const currentSettings = settingsRef.current
if (!currentSettings) {
return
}
applyTerminalAppearance(
manager,
currentSettings,
systemPrefersDarkRef.current,
paneFontSizesRef.current,
paneTransportsRef.current
)
}
// Initialize PaneManager instance once
useEffect(() => {
const container = containerRef.current
if (!container) {
return
}
const expandedStyleSnapshots = expandedStyleSnapshotRef.current
const paneTransports = paneTransportsRef.current
const pendingWrites = pendingWritesRef.current
let resizeRaf: number | null = null
const queueResizeAll = (focusActive: boolean): void => {
if (resizeRaf !== null) {
cancelAnimationFrame(resizeRaf)
}
resizeRaf = requestAnimationFrame(() => {
resizeRaf = null
const manager = managerRef.current
if (!manager) {
return
}
if (focusActive) {
fitAndFocusPanes(manager)
return
}
fitPanes(manager)
})
}
const syncCanExpandState = (): void => {
const paneCount = managerRef.current?.getPanes().length ?? 1
setTabCanExpandPane(tabId, paneCount > 1)
}
let shouldPersistLayout = false
const ptyDeps = {
tabId,
worktreeId,
cwd,
paneTransportsRef,
pendingWritesRef,
isActiveRef,
onPtyExitRef,
clearTabPtyId,
updateTabTitle,
updateTabPtyId,
markWorktreeUnreadFromBell
}
const manager = new PaneManager(container, {
onPaneCreated: (pane) => {
applyAppearance(manager)
connectPanePty(pane, manager, ptyDeps)
queueResizeAll(true)
},
onPaneClosed: (paneId) => {
const transport = paneTransportsRef.current.get(paneId)
if (transport) {
transport.destroy?.()
paneTransportsRef.current.delete(paneId)
}
paneFontSizesRef.current.delete(paneId)
pendingWritesRef.current.delete(paneId)
},
onActivePaneChange: () => {
if (shouldPersistLayout) {
persistLayoutSnapshot()
}
},
onLayoutChanged: () => {
syncExpandedLayout()
syncCanExpandState()
queueResizeAll(false)
if (shouldPersistLayout) {
persistLayoutSnapshot()
}
},
terminalOptions: () => {
const currentSettings = settingsRef.current
return {
fontSize: currentSettings?.terminalFontSize ?? 14,
fontFamily: buildFontFamily(currentSettings?.terminalFontFamily ?? 'SF Mono'),
scrollback: Math.min(
50_000,
Math.max(
1000,
Math.round((currentSettings?.terminalScrollbackBytes ?? 10_000_000) / 200)
)
),
cursorStyle: currentSettings?.terminalCursorStyle ?? 'bar',
cursorBlink: currentSettings?.terminalCursorBlink ?? true
}
},
onLinkClick: (url) => {
window.api.shell.openExternal(url)
}
})
managerRef.current = manager
const restoredPaneByLeafId = replayTerminalLayout(manager, initialLayoutRef.current, isActive)
const restoredActivePaneId =
(initialLayoutRef.current.activeLeafId
? restoredPaneByLeafId.get(initialLayoutRef.current.activeLeafId)
: null) ??
manager.getActivePane()?.id ??
manager.getPanes()[0]?.id ??
null
if (restoredActivePaneId !== null) {
manager.setActivePane(restoredActivePaneId, { focus: isActive })
}
const restoredExpandedPaneId = initialLayoutRef.current.expandedLeafId
? (restoredPaneByLeafId.get(initialLayoutRef.current.expandedLeafId) ?? null)
: null
if (restoredExpandedPaneId !== null && manager.getPanes().length > 1) {
setExpandedPane(restoredExpandedPaneId)
applyExpandedLayoutTo(restoredExpandedPaneId, {
managerRef,
containerRef,
expandedStyleSnapshotRef
})
} else {
setExpandedPane(null)
}
shouldPersistLayout = true
syncCanExpandState()
applyAppearance(manager)
queueResizeAll(isActive)
persistLayoutSnapshot()
return () => {
if (resizeRaf !== null) {
cancelAnimationFrame(resizeRaf)
}
restoreExpandedLayoutFrom(expandedStyleSnapshots)
for (const transport of paneTransports.values()) {
transport.destroy?.()
}
paneTransports.clear()
pendingWrites.clear()
manager.destroy()
managerRef.current = null
setTabPaneExpanded(tabId, false)
setTabCanExpandPane(tabId, false)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [tabId, cwd])
useEffect(() => {
const manager = managerRef.current
if (!manager || !settings) {
return
}
applyAppearance(manager)
const fontFamily = buildFontFamily(settings.terminalFontFamily)
for (const pane of manager.getPanes()) {
pane.terminal.options.fontFamily = fontFamily
try {
pane.fitAddon.fit()
} catch {
/* ignore */
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [settings, systemPrefersDark])
}
+2 -767
View File
@@ -1,773 +1,8 @@
import type { ITheme } from '@xterm/xterm'
export const TERMINAL_THEMES: Record<string, ITheme> = {
// ──────────────────────────────────────────────
// Defaults
// ──────────────────────────────────────────────
import { TERMINAL_THEME_CATALOG } from './terminal-themes'
// Exact colors from Ghostty source: src/terminal/color.zig + src/config/Config.zig
'Ghostty Default Style Dark': {
background: '#282c34',
foreground: '#ffffff',
cursor: '#ffffff',
cursorAccent: '#282c34',
selectionBackground: '#3e4451',
selectionForeground: '#ffffff',
black: '#1d1f21',
red: '#cc6666',
green: '#b5bd68',
yellow: '#f0c674',
blue: '#81a2be',
magenta: '#b294bb',
cyan: '#8abeb7',
white: '#c5c8c6',
brightBlack: '#666666',
brightRed: '#d54e53',
brightGreen: '#b9ca4a',
brightYellow: '#e7c547',
brightBlue: '#7aa6da',
brightMagenta: '#c397d8',
brightCyan: '#70c0b1',
brightWhite: '#eaeaea'
},
'Builtin Tango Light': {
background: '#ffffff',
foreground: '#2e3434',
cursor: '#2e3434',
cursorAccent: '#ffffff',
selectionBackground: '#accef7',
selectionForeground: '#2e3434',
black: '#2e3436',
red: '#cc0000',
green: '#4e9a06',
yellow: '#c4a000',
blue: '#3465a4',
magenta: '#75507b',
cyan: '#06989a',
white: '#d3d7cf',
brightBlack: '#555753',
brightRed: '#ef2929',
brightGreen: '#8ae234',
brightYellow: '#fce94f',
brightBlue: '#729fcf',
brightMagenta: '#ad7fa8',
brightCyan: '#34e2e2',
brightWhite: '#eeeeec'
},
// ──────────────────────────────────────────────
// Popular Dark
// ──────────────────────────────────────────────
Dracula: {
background: '#282a36',
foreground: '#f8f8f2',
cursor: '#f8f8f2',
cursorAccent: '#282a36',
selectionBackground: '#44475a',
selectionForeground: '#f8f8f2',
black: '#21222c',
red: '#ff5555',
green: '#50fa7b',
yellow: '#f1fa8c',
blue: '#bd93f9',
magenta: '#ff79c6',
cyan: '#8be9fd',
white: '#f8f8f2',
brightBlack: '#6272a4',
brightRed: '#ff6e6e',
brightGreen: '#69ff94',
brightYellow: '#ffffa5',
brightBlue: '#d6acff',
brightMagenta: '#ff92df',
brightCyan: '#a4ffff',
brightWhite: '#ffffff'
},
'One Dark': {
background: '#282c34',
foreground: '#abb2bf',
cursor: '#528bff',
cursorAccent: '#282c34',
selectionBackground: '#3e4451',
selectionForeground: '#abb2bf',
black: '#282c34',
red: '#e06c75',
green: '#98c379',
yellow: '#e5c07b',
blue: '#61afef',
magenta: '#c678dd',
cyan: '#56b6c2',
white: '#abb2bf',
brightBlack: '#5c6370',
brightRed: '#e06c75',
brightGreen: '#98c379',
brightYellow: '#e5c07b',
brightBlue: '#61afef',
brightMagenta: '#c678dd',
brightCyan: '#56b6c2',
brightWhite: '#ffffff'
},
Nord: {
background: '#2e3440',
foreground: '#d8dee9',
cursor: '#d8dee9',
cursorAccent: '#2e3440',
selectionBackground: '#434c5e',
selectionForeground: '#d8dee9',
black: '#3b4252',
red: '#bf616a',
green: '#a3be8c',
yellow: '#ebcb8b',
blue: '#81a1c1',
magenta: '#b48ead',
cyan: '#88c0d0',
white: '#e5e9f0',
brightBlack: '#4c566a',
brightRed: '#bf616a',
brightGreen: '#a3be8c',
brightYellow: '#ebcb8b',
brightBlue: '#81a1c1',
brightMagenta: '#b48ead',
brightCyan: '#8fbcbb',
brightWhite: '#eceff4'
},
Monokai: {
background: '#272822',
foreground: '#f8f8f2',
cursor: '#f8f8f0',
cursorAccent: '#272822',
selectionBackground: '#49483e',
selectionForeground: '#f8f8f2',
black: '#272822',
red: '#f92672',
green: '#a6e22e',
yellow: '#f4bf75',
blue: '#66d9ef',
magenta: '#ae81ff',
cyan: '#a1efe4',
white: '#f8f8f2',
brightBlack: '#75715e',
brightRed: '#f92672',
brightGreen: '#a6e22e',
brightYellow: '#f4bf75',
brightBlue: '#66d9ef',
brightMagenta: '#ae81ff',
brightCyan: '#a1efe4',
brightWhite: '#f9f8f5'
},
'Tokyo Night': {
background: '#1a1b26',
foreground: '#c0caf5',
cursor: '#c0caf5',
cursorAccent: '#1a1b26',
selectionBackground: '#33467c',
selectionForeground: '#c0caf5',
black: '#15161e',
red: '#f7768e',
green: '#9ece6a',
yellow: '#e0af68',
blue: '#7aa2f7',
magenta: '#bb9af7',
cyan: '#7dcfff',
white: '#a9b1d6',
brightBlack: '#414868',
brightRed: '#f7768e',
brightGreen: '#9ece6a',
brightYellow: '#e0af68',
brightBlue: '#7aa2f7',
brightMagenta: '#bb9af7',
brightCyan: '#7dcfff',
brightWhite: '#c0caf5'
},
'Gruvbox Dark': {
background: '#282828',
foreground: '#ebdbb2',
cursor: '#ebdbb2',
cursorAccent: '#282828',
selectionBackground: '#504945',
selectionForeground: '#ebdbb2',
black: '#282828',
red: '#cc241d',
green: '#98971a',
yellow: '#d79921',
blue: '#458588',
magenta: '#b16286',
cyan: '#689d6a',
white: '#a89984',
brightBlack: '#928374',
brightRed: '#fb4934',
brightGreen: '#b8bb26',
brightYellow: '#fabd2f',
brightBlue: '#83a598',
brightMagenta: '#d3869b',
brightCyan: '#8ec07c',
brightWhite: '#ebdbb2'
},
'Catppuccin Mocha': {
background: '#1e1e2e',
foreground: '#cdd6f4',
cursor: '#f5e0dc',
cursorAccent: '#1e1e2e',
selectionBackground: '#585b70',
selectionForeground: '#cdd6f4',
black: '#45475a',
red: '#f38ba8',
green: '#a6e3a1',
yellow: '#f9e2af',
blue: '#89b4fa',
magenta: '#f5c2e7',
cyan: '#94e2d5',
white: '#bac2de',
brightBlack: '#585b70',
brightRed: '#f38ba8',
brightGreen: '#a6e3a1',
brightYellow: '#f9e2af',
brightBlue: '#89b4fa',
brightMagenta: '#f5c2e7',
brightCyan: '#94e2d5',
brightWhite: '#a6adc8'
},
'Solarized Dark': {
background: '#002b36',
foreground: '#839496',
cursor: '#839496',
cursorAccent: '#002b36',
selectionBackground: '#073642',
selectionForeground: '#93a1a1',
black: '#073642',
red: '#dc322f',
green: '#859900',
yellow: '#b58900',
blue: '#268bd2',
magenta: '#d33682',
cyan: '#2aa198',
white: '#eee8d5',
brightBlack: '#002b36',
brightRed: '#cb4b16',
brightGreen: '#586e75',
brightYellow: '#657b83',
brightBlue: '#839496',
brightMagenta: '#6c71c4',
brightCyan: '#93a1a1',
brightWhite: '#fdf6e3'
},
'Material Dark': {
background: '#263238',
foreground: '#eeffff',
cursor: '#ffcc00',
cursorAccent: '#263238',
selectionBackground: '#546e7a',
selectionForeground: '#eeffff',
black: '#000000',
red: '#f07178',
green: '#c3e88d',
yellow: '#ffcb6b',
blue: '#82aaff',
magenta: '#c792ea',
cyan: '#89ddff',
white: '#eeffff',
brightBlack: '#546e7a',
brightRed: '#f07178',
brightGreen: '#c3e88d',
brightYellow: '#ffcb6b',
brightBlue: '#82aaff',
brightMagenta: '#c792ea',
brightCyan: '#89ddff',
brightWhite: '#ffffff'
},
'Ayu Dark': {
background: '#0a0e14',
foreground: '#b3b1ad',
cursor: '#e6b450',
cursorAccent: '#0a0e14',
selectionBackground: '#273747',
selectionForeground: '#b3b1ad',
black: '#01060e',
red: '#ea6c73',
green: '#91b362',
yellow: '#f9af4f',
blue: '#53bdfa',
magenta: '#fae994',
cyan: '#90e1c6',
white: '#c7c7c7',
brightBlack: '#686868',
brightRed: '#f07178',
brightGreen: '#c2d94c',
brightYellow: '#ffb454',
brightBlue: '#59c2ff',
brightMagenta: '#ffee99',
brightCyan: '#95e6cb',
brightWhite: '#ffffff'
},
Nightfox: {
background: '#192330',
foreground: '#cdcecf',
cursor: '#cdcecf',
cursorAccent: '#192330',
selectionBackground: '#2b3b51',
selectionForeground: '#cdcecf',
black: '#393b44',
red: '#c94f6d',
green: '#81b29a',
yellow: '#dbc074',
blue: '#719cd6',
magenta: '#9d79d6',
cyan: '#63cdcf',
white: '#dfdfe0',
brightBlack: '#575860',
brightRed: '#d16983',
brightGreen: '#8ebaa4',
brightYellow: '#e0c989',
brightBlue: '#86abdc',
brightMagenta: '#baa1e2',
brightCyan: '#7ad5d6',
brightWhite: '#e4e4e5'
},
Kanagawa: {
background: '#1f1f28',
foreground: '#dcd7ba',
cursor: '#c8c093',
cursorAccent: '#1f1f28',
selectionBackground: '#2d4f67',
selectionForeground: '#dcd7ba',
black: '#090618',
red: '#c34043',
green: '#76946a',
yellow: '#c0a36e',
blue: '#7e9cd8',
magenta: '#957fb8',
cyan: '#6a9589',
white: '#c8c093',
brightBlack: '#727169',
brightRed: '#e82424',
brightGreen: '#98bb6c',
brightYellow: '#e6c384',
brightBlue: '#7fb4ca',
brightMagenta: '#938aa9',
brightCyan: '#7aa89f',
brightWhite: '#dcd7ba'
},
'Rose Pine': {
background: '#191724',
foreground: '#e0def4',
cursor: '#524f67',
cursorAccent: '#e0def4',
selectionBackground: '#403d52',
selectionForeground: '#e0def4',
black: '#26233a',
red: '#eb6f92',
green: '#31748f',
yellow: '#f6c177',
blue: '#9ccfd8',
magenta: '#c4a7e7',
cyan: '#ebbcba',
white: '#e0def4',
brightBlack: '#6e6a86',
brightRed: '#eb6f92',
brightGreen: '#31748f',
brightYellow: '#f6c177',
brightBlue: '#9ccfd8',
brightMagenta: '#c4a7e7',
brightCyan: '#ebbcba',
brightWhite: '#e0def4'
},
'Everforest Dark': {
background: '#2d353b',
foreground: '#d3c6aa',
cursor: '#d3c6aa',
cursorAccent: '#2d353b',
selectionBackground: '#543a48',
selectionForeground: '#d3c6aa',
black: '#475258',
red: '#e67e80',
green: '#a7c080',
yellow: '#dbbc7f',
blue: '#7fbbb3',
magenta: '#d699b6',
cyan: '#83c092',
white: '#d3c6aa',
brightBlack: '#697379',
brightRed: '#e67e80',
brightGreen: '#a7c080',
brightYellow: '#dbbc7f',
brightBlue: '#7fbbb3',
brightMagenta: '#d699b6',
brightCyan: '#83c092',
brightWhite: '#d3c6aa'
},
Palenight: {
background: '#292d3e',
foreground: '#a6accd',
cursor: '#ffcc00',
cursorAccent: '#292d3e',
selectionBackground: '#434758',
selectionForeground: '#a6accd',
black: '#292d3e',
red: '#f07178',
green: '#c3e88d',
yellow: '#ffcb6b',
blue: '#82aaff',
magenta: '#c792ea',
cyan: '#89ddff',
white: '#a6accd',
brightBlack: '#676e95',
brightRed: '#f07178',
brightGreen: '#c3e88d',
brightYellow: '#ffcb6b',
brightBlue: '#82aaff',
brightMagenta: '#c792ea',
brightCyan: '#89ddff',
brightWhite: '#ffffff'
},
'Horizon Dark': {
background: '#1c1e26',
foreground: '#e0e0e0',
cursor: '#e95678',
cursorAccent: '#1c1e26',
selectionBackground: '#2e303e',
selectionForeground: '#e0e0e0',
black: '#16161c',
red: '#e95678',
green: '#29d398',
yellow: '#fab795',
blue: '#26bbd9',
magenta: '#ee64ac',
cyan: '#59e1e3',
white: '#d5d8da',
brightBlack: '#6c6f93',
brightRed: '#ec6a88',
brightGreen: '#3fdaa4',
brightYellow: '#fbc3a7',
brightBlue: '#3fc4de',
brightMagenta: '#f075b5',
brightCyan: '#6be4e6',
brightWhite: '#f0f0f0'
},
'Night Owl': {
background: '#011627',
foreground: '#d6deeb',
cursor: '#80a4c2',
cursorAccent: '#011627',
selectionBackground: '#1d3b53',
selectionForeground: '#d6deeb',
black: '#011627',
red: '#ef5350',
green: '#22da6e',
yellow: '#addb67',
blue: '#82aaff',
magenta: '#c792ea',
cyan: '#21c7a8',
white: '#ffffff',
brightBlack: '#575656',
brightRed: '#ef5350',
brightGreen: '#22da6e',
brightYellow: '#ffeb95',
brightBlue: '#82aaff',
brightMagenta: '#c792ea',
brightCyan: '#7fdbca',
brightWhite: '#ffffff'
},
// ──────────────────────────────────────────────
// Popular Light
// ──────────────────────────────────────────────
'Solarized Light': {
background: '#fdf6e3',
foreground: '#657b83',
cursor: '#657b83',
cursorAccent: '#fdf6e3',
selectionBackground: '#eee8d5',
selectionForeground: '#586e75',
black: '#073642',
red: '#dc322f',
green: '#859900',
yellow: '#b58900',
blue: '#268bd2',
magenta: '#d33682',
cyan: '#2aa198',
white: '#eee8d5',
brightBlack: '#002b36',
brightRed: '#cb4b16',
brightGreen: '#586e75',
brightYellow: '#657b83',
brightBlue: '#839496',
brightMagenta: '#6c71c4',
brightCyan: '#93a1a1',
brightWhite: '#fdf6e3'
},
'One Light': {
background: '#fafafa',
foreground: '#383a42',
cursor: '#526fff',
cursorAccent: '#fafafa',
selectionBackground: '#e5e5e6',
selectionForeground: '#383a42',
black: '#383a42',
red: '#e45649',
green: '#50a14f',
yellow: '#c18401',
blue: '#4078f2',
magenta: '#a626a4',
cyan: '#0184bc',
white: '#a0a1a7',
brightBlack: '#696c77',
brightRed: '#e45649',
brightGreen: '#50a14f',
brightYellow: '#c18401',
brightBlue: '#4078f2',
brightMagenta: '#a626a4',
brightCyan: '#0184bc',
brightWhite: '#fafafa'
},
'Catppuccin Latte': {
background: '#eff1f5',
foreground: '#4c4f69',
cursor: '#dc8a78',
cursorAccent: '#eff1f5',
selectionBackground: '#acb0be',
selectionForeground: '#4c4f69',
black: '#5c5f77',
red: '#d20f39',
green: '#40a02b',
yellow: '#df8e1d',
blue: '#1e66f5',
magenta: '#ea76cb',
cyan: '#179299',
white: '#acb0be',
brightBlack: '#6c6f85',
brightRed: '#d20f39',
brightGreen: '#40a02b',
brightYellow: '#df8e1d',
brightBlue: '#1e66f5',
brightMagenta: '#ea76cb',
brightCyan: '#179299',
brightWhite: '#bcc0cc'
},
'GitHub Light': {
background: '#ffffff',
foreground: '#24292e',
cursor: '#044289',
cursorAccent: '#ffffff',
selectionBackground: '#c8c8fa',
selectionForeground: '#24292e',
black: '#24292e',
red: '#d73a49',
green: '#28a745',
yellow: '#dbab09',
blue: '#0366d6',
magenta: '#5a32a3',
cyan: '#0598bc',
white: '#6a737d',
brightBlack: '#959da5',
brightRed: '#cb2431',
brightGreen: '#22863a',
brightYellow: '#b08800',
brightBlue: '#005cc5',
brightMagenta: '#5a32a3',
brightCyan: '#3192aa',
brightWhite: '#d1d5da'
},
'Rose Pine Dawn': {
background: '#faf4ed',
foreground: '#575279',
cursor: '#9893a5',
cursorAccent: '#faf4ed',
selectionBackground: '#dfdad9',
selectionForeground: '#575279',
black: '#f2e9e1',
red: '#b4637a',
green: '#286983',
yellow: '#ea9d34',
blue: '#56949f',
magenta: '#907aa9',
cyan: '#d7827e',
white: '#575279',
brightBlack: '#9893a5',
brightRed: '#b4637a',
brightGreen: '#286983',
brightYellow: '#ea9d34',
brightBlue: '#56949f',
brightMagenta: '#907aa9',
brightCyan: '#d7827e',
brightWhite: '#575279'
},
'Gruvbox Light': {
background: '#fbf1c7',
foreground: '#3c3836',
cursor: '#3c3836',
cursorAccent: '#fbf1c7',
selectionBackground: '#ebdbb2',
selectionForeground: '#3c3836',
black: '#fbf1c7',
red: '#cc241d',
green: '#98971a',
yellow: '#d79921',
blue: '#458588',
magenta: '#b16286',
cyan: '#689d6a',
white: '#7c6f64',
brightBlack: '#928374',
brightRed: '#9d0006',
brightGreen: '#79740e',
brightYellow: '#b57614',
brightBlue: '#076678',
brightMagenta: '#8f3f71',
brightCyan: '#427b58',
brightWhite: '#3c3836'
},
'Tokyo Night Light': {
background: '#d5d6db',
foreground: '#343b58',
cursor: '#343b58',
cursorAccent: '#d5d6db',
selectionBackground: '#9699a3',
selectionForeground: '#343b58',
black: '#0f0f14',
red: '#8c4351',
green: '#485e30',
yellow: '#8f5e15',
blue: '#34548a',
magenta: '#5a4a78',
cyan: '#0f4b6e',
white: '#343b58',
brightBlack: '#9699a3',
brightRed: '#8c4351',
brightGreen: '#485e30',
brightYellow: '#8f5e15',
brightBlue: '#34548a',
brightMagenta: '#5a4a78',
brightCyan: '#0f4b6e',
brightWhite: '#343b58'
},
'Everforest Light': {
background: '#fdf6e3',
foreground: '#5c6a72',
cursor: '#5c6a72',
cursorAccent: '#fdf6e3',
selectionBackground: '#e6e2cc',
selectionForeground: '#5c6a72',
black: '#5c6a72',
red: '#f85552',
green: '#8da101',
yellow: '#dfa000',
blue: '#3a94c5',
magenta: '#df69ba',
cyan: '#35a77c',
white: '#dfd9a8',
brightBlack: '#939f91',
brightRed: '#f85552',
brightGreen: '#8da101',
brightYellow: '#dfa000',
brightBlue: '#3a94c5',
brightMagenta: '#df69ba',
brightCyan: '#35a77c',
brightWhite: '#fdf6e3'
},
// ──────────────────────────────────────────────
// Classic
// ──────────────────────────────────────────────
'Tango Dark': {
background: '#000000',
foreground: '#d3d7cf',
cursor: '#d3d7cf',
cursorAccent: '#000000',
selectionBackground: '#555753',
selectionForeground: '#eeeeec',
black: '#2e3436',
red: '#cc0000',
green: '#4e9a06',
yellow: '#c4a000',
blue: '#3465a4',
magenta: '#75507b',
cyan: '#06989a',
white: '#d3d7cf',
brightBlack: '#555753',
brightRed: '#ef2929',
brightGreen: '#8ae234',
brightYellow: '#fce94f',
brightBlue: '#729fcf',
brightMagenta: '#ad7fa8',
brightCyan: '#34e2e2',
brightWhite: '#eeeeec'
},
Homebrew: {
background: '#000000',
foreground: '#00ff00',
cursor: '#00ff00',
cursorAccent: '#000000',
selectionBackground: '#005500',
selectionForeground: '#00ff00',
black: '#000000',
red: '#990000',
green: '#00a600',
yellow: '#999900',
blue: '#0000b2',
magenta: '#b200b2',
cyan: '#00a6b2',
white: '#bfbfbf',
brightBlack: '#666666',
brightRed: '#e50000',
brightGreen: '#00d900',
brightYellow: '#e5e500',
brightBlue: '#0000ff',
brightMagenta: '#e500e5',
brightCyan: '#00e5e5',
brightWhite: '#e5e5e5'
},
Snazzy: {
background: '#282a36',
foreground: '#eff0eb',
cursor: '#97979b',
cursorAccent: '#282a36',
selectionBackground: '#3e404a',
selectionForeground: '#eff0eb',
black: '#282a36',
red: '#ff5c57',
green: '#5af78e',
yellow: '#f3f99d',
blue: '#57c7ff',
magenta: '#ff6ac1',
cyan: '#9aedfe',
white: '#f1f1f0',
brightBlack: '#686868',
brightRed: '#ff5c57',
brightGreen: '#5af78e',
brightYellow: '#f3f99d',
brightBlue: '#57c7ff',
brightMagenta: '#ff6ac1',
brightCyan: '#9aedfe',
brightWhite: '#f1f1f0'
}
}
export const TERMINAL_THEMES: Record<string, ITheme> = TERMINAL_THEME_CATALOG
export function getThemeNames(): string[] {
return Object.keys(TERMINAL_THEMES).sort()
@@ -0,0 +1,78 @@
import type { TerminalThemeMap } from './types'
export const CLASSIC_TERMINAL_THEMES: TerminalThemeMap = {
'Tango Dark': {
background: '#000000',
foreground: '#d3d7cf',
cursor: '#d3d7cf',
cursorAccent: '#000000',
selectionBackground: '#555753',
selectionForeground: '#eeeeec',
black: '#2e3436',
red: '#cc0000',
green: '#4e9a06',
yellow: '#c4a000',
blue: '#3465a4',
magenta: '#75507b',
cyan: '#06989a',
white: '#d3d7cf',
brightBlack: '#555753',
brightRed: '#ef2929',
brightGreen: '#8ae234',
brightYellow: '#fce94f',
brightBlue: '#729fcf',
brightMagenta: '#ad7fa8',
brightCyan: '#34e2e2',
brightWhite: '#eeeeec'
},
Homebrew: {
background: '#000000',
foreground: '#00ff00',
cursor: '#00ff00',
cursorAccent: '#000000',
selectionBackground: '#005500',
selectionForeground: '#00ff00',
black: '#000000',
red: '#990000',
green: '#00a600',
yellow: '#999900',
blue: '#0000b2',
magenta: '#b200b2',
cyan: '#00a6b2',
white: '#bfbfbf',
brightBlack: '#666666',
brightRed: '#e50000',
brightGreen: '#00d900',
brightYellow: '#e5e500',
brightBlue: '#0000ff',
brightMagenta: '#e500e5',
brightCyan: '#00e5e5',
brightWhite: '#e5e5e5'
},
Snazzy: {
background: '#282a36',
foreground: '#eff0eb',
cursor: '#97979b',
cursorAccent: '#282a36',
selectionBackground: '#3e404a',
selectionForeground: '#eff0eb',
black: '#282a36',
red: '#ff5c57',
green: '#5af78e',
yellow: '#f3f99d',
blue: '#57c7ff',
magenta: '#ff6ac1',
cyan: '#9aedfe',
white: '#f1f1f0',
brightBlack: '#686868',
brightRed: '#ff5c57',
brightGreen: '#5af78e',
brightYellow: '#f3f99d',
brightBlue: '#57c7ff',
brightMagenta: '#ff6ac1',
brightCyan: '#9aedfe',
brightWhite: '#f1f1f0'
}
}
@@ -0,0 +1,54 @@
import type { TerminalThemeMap } from './types'
export const DEFAULT_TERMINAL_THEMES: TerminalThemeMap = {
// Exact colors from Ghostty source: src/terminal/color.zig + src/config/Config.zig
'Ghostty Default Style Dark': {
background: '#282c34',
foreground: '#ffffff',
cursor: '#ffffff',
cursorAccent: '#282c34',
selectionBackground: '#3e4451',
selectionForeground: '#ffffff',
black: '#1d1f21',
red: '#cc6666',
green: '#b5bd68',
yellow: '#f0c674',
blue: '#81a2be',
magenta: '#b294bb',
cyan: '#8abeb7',
white: '#c5c8c6',
brightBlack: '#666666',
brightRed: '#d54e53',
brightGreen: '#b9ca4a',
brightYellow: '#e7c547',
brightBlue: '#7aa6da',
brightMagenta: '#c397d8',
brightCyan: '#70c0b1',
brightWhite: '#eaeaea'
},
'Builtin Tango Light': {
background: '#ffffff',
foreground: '#2e3434',
cursor: '#2e3434',
cursorAccent: '#ffffff',
selectionBackground: '#accef7',
selectionForeground: '#2e3434',
black: '#2e3436',
red: '#cc0000',
green: '#4e9a06',
yellow: '#c4a000',
blue: '#3465a4',
magenta: '#75507b',
cyan: '#06989a',
white: '#d3d7cf',
brightBlack: '#555753',
brightRed: '#ef2929',
brightGreen: '#8ae234',
brightYellow: '#fce94f',
brightBlue: '#729fcf',
brightMagenta: '#ad7fa8',
brightCyan: '#34e2e2',
brightWhite: '#eeeeec'
}
}
@@ -0,0 +1,17 @@
import { CLASSIC_TERMINAL_THEMES } from './classic'
import { DEFAULT_TERMINAL_THEMES } from './defaults'
import { POPULAR_DARK_TERMINAL_THEMES } from './popular-dark'
import { POPULAR_LIGHT_TERMINAL_THEMES } from './popular-light'
import { mergeTerminalThemeCatalogs } from './shared'
import type { TerminalThemeMap } from './types'
const THEME_CATEGORIES: readonly TerminalThemeMap[] = [
DEFAULT_TERMINAL_THEMES,
POPULAR_DARK_TERMINAL_THEMES,
POPULAR_LIGHT_TERMINAL_THEMES,
CLASSIC_TERMINAL_THEMES
]
export const TERMINAL_THEME_CATALOG: TerminalThemeMap = mergeTerminalThemeCatalogs(
...THEME_CATEGORIES
)
@@ -0,0 +1,196 @@
import type { TerminalThemeMap } from './types'
export const POPULAR_DARK_CORE_TERMINAL_THEMES: TerminalThemeMap = {
Dracula: {
background: '#282a36',
foreground: '#f8f8f2',
cursor: '#f8f8f2',
cursorAccent: '#282a36',
selectionBackground: '#44475a',
selectionForeground: '#f8f8f2',
black: '#21222c',
red: '#ff5555',
green: '#50fa7b',
yellow: '#f1fa8c',
blue: '#bd93f9',
magenta: '#ff79c6',
cyan: '#8be9fd',
white: '#f8f8f2',
brightBlack: '#6272a4',
brightRed: '#ff6e6e',
brightGreen: '#69ff94',
brightYellow: '#ffffa5',
brightBlue: '#d6acff',
brightMagenta: '#ff92df',
brightCyan: '#a4ffff',
brightWhite: '#ffffff'
},
'One Dark': {
background: '#282c34',
foreground: '#abb2bf',
cursor: '#528bff',
cursorAccent: '#282c34',
selectionBackground: '#3e4451',
selectionForeground: '#abb2bf',
black: '#282c34',
red: '#e06c75',
green: '#98c379',
yellow: '#e5c07b',
blue: '#61afef',
magenta: '#c678dd',
cyan: '#56b6c2',
white: '#abb2bf',
brightBlack: '#5c6370',
brightRed: '#e06c75',
brightGreen: '#98c379',
brightYellow: '#e5c07b',
brightBlue: '#61afef',
brightMagenta: '#c678dd',
brightCyan: '#56b6c2',
brightWhite: '#ffffff'
},
Nord: {
background: '#2e3440',
foreground: '#d8dee9',
cursor: '#d8dee9',
cursorAccent: '#2e3440',
selectionBackground: '#434c5e',
selectionForeground: '#d8dee9',
black: '#3b4252',
red: '#bf616a',
green: '#a3be8c',
yellow: '#ebcb8b',
blue: '#81a1c1',
magenta: '#b48ead',
cyan: '#88c0d0',
white: '#e5e9f0',
brightBlack: '#4c566a',
brightRed: '#bf616a',
brightGreen: '#a3be8c',
brightYellow: '#ebcb8b',
brightBlue: '#81a1c1',
brightMagenta: '#b48ead',
brightCyan: '#8fbcbb',
brightWhite: '#eceff4'
},
Monokai: {
background: '#272822',
foreground: '#f8f8f2',
cursor: '#f8f8f0',
cursorAccent: '#272822',
selectionBackground: '#49483e',
selectionForeground: '#f8f8f2',
black: '#272822',
red: '#f92672',
green: '#a6e22e',
yellow: '#f4bf75',
blue: '#66d9ef',
magenta: '#ae81ff',
cyan: '#a1efe4',
white: '#f8f8f2',
brightBlack: '#75715e',
brightRed: '#f92672',
brightGreen: '#a6e22e',
brightYellow: '#f4bf75',
brightBlue: '#66d9ef',
brightMagenta: '#ae81ff',
brightCyan: '#a1efe4',
brightWhite: '#f9f8f5'
},
'Tokyo Night': {
background: '#1a1b26',
foreground: '#c0caf5',
cursor: '#c0caf5',
cursorAccent: '#1a1b26',
selectionBackground: '#33467c',
selectionForeground: '#c0caf5',
black: '#15161e',
red: '#f7768e',
green: '#9ece6a',
yellow: '#e0af68',
blue: '#7aa2f7',
magenta: '#bb9af7',
cyan: '#7dcfff',
white: '#a9b1d6',
brightBlack: '#414868',
brightRed: '#f7768e',
brightGreen: '#9ece6a',
brightYellow: '#e0af68',
brightBlue: '#7aa2f7',
brightMagenta: '#bb9af7',
brightCyan: '#7dcfff',
brightWhite: '#c0caf5'
},
'Gruvbox Dark': {
background: '#282828',
foreground: '#ebdbb2',
cursor: '#ebdbb2',
cursorAccent: '#282828',
selectionBackground: '#504945',
selectionForeground: '#ebdbb2',
black: '#282828',
red: '#cc241d',
green: '#98971a',
yellow: '#d79921',
blue: '#458588',
magenta: '#b16286',
cyan: '#689d6a',
white: '#a89984',
brightBlack: '#928374',
brightRed: '#fb4934',
brightGreen: '#b8bb26',
brightYellow: '#fabd2f',
brightBlue: '#83a598',
brightMagenta: '#d3869b',
brightCyan: '#8ec07c',
brightWhite: '#ebdbb2'
},
'Catppuccin Mocha': {
background: '#1e1e2e',
foreground: '#cdd6f4',
cursor: '#f5e0dc',
cursorAccent: '#1e1e2e',
selectionBackground: '#585b70',
selectionForeground: '#cdd6f4',
black: '#45475a',
red: '#f38ba8',
green: '#a6e3a1',
yellow: '#f9e2af',
blue: '#89b4fa',
magenta: '#f5c2e7',
cyan: '#94e2d5',
white: '#bac2de',
brightBlack: '#585b70',
brightRed: '#f38ba8',
brightGreen: '#a6e3a1',
brightYellow: '#f9e2af',
brightBlue: '#89b4fa',
brightMagenta: '#f5c2e7',
brightCyan: '#94e2d5',
brightWhite: '#a6adc8'
},
'Solarized Dark': {
background: '#002b36',
foreground: '#839496',
cursor: '#839496',
cursorAccent: '#002b36',
selectionBackground: '#073642',
selectionForeground: '#93a1a1',
black: '#073642',
red: '#dc322f',
green: '#859900',
yellow: '#b58900',
blue: '#268bd2',
magenta: '#d33682',
cyan: '#2aa198',
white: '#eee8d5',
brightBlack: '#002b36',
brightRed: '#cb4b16',
brightGreen: '#586e75',
brightYellow: '#657b83',
brightBlue: '#839496',
brightMagenta: '#6c71c4',
brightCyan: '#93a1a1',
brightWhite: '#fdf6e3'
}
}
@@ -0,0 +1,220 @@
import type { TerminalThemeMap } from './types'
export const POPULAR_DARK_EXTENDED_TERMINAL_THEMES: TerminalThemeMap = {
'Material Dark': {
background: '#263238',
foreground: '#eeffff',
cursor: '#ffcc00',
cursorAccent: '#263238',
selectionBackground: '#546e7a',
selectionForeground: '#eeffff',
black: '#000000',
red: '#f07178',
green: '#c3e88d',
yellow: '#ffcb6b',
blue: '#82aaff',
magenta: '#c792ea',
cyan: '#89ddff',
white: '#eeffff',
brightBlack: '#546e7a',
brightRed: '#f07178',
brightGreen: '#c3e88d',
brightYellow: '#ffcb6b',
brightBlue: '#82aaff',
brightMagenta: '#c792ea',
brightCyan: '#89ddff',
brightWhite: '#ffffff'
},
'Ayu Dark': {
background: '#0a0e14',
foreground: '#b3b1ad',
cursor: '#e6b450',
cursorAccent: '#0a0e14',
selectionBackground: '#273747',
selectionForeground: '#b3b1ad',
black: '#01060e',
red: '#ea6c73',
green: '#91b362',
yellow: '#f9af4f',
blue: '#53bdfa',
magenta: '#fae994',
cyan: '#90e1c6',
white: '#c7c7c7',
brightBlack: '#686868',
brightRed: '#f07178',
brightGreen: '#c2d94c',
brightYellow: '#ffb454',
brightBlue: '#59c2ff',
brightMagenta: '#ffee99',
brightCyan: '#95e6cb',
brightWhite: '#ffffff'
},
Nightfox: {
background: '#192330',
foreground: '#cdcecf',
cursor: '#cdcecf',
cursorAccent: '#192330',
selectionBackground: '#2b3b51',
selectionForeground: '#cdcecf',
black: '#393b44',
red: '#c94f6d',
green: '#81b29a',
yellow: '#dbc074',
blue: '#719cd6',
magenta: '#9d79d6',
cyan: '#63cdcf',
white: '#dfdfe0',
brightBlack: '#575860',
brightRed: '#d16983',
brightGreen: '#8ebaa4',
brightYellow: '#e0c989',
brightBlue: '#86abdc',
brightMagenta: '#baa1e2',
brightCyan: '#7ad5d6',
brightWhite: '#e4e4e5'
},
Kanagawa: {
background: '#1f1f28',
foreground: '#dcd7ba',
cursor: '#c8c093',
cursorAccent: '#1f1f28',
selectionBackground: '#2d4f67',
selectionForeground: '#dcd7ba',
black: '#090618',
red: '#c34043',
green: '#76946a',
yellow: '#c0a36e',
blue: '#7e9cd8',
magenta: '#957fb8',
cyan: '#6a9589',
white: '#c8c093',
brightBlack: '#727169',
brightRed: '#e82424',
brightGreen: '#98bb6c',
brightYellow: '#e6c384',
brightBlue: '#7fb4ca',
brightMagenta: '#938aa9',
brightCyan: '#7aa89f',
brightWhite: '#dcd7ba'
},
'Rose Pine': {
background: '#191724',
foreground: '#e0def4',
cursor: '#524f67',
cursorAccent: '#e0def4',
selectionBackground: '#403d52',
selectionForeground: '#e0def4',
black: '#26233a',
red: '#eb6f92',
green: '#31748f',
yellow: '#f6c177',
blue: '#9ccfd8',
magenta: '#c4a7e7',
cyan: '#ebbcba',
white: '#e0def4',
brightBlack: '#6e6a86',
brightRed: '#eb6f92',
brightGreen: '#31748f',
brightYellow: '#f6c177',
brightBlue: '#9ccfd8',
brightMagenta: '#c4a7e7',
brightCyan: '#ebbcba',
brightWhite: '#e0def4'
},
'Everforest Dark': {
background: '#2d353b',
foreground: '#d3c6aa',
cursor: '#d3c6aa',
cursorAccent: '#2d353b',
selectionBackground: '#543a48',
selectionForeground: '#d3c6aa',
black: '#475258',
red: '#e67e80',
green: '#a7c080',
yellow: '#dbbc7f',
blue: '#7fbbb3',
magenta: '#d699b6',
cyan: '#83c092',
white: '#d3c6aa',
brightBlack: '#697379',
brightRed: '#e67e80',
brightGreen: '#a7c080',
brightYellow: '#dbbc7f',
brightBlue: '#7fbbb3',
brightMagenta: '#d699b6',
brightCyan: '#83c092',
brightWhite: '#d3c6aa'
},
Palenight: {
background: '#292d3e',
foreground: '#a6accd',
cursor: '#ffcc00',
cursorAccent: '#292d3e',
selectionBackground: '#434758',
selectionForeground: '#a6accd',
black: '#292d3e',
red: '#f07178',
green: '#c3e88d',
yellow: '#ffcb6b',
blue: '#82aaff',
magenta: '#c792ea',
cyan: '#89ddff',
white: '#a6accd',
brightBlack: '#676e95',
brightRed: '#f07178',
brightGreen: '#c3e88d',
brightYellow: '#ffcb6b',
brightBlue: '#82aaff',
brightMagenta: '#c792ea',
brightCyan: '#89ddff',
brightWhite: '#ffffff'
},
'Horizon Dark': {
background: '#1c1e26',
foreground: '#e0e0e0',
cursor: '#e95678',
cursorAccent: '#1c1e26',
selectionBackground: '#2e303e',
selectionForeground: '#e0e0e0',
black: '#16161c',
red: '#e95678',
green: '#29d398',
yellow: '#fab795',
blue: '#26bbd9',
magenta: '#ee64ac',
cyan: '#59e1e3',
white: '#d5d8da',
brightBlack: '#6c6f93',
brightRed: '#ec6a88',
brightGreen: '#3fdaa4',
brightYellow: '#fbc3a7',
brightBlue: '#3fc4de',
brightMagenta: '#f075b5',
brightCyan: '#6be4e6',
brightWhite: '#f0f0f0'
},
'Night Owl': {
background: '#011627',
foreground: '#d6deeb',
cursor: '#80a4c2',
cursorAccent: '#011627',
selectionBackground: '#1d3b53',
selectionForeground: '#d6deeb',
black: '#011627',
red: '#ef5350',
green: '#22da6e',
yellow: '#addb67',
blue: '#82aaff',
magenta: '#c792ea',
cyan: '#21c7a8',
white: '#ffffff',
brightBlack: '#575656',
brightRed: '#ef5350',
brightGreen: '#22da6e',
brightYellow: '#ffeb95',
brightBlue: '#82aaff',
brightMagenta: '#c792ea',
brightCyan: '#7fdbca',
brightWhite: '#ffffff'
}
}
@@ -0,0 +1,8 @@
import { mergeTerminalThemeCatalogs } from './shared'
import { POPULAR_DARK_CORE_TERMINAL_THEMES } from './popular-dark-core'
import { POPULAR_DARK_EXTENDED_TERMINAL_THEMES } from './popular-dark-extended'
export const POPULAR_DARK_TERMINAL_THEMES = mergeTerminalThemeCatalogs(
POPULAR_DARK_CORE_TERMINAL_THEMES,
POPULAR_DARK_EXTENDED_TERMINAL_THEMES
)
@@ -0,0 +1,203 @@
import type { TerminalThemeMap } from './types'
export const POPULAR_LIGHT_TERMINAL_THEMES: TerminalThemeMap = {
'Solarized Light': {
background: '#fdf6e3',
foreground: '#657b83',
cursor: '#657b83',
cursorAccent: '#fdf6e3',
selectionBackground: '#eee8d5',
selectionForeground: '#586e75',
black: '#073642',
red: '#dc322f',
green: '#859900',
yellow: '#b58900',
blue: '#268bd2',
magenta: '#d33682',
cyan: '#2aa198',
white: '#eee8d5',
brightBlack: '#002b36',
brightRed: '#cb4b16',
brightGreen: '#586e75',
brightYellow: '#657b83',
brightBlue: '#839496',
brightMagenta: '#6c71c4',
brightCyan: '#93a1a1',
brightWhite: '#fdf6e3'
},
'One Light': {
background: '#fafafa',
foreground: '#383a42',
cursor: '#526fff',
cursorAccent: '#fafafa',
selectionBackground: '#e5e5e6',
selectionForeground: '#383a42',
black: '#383a42',
red: '#e45649',
green: '#50a14f',
yellow: '#c18401',
blue: '#4078f2',
magenta: '#a626a4',
cyan: '#0184bc',
white: '#a0a1a7',
brightBlack: '#696c77',
brightRed: '#e45649',
brightGreen: '#50a14f',
brightYellow: '#c18401',
brightBlue: '#4078f2',
brightMagenta: '#a626a4',
brightCyan: '#0184bc',
brightWhite: '#fafafa'
},
'Catppuccin Latte': {
background: '#eff1f5',
foreground: '#4c4f69',
cursor: '#dc8a78',
cursorAccent: '#eff1f5',
selectionBackground: '#acb0be',
selectionForeground: '#4c4f69',
black: '#5c5f77',
red: '#d20f39',
green: '#40a02b',
yellow: '#df8e1d',
blue: '#1e66f5',
magenta: '#ea76cb',
cyan: '#179299',
white: '#acb0be',
brightBlack: '#6c6f85',
brightRed: '#d20f39',
brightGreen: '#40a02b',
brightYellow: '#df8e1d',
brightBlue: '#1e66f5',
brightMagenta: '#ea76cb',
brightCyan: '#179299',
brightWhite: '#bcc0cc'
},
'GitHub Light': {
background: '#ffffff',
foreground: '#24292e',
cursor: '#044289',
cursorAccent: '#ffffff',
selectionBackground: '#c8c8fa',
selectionForeground: '#24292e',
black: '#24292e',
red: '#d73a49',
green: '#28a745',
yellow: '#dbab09',
blue: '#0366d6',
magenta: '#5a32a3',
cyan: '#0598bc',
white: '#6a737d',
brightBlack: '#959da5',
brightRed: '#cb2431',
brightGreen: '#22863a',
brightYellow: '#b08800',
brightBlue: '#005cc5',
brightMagenta: '#5a32a3',
brightCyan: '#3192aa',
brightWhite: '#d1d5da'
},
'Rose Pine Dawn': {
background: '#faf4ed',
foreground: '#575279',
cursor: '#9893a5',
cursorAccent: '#faf4ed',
selectionBackground: '#dfdad9',
selectionForeground: '#575279',
black: '#f2e9e1',
red: '#b4637a',
green: '#286983',
yellow: '#ea9d34',
blue: '#56949f',
magenta: '#907aa9',
cyan: '#d7827e',
white: '#575279',
brightBlack: '#9893a5',
brightRed: '#b4637a',
brightGreen: '#286983',
brightYellow: '#ea9d34',
brightBlue: '#56949f',
brightMagenta: '#907aa9',
brightCyan: '#d7827e',
brightWhite: '#575279'
},
'Gruvbox Light': {
background: '#fbf1c7',
foreground: '#3c3836',
cursor: '#3c3836',
cursorAccent: '#fbf1c7',
selectionBackground: '#ebdbb2',
selectionForeground: '#3c3836',
black: '#fbf1c7',
red: '#cc241d',
green: '#98971a',
yellow: '#d79921',
blue: '#458588',
magenta: '#b16286',
cyan: '#689d6a',
white: '#7c6f64',
brightBlack: '#928374',
brightRed: '#9d0006',
brightGreen: '#79740e',
brightYellow: '#b57614',
brightBlue: '#076678',
brightMagenta: '#8f3f71',
brightCyan: '#427b58',
brightWhite: '#3c3836'
},
'Tokyo Night Light': {
background: '#d5d6db',
foreground: '#343b58',
cursor: '#343b58',
cursorAccent: '#d5d6db',
selectionBackground: '#9699a3',
selectionForeground: '#343b58',
black: '#0f0f14',
red: '#8c4351',
green: '#485e30',
yellow: '#8f5e15',
blue: '#34548a',
magenta: '#5a4a78',
cyan: '#0f4b6e',
white: '#343b58',
brightBlack: '#9699a3',
brightRed: '#8c4351',
brightGreen: '#485e30',
brightYellow: '#8f5e15',
brightBlue: '#34548a',
brightMagenta: '#5a4a78',
brightCyan: '#0f4b6e',
brightWhite: '#343b58'
},
'Everforest Light': {
background: '#fdf6e3',
foreground: '#5c6a72',
cursor: '#5c6a72',
cursorAccent: '#fdf6e3',
selectionBackground: '#e6e2cc',
selectionForeground: '#5c6a72',
black: '#5c6a72',
red: '#f85552',
green: '#8da101',
yellow: '#dfa000',
blue: '#3a94c5',
magenta: '#df69ba',
cyan: '#35a77c',
white: '#dfd9a8',
brightBlack: '#939f91',
brightRed: '#f85552',
brightGreen: '#8da101',
brightYellow: '#dfa000',
brightBlue: '#3a94c5',
brightMagenta: '#df69ba',
brightCyan: '#35a77c',
brightWhite: '#fdf6e3'
}
}
@@ -0,0 +1,18 @@
import type { TerminalThemeMap } from './types'
export function mergeTerminalThemeCatalogs(
...catalogs: readonly TerminalThemeMap[]
): TerminalThemeMap {
const merged: TerminalThemeMap = {}
for (const catalog of catalogs) {
for (const [name, theme] of Object.entries(catalog)) {
if (Object.prototype.hasOwnProperty.call(merged, name)) {
throw new Error(`Duplicate terminal theme name: ${name}`)
}
merged[name] = theme
}
}
return merged
}
@@ -0,0 +1,3 @@
import type { ITheme } from '@xterm/xterm'
export type TerminalThemeMap = Record<string, ITheme>