(colors: TerminalColors, mode: "dark" | "light")
| 358 | } |
| 359 | |
| 360 | export function generateSystem(colors: TerminalColors, mode: "dark" | "light"): ThemeJson { |
| 361 | const bg = RGBA.fromHex(colors.defaultBackground ?? colors.palette[0]!) |
| 362 | const fg = RGBA.fromHex(colors.defaultForeground ?? colors.palette[7]!) |
| 363 | const transparent = RGBA.fromValues(bg.r, bg.g, bg.b, 0) |
| 364 | const isDark = mode == "dark" |
| 365 | |
| 366 | const col = (i: number) => { |
| 367 | const value = colors.palette[i] |
| 368 | if (value) return RGBA.fromHex(value) |
| 369 | return ansiToRgba(i) |
| 370 | } |
| 371 | |
| 372 | // Generate gray scale based on terminal background |
| 373 | const grays = generateGrayScale(bg, isDark) |
| 374 | const textMuted = generateMutedTextColor(bg, isDark) |
| 375 | |
| 376 | // ANSI color references |
| 377 | const ansiColors = { |
| 378 | black: col(0), |
| 379 | red: col(1), |
| 380 | green: col(2), |
| 381 | yellow: col(3), |
| 382 | blue: col(4), |
| 383 | magenta: col(5), |
| 384 | cyan: col(6), |
| 385 | white: col(7), |
| 386 | redBright: col(9), |
| 387 | greenBright: col(10), |
| 388 | } |
| 389 | |
| 390 | const diffAlpha = isDark ? 0.22 : 0.14 |
| 391 | const diffAddedBg = tint(bg, ansiColors.green, diffAlpha) |
| 392 | const diffRemovedBg = tint(bg, ansiColors.red, diffAlpha) |
| 393 | const diffContextBg = grays[2] |
| 394 | const diffAddedLineNumberBg = tint(diffContextBg, ansiColors.green, diffAlpha) |
| 395 | const diffRemovedLineNumberBg = tint(diffContextBg, ansiColors.red, diffAlpha) |
| 396 | const diffLineNumber = textMuted |
| 397 | |
| 398 | return { |
| 399 | theme: { |
| 400 | // Primary colors using ANSI |
| 401 | primary: ansiColors.cyan, |
| 402 | secondary: ansiColors.magenta, |
| 403 | accent: ansiColors.cyan, |
| 404 | |
| 405 | // Status colors using ANSI |
| 406 | error: ansiColors.red, |
| 407 | warning: ansiColors.yellow, |
| 408 | success: ansiColors.green, |
| 409 | info: ansiColors.cyan, |
| 410 | |
| 411 | // Text colors |
| 412 | text: fg, |
| 413 | textMuted, |
| 414 | selectedListItemText: bg, |
| 415 | |
| 416 | // Background colors - use transparent to respect terminal transparency |
| 417 | background: transparent, |
no test coverage detected