@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 130 lines 2.86 KB
Raw
1 import {
2 getMobileThemeColors,
3 getMobileThemeVariables,
4 themeColorToNativeColor,
5 type MobileThemeId,
6 } from "../../lib/mobileTheme";
7
8 export type TerminalAppearanceScheme = "light" | "dark";
9
10 export interface TerminalTheme {
11 readonly background: string;
12 readonly foreground: string;
13 readonly mutedForeground: string;
14 readonly border: string;
15 readonly cursorForeground: string;
16 readonly cursorBackground: string;
17 readonly palette: TerminalPalette;
18 }
19
20 type TerminalPalette = readonly [
21 string,
22 string,
23 string,
24 string,
25 string,
26 string,
27 string,
28 string,
29 string,
30 string,
31 string,
32 string,
33 string,
34 string,
35 string,
36 string,
37 ];
38
39 const PIERRE_LIGHT_THEME: TerminalTheme = {
40 background: "#fcfcfc",
41 foreground: "#6C6C71",
42 mutedForeground: "#8E8E95",
43 border: "#eeeeef",
44 cursorForeground: "#009fff",
45 cursorBackground: "#fcfcfc",
46 palette: [
47 "#1F1F21",
48 "#ff2e3f",
49 "#0dbe4e",
50 "#ffca00",
51 "#009fff",
52 "#c635e4",
53 "#08c0ef",
54 "#c6c6c8",
55 "#1F1F21",
56 "#ff2e3f",
57 "#0dbe4e",
58 "#ffca00",
59 "#009fff",
60 "#c635e4",
61 "#08c0ef",
62 "#c6c6c8",
63 ],
64 };
65
66 const PIERRE_DARK_THEME: TerminalTheme = {
67 background: "#0a0a0a",
68 foreground: "#adadb1",
69 mutedForeground: "#8E8E95",
70 border: "#2e2e30",
71 cursorForeground: "#009fff",
72 cursorBackground: "#0a0a0a",
73 palette: [
74 "#141415",
75 "#ff2e3f",
76 "#0dbe4e",
77 "#ffca00",
78 "#009fff",
79 "#c635e4",
80 "#08c0ef",
81 "#c6c6c8",
82 "#141415",
83 "#ff2e3f",
84 "#0dbe4e",
85 "#ffca00",
86 "#009fff",
87 "#c635e4",
88 "#08c0ef",
89 "#c6c6c8",
90 ],
91 };
92
93 function getPierreTerminalTheme(scheme: TerminalAppearanceScheme): TerminalTheme {
94 return scheme === "light" ? PIERRE_LIGHT_THEME : PIERRE_DARK_THEME;
95 }
96
97 export function getMobileTerminalTheme(
98 themeId: MobileThemeId,
99 scheme: TerminalAppearanceScheme,
100 ): TerminalTheme {
101 const base = getPierreTerminalTheme(scheme);
102 const paletteId = themeId === "material-you" ? "t3-code" : themeId;
103 const palette = getMobileThemeColors(paletteId, scheme);
104 const colors = getMobileThemeVariables(paletteId, scheme);
105 const background = themeColorToNativeColor(palette.terminalBackground);
106 return {
107 ...base,
108 background,
109 foreground: themeColorToNativeColor(palette.terminalForeground),
110 mutedForeground: colors["--color-foreground-muted"],
111 border: colors["--color-border"],
112 cursorForeground: themeColorToNativeColor(palette.terminalCursor),
113 cursorBackground: background,
114 };
115 }
116
117 export function buildGhosttyThemeConfig(theme: TerminalTheme): string {
118 const lines = [
119 `background = ${theme.background}`,
120 `foreground = ${theme.foreground}`,
121 `cursor-color = ${theme.cursorForeground}`,
122 `cursor-text = ${theme.cursorBackground}`,
123 ];
124
125 for (const [index, color] of theme.palette.entries()) {
126 lines.push(`palette = ${index}=${color}`);
127 }
128
129 return `${lines.join("\n")}\n`;
130 }