package style import ( "git.gophernest.net/azpect/TextEditor/internal/core" "github.com/charmbracelet/lipgloss" ) // Styles holds all the visual styling for the editor. type Styles struct { // Cursor styles by mode CursorNormal lipgloss.Style CursorInsert lipgloss.Style CursorCommand lipgloss.Style CursorReplace lipgloss.Style // Gutter (line numbers) Gutter lipgloss.Style GutterCurrentLine lipgloss.Style // Visual mode VisualHighlight lipgloss.Style VisualAnchor lipgloss.Style // Status bar StatusBar lipgloss.Style StatusBarActive lipgloss.Style // Command line CommandError lipgloss.Style CommandOutputBorder lipgloss.Style CommandContinueMessage lipgloss.Style // General styles LineStyle lipgloss.Style BackgroundStyle lipgloss.Style } // DefaultStyles: Returns the default editor color scheme. func DefaultStyles() Styles { bg := lipgloss.Color("#1f2335") fg := lipgloss.Color("#dcd7ba") return Styles{ CursorNormal: lipgloss.NewStyle(). Background(fg). Foreground(bg), CursorInsert: lipgloss.NewStyle(). Background(bg). Foreground(fg). Underline(true), CursorCommand: lipgloss.NewStyle(). Background(fg). Foreground(bg), CursorReplace: lipgloss.NewStyle(). Background(bg). Foreground(fg). Underline(true), Gutter: lipgloss.NewStyle(). Background(lipgloss.Color("#181b2a")). Foreground(lipgloss.Color("#7e8399")), GutterCurrentLine: lipgloss.NewStyle(). Background(lipgloss.Color("#181b2a")). Foreground(lipgloss.Color("#e6c384")), VisualHighlight: lipgloss.NewStyle(). Background(lipgloss.Color("#2f334d")), VisualAnchor: lipgloss.NewStyle(). Background(lipgloss.Color("#3a3f5f")), StatusBar: lipgloss.NewStyle(). Background(lipgloss.Color("#181b2a")). Foreground(lipgloss.Color("#8ea4a2")), StatusBarActive: lipgloss.NewStyle(). Background(lipgloss.Color("#223249")). Foreground(lipgloss.Color("#9ec1cf")), CommandError: lipgloss.NewStyle(). Foreground(lipgloss.Color("#e82424")), CommandOutputBorder: lipgloss.NewStyle(). Background(lipgloss.Color("#11131d")), CommandContinueMessage: lipgloss.NewStyle(). Foreground(lipgloss.Color("#7aa2f7")), LineStyle: lipgloss.NewStyle(). Foreground(fg). Background(bg), BackgroundStyle: lipgloss.NewStyle(). Background(bg), } } // Styles.DefaultCursorStyle: Returns the appropriate cursor style for the given mode. func (s Styles) DefaultCursorStyle(mode core.Mode) lipgloss.Style { switch mode { case core.InsertMode: return s.CursorInsert case core.CommandMode: return s.CursorCommand case core.ReplaceMode: return s.CursorReplace default: return s.CursorNormal } } // Styles.CursorStyle: Returns a cursor style derived from the text style. func (s Styles) CursorStyle(mode core.Mode, textStyle lipgloss.Style) lipgloss.Style { switch mode { case core.NormalMode, core.VisualLineMode, core.VisualBlockMode, core.VisualMode: return lipgloss.NewStyle(). Background(textStyle.GetForeground()). Foreground(textStyle.GetBackground()) case core.ReplaceMode, core.WaitingMode: return lipgloss.NewStyle(). Background(textStyle.GetBackground()). Foreground(textStyle.GetForeground()). Underline(true) default: return lipgloss.NewStyle(). Background(s.BackgroundStyle.GetBackground()). Foreground(textStyle.GetForeground()). Underline(true) } } // Styles.VisualHighlightWithTextColor: Applies visual background while preserving text color. func (s Styles) VisualHighlightWithTextColor(textStyle lipgloss.Style) lipgloss.Style { return lipgloss.NewStyle(). Background(s.VisualHighlight.GetBackground()). Foreground(textStyle.GetForeground()) }