style

package
v0.0.0-...-14468cb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DOT      = '•'
	ELLIPSES = '…'

	UP_ARROW   = '▲'
	DOWN_ARROW = '▼'

	COLLAPSED = '+'
	EXPANDED  = '−'
)

Variables

View Source
var (
	BARS = [...]rune{' ', '▁', '▂', '▃', '▄', '▅', '▆', '▇', '█'}

	SHADED_BLOCKS = [...]rune{' ', '░', '▒', '▓', '█'}

	IRREGULAR_BLOCKS = [...]rune{
		' ', '▘', '▝', '▀', '▖', '▌', '▞', '▛',
		'▗', '▚', '▐', '▜', '▄', '▙', '▟', '█',
	}

	BRAILLE_OFFSET = '\u2800'
	BRAILLE        = [4][2]rune{
		{'\u0001', '\u0008'},
		{'\u0002', '\u0010'},
		{'\u0004', '\u0020'},
		{'\u0040', '\u0080'},
	}

	DOUBLE_BRAILLE = map[[2]int]rune{
		[2]int{0, 0}: '⣀',
		[2]int{0, 1}: '⡠',
		[2]int{0, 2}: '⡐',
		[2]int{0, 3}: '⡈',

		[2]int{1, 0}: '⢄',
		[2]int{1, 1}: '⠤',
		[2]int{1, 2}: '⠔',
		[2]int{1, 3}: '⠌',

		[2]int{2, 0}: '⢂',
		[2]int{2, 1}: '⠢',
		[2]int{2, 2}: '⠒',
		[2]int{2, 3}: '⠊',

		[2]int{3, 0}: '⢁',
		[2]int{3, 1}: '⠡',
		[2]int{3, 2}: '⠑',
		[2]int{3, 3}: '⠉',
	}

	SINGLE_BRAILLE_LEFT  = [4]rune{'\u2840', '⠄', '⠂', '⠁'}
	SINGLE_BRAILLE_RIGHT = [4]rune{'\u2880', '⠠', '⠐', '⠈'}
)
View Source
var BaseStyles = []Style{
	view.NewStyle(ColorBlack),
	view.NewStyle(ColorRed),
	view.NewStyle(ColorGreen),
	view.NewStyle(ColorYellow),
	view.NewStyle(ColorBlue),
	view.NewStyle(ColorMagenta),
	view.NewStyle(ColorCyan),
	view.NewStyle(ColorWhite),
}
View Source
var StyledParserColorMap = map[string]Color{
	"black":   ColorBlack,
	"red":     ColorRed,
	"green":   ColorGreen,
	"yellow":  ColorYellow,
	"blue":    ColorBlue,
	"magenta": ColorMagenta,
	"cyan":    ColorCyan,
	"white":   ColorWhite,
}
View Source
var Theme = BaseTheme{
	Default: view.NewStyle(ColorWhite),

	Module: ModuleTheme{
		Title:  view.NewStyle(ColorWhite),
		Border: view.NewStyle(ColorWhite),
	},
	Text: TextTheme{
		Text: view.NewStyle(ColorWhite),
	},
}

Functions

func ParseStyles

func ParseStyles(s string, defaultStyle Style) []view.Cell

Types

type Attr

type Attr uint16

type BaseTheme

type BaseTheme struct {
	Default Style
	// Put module themes here
	Module ModuleTheme
	Text   TextTheme
}

BaseTheme is where all the mappings for modules and the corresponding Type, which defines the expected properties for that module are defined. For instance, the Text module is mapped to the TextTheme struct, which expects a single property, Text, which holds the property for the color of the text.

To add a new module, first create an exported struct with the required properties (types set to Color or Style), and then add it to the BaseTheme struct. Naming convention should be to use the name of the module followed by theme for the struct name, and using only the module name for the property name in BaseTheme.

type Color

type Color int
const (
	ColorClear   Color = -1
	ColorBlack   Color = 0
	ColorRed     Color = 1
	ColorGreen   Color = 2
	ColorYellow  Color = 3
	ColorBlue    Color = 4
	ColorMagenta Color = 5
	ColorCyan    Color = 6
	ColorWhite   Color = 7
)

type Modifier

type Modifier uint
const (
	ModifierClear Modifier = 0
	ModifierBold  Modifier = 1 << (iota + 9)
	ModifierUnderline
	ModifierItalic
	ModifierReverse
)

type ModuleTheme

type ModuleTheme struct {
	Title  Style
	Border Style
}

type Style

type Style struct {
	Fg       Color
	Bg       Color
	Modifier Modifier
}

type TextTheme

type TextTheme struct {
	Text Style
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL