common

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2021 License: MIT Imports: 5 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Color wraps termenv.ColorProfile.Color, which produces a termenv color
	// for use in termenv styling.
	Color func(string) te.Color = te.ColorProfile().Color

	// HasDarkBackground stores whether or not the terminal has a dark
	// background.
	HasDarkBackground = te.HasDarkBackground()
)
View Source
var (
	Indigo       ColorPair = NewColorPair("#7571F9", "#5A56E0")
	SubtleIndigo           = NewColorPair("#514DC1", "#7D79F6")
	Cream                  = NewColorPair("#FFFDF5", "#FFFDF5")
	YellowGreen            = NewColorPair("#ECFD65", "#04B575")
	Fuschia                = NewColorPair("#EE6FF8", "#EE6FF8")
	Green                  = NewColorPair("#04B575", "#04B575")
	Red                    = NewColorPair("#ED567A", "#FF4672")
	FaintRed               = NewColorPair("#C74665", "#FF6F91")
	SpinnerColor           = NewColorPair("#747373", "#8E8E8E")
	NoColor                = NewColorPair("", "")
)

Colors for dark and light backgrounds.

View Source
var (
	IndigoFg       func(string) string = te.Style{}.Foreground(Indigo.Color()).Styled
	SubtleIndigoFg                     = te.Style{}.Foreground(SubtleIndigo.Color()).Styled
	RedFg                              = te.Style{}.Foreground(Red.Color()).Styled
	FaintRedFg                         = te.Style{}.Foreground(FaintRed.Color()).Styled
)

Functions for styling strings.

View Source
var Spinner = spinner.Dot

Functions

func ButtonView

func ButtonView(text string, focused bool) string

ButtonView renders something that resembles a button.

func CancelButtonView

func CancelButtonView(focused bool, defaultButton bool) string

CancelButtonView returns a button reading "Cancel.".

func Code

func Code(s string) string

Code applies special formatting to strings indeded to read as code.

func HelpView

func HelpView(sections ...string) string

HelpView renders text intended to display at help text, often at the bottom of a view.

func KeyValueView

func KeyValueView(stuff ...string) string

KeyValueView renders key-value pairs.

func Keyword

func Keyword(s string) string

Keyword applies special formatting to imporant words or phrases.

func NoButtonView

func NoButtonView(focused bool) string

NoButtonView returns a button reading "No.".

func OKButtonView

func OKButtonView(focused bool, defaultButton bool) string

OKButtonView returns a button reading "OK".

func Subtle

func Subtle(s string) string

Subtle applies formatting to strings intended to be "subtle".

func VerticalLine

func VerticalLine(state State) string

VerticalLine return a vertical line colored according to the given state.

func Wrap

func Wrap(s string) string

Wrap wraps lines at a predefined width via package muesli/reflow.

func YesButtonView

func YesButtonView(focused bool) string

YesButtonView return a button reading "Yes".

Types

type ColorPair

type ColorPair struct {
	Dark  string
	Light string
}

ColorPair is a pair of colors, one intended for a dark background and the other intended for a light background. We'll automatically determine which of these colors to use.

func NewColorPair

func NewColorPair(dark, light string) ColorPair

NewColorPair is a helper function for creating a ColorPair.

func (ColorPair) Color

func (c ColorPair) Color() te.Color

Color returns the appropriate termenv.Color for the terminal background.

func (ColorPair) String

func (c ColorPair) String() string

String returns a string representation of the color appropriate for the current terminal background.

type State

type State int

State is a general UI state used to help style components.

const (
	StateNormal State = iota
	StateSelected
	StateActive
	StateSpecial
	StateDeleting
)

UI states.

Jump to

Keyboard shortcuts

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