core

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: Unlicense Imports: 1 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ColourFgFaint = NewColour(128, 128, 128)
View Source
var StyleInherit = Style{
	InheritBg:   true,
	InheritFg:   true,
	ButtonEdges: ButtonEdgesStyleDefault,
}

Functions

func SetStyle added in v0.0.13

func SetStyle(style Style)

Types

type Alignment

type Alignment uint8
const (
	AlignLeft Alignment = iota
	AlignRight
	AlignCenter
	AlignTop    = AlignLeft
	AlignBottom = AlignRight
)

type ButtonEdgesStyle added in v0.0.14

type ButtonEdgesStyle string
const (
	ButtonEdgesStyleAngled  ButtonEdgesStyle = "angled"
	ButtonEdgesStyleFlat    ButtonEdgesStyle = "flat"
	ButtonEdgesStyleRound   ButtonEdgesStyle = "round"
	ButtonEdgesStyleSlanted ButtonEdgesStyle = "slanted"
	ButtonEdgesStyleNone    ButtonEdgesStyle = "none"
	ButtonEdgesStyleDefault ButtonEdgesStyle = ButtonEdgesStyleAngled
)

type Canvas

type Canvas interface {
	Fill(r rune, s Style)
	Set(x, y int, r rune, s Style)
	Size() Size
	Cutout(x, y int, s Size) Canvas
}

type Colour

type Colour [3]int32

func FaintColour added in v0.0.13

func FaintColour(c Colour) Colour

func NewColour

func NewColour(r, g, b int32) Colour

func (Colour) Blue

func (c Colour) Blue() int32

func (Colour) Green

func (c Colour) Green() int32

func (Colour) IsDefault added in v0.0.13

func (c Colour) IsDefault() bool

func (Colour) Red

func (c Colour) Red() int32

type Component

type Component interface {
	// Render draws the component to the provided canvas
	Render(canvas Canvas)
	// MinimumSize returns the minimum size required by the component
	MinimumSize() Size
}

type Container

type Container interface {
	Component
	Add(c Component)
	Remove(c Component)
	SetAlignment(alignment Alignment)
}

type Selectable

type Selectable interface {
	Component
	Select() bool
	Deselect()
	HandleKeypress(key *tcell.EventKey)
}

type Selector

type Selector struct {
	// contains filtered or unexported fields
}

func NewSelector

func NewSelector() *Selector

func (*Selector) Deselect

func (s *Selector) Deselect()

func (*Selector) GetSelected

func (s *Selector) GetSelected() Selectable

func (*Selector) Next

func (s *Selector) Next(components []Component) bool

func (*Selector) Previous

func (s *Selector) Previous(components []Component) bool

func (*Selector) Select

func (s *Selector) Select(components []Component) bool

type Size

type Size struct {
	W, H int
}

func CalculateSize

func CalculateSize(component Component, available Size) Size

func (Size) Add

func (s Size) Add(a Size) Size

func (Size) Minus

func (s Size) Minus(a Size) Size

type SizeStrategy

type SizeStrategy func(available Size, required Size) Size

func SizeStrategyAtLeast

func SizeStrategyAtLeast(min Size) SizeStrategy

func SizeStrategyAtMost

func SizeStrategyAtMost(max Size) SizeStrategy

func SizeStrategyMaximum

func SizeStrategyMaximum() SizeStrategy

func SizeStrategyMaximumHeight

func SizeStrategyMaximumHeight() SizeStrategy

func SizeStrategyMaximumWidth

func SizeStrategyMaximumWidth() SizeStrategy

func SizeStrategyMinimum

func SizeStrategyMinimum() SizeStrategy

func SizeStrategyMultiple

func SizeStrategyMultiple(strategies ...SizeStrategy) SizeStrategy

func SizeStrategyPercentage

func SizeStrategyPercentage(wPc, hPc int) SizeStrategy

type Sizer

type Sizer struct {
	// contains filtered or unexported fields
}

func (Sizer) GetSizeStrategy

func (s Sizer) GetSizeStrategy() SizeStrategy

func (*Sizer) SetSizeStrategy

func (s *Sizer) SetSizeStrategy(strategy SizeStrategy)

type StrategicSizer

type StrategicSizer interface {
	SetSizeStrategy(strategy SizeStrategy)
	GetSizeStrategy() SizeStrategy
}

type Style

type Style struct {
	InheritFg   bool             `mapstructure:"inherit_fg"`
	InheritBg   bool             `mapstructure:"inherit_bg"`
	Invert      bool             `mapstructure:"invert"`
	Underline   bool             `mapstructure:"underline"`
	Bold        bool             `mapstructure:"bold"`
	Bg          Colour           `mapstructure:"bg"`
	Fg          Colour           `mapstructure:"fg"`
	ButtonEdges ButtonEdgesStyle `mapstructure:"button_edges"`
}
var (
	StyleDefault        Style
	StyleSelected       Style
	StyleFaint          Style
	StyleButton         Style
	StyleButtonSelected Style
	StyleInput          Style
)

func (Style) GetBackground

func (s Style) GetBackground() Colour

func (Style) GetButtonEdges added in v0.0.14

func (s Style) GetButtonEdges() [2]rune

func (Style) GetForeground

func (s Style) GetForeground() Colour

func (Style) RemoveBackground

func (s Style) RemoveBackground() Style

func (Style) SetBackground

func (s Style) SetBackground(colour Colour) Style

func (Style) SetBold added in v0.0.13

func (s Style) SetBold(on bool) Style

func (Style) SetButtonEdges added in v0.0.14

func (s Style) SetButtonEdges(b ButtonEdgesStyle) Style

func (Style) SetForeground

func (s Style) SetForeground(colour Colour) Style

func (Style) SetInheritBackground added in v0.0.13

func (s Style) SetInheritBackground(inheritBg bool) Style

func (Style) SetInheritForeground added in v0.0.13

func (s Style) SetInheritForeground(inheritFg bool) Style

func (Style) SetUnderline added in v0.0.13

func (s Style) SetUnderline(on bool) Style

func (Style) Tcell

func (s Style) Tcell() tcell.Style

func (Style) ToggleInvert added in v0.0.13

func (s Style) ToggleInvert() Style

Jump to

Keyboard shortcuts

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