76 lines
1.8 KiB
Go
76 lines
1.8 KiB
Go
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
|
|
|
|
// Gutter (line numbers)
|
|
Gutter lipgloss.Style
|
|
GutterCurrentLine lipgloss.Style
|
|
|
|
// Visual mode
|
|
VisualHighlight lipgloss.Style
|
|
VisualAnchor lipgloss.Style // debugging
|
|
|
|
// Status bar
|
|
StatusBar lipgloss.Style
|
|
StatusBarActive lipgloss.Style
|
|
|
|
// Command line
|
|
CommandError lipgloss.Style
|
|
}
|
|
|
|
// DefaultStyles returns the default editor color scheme.
|
|
func DefaultStyles() Styles {
|
|
return Styles{
|
|
CursorNormal: lipgloss.NewStyle().Reverse(true),
|
|
CursorInsert: lipgloss.NewStyle().Underline(true),
|
|
CursorCommand: lipgloss.NewStyle().Reverse(true),
|
|
|
|
Gutter: lipgloss.NewStyle().
|
|
Background(lipgloss.Color("236")).
|
|
Foreground(lipgloss.Color("243")),
|
|
|
|
GutterCurrentLine: lipgloss.NewStyle().
|
|
Background(lipgloss.Color("236")).
|
|
Foreground(lipgloss.Color("#d69d00")),
|
|
|
|
VisualHighlight: lipgloss.NewStyle().
|
|
Background(lipgloss.Color("#7a6a00")),
|
|
|
|
VisualAnchor: lipgloss.NewStyle().
|
|
Background(lipgloss.Color("#a89020")),
|
|
|
|
StatusBar: lipgloss.NewStyle().
|
|
Background(lipgloss.Color("236")).
|
|
Foreground(lipgloss.Color("243")),
|
|
|
|
StatusBarActive: lipgloss.NewStyle().
|
|
Background(lipgloss.Color("62")).
|
|
Foreground(lipgloss.Color("230")),
|
|
|
|
CommandError: lipgloss.NewStyle().
|
|
Foreground(lipgloss.Color("#e3203a")),
|
|
}
|
|
}
|
|
|
|
// CursorStyle returns the appropriate cursor style for the given mode.
|
|
func (s Styles) CursorStyle(mode core.Mode) lipgloss.Style {
|
|
switch mode {
|
|
case core.InsertMode:
|
|
return s.CursorInsert
|
|
case core.CommandMode:
|
|
return s.CursorCommand
|
|
default:
|
|
return s.CursorNormal
|
|
}
|
|
}
|