--- Error display --- errorView renders a styled error message inside a bordered box.
(errMsg string, width int)
| 44 | |
| 45 | // colorPaper is the terminal's own background and colorHues are the colors it renders |
| 46 | // the ANSI slots as, both taken from the theme when it says. They are what anything |
| 47 | // drawn *on* a hue needs: an ANSI slot's nominal value says nothing about what a |
| 48 | // reader sees, since a theme retints the running terminal over OSC 4. ANSI blue is |
| 49 | // #000080 nominally and a light periwinkle in a dark Omarchy theme. |
| 50 | colorPaper color.Color = lipgloss.Black |
| 51 | colorHues map[string]color.Color |
| 52 | ) |
| 53 | |
| 54 | // styleMuted dims the theme's default foreground with the SGR faint |
| 55 | // attribute (what eza uses for backup files) instead of coloring it |
| 56 | // BrightBlack: many themes make BrightBlack nearly invisible, while a |
| 57 | // dimmed foreground stays legible everywhere. Use this for all secondary |
| 58 | // text, borders and separators. |
| 59 | var styleMuted = lipgloss.NewStyle().Faint(true) |
| 60 | |
| 61 | // applyTheme makes theme the active palette. Styles built before the call keep the |
| 62 | // old colors — rebuild them with newStyles. |
| 63 | func applyTheme(theme Theme) { |
| 64 | colorPrimary = theme.Accent |
| 65 | colorMuted = theme.Muted |
| 66 | colorBright = theme.Bright |
| 67 | colorLink = lipgloss.BrightCyan |
| 68 | colorError = theme.Error |
| 69 | colorSelection = nil |
| 70 | if theme.Selection != nil && (theme.Trusted || contrastRatio(theme.Accent, theme.Selection) >= minSelectionContrast) { |
| 71 | colorSelection = theme.Selection |
| 72 | } |
| 73 | _, coverColorless = theme.Accent.(lipgloss.NoColor) |
| 74 | // The pill keeps its classic black text on the ANSI accent, but a themed |
| 75 | // accent can be dark enough that black is unreadable on it — lupine's blue |
| 76 | // carries black at only 3.7:1 — so pick whichever of black or white reads |
| 77 | // better there. |
| 78 | colorOnAccent = lipgloss.Black |
| 79 | if nc, ok := theme.Accent.(lipgloss.NoColor); ok { |