ui

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Icons = struct {
		BargraphChar    rune
		BargraphRBorder rune
		BargraphLBorder rune
		Factory         rune
		Battery         rune
		Package         rune
		Anchor          rune
		Rocket          rune
		Thermometer     rune
		Sun             rune
		Knobs           rune
		Drum            rune
		M               rune
		Plane           rune
		Controller      rune
		Clock           rune
		TrafficLight    rune
	}{
		BargraphChar:    '|',
		BargraphLBorder: '[',
		BargraphRBorder: ']',
		Factory:         '🏭',
		Battery:         '🔋',
		Package:         '📦',
		Anchor:          '⚓',
		Rocket:          '🚀',
		Thermometer:     '🌡',
		Sun:             '☀',
		Knobs:           '🎛',
		Drum:            '🥁',
		M:               'Ⓜ',
		Plane:           '🛩',
		Controller:      '🛂',
		Clock:           '⏰',
		TrafficLight:    '🚦',
	}
)

Functions

func BarGraph

func BarGraph(scale int, ratio Ratio, colors ColorKeys) string

BarGraph returns a colorized string, like ||||||||, which represents a bargrah built using scale and ratio values. Colors provide key mapping to colorize the graph basede on the value of ratio. If ratio is zero (nothing to graph), the function returns a series of dots.

Types

type ColorKeys

type ColorKeys map[int]string

ColorKeys represents color gradients mapping of a percentage value (expressed as integer i.e. 20 for 20%) to a color.

func ColorKeysFromSlice

func ColorKeysFromSlice(colors []string) ColorKeys

ColorKeysFromSlice automatically builds a color key mapping by equally dividing the slice items into a key value. For instance, []string{"green", "yellow", "red"} returns ColorKeys{33:"green",66:"yellow",100:"red"}

func (ColorKeys) Keys

func (ck ColorKeys) Keys() []int

Keys returns a ascending sorted slice of color keys

type Panel

type Panel interface {
	Layout(data interface{})
	DrawHeader(data interface{})
	// TODO add context to DrawXXX methods
	DrawBody(data interface{})
	DrawFooter(param interface{})
	Clear()
	GetTitle() string
	GetRootView() tview.Primitive
	GetChildrenViews() []tview.Primitive
}

type PanelController added in v0.1.0

type PanelController interface {
	Panel
	Run(context.Context) error
}

type Ratio

type Ratio float64

Ratio float64 type used to represents ratio values

func GetRatio

func GetRatio(val0, val1 float64) Ratio

GetRatio returns a ration between val0/val1. If val <= 0, it return 0.

Jump to

Keyboard shortcuts

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