cat / 012
clone

a spreadsheet for the terminal: lotus 1-2-3 looks, google sheets keys and formulas, one go binary

main
012 / internal / ui / theme / code.go
code.go 1.6K
1package theme23import "charm.land/lipgloss/v2"45// Syntax is a kind of token in a code cell, which Theme.Code styles.6type Syntax int78const (9 SyntaxCommand Syntax = iota // a command's name: ls, where, open10 SyntaxString // a string: "a", 'b', a bare word argument11 SyntaxVariable // $name, $in12 SyntaxNumber // numbers, sizes, durations, dates13 SyntaxKeyword // let, def, if, true, null14 SyntaxOperator // |, ==, and, =15 SyntaxComment // # to the end of the line16 NumSyntax17)1819// codeRoles are the notebooks' roles.20func codeRoles(t *Theme, dark bool) {21 muted := lipgloss.BrightBlack22 command, number := lipgloss.Cyan, lipgloss.Yellow23 if !dark {24 muted = lipgloss.Black25 command, number = lipgloss.Blue, lipgloss.Red26 }27 t.Code = [NumSyntax]lipgloss.Style{28 SyntaxCommand: lipgloss.NewStyle().Foreground(command),29 SyntaxString: lipgloss.NewStyle().Foreground(lipgloss.Green),30 SyntaxVariable: lipgloss.NewStyle().Foreground(lipgloss.Magenta),31 SyntaxNumber: lipgloss.NewStyle().Foreground(number),32 SyntaxKeyword: lipgloss.NewStyle().Bold(true),33 SyntaxOperator: lipgloss.NewStyle().Bold(true),34 SyntaxComment: lipgloss.NewStyle().Foreground(muted).Italic(true),35 }36 t.CellHead = lipgloss.NewStyle().Foreground(muted)37 t.CellBar = lipgloss.NewStyle().Foreground(lipgloss.Blue)38 t.CellBarEdit = lipgloss.NewStyle().Foreground(lipgloss.Green)39 t.OutputHead = lipgloss.NewStyle().Bold(true).Underline(true)40 t.Stale = lipgloss.NewStyle().Foreground(lipgloss.Yellow).Italic(true)41 if !dark {42 t.Stale = t.Stale.Foreground(lipgloss.Magenta)43 }44}