package themes import ( "strings" "git.gophernest.net/azpect/TextEditor/internal/theme" "github.com/charmbracelet/lipgloss" ) const background = lipgloss.Color("#111418") const foreground = lipgloss.Color("#d4d8e1") func NewDefaultTheme() theme.EditorTheme { hightlight := lipgloss.NewStyle(). Background(lipgloss.Color("#2f334d")) line := lipgloss.NewStyle(). Foreground(foreground). Background(background) background := lipgloss.NewStyle(). Background(background) return theme.EditorTheme{ Cursors: newDefaultCursorTheme(), Gutter: newDefaultGutterTheme(), VisualHightlight: hightlight, StatusBar: newDefaultStatusBarTheme(), CommandLine: newDefaultCommandLineTheme(), Line: line, Background: background, Syntax: newDefaultSyntaxTheme(), } } // This is only used for the default cursors, in any other case // the EditorTheme.Cursor() method is preferred. func newDefaultCursorTheme() theme.CursorTheme { base := lipgloss.NewStyle(). Foreground(foreground). Background(background) inv := lipgloss.NewStyle(). Foreground(background). Background(foreground) return theme.CursorTheme{ Normal: inv, Insert: base.Underline(true), Command: inv, Replace: base.Underline(true), } } func newDefaultGutterTheme() theme.GutterTheme { base := lipgloss.NewStyle(). Background(lipgloss.Color("#0d1014")). Foreground(lipgloss.Color("#6b7280")) return theme.GutterTheme{ Default: base, CurrentLine: base.Foreground(lipgloss.Color("#c0c8d8")), } } func newDefaultStatusBarTheme() theme.StatusBarTheme { bar := lipgloss.NewStyle(). Background(lipgloss.Color("#0d1014")). Foreground(lipgloss.Color("#8f99aa")) return theme.StatusBarTheme{ Default: bar, } } func newDefaultCommandLineTheme() theme.CommandLineTheme { base := lipgloss.NewStyle(). Foreground(foreground). Background(background) return theme.CommandLineTheme{ Error: base.Foreground(lipgloss.Color("#bf616a")), OutputBorder: base.Background(lipgloss.Color("#0d1014")), ContinueMessage: base.Foreground(lipgloss.Color("#81a1c1")), } } func newDefaultSyntaxTheme() theme.SyntaxTheme { exact := map[string]lipgloss.Style{ "attribute.builtin": color("#ebcb8b"), "character.special": color("#d08770"), "comment.documentation": color("#8f99aa"), "constant.builtin": color("#88c0d0"), "constant.macro": color("#d08770"), "function.builtin": color("#88c0d0"), "function.call": color("#81a1c1"), "function.macro": color("#d08770"), "function.method": color("#81a1c1"), "function.method.call": color("#81a1c1"), "keyword.conditional": color("#b48ead"), "keyword.conditional.ternary": color("#b48ead"), "keyword.coroutine": color("#b48ead"), "keyword.debug": color("#b48ead"), "keyword.directive": color("#b48ead"), "keyword.directive.define": color("#b48ead"), "keyword.exception": color("#b48ead"), "keyword.function": color("#b48ead"), "keyword.import": color("#b48ead"), "keyword.modifier": color("#b48ead"), "keyword.operator": color("#d08770"), "keyword.repeat": color("#b48ead"), "keyword.return": color("#b48ead"), "keyword.type": color("#ebcb8b"), "markup.heading": color("#ebcb8b"), "markup.heading.1": color("#ebcb8b"), "markup.heading.2": color("#e5c68a"), "markup.heading.3": color("#ddbe88"), "markup.heading.4": color("#d5b686"), "markup.heading.5": color("#cdaf84"), "markup.heading.6": color("#c5a883"), "markup.italic": color("#c0c8d8"), "markup.link.label": color("#81a1c1"), "markup.raw": color("#a3be8c"), "markup.strikethrough": color("#7f8795"), "markup.strong": color("#ebcb8b"), "markup.underline": color("#88c0d0"), "module.builtin": color("#88c0d0"), "number.float": color("#88c0d0"), "punctuation.bracket": color("#9aa4b2"), "punctuation.delimiter": color("#9aa4b2"), "punctuation.special": color("#d08770"), "string.documentation": color("#a3be8c"), "string.escape": color("#d08770"), "string.regexp": color("#88c0d0"), "string.special.path": color("#a3be8c"), "string.special.symbol": color("#88c0d0"), "string.special.url": color("#88c0d0"), "tag.attribute": color("#ebcb8b"), "tag.attribute.url": color("#88c0d0"), "tag.builtin": color("#81a1c1"), "tag.delimiter": color("#9aa4b2"), "type.builtin": color("#ebcb8b"), "type.definition": color("#ebcb8b"), "variable.builtin": color("#8fbcbb"), "variable.member": color("#c0c8d8"), "variable.parameter": color("#c0c8d8"), } group := map[string]lipgloss.Style{ "attribute": color("#ebcb8b"), "boolean": color("#88c0d0"), "character": color("#a3be8c"), "charset": color("#ebcb8b"), "comment": color("#7f8795"), "conceal": color("#7f8795"), "constant": color("#88c0d0"), "constructor": color("#ebcb8b"), "error": color("#bf616a"), "function": color("#81a1c1"), "import": color("#b48ead"), "interface": color("#ebcb8b"), "keyframes": color("#d08770"), "keyword": color("#b48ead"), "label": color("#d08770"), "media": color("#d08770"), "module": color("#81a1c1"), "namespace": color("#81a1c1"), "none": color("#d4d8e1"), "nospell": color("#d4d8e1"), "number": color("#88c0d0"), "operator": color("#9aa4b2"), "property": color("#c0c8d8"), "spell": color("#d4d8e1"), "string": color("#a3be8c"), "supports": color("#d08770"), "tag": color("#81a1c1"), "type": color("#ebcb8b"), "variable": color("#d4d8e1"), } return theme.SyntaxTheme{ Exact: exact, Group: group, } } // Simple helper to create a lipgloss style with the provided foreground func color(c string) lipgloss.Style { col := foreground if strings.TrimSpace(c) != "" { col = lipgloss.Color(c) } return lipgloss.NewStyle(). Background(background). Foreground(col) }