diff options
Diffstat (limited to 'internal/tui/styles')
| -rw-r--r-- | internal/tui/styles/huh.go | 173 | ||||
| -rw-r--r-- | internal/tui/styles/markdown.go | 1101 | ||||
| -rw-r--r-- | internal/tui/styles/styles.go | 315 |
3 files changed, 510 insertions, 1079 deletions
diff --git a/internal/tui/styles/huh.go b/internal/tui/styles/huh.go index d0e872758..8df454c1f 100644 --- a/internal/tui/styles/huh.go +++ b/internal/tui/styles/huh.go @@ -3,44 +3,157 @@ package styles import ( "github.com/charmbracelet/huh" "github.com/charmbracelet/lipgloss" + "github.com/opencode-ai/opencode/internal/tui/theme" ) +// returns a huh.Theme configured with the current app theme colors func HuhTheme() *huh.Theme { t := huh.ThemeBase() + currentTheme := theme.CurrentTheme() - t.Focused.Base = t.Focused.Base.BorderStyle(lipgloss.HiddenBorder()) - t.Focused.Title = t.Focused.Title.Foreground(Text) - t.Focused.NoteTitle = t.Focused.NoteTitle.Foreground(Text) - t.Focused.Directory = t.Focused.Directory.Foreground(Text) - t.Focused.Description = t.Focused.Description.Foreground(SubText0) - t.Focused.ErrorIndicator = t.Focused.ErrorIndicator.Foreground(Red) - t.Focused.ErrorMessage = t.Focused.ErrorMessage.Foreground(Red) - t.Focused.SelectSelector = t.Focused.SelectSelector.Foreground(Blue) - t.Focused.NextIndicator = t.Focused.NextIndicator.Foreground(Blue) - t.Focused.PrevIndicator = t.Focused.PrevIndicator.Foreground(Blue) - t.Focused.Option = t.Focused.Option.Foreground(Text) - t.Focused.MultiSelectSelector = t.Focused.MultiSelectSelector.Foreground(Blue) - t.Focused.SelectedOption = t.Focused.SelectedOption.Foreground(Green) - t.Focused.SelectedPrefix = t.Focused.SelectedPrefix.Foreground(Green) - t.Focused.UnselectedPrefix = t.Focused.UnselectedPrefix.Foreground(Text) - t.Focused.UnselectedOption = t.Focused.UnselectedOption.Foreground(Text) - t.Focused.FocusedButton = t.Focused.FocusedButton.Foreground(Base).Background(Blue) - t.Focused.BlurredButton = t.Focused.BlurredButton.Foreground(Text).Background(Base) - - t.Focused.TextInput.Cursor = t.Focused.TextInput.Cursor.Foreground(Teal) - t.Focused.TextInput.Placeholder = t.Focused.TextInput.Placeholder.Foreground(Overlay0) - t.Focused.TextInput.Prompt = t.Focused.TextInput.Prompt.Foreground(Blue) + // Base theme elements + bgColor := currentTheme.Background() + bgSecondaryColor := currentTheme.BackgroundSecondary() + textColor := currentTheme.Text() + textMutedColor := currentTheme.TextMuted() + primaryColor := currentTheme.Primary() + secondaryColor := currentTheme.Secondary() + // accentColor := currentTheme.Accent() + errorColor := currentTheme.Error() + successColor := currentTheme.Success() + // warningColor := currentTheme.Warning() + // infoColor := currentTheme.Info() + borderColor := currentTheme.BorderNormal() + borderFocusedColor := currentTheme.BorderFocused() + // Focused styles + t.Focused.Base = t.Focused.Base. + BorderStyle(lipgloss.HiddenBorder()). + Background(bgColor). + BorderForeground(borderColor) + + t.Focused.Title = t.Focused.Title. + Foreground(textColor). + Background(bgColor) + + t.Focused.NoteTitle = t.Focused.NoteTitle. + Foreground(textColor). + Background(bgColor) + + t.Focused.Directory = t.Focused.Directory. + Foreground(textColor). + Background(bgColor) + + t.Focused.Description = t.Focused.Description. + Foreground(textMutedColor). + Background(bgColor) + + t.Focused.ErrorIndicator = t.Focused.ErrorIndicator. + Foreground(errorColor). + Background(bgColor) + + t.Focused.ErrorMessage = t.Focused.ErrorMessage. + Foreground(errorColor). + Background(bgColor) + + t.Focused.SelectSelector = t.Focused.SelectSelector. + Foreground(primaryColor). + Background(bgColor) + + t.Focused.NextIndicator = t.Focused.NextIndicator. + Foreground(primaryColor). + Background(bgColor) + + t.Focused.PrevIndicator = t.Focused.PrevIndicator. + Foreground(primaryColor). + Background(bgColor) + + t.Focused.Option = t.Focused.Option. + Foreground(textColor). + Background(bgColor) + + t.Focused.MultiSelectSelector = t.Focused.MultiSelectSelector. + Foreground(primaryColor). + Background(bgColor) + + t.Focused.SelectedOption = t.Focused.SelectedOption. + Foreground(successColor). + Background(bgColor) + + t.Focused.SelectedPrefix = t.Focused.SelectedPrefix. + Foreground(successColor). + Background(bgColor) + + t.Focused.UnselectedPrefix = t.Focused.UnselectedPrefix. + Foreground(textColor). + Background(bgColor) + + t.Focused.UnselectedOption = t.Focused.UnselectedOption. + Foreground(textColor). + Background(bgColor) + + t.Focused.FocusedButton = t.Focused.FocusedButton. + Foreground(bgColor). + Background(primaryColor). + BorderForeground(borderFocusedColor) + + t.Focused.BlurredButton = t.Focused.BlurredButton. + Foreground(textColor). + Background(bgSecondaryColor). + BorderForeground(borderColor) + + // Text input styles + t.Focused.TextInput.Cursor = t.Focused.TextInput.Cursor. + Foreground(secondaryColor). + Background(bgColor) + + t.Focused.TextInput.Placeholder = t.Focused.TextInput.Placeholder. + Foreground(textMutedColor). + Background(bgColor) + + t.Focused.TextInput.Prompt = t.Focused.TextInput.Prompt. + Foreground(primaryColor). + Background(bgColor) + + t.Focused.TextInput.Text = t.Focused.TextInput.Text. + Foreground(textColor). + Background(bgColor) + + // Blur and focus states should be similar t.Blurred = t.Focused - t.Blurred.Base = t.Blurred.Base.BorderStyle(lipgloss.HiddenBorder()) + t.Blurred.Base = t.Blurred.Base. + BorderStyle(lipgloss.HiddenBorder()). + Background(bgColor) - t.Help.Ellipsis = t.Help.Ellipsis.Foreground(SubText0) - t.Help.ShortKey = t.Help.ShortKey.Foreground(SubText0) - t.Help.ShortDesc = t.Help.ShortDesc.Foreground(Ovelay1) - t.Help.ShortSeparator = t.Help.ShortSeparator.Foreground(SubText0) - t.Help.FullKey = t.Help.FullKey.Foreground(SubText0) - t.Help.FullDesc = t.Help.FullDesc.Foreground(Ovelay1) - t.Help.FullSeparator = t.Help.FullSeparator.Foreground(SubText0) + // Help styles + t.Help.Ellipsis = t.Help.Ellipsis. + Foreground(textMutedColor). + Background(bgColor) + + t.Help.ShortKey = t.Help.ShortKey. + Foreground(primaryColor). + Background(bgColor) + + t.Help.ShortDesc = t.Help.ShortDesc. + Foreground(textMutedColor). + Background(bgColor) + + t.Help.ShortSeparator = t.Help.ShortSeparator. + Foreground(textMutedColor). + Background(bgColor) + + t.Help.FullKey = t.Help.FullKey. + Foreground(primaryColor). + Background(bgColor) + + t.Help.FullDesc = t.Help.FullDesc. + Foreground(textMutedColor). + Background(bgColor) + + t.Help.FullSeparator = t.Help.FullSeparator. + Foreground(textMutedColor). + Background(bgColor) return t } + diff --git a/internal/tui/styles/markdown.go b/internal/tui/styles/markdown.go index 52816eab3..6b43d97cf 100644 --- a/internal/tui/styles/markdown.go +++ b/internal/tui/styles/markdown.go @@ -1,8 +1,10 @@ package styles import ( + "github.com/charmbracelet/glamour" "github.com/charmbracelet/glamour/ansi" "github.com/charmbracelet/lipgloss" + "github.com/opencode-ai/opencode/internal/tui/theme" ) const defaultMargin = 1 @@ -12,930 +14,271 @@ func boolPtr(b bool) *bool { return &b } func stringPtr(s string) *string { return &s } func uintPtr(u uint) *uint { return &u } -// CatppuccinMarkdownStyle is the Catppuccin Mocha style for Glamour markdown rendering. -func CatppuccinMarkdownStyle() ansi.StyleConfig { - isDark := lipgloss.HasDarkBackground() - if isDark { - return catppuccinDark - } - return catppuccinLight +// returns a glamour TermRenderer configured with the current theme +func GetMarkdownRenderer(width int) *glamour.TermRenderer { + r, _ := glamour.NewTermRenderer( + glamour.WithStyles(generateMarkdownStyleConfig()), + glamour.WithWordWrap(width), + ) + return r } -var catppuccinDark = ansi.StyleConfig{ - Document: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - BlockPrefix: "\n", - BlockSuffix: "", - Color: stringPtr(dark.Text().Hex), - }, - Margin: uintPtr(defaultMargin), - }, - BlockQuote: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Color: stringPtr(dark.Yellow().Hex), - Italic: boolPtr(true), - Prefix: "┃ ", - }, - Indent: uintPtr(1), - IndentToken: stringPtr(BaseStyle.Render(" ")), - }, - List: ansi.StyleList{ - LevelIndent: defaultMargin, - StyleBlock: ansi.StyleBlock{ - IndentToken: stringPtr(BaseStyle.Render(" ")), - StylePrimitive: ansi.StylePrimitive{ - Color: stringPtr(dark.Text().Hex), - }, - }, - }, - Heading: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - BlockSuffix: "\n", - Color: stringPtr(dark.Mauve().Hex), - Bold: boolPtr(true), - }, - }, - H1: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Prefix: "# ", - Color: stringPtr(dark.Lavender().Hex), - Bold: boolPtr(true), - BlockPrefix: "\n", - }, - }, - H2: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Prefix: "## ", - Color: stringPtr(dark.Mauve().Hex), - Bold: boolPtr(true), - }, - }, - H3: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Prefix: "### ", - Color: stringPtr(dark.Pink().Hex), - Bold: boolPtr(true), - }, - }, - H4: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Prefix: "#### ", - Color: stringPtr(dark.Flamingo().Hex), - Bold: boolPtr(true), - }, - }, - H5: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Prefix: "##### ", - Color: stringPtr(dark.Rosewater().Hex), - Bold: boolPtr(true), - }, - }, - H6: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Prefix: "###### ", - Color: stringPtr(dark.Rosewater().Hex), - Bold: boolPtr(true), - }, - }, - Strikethrough: ansi.StylePrimitive{ - CrossedOut: boolPtr(true), - Color: stringPtr(dark.Overlay1().Hex), - }, - Emph: ansi.StylePrimitive{ - Color: stringPtr(dark.Yellow().Hex), - Italic: boolPtr(true), - }, - Strong: ansi.StylePrimitive{ - Bold: boolPtr(true), - Color: stringPtr(dark.Peach().Hex), - }, - HorizontalRule: ansi.StylePrimitive{ - Color: stringPtr(dark.Overlay0().Hex), - Format: "\n─────────────────────────────────────────\n", - }, - Item: ansi.StylePrimitive{ - BlockPrefix: "• ", - Color: stringPtr(dark.Blue().Hex), - }, - Enumeration: ansi.StylePrimitive{ - BlockPrefix: ". ", - Color: stringPtr(dark.Sky().Hex), - }, - Task: ansi.StyleTask{ - StylePrimitive: ansi.StylePrimitive{}, - Ticked: "[✓] ", - Unticked: "[ ] ", - }, - Link: ansi.StylePrimitive{ - Color: stringPtr(dark.Sky().Hex), - Underline: boolPtr(true), - }, - LinkText: ansi.StylePrimitive{ - Color: stringPtr(dark.Pink().Hex), - Bold: boolPtr(true), - }, - Image: ansi.StylePrimitive{ - Color: stringPtr(dark.Sapphire().Hex), - Underline: boolPtr(true), - Format: "🖼 {{.text}}", - }, - ImageText: ansi.StylePrimitive{ - Color: stringPtr(dark.Pink().Hex), - Format: "{{.text}}", - }, - Code: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Color: stringPtr(dark.Green().Hex), - Prefix: "", - Suffix: "", - }, - }, - CodeBlock: ansi.StyleCodeBlock{ - StyleBlock: ansi.StyleBlock{ +// creates an ansi.StyleConfig for markdown rendering +// using adaptive colors from the provided theme. +func generateMarkdownStyleConfig() ansi.StyleConfig { + t := theme.CurrentTheme() + + return ansi.StyleConfig{ + Document: ansi.StyleBlock{ StylePrimitive: ansi.StylePrimitive{ - Prefix: " ", - Color: stringPtr(dark.Text().Hex), + BlockPrefix: "", + BlockSuffix: "", + Color: stringPtr(adaptiveColorToString(t.MarkdownText())), }, - Margin: uintPtr(defaultMargin), }, - Chroma: &ansi.Chroma{ - Text: ansi.StylePrimitive{ - Color: stringPtr(dark.Text().Hex), - }, - Error: ansi.StylePrimitive{ - Color: stringPtr(dark.Text().Hex), - }, - Comment: ansi.StylePrimitive{ - Color: stringPtr(dark.Overlay1().Hex), - }, - CommentPreproc: ansi.StylePrimitive{ - Color: stringPtr(dark.Pink().Hex), - }, - Keyword: ansi.StylePrimitive{ - Color: stringPtr(dark.Pink().Hex), - }, - KeywordReserved: ansi.StylePrimitive{ - Color: stringPtr(dark.Pink().Hex), - }, - KeywordNamespace: ansi.StylePrimitive{ - Color: stringPtr(dark.Pink().Hex), - }, - KeywordType: ansi.StylePrimitive{ - Color: stringPtr(dark.Sky().Hex), - }, - Operator: ansi.StylePrimitive{ - Color: stringPtr(dark.Pink().Hex), - }, - Punctuation: ansi.StylePrimitive{ - Color: stringPtr(dark.Text().Hex), - }, - Name: ansi.StylePrimitive{ - Color: stringPtr(dark.Sky().Hex), - }, - NameBuiltin: ansi.StylePrimitive{ - Color: stringPtr(dark.Sky().Hex), - }, - NameTag: ansi.StylePrimitive{ - Color: stringPtr(dark.Pink().Hex), - }, - NameAttribute: ansi.StylePrimitive{ - Color: stringPtr(dark.Green().Hex), - }, - NameClass: ansi.StylePrimitive{ - Color: stringPtr(dark.Sky().Hex), - }, - NameConstant: ansi.StylePrimitive{ - Color: stringPtr(dark.Mauve().Hex), - }, - NameDecorator: ansi.StylePrimitive{ - Color: stringPtr(dark.Green().Hex), - }, - NameFunction: ansi.StylePrimitive{ - Color: stringPtr(dark.Green().Hex), - }, - LiteralNumber: ansi.StylePrimitive{ - Color: stringPtr(dark.Teal().Hex), - }, - LiteralString: ansi.StylePrimitive{ - Color: stringPtr(dark.Yellow().Hex), - }, - LiteralStringEscape: ansi.StylePrimitive{ - Color: stringPtr(dark.Pink().Hex), - }, - GenericDeleted: ansi.StylePrimitive{ - Color: stringPtr(dark.Red().Hex), - }, - GenericEmph: ansi.StylePrimitive{ - Color: stringPtr(dark.Yellow().Hex), + BlockQuote: ansi.StyleBlock{ + StylePrimitive: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.MarkdownBlockQuote())), Italic: boolPtr(true), + Prefix: "┃ ", }, - GenericInserted: ansi.StylePrimitive{ - Color: stringPtr(dark.Green().Hex), - }, - GenericStrong: ansi.StylePrimitive{ - Color: stringPtr(dark.Peach().Hex), - Bold: boolPtr(true), - }, - GenericSubheading: ansi.StylePrimitive{ - Color: stringPtr(dark.Mauve().Hex), + Indent: uintPtr(1), + IndentToken: stringPtr(BaseStyle().Render(" ")), + }, + List: ansi.StyleList{ + LevelIndent: defaultMargin, + StyleBlock: ansi.StyleBlock{ + IndentToken: stringPtr(BaseStyle().Render(" ")), + StylePrimitive: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.MarkdownText())), + }, }, }, - }, - Table: ansi.StyleTable{ - StyleBlock: ansi.StyleBlock{ + Heading: ansi.StyleBlock{ StylePrimitive: ansi.StylePrimitive{ - BlockPrefix: "\n", BlockSuffix: "\n", + Color: stringPtr(adaptiveColorToString(t.MarkdownHeading())), + Bold: boolPtr(true), }, }, - CenterSeparator: stringPtr("┼"), - ColumnSeparator: stringPtr("│"), - RowSeparator: stringPtr("─"), - }, - DefinitionDescription: ansi.StylePrimitive{ - BlockPrefix: "\n ❯ ", - Color: stringPtr(dark.Sapphire().Hex), - }, -} - -var catppuccinLight = ansi.StyleConfig{ - Document: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - BlockPrefix: "\n", - BlockSuffix: "\n", - Color: stringPtr(light.Text().Hex), - }, - Margin: uintPtr(defaultMargin), - }, - BlockQuote: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Color: stringPtr(light.Yellow().Hex), - Italic: boolPtr(true), - Prefix: "┃ ", - }, - Indent: uintPtr(1), - Margin: uintPtr(defaultMargin), - }, - List: ansi.StyleList{ - LevelIndent: defaultMargin, - StyleBlock: ansi.StyleBlock{ + H1: ansi.StyleBlock{ StylePrimitive: ansi.StylePrimitive{ - Color: stringPtr(light.Text().Hex), + Prefix: "# ", + Color: stringPtr(adaptiveColorToString(t.MarkdownHeading())), + Bold: boolPtr(true), }, }, - }, - Heading: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - BlockSuffix: "\n", - Color: stringPtr(light.Mauve().Hex), - Bold: boolPtr(true), - }, - }, - H1: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Prefix: "# ", - Color: stringPtr(light.Lavender().Hex), - Bold: boolPtr(true), - BlockPrefix: "\n", - }, - }, - H2: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Prefix: "## ", - Color: stringPtr(light.Mauve().Hex), - Bold: boolPtr(true), - }, - }, - H3: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Prefix: "### ", - Color: stringPtr(light.Pink().Hex), - Bold: boolPtr(true), - }, - }, - H4: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Prefix: "#### ", - Color: stringPtr(light.Flamingo().Hex), - Bold: boolPtr(true), - }, - }, - H5: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Prefix: "##### ", - Color: stringPtr(light.Rosewater().Hex), - Bold: boolPtr(true), - }, - }, - H6: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Prefix: "###### ", - Color: stringPtr(light.Rosewater().Hex), - Bold: boolPtr(true), - }, - }, - Strikethrough: ansi.StylePrimitive{ - CrossedOut: boolPtr(true), - Color: stringPtr(light.Overlay1().Hex), - }, - Emph: ansi.StylePrimitive{ - Color: stringPtr(light.Yellow().Hex), - Italic: boolPtr(true), - }, - Strong: ansi.StylePrimitive{ - Bold: boolPtr(true), - Color: stringPtr(light.Peach().Hex), - }, - HorizontalRule: ansi.StylePrimitive{ - Color: stringPtr(light.Overlay0().Hex), - Format: "\n─────────────────────────────────────────\n", - }, - Item: ansi.StylePrimitive{ - BlockPrefix: "• ", - Color: stringPtr(light.Blue().Hex), - }, - Enumeration: ansi.StylePrimitive{ - BlockPrefix: ". ", - Color: stringPtr(light.Sky().Hex), - }, - Task: ansi.StyleTask{ - StylePrimitive: ansi.StylePrimitive{}, - Ticked: "[✓] ", - Unticked: "[ ] ", - }, - Link: ansi.StylePrimitive{ - Color: stringPtr(light.Sky().Hex), - Underline: boolPtr(true), - }, - LinkText: ansi.StylePrimitive{ - Color: stringPtr(light.Pink().Hex), - Bold: boolPtr(true), - }, - Image: ansi.StylePrimitive{ - Color: stringPtr(light.Sapphire().Hex), - Underline: boolPtr(true), - Format: "🖼 {{.text}}", - }, - ImageText: ansi.StylePrimitive{ - Color: stringPtr(light.Pink().Hex), - Format: "{{.text}}", - }, - Code: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Color: stringPtr(light.Green().Hex), - Prefix: " ", - Suffix: " ", - }, - }, - CodeBlock: ansi.StyleCodeBlock{ - StyleBlock: ansi.StyleBlock{ + H2: ansi.StyleBlock{ StylePrimitive: ansi.StylePrimitive{ - Prefix: " ", - Color: stringPtr(light.Text().Hex), + Prefix: "## ", + Color: stringPtr(adaptiveColorToString(t.MarkdownHeading())), + Bold: boolPtr(true), }, - - Margin: uintPtr(defaultMargin), }, - Chroma: &ansi.Chroma{ - Text: ansi.StylePrimitive{ - Color: stringPtr(light.Text().Hex), - }, - Error: ansi.StylePrimitive{ - Color: stringPtr(light.Text().Hex), - }, - Comment: ansi.StylePrimitive{ - Color: stringPtr(light.Overlay1().Hex), - }, - CommentPreproc: ansi.StylePrimitive{ - Color: stringPtr(light.Pink().Hex), - }, - Keyword: ansi.StylePrimitive{ - Color: stringPtr(light.Pink().Hex), - }, - KeywordReserved: ansi.StylePrimitive{ - Color: stringPtr(light.Pink().Hex), - }, - KeywordNamespace: ansi.StylePrimitive{ - Color: stringPtr(light.Pink().Hex), - }, - KeywordType: ansi.StylePrimitive{ - Color: stringPtr(light.Sky().Hex), - }, - Operator: ansi.StylePrimitive{ - Color: stringPtr(light.Pink().Hex), - }, - Punctuation: ansi.StylePrimitive{ - Color: stringPtr(light.Text().Hex), - }, - Name: ansi.StylePrimitive{ - Color: stringPtr(light.Sky().Hex), - }, - NameBuiltin: ansi.StylePrimitive{ - Color: stringPtr(light.Sky().Hex), - }, - NameTag: ansi.StylePrimitive{ - Color: stringPtr(light.Pink().Hex), - }, - NameAttribute: ansi.StylePrimitive{ - Color: stringPtr(light.Green().Hex), - }, - NameClass: ansi.StylePrimitive{ - Color: stringPtr(light.Sky().Hex), - }, - NameConstant: ansi.StylePrimitive{ - Color: stringPtr(light.Mauve().Hex), - }, - NameDecorator: ansi.StylePrimitive{ - Color: stringPtr(light.Green().Hex), - }, - NameFunction: ansi.StylePrimitive{ - Color: stringPtr(light.Green().Hex), - }, - LiteralNumber: ansi.StylePrimitive{ - Color: stringPtr(light.Teal().Hex), - }, - LiteralString: ansi.StylePrimitive{ - Color: stringPtr(light.Yellow().Hex), - }, - LiteralStringEscape: ansi.StylePrimitive{ - Color: stringPtr(light.Pink().Hex), - }, - GenericDeleted: ansi.StylePrimitive{ - Color: stringPtr(light.Red().Hex), - }, - GenericEmph: ansi.StylePrimitive{ - Color: stringPtr(light.Yellow().Hex), - Italic: boolPtr(true), - }, - GenericInserted: ansi.StylePrimitive{ - Color: stringPtr(light.Green().Hex), - }, - GenericStrong: ansi.StylePrimitive{ - Color: stringPtr(light.Peach().Hex), - Bold: boolPtr(true), - }, - GenericSubheading: ansi.StylePrimitive{ - Color: stringPtr(light.Mauve().Hex), - }, - }, - }, - Table: ansi.StyleTable{ - StyleBlock: ansi.StyleBlock{ + H3: ansi.StyleBlock{ StylePrimitive: ansi.StylePrimitive{ - BlockPrefix: "\n", - BlockSuffix: "\n", + Prefix: "### ", + Color: stringPtr(adaptiveColorToString(t.MarkdownHeading())), + Bold: boolPtr(true), }, }, - CenterSeparator: stringPtr("┼"), - ColumnSeparator: stringPtr("│"), - RowSeparator: stringPtr("─"), - }, - DefinitionDescription: ansi.StylePrimitive{ - BlockPrefix: "\n ❯ ", - Color: stringPtr(light.Sapphire().Hex), - }, -} - -func MarkdownTheme(focused bool) ansi.StyleConfig { - if !focused { - return ASCIIStyleConfig - } else { - return DraculaStyleConfig - } -} - -const ( - defaultListIndent = 2 - defaultListLevelIndent = 4 -) - -var ASCIIStyleConfig = ansi.StyleConfig{ - Document: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - Color: stringPtr(ForgroundDim.Dark), - }, - Indent: uintPtr(1), - IndentToken: stringPtr(BaseStyle.Render(" ")), - }, - BlockQuote: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - }, - Indent: uintPtr(1), - IndentToken: stringPtr("| "), - }, - Paragraph: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - }, - }, - List: ansi.StyleList{ - StyleBlock: ansi.StyleBlock{ - IndentToken: stringPtr(BaseStyle.Render(" ")), + H4: ansi.StyleBlock{ StylePrimitive: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), + Prefix: "#### ", + Color: stringPtr(adaptiveColorToString(t.MarkdownHeading())), + Bold: boolPtr(true), }, }, - LevelIndent: defaultListLevelIndent, - }, - Heading: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - BlockSuffix: "\n", - }, - }, - H1: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - Prefix: "# ", - }, - }, - H2: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - Prefix: "## ", - }, - }, - H3: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - Prefix: "### ", - }, - }, - H4: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - Prefix: "#### ", - }, - }, - H5: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - Prefix: "##### ", - }, - }, - H6: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - Prefix: "###### ", - }, - }, - Strikethrough: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - BlockPrefix: "~~", - BlockSuffix: "~~", - }, - Emph: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - BlockPrefix: "*", - BlockSuffix: "*", - }, - Strong: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - BlockPrefix: "**", - BlockSuffix: "**", - }, - HorizontalRule: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - Format: "\n--------\n", - }, - Item: ansi.StylePrimitive{ - BlockPrefix: "• ", - BackgroundColor: stringPtr(Background.Dark), - }, - Enumeration: ansi.StylePrimitive{ - BlockPrefix: ". ", - BackgroundColor: stringPtr(Background.Dark), - }, - Task: ansi.StyleTask{ - Ticked: "[x] ", - Unticked: "[ ] ", - StylePrimitive: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - }, - }, - ImageText: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - Format: "Image: {{.text}} →", - }, - Code: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - BlockPrefix: "`", - BlockSuffix: "`", - BackgroundColor: stringPtr(Background.Dark), - }, - }, - CodeBlock: ansi.StyleCodeBlock{ - StyleBlock: ansi.StyleBlock{ + H5: ansi.StyleBlock{ StylePrimitive: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), + Prefix: "##### ", + Color: stringPtr(adaptiveColorToString(t.MarkdownHeading())), + Bold: boolPtr(true), }, - Margin: uintPtr(defaultMargin), }, - }, - Table: ansi.StyleTable{ - StyleBlock: ansi.StyleBlock{ + H6: ansi.StyleBlock{ StylePrimitive: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), + Prefix: "###### ", + Color: stringPtr(adaptiveColorToString(t.MarkdownHeading())), + Bold: boolPtr(true), }, - IndentToken: stringPtr(BaseStyle.Render(" ")), - }, - CenterSeparator: stringPtr("|"), - ColumnSeparator: stringPtr("|"), - RowSeparator: stringPtr("-"), - }, - DefinitionDescription: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - BlockPrefix: "\n* ", - }, -} - -var DraculaStyleConfig = ansi.StyleConfig{ - Document: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Color: stringPtr(Forground.Dark), - BackgroundColor: stringPtr(Background.Dark), - }, - Indent: uintPtr(defaultMargin), - IndentToken: stringPtr(BaseStyle.Render(" ")), - }, - BlockQuote: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Color: stringPtr("#f1fa8c"), - Italic: boolPtr(true), - BackgroundColor: stringPtr(Background.Dark), }, - Indent: uintPtr(defaultMargin), - IndentToken: stringPtr(BaseStyle.Render(" ")), - }, - Paragraph: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), + Strikethrough: ansi.StylePrimitive{ + CrossedOut: boolPtr(true), + Color: stringPtr(adaptiveColorToString(t.TextMuted())), }, - }, - List: ansi.StyleList{ - LevelIndent: defaultMargin, - StyleBlock: ansi.StyleBlock{ - IndentToken: stringPtr(BaseStyle.Render(" ")), - StylePrimitive: ansi.StylePrimitive{ - Color: stringPtr(Forground.Dark), - BackgroundColor: stringPtr(Background.Dark), - }, + Emph: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.MarkdownEmph())), + Italic: boolPtr(true), }, - }, - Heading: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - BlockSuffix: "\n", - Color: stringPtr(PrimaryColor.Dark), - Bold: boolPtr(true), - BackgroundColor: stringPtr(Background.Dark), + Strong: ansi.StylePrimitive{ + Bold: boolPtr(true), + Color: stringPtr(adaptiveColorToString(t.MarkdownStrong())), }, - }, - H1: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Prefix: "# ", - BackgroundColor: stringPtr(Background.Dark), + HorizontalRule: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.MarkdownHorizontalRule())), + Format: "\n─────────────────────────────────────────\n", }, - }, - H2: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Prefix: "## ", - BackgroundColor: stringPtr(Background.Dark), + Item: ansi.StylePrimitive{ + BlockPrefix: "• ", + Color: stringPtr(adaptiveColorToString(t.MarkdownListItem())), }, - }, - H3: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Prefix: "### ", - BackgroundColor: stringPtr(Background.Dark), + Enumeration: ansi.StylePrimitive{ + BlockPrefix: ". ", + Color: stringPtr(adaptiveColorToString(t.MarkdownListEnumeration())), }, - }, - H4: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Prefix: "#### ", - BackgroundColor: stringPtr(Background.Dark), + Task: ansi.StyleTask{ + StylePrimitive: ansi.StylePrimitive{}, + Ticked: "[✓] ", + Unticked: "[ ] ", }, - }, - H5: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Prefix: "##### ", - BackgroundColor: stringPtr(Background.Dark), + Link: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.MarkdownLink())), + Underline: boolPtr(true), }, - }, - H6: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Prefix: "###### ", - BackgroundColor: stringPtr(Background.Dark), + LinkText: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.MarkdownLinkText())), + Bold: boolPtr(true), }, - }, - Strikethrough: ansi.StylePrimitive{ - CrossedOut: boolPtr(true), - BackgroundColor: stringPtr(Background.Dark), - }, - Emph: ansi.StylePrimitive{ - Color: stringPtr("#f1fa8c"), - Italic: boolPtr(true), - BackgroundColor: stringPtr(Background.Dark), - }, - Strong: ansi.StylePrimitive{ - Bold: boolPtr(true), - Color: stringPtr(Blue.Dark), - BackgroundColor: stringPtr(Background.Dark), - }, - HorizontalRule: ansi.StylePrimitive{ - Color: stringPtr("#6272A4"), - Format: "\n--------\n", - BackgroundColor: stringPtr(Background.Dark), - }, - Item: ansi.StylePrimitive{ - BlockPrefix: "• ", - BackgroundColor: stringPtr(Background.Dark), - }, - Enumeration: ansi.StylePrimitive{ - BlockPrefix: ". ", - Color: stringPtr("#8be9fd"), - BackgroundColor: stringPtr(Background.Dark), - }, - Task: ansi.StyleTask{ - StylePrimitive: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), + Image: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.MarkdownImage())), + Underline: boolPtr(true), + Format: "🖼 {{.text}}", }, - Ticked: "[✓] ", - Unticked: "[ ] ", - }, - Link: ansi.StylePrimitive{ - Color: stringPtr("#8be9fd"), - Underline: boolPtr(true), - BackgroundColor: stringPtr(Background.Dark), - }, - LinkText: ansi.StylePrimitive{ - Color: stringPtr("#ff79c6"), - BackgroundColor: stringPtr(Background.Dark), - }, - Image: ansi.StylePrimitive{ - Color: stringPtr("#8be9fd"), - Underline: boolPtr(true), - BackgroundColor: stringPtr(Background.Dark), - }, - ImageText: ansi.StylePrimitive{ - Color: stringPtr("#ff79c6"), - Format: "Image: {{.text}} →", - BackgroundColor: stringPtr(Background.Dark), - }, - Code: ansi.StyleBlock{ - StylePrimitive: ansi.StylePrimitive{ - Color: stringPtr("#50fa7b"), - BackgroundColor: stringPtr(Background.Dark), + ImageText: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.MarkdownImageText())), + Format: "{{.text}}", }, - }, - Text: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - }, - DefinitionList: ansi.StyleBlock{}, - CodeBlock: ansi.StyleCodeBlock{ - StyleBlock: ansi.StyleBlock{ + Code: ansi.StyleBlock{ StylePrimitive: ansi.StylePrimitive{ - Color: stringPtr(Blue.Dark), - BackgroundColor: stringPtr(Background.Dark), - }, - Margin: uintPtr(defaultMargin), - }, - Chroma: &ansi.Chroma{ - NameOther: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - }, - Literal: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - }, - NameException: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - }, - LiteralDate: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - }, - Text: ansi.StylePrimitive{ - Color: stringPtr(Forground.Dark), - BackgroundColor: stringPtr(Background.Dark), - }, - Error: ansi.StylePrimitive{ - Color: stringPtr("#f8f8f2"), - BackgroundColor: stringPtr("#ff5555"), - }, - Comment: ansi.StylePrimitive{ - Color: stringPtr("#6272A4"), - BackgroundColor: stringPtr(Background.Dark), - }, - CommentPreproc: ansi.StylePrimitive{ - Color: stringPtr("#ff79c6"), - BackgroundColor: stringPtr(Background.Dark), - }, - Keyword: ansi.StylePrimitive{ - Color: stringPtr("#ff79c6"), - BackgroundColor: stringPtr(Background.Dark), - }, - KeywordReserved: ansi.StylePrimitive{ - Color: stringPtr("#ff79c6"), - BackgroundColor: stringPtr(Background.Dark), - }, - KeywordNamespace: ansi.StylePrimitive{ - Color: stringPtr("#ff79c6"), - BackgroundColor: stringPtr(Background.Dark), - }, - KeywordType: ansi.StylePrimitive{ - Color: stringPtr("#8be9fd"), - BackgroundColor: stringPtr(Background.Dark), - }, - Operator: ansi.StylePrimitive{ - Color: stringPtr("#ff79c6"), - BackgroundColor: stringPtr(Background.Dark), - }, - Punctuation: ansi.StylePrimitive{ - Color: stringPtr(Forground.Dark), - BackgroundColor: stringPtr(Background.Dark), - }, - Name: ansi.StylePrimitive{ - Color: stringPtr("#8be9fd"), - BackgroundColor: stringPtr(Background.Dark), - }, - NameBuiltin: ansi.StylePrimitive{ - Color: stringPtr("#8be9fd"), - BackgroundColor: stringPtr(Background.Dark), - }, - NameTag: ansi.StylePrimitive{ - Color: stringPtr("#ff79c6"), - BackgroundColor: stringPtr(Background.Dark), - }, - NameAttribute: ansi.StylePrimitive{ - Color: stringPtr("#50fa7b"), - BackgroundColor: stringPtr(Background.Dark), - }, - NameClass: ansi.StylePrimitive{ - Color: stringPtr("#8be9fd"), - BackgroundColor: stringPtr(Background.Dark), - }, - NameConstant: ansi.StylePrimitive{ - Color: stringPtr("#bd93f9"), - BackgroundColor: stringPtr(Background.Dark), - }, - NameDecorator: ansi.StylePrimitive{ - Color: stringPtr("#50fa7b"), - BackgroundColor: stringPtr(Background.Dark), - }, - NameFunction: ansi.StylePrimitive{ - Color: stringPtr("#50fa7b"), - BackgroundColor: stringPtr(Background.Dark), - }, - LiteralNumber: ansi.StylePrimitive{ - Color: stringPtr("#6EEFC0"), - BackgroundColor: stringPtr(Background.Dark), - }, - LiteralString: ansi.StylePrimitive{ - Color: stringPtr("#f1fa8c"), - BackgroundColor: stringPtr(Background.Dark), - }, - LiteralStringEscape: ansi.StylePrimitive{ - Color: stringPtr("#ff79c6"), - BackgroundColor: stringPtr(Background.Dark), - }, - GenericDeleted: ansi.StylePrimitive{ - Color: stringPtr("#ff5555"), - BackgroundColor: stringPtr(Background.Dark), - }, - GenericEmph: ansi.StylePrimitive{ - Color: stringPtr("#f1fa8c"), - Italic: boolPtr(true), - BackgroundColor: stringPtr(Background.Dark), - }, - GenericInserted: ansi.StylePrimitive{ - Color: stringPtr("#50fa7b"), - BackgroundColor: stringPtr(Background.Dark), - }, - GenericStrong: ansi.StylePrimitive{ - Color: stringPtr("#ffb86c"), - Bold: boolPtr(true), - BackgroundColor: stringPtr(Background.Dark), - }, - GenericSubheading: ansi.StylePrimitive{ - Color: stringPtr("#bd93f9"), - BackgroundColor: stringPtr(Background.Dark), - }, - Background: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), - }, - }, - }, - Table: ansi.StyleTable{ - StyleBlock: ansi.StyleBlock{ + Color: stringPtr(adaptiveColorToString(t.MarkdownCode())), + Prefix: "", + Suffix: "", + }, + }, + CodeBlock: ansi.StyleCodeBlock{ + StyleBlock: ansi.StyleBlock{ + StylePrimitive: ansi.StylePrimitive{ + Prefix: " ", + Color: stringPtr(adaptiveColorToString(t.MarkdownCodeBlock())), + }, + Margin: uintPtr(defaultMargin), + }, + Chroma: &ansi.Chroma{ + Text: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.MarkdownText())), + }, + Error: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.Error())), + }, + Comment: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.SyntaxComment())), + }, + CommentPreproc: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.SyntaxKeyword())), + }, + Keyword: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.SyntaxKeyword())), + }, + KeywordReserved: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.SyntaxKeyword())), + }, + KeywordNamespace: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.SyntaxKeyword())), + }, + KeywordType: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.SyntaxType())), + }, + Operator: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.SyntaxOperator())), + }, + Punctuation: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.SyntaxPunctuation())), + }, + Name: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.SyntaxVariable())), + }, + NameBuiltin: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.SyntaxVariable())), + }, + NameTag: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.SyntaxKeyword())), + }, + NameAttribute: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.SyntaxFunction())), + }, + NameClass: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.SyntaxType())), + }, + NameConstant: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.SyntaxVariable())), + }, + NameDecorator: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.SyntaxFunction())), + }, + NameFunction: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.SyntaxFunction())), + }, + LiteralNumber: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.SyntaxNumber())), + }, + LiteralString: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.SyntaxString())), + }, + LiteralStringEscape: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.SyntaxKeyword())), + }, + GenericDeleted: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.DiffRemoved())), + }, + GenericEmph: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.MarkdownEmph())), + Italic: boolPtr(true), + }, + GenericInserted: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.DiffAdded())), + }, + GenericStrong: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.MarkdownStrong())), + Bold: boolPtr(true), + }, + GenericSubheading: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.MarkdownHeading())), + }, + }, + }, + Table: ansi.StyleTable{ + StyleBlock: ansi.StyleBlock{ + StylePrimitive: ansi.StylePrimitive{ + BlockPrefix: "\n", + BlockSuffix: "\n", + }, + }, + CenterSeparator: stringPtr("┼"), + ColumnSeparator: stringPtr("│"), + RowSeparator: stringPtr("─"), + }, + DefinitionDescription: ansi.StylePrimitive{ + BlockPrefix: "\n ❯ ", + Color: stringPtr(adaptiveColorToString(t.MarkdownLinkText())), + }, + Text: ansi.StylePrimitive{ + Color: stringPtr(adaptiveColorToString(t.MarkdownText())), + }, + Paragraph: ansi.StyleBlock{ StylePrimitive: ansi.StylePrimitive{ - BackgroundColor: stringPtr(Background.Dark), + Color: stringPtr(adaptiveColorToString(t.MarkdownText())), }, - IndentToken: stringPtr(BaseStyle.Render(" ")), }, - }, - DefinitionDescription: ansi.StylePrimitive{ - BlockPrefix: "\n* ", - BackgroundColor: stringPtr(Background.Dark), - }, + } +} + +// adaptiveColorToString converts a lipgloss.AdaptiveColor to the appropriate +// hex color string based on the current terminal background +func adaptiveColorToString(color lipgloss.AdaptiveColor) string { + if lipgloss.HasDarkBackground() { + return color.Dark + } + return color.Light } diff --git a/internal/tui/styles/styles.go b/internal/tui/styles/styles.go index 476339b57..1d6cf80d5 100644 --- a/internal/tui/styles/styles.go +++ b/internal/tui/styles/styles.go @@ -1,177 +1,152 @@ package styles import ( - catppuccin "github.com/catppuccin/go" "github.com/charmbracelet/lipgloss" + "github.com/opencode-ai/opencode/internal/tui/theme" ) -var ( - light = catppuccin.Latte - dark = catppuccin.Mocha -) - -// NEW STYLES -var ( - Background = lipgloss.AdaptiveColor{ - Dark: "#212121", - Light: "#212121", - } - BackgroundDim = lipgloss.AdaptiveColor{ - Dark: "#2c2c2c", - Light: "#2c2c2c", - } - BackgroundDarker = lipgloss.AdaptiveColor{ - Dark: "#181818", - Light: "#181818", - } - BorderColor = lipgloss.AdaptiveColor{ - Dark: "#4b4c5c", - Light: "#4b4c5c", - } - - Forground = lipgloss.AdaptiveColor{ - Dark: "#d3d3d3", - Light: "#d3d3d3", - } - - ForgroundMid = lipgloss.AdaptiveColor{ - Dark: "#a0a0a0", - Light: "#a0a0a0", - } - - ForgroundDim = lipgloss.AdaptiveColor{ - Dark: "#737373", - Light: "#737373", - } - - BaseStyle = lipgloss.NewStyle(). - Background(Background). - Foreground(Forground) - - PrimaryColor = lipgloss.AdaptiveColor{ - Dark: "#fab283", - Light: "#fab283", - } -) +// Style generation functions that use the current theme + +// BaseStyle returns the base style with background and foreground colors +func BaseStyle() lipgloss.Style { + t := theme.CurrentTheme() + return lipgloss.NewStyle(). + Background(t.Background()). + Foreground(t.Text()) +} + +// Regular returns a basic unstyled lipgloss.Style +func Regular() lipgloss.Style { + return lipgloss.NewStyle() +} + +// Bold returns a bold style +func Bold() lipgloss.Style { + return Regular().Bold(true) +} + +// Padded returns a style with horizontal padding +func Padded() lipgloss.Style { + return Regular().Padding(0, 1) +} + +// Border returns a style with a normal border +func Border() lipgloss.Style { + t := theme.CurrentTheme() + return Regular(). + Border(lipgloss.NormalBorder()). + BorderForeground(t.BorderNormal()) +} + +// ThickBorder returns a style with a thick border +func ThickBorder() lipgloss.Style { + t := theme.CurrentTheme() + return Regular(). + Border(lipgloss.ThickBorder()). + BorderForeground(t.BorderNormal()) +} + +// DoubleBorder returns a style with a double border +func DoubleBorder() lipgloss.Style { + t := theme.CurrentTheme() + return Regular(). + Border(lipgloss.DoubleBorder()). + BorderForeground(t.BorderNormal()) +} + +// FocusedBorder returns a style with a border using the focused border color +func FocusedBorder() lipgloss.Style { + t := theme.CurrentTheme() + return Regular(). + Border(lipgloss.NormalBorder()). + BorderForeground(t.BorderFocused()) +} + +// DimBorder returns a style with a border using the dim border color +func DimBorder() lipgloss.Style { + t := theme.CurrentTheme() + return Regular(). + Border(lipgloss.NormalBorder()). + BorderForeground(t.BorderDim()) +} + +// PrimaryColor returns the primary color from the current theme +func PrimaryColor() lipgloss.AdaptiveColor { + return theme.CurrentTheme().Primary() +} + +// SecondaryColor returns the secondary color from the current theme +func SecondaryColor() lipgloss.AdaptiveColor { + return theme.CurrentTheme().Secondary() +} + +// AccentColor returns the accent color from the current theme +func AccentColor() lipgloss.AdaptiveColor { + return theme.CurrentTheme().Accent() +} + +// ErrorColor returns the error color from the current theme +func ErrorColor() lipgloss.AdaptiveColor { + return theme.CurrentTheme().Error() +} + +// WarningColor returns the warning color from the current theme +func WarningColor() lipgloss.AdaptiveColor { + return theme.CurrentTheme().Warning() +} + +// SuccessColor returns the success color from the current theme +func SuccessColor() lipgloss.AdaptiveColor { + return theme.CurrentTheme().Success() +} + +// InfoColor returns the info color from the current theme +func InfoColor() lipgloss.AdaptiveColor { + return theme.CurrentTheme().Info() +} + +// TextColor returns the text color from the current theme +func TextColor() lipgloss.AdaptiveColor { + return theme.CurrentTheme().Text() +} + +// TextMutedColor returns the muted text color from the current theme +func TextMutedColor() lipgloss.AdaptiveColor { + return theme.CurrentTheme().TextMuted() +} + +// TextEmphasizedColor returns the emphasized text color from the current theme +func TextEmphasizedColor() lipgloss.AdaptiveColor { + return theme.CurrentTheme().TextEmphasized() +} + +// BackgroundColor returns the background color from the current theme +func BackgroundColor() lipgloss.AdaptiveColor { + return theme.CurrentTheme().Background() +} + +// BackgroundSecondaryColor returns the secondary background color from the current theme +func BackgroundSecondaryColor() lipgloss.AdaptiveColor { + return theme.CurrentTheme().BackgroundSecondary() +} + +// BackgroundDarkerColor returns the darker background color from the current theme +func BackgroundDarkerColor() lipgloss.AdaptiveColor { + return theme.CurrentTheme().BackgroundDarker() +} + +// BorderNormalColor returns the normal border color from the current theme +func BorderNormalColor() lipgloss.AdaptiveColor { + return theme.CurrentTheme().BorderNormal() +} + +// BorderFocusedColor returns the focused border color from the current theme +func BorderFocusedColor() lipgloss.AdaptiveColor { + return theme.CurrentTheme().BorderFocused() +} + +// BorderDimColor returns the dim border color from the current theme +func BorderDimColor() lipgloss.AdaptiveColor { + return theme.CurrentTheme().BorderDim() +} -var ( - Regular = lipgloss.NewStyle() - Bold = Regular.Bold(true) - Padded = Regular.Padding(0, 1) - - Border = Regular.Border(lipgloss.NormalBorder()) - ThickBorder = Regular.Border(lipgloss.ThickBorder()) - DoubleBorder = Regular.Border(lipgloss.DoubleBorder()) - - // Colors - White = lipgloss.Color("#ffffff") - Surface0 = lipgloss.AdaptiveColor{ - Dark: dark.Surface0().Hex, - Light: light.Surface0().Hex, - } - - Overlay0 = lipgloss.AdaptiveColor{ - Dark: dark.Overlay0().Hex, - Light: light.Overlay0().Hex, - } - - Ovelay1 = lipgloss.AdaptiveColor{ - Dark: dark.Overlay1().Hex, - Light: light.Overlay1().Hex, - } - - Text = lipgloss.AdaptiveColor{ - Dark: dark.Text().Hex, - Light: light.Text().Hex, - } - - SubText0 = lipgloss.AdaptiveColor{ - Dark: dark.Subtext0().Hex, - Light: light.Subtext0().Hex, - } - - SubText1 = lipgloss.AdaptiveColor{ - Dark: dark.Subtext1().Hex, - Light: light.Subtext1().Hex, - } - - LightGrey = lipgloss.AdaptiveColor{ - Dark: dark.Surface0().Hex, - Light: light.Surface0().Hex, - } - Grey = lipgloss.AdaptiveColor{ - Dark: dark.Surface1().Hex, - Light: light.Surface1().Hex, - } - - DarkGrey = lipgloss.AdaptiveColor{ - Dark: dark.Surface2().Hex, - Light: light.Surface2().Hex, - } - - Base = lipgloss.AdaptiveColor{ - Dark: dark.Base().Hex, - Light: light.Base().Hex, - } - - Crust = lipgloss.AdaptiveColor{ - Dark: dark.Crust().Hex, - Light: light.Crust().Hex, - } - - Blue = lipgloss.AdaptiveColor{ - Dark: dark.Blue().Hex, - Light: light.Blue().Hex, - } - - Red = lipgloss.AdaptiveColor{ - Dark: dark.Red().Hex, - Light: light.Red().Hex, - } - - Green = lipgloss.AdaptiveColor{ - Dark: dark.Green().Hex, - Light: light.Green().Hex, - } - - Mauve = lipgloss.AdaptiveColor{ - Dark: dark.Mauve().Hex, - Light: light.Mauve().Hex, - } - - Teal = lipgloss.AdaptiveColor{ - Dark: dark.Teal().Hex, - Light: light.Teal().Hex, - } - - Rosewater = lipgloss.AdaptiveColor{ - Dark: dark.Rosewater().Hex, - Light: light.Rosewater().Hex, - } - - Flamingo = lipgloss.AdaptiveColor{ - Dark: dark.Flamingo().Hex, - Light: light.Flamingo().Hex, - } - - Lavender = lipgloss.AdaptiveColor{ - Dark: dark.Lavender().Hex, - Light: light.Lavender().Hex, - } - - Peach = lipgloss.AdaptiveColor{ - Dark: dark.Peach().Hex, - Light: light.Peach().Hex, - } - - Yellow = lipgloss.AdaptiveColor{ - Dark: dark.Yellow().Hex, - Light: light.Yellow().Hex, - } - - Primary = Blue - Secondary = Mauve - - Warning = Peach - Error = Red -) |
