(colors: TerminalColors, pick: "dark" | "light")
| 380 | } |
| 381 | |
| 382 | export function generateSystem(colors: TerminalColors, pick: "dark" | "light"): ThemeJson { |
| 383 | const bg_snapshot = RGBA.fromHex(colors.defaultBackground ?? colors.palette[0]!) |
| 384 | const fg_snapshot = RGBA.fromHex(colors.defaultForeground ?? colors.palette[7]!) |
| 385 | const bg = RGBA.defaultBackground(bg_snapshot) |
| 386 | const fg = RGBA.defaultForeground(fg_snapshot) |
| 387 | const isDark = pick === "dark" |
| 388 | |
| 389 | const color = (index: number) => paletteColor(colors, index) |
| 390 | |
| 391 | const grays = generateGrayScale(bg_snapshot, isDark, (rgba) => rgba) |
| 392 | const textMuted = generateMutedTextColor(bg_snapshot, isDark, (rgba) => rgba) |
| 393 | |
| 394 | const ansi = { |
| 395 | red: color(1), |
| 396 | green: color(2), |
| 397 | yellow: color(3), |
| 398 | blue: color(4), |
| 399 | magenta: color(5), |
| 400 | cyan: color(6), |
| 401 | red_bright: color(9), |
| 402 | green_bright: color(10), |
| 403 | } |
| 404 | |
| 405 | const diff_alpha = isDark ? 0.22 : 0.14 |
| 406 | const diff_context_bg = grays[2] |
| 407 | const primary = ansi.cyan |
| 408 | const secondary = ansi.magenta |
| 409 | |
| 410 | return { |
| 411 | theme: { |
| 412 | primary, |
| 413 | secondary, |
| 414 | accent: primary, |
| 415 | error: ansi.red, |
| 416 | warning: ansi.yellow, |
| 417 | success: ansi.green, |
| 418 | info: ansi.cyan, |
| 419 | text: fg, |
| 420 | textMuted, |
| 421 | selectedListItemText: bg, |
| 422 | background: alpha(bg, 0), |
| 423 | backgroundPanel: grays[2], |
| 424 | backgroundElement: grays[3], |
| 425 | backgroundMenu: grays[3], |
| 426 | borderSubtle: grays[6], |
| 427 | border: grays[7], |
| 428 | borderActive: grays[8], |
| 429 | diffAdded: ansi.green, |
| 430 | diffRemoved: ansi.red, |
| 431 | diffContext: grays[7], |
| 432 | diffHunkHeader: grays[7], |
| 433 | diffHighlightAdded: ansi.green_bright, |
| 434 | diffHighlightRemoved: ansi.red_bright, |
| 435 | diffAddedBg: tint(bg_snapshot, ansi.green, diff_alpha), |
| 436 | diffRemovedBg: tint(bg_snapshot, ansi.red, diff_alpha), |
| 437 | diffContextBg: diff_context_bg, |
| 438 | diffLineNumber: textMuted, |
| 439 | diffAddedLineNumberBg: tint(diff_context_bg, ansi.green, diff_alpha), |
no test coverage detected