termui

package module
v3.0.0-...-c39b932 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: MIT Imports: 13 Imported by: 0

README

termui

termui is a cross-platform and fully-customizable terminal dashboard and widget library built on top of termbox-go. It is inspired by blessed-contrib and tui-rs and written purely in Go.

Features

  • Several premade widgets for common use cases
  • Easily create custom widgets
  • Position widgets either in a relative grid or with absolute coordinates
  • Keyboard, mouse, and terminal resizing events
  • Colors and styling

Installation

Go modules

It is not necessary to go get termui, since Go will automatically manage any imported dependencies for you. Do note that you have to include /v3 in the import statements as shown in the 'Hello World' example below.

Dep

Add with dep ensure -add github.com/gizak/termui. With Dep, /v3 should not be included in the import statements.

Hello World

package main

import (
	"log"

	ui "github.com/gizak/termui/v3"
	"github.com/gizak/termui/v3/widgets"
)

func main() {
	if err := ui.Init(); err != nil {
		log.Fatalf("failed to initialize termui: %v", err)
	}
	defer ui.Close()

	p := widgets.NewParagraph()
	p.Text = "Hello World!"
	p.SetRect(0, 0, 25, 5)

	ui.Render(p)

	for e := range ui.PollEvents() {
		if e.Type == ui.KeyboardEvent {
			break
		}
	}
}

Widgets

Run an example with go run _examples/{example}.go or run each example consecutively with make run-examples.

Documentation

Uses

License

MIT

Documentation

Overview

Package termui is a library for creating terminal user interfaces (TUIs) using widgets.

Index

Constants

View Source
const (
	KeyboardEvent EventType = iota
	MouseEvent
	ResizeEvent
	TickerEvent  // событие тикера должен иметь набор константных типов
	ServiceEvent // событие от внеш сервиса id сервиса
	SystemEvent  //  события внутри приложения
	InputEvent   // события полей редактирования

	SystemEventActionSomeOp        = 0x100 // передаем id виджета
	SystemEventActionUpdateDataOp  = 0x101 // передаем id виджета
	SystemEventDashboardIconSwitch = 0x102 // передаем имя параметра дащборда если он есть

	SysEventOpCustom     = 0x00 // free style
	SysEventOpUpdateDP   = 0x01 // update data provider
	SysEventOpUpdateData = 0x02 // update storage data

	// SysEventOpModifyWidget - тип операции, который указывает, что мы меняем данные
	// в самом виджете. Например заголовок. Требуется что бы группа виджет - провайдер данных
	// имела один идентификатор. При данном типе операции первым значением в Payload Data идет
	// индекс, начиная с которого идут данные для виджета.
	SysEventOpModifyWidget = 0x04

	SysEventOpDashIconSwitch = 0x08
	SysEventOpUpdateGrData   = 0x10
	SysEventOpUpdateGrDP     = 0x20
)
View Source
const (
	TokenBeginStyledText = '['
	TokenEndStyledText   = ']'
)
View Source
const (
	DOT      = '•'
	ELLIPSES = '…'

	UP_ARROW    = '▲'
	DOWN_ARROW  = '▼'
	LEFT_ARROW  = '◀'
	RIGHT_ARROW = '▶'

	COLLAPSED               = '+'
	EXPANDED                = '−'
	EMPTY             int32 = ' '
	RUR               int32 = '₽'
	SHEKEL            int32 = '₪'
	LAOS_KIP          int32 = '₭'
	LIGHT_COIN        int32 = 'Ł'
	SYMBOL_YAT        int32 = 'Ѣ'
	SYMBOL_MATH_MINUS int32 = '−'
	SYMBOL_MATH_PLUS  int32 = '+'

	CHECK_DEFAULT   int32 = '✓'
	DISABLE_DEFAULT int32 = '✖'

	GR_TETA  int32 = 'Θ'
	GR_DELTA int32 = 'Δ'
	GR_KSI   int32 = 'Ξ'
	GR_PSI   int32 = 'Ψ'
	GR_OMEGA int32 = 'Ω'
	GR_SIGMA int32 = 'Σ'

	ROME_1  int32 = 'Ⅰ'
	ROME_2  int32 = 'Ⅱ'
	ROME_3  int32 = 'Ⅲ'
	ROME_4  int32 = 'Ⅳ'
	ROME_5  int32 = 'Ⅴ'
	ROME_6  int32 = 'Ⅵ'
	ROME_7  int32 = 'Ⅶ'
	ROME_8  int32 = 'Ⅷ'
	ROME_9  int32 = 'Ⅸ'
	ROME_10 int32 = 'Ⅹ'
	ROME_11 int32 = 'Ⅺ'
	ROME_12 int32 = 'Ⅻ'

	ROME_50   int32 = 'Ⅼ'
	ROME_100  int32 = 'Ⅽ'
	ROME_500  int32 = 'Ⅾ'
	ROME_1000 int32 = 'Ⅿ'

	NUMBER_BOLD_0 int32 = '𝟬'
	NUMBER_BOLD_1 int32 = '𝟭'
	NUMBER_BOLD_2 int32 = '𝟮'
	NUMBER_BOLD_3 int32 = '𝟯'
	NUMBER_BOLD_4 int32 = '𝟰'
	NUMBER_BOLD_5 int32 = '𝟱'
	NUMBER_BOLD_6 int32 = '𝟲'
	NUMBER_BOLD_7 int32 = '𝟳'
	NUMBER_BOLD_8 int32 = '𝟴'
	NUMBER_BOLD_9 int32 = '𝟵'

	CS_FOOTPRINT        int32 = '👣'
	CS_FOOTPRINT_ANIMAL int32 = '🐾'
	CS_CLOVER_4_LIST    int32 = '🍀'
	CS_ANGER            int32 = '💢'
	CS_EYES             int32 = '👀'
	CS_HOURGLASS        int32 = '⌛'
	CS_COFFEE           int32 = '☕'
	CS_SHOWING          int32 = '🌨'
	CS_FIRE             int32 = '🔥'
	CS_FIRE_ENGINE      int32 = '🚒'
	CS_ROCKET           int32 = '🚀'
	CS_DIZZINESS        int32 = '💫'
	CS_BUMP             int32 = '💥'
	CS_NOTES            int32 = '🎶'
	CS_BEEPER           int32 = '📯'

	/*
		triangles
	*/
	TRIA_TOP_L    int32 = '◸'
	TRIA_TOP_R    int32 = '◹'
	TRIA_BOTTOM_L int32 = '◺'
	TRIA_BOTTOM_R int32 = '◿'

	/*
		i-chin
	*/
	I_CHIN_1 int32 = '☰'
	I_CHIN_2 int32 = '☱'
	I_CHIN_3 int32 = '☲'
	I_CHIN_4 int32 = '☳'
	I_CHIN_5 int32 = '☴'
	I_CHIN_6 int32 = '☵'
	I_CHIN_7 int32 = '☶'
	I_CHIN_8 int32 = '☷'
)
View Source
const (
	TOP_LEFT     int32 = '┌'
	TOP_RIGHT    int32 = '┐'
	BOTTOM_LEFT  int32 = '└'
	BOTTOM_RIGHT int32 = '┘'

	VERTICAL_LINE   int32 = '│'
	HORIZONTAL_LINE int32 = '─'

	VERTICAL_LEFT   int32 = '┤'
	VERTICAL_RIGHT  int32 = '├'
	HORIZONTAL_UP   int32 = '┴'
	HORIZONTAL_DOWN int32 = '┬'

	QUOTA_LEFT  int32 = '«'
	QUOTA_RIGHT int32 = '»'

	VERTICAL_DASH   int32 = '┊'
	HORIZONTAL_DASH int32 = '┈'
)

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 CellClear = Cell{
	Rune:  ' ',
	Style: StyleClear,
}
View Source
var StyleClear = Style{
	Fg:       ColorClear,
	Bg:       ColorClear,
	Modifier: ModifierClear,
}

StyleClear represents a default Style, with no colors or modifiers

View Source
var StyleParserColorMap = map[string]Color{
	"red":     ColorRed,
	"blue":    ColorBlue,
	"black":   ColorBlack,
	"cyan":    ColorCyan,
	"yellow":  ColorYellow,
	"white":   ColorWhite,
	"clear":   ColorClear,
	"green":   ColorGreen,
	"magenta": ColorMagenta,
	"22":      ColorGreenBgDunkel,
	"23":      ColorGreenBlue,
	"30":      ColorBlueLightFg,
	"31":      ColorBlueLightFg2,
}

StyleParserColorMap can be modified to add custom color parsing to text

View Source
var Theme = RootTheme{
	Default: NewStyle(ColorWhite),

	Block: BlockTheme{
		Title:  NewStyle(ColorWhite),
		Border: NewStyle(ColorWhite),
	},

	BarChart: BarChartTheme{
		Bars:   StandardColors,
		Nums:   StandardStyles,
		Labels: StandardStyles,
	},

	Paragraph: ParagraphTheme{
		Text: NewStyle(ColorWhite),
	},

	PieChart: PieChartTheme{
		Slices: StandardColors,
	},

	List: ListTheme{
		Text: NewStyle(ColorWhite),
	},

	Tree: TreeTheme{
		Text:      NewStyle(ColorWhite),
		Collapsed: COLLAPSED,
		Expanded:  EXPANDED,
	},

	StackedBarChart: StackedBarChartTheme{
		Bars:   StandardColors,
		Nums:   StandardStyles,
		Labels: StandardStyles,
	},

	Gauge: GaugeTheme{
		Bar:   ColorWhite,
		Label: NewStyle(ColorWhite),
	},

	Sparkline: SparklineTheme{
		Title: NewStyle(ColorWhite),
		Line:  ColorWhite,
	},

	Plot: PlotTheme{
		Lines: StandardColors,
		Axes:  ColorWhite,
	},

	Table: TableTheme{
		Text: NewStyle(ColorWhite),
	},

	Tab: TabTheme{
		Active:   NewStyle(ColorRed),
		Inactive: NewStyle(ColorWhite),
	},
}

Theme holds the default Styles and Colors for all widgets. You can set default widget Styles by modifying the Theme before creating the widgets.

Functions

func AbsInt

func AbsInt(x int) int

func CellsToString

func CellsToString(cells []Cell) string

func Clear

func Clear()

func Close

func Close()

Close closes termbox-go.

func ConvWidthRelativeToAbs

func ConvWidthRelativeToAbs(minX, maxX int, size []int, row []string) []int

ConvWidthRelativeToAbs - цели: значения размеров указанных как -1 или 0. Такие размеры являются относительными -1 - такая ячейка займет все не размеченное пространство, если их несколько то будет их делить

    поровну с остальными такими же
0 - размер такой колонки определиться по длине текста в первой строке

Размер size и data должны совпадать Если возникают какие-то ошибки возвращается массив с "резиновыми" значениями

func ConvertSymToMarkers

func ConvertSymToMarkers(in string) string

func ConvertSymToSquaredMarker

func ConvertSymToSquaredMarker(in string) string

func ConvertToBoldNumbers

func ConvertToBoldNumbers(in int32) string

func ConvertToFullNumbers

func ConvertToFullNumbers(in int32) string

func ConvertToMonoNumbers

func ConvertToMonoNumbers(in int32) string

func ConvertToRomeNumbers

func ConvertToRomeNumbers(in int32) string

ConvertToRomeNumbers Актуальны числа от 1 до 12, 50, 100, 500, 1000

func FloorFloat64

func FloorFloat64(x float64) float64

func FormatAmount

func FormatAmount(amount, decimal int32, isMono bool, addCurSym bool) string

FormatAmount - вывод форматированной суммы. @decimal - если меньше 0, значит вывод десятичных отключаем

func FormatAmountToMonoNumbers

func FormatAmountToMonoNumbers(amount int64, decimal int32, addCurSym bool) string

func FormatStrAsMarkers

func FormatStrAsMarkers(in string, asSquared bool) string

func FormatStrWithStyle

func FormatStrWithStyle(in string, style Style) string

func GetAddressElements

func GetAddressElements(address ...uint32) (p, r, c uint32)

GetAddressElements - элементы адреса: - один элемент - номер параметра для текста, номер параметра для 0 строки списка, 0 строки и 0 колонки таблицы - два элемента - номер строки, номер параметра, 0 - номер колонки для таблицы - три элемента - номер строки, номер колонки, номер параметра

func GetMaxFloat64From2dSlice

func GetMaxFloat64From2dSlice(slices [][]float64) (float64, error)

func GetMaxFloat64FromSlice

func GetMaxFloat64FromSlice(slice []float64) (float64, error)

func GetMaxIntFromSlice

func GetMaxIntFromSlice(slice []int) (int, error)

func Init

func Init() error

Init initializes termbox-go and is required to render anything. After initialization, the library must be finalized with `Close`.

func InterfaceSlice

func InterfaceSlice(slice interface{}) []interface{}

InterfaceSlice takes an []interface{} represented as an interface{} and converts it https://stackoverflow.com/questions/12753805/type-converting-slices-of-interfaces-in-go

func MakeCenterPositionWidget

func MakeCenterPositionWidget(parent image.Rectangle, wData, hData int) image.Rectangle

MakeCenterPositionWidget - расчет позиционирования виджета по середине родительского фрейма maxX, maxY - размеры

func MakeDataProviderAddress

func MakeDataProviderAddress(param, row, col uint32) uint32

func MakeEventUuid

func MakeEventUuid(eventId string, t EventType, adv ...interface{}) string

func MakeStr

func MakeStr(countParams uint8, data []interface{}, useSplit32 bool) string

func MakeStrStaticW

func MakeStrStaticW(data []interface{}, rw []uint8, useSplit32 bool) string

func MaxFloat64

func MaxFloat64(x, y float64) float64

func MaxInt

func MaxInt(x, y int) int

func MinFloat64

func MinFloat64(x, y float64) float64

func MinInt

func MinInt(x, y int) int

func ParseDataProviderAddress

func ParseDataProviderAddress(address uint32) (uint32, uint32, uint32)

ParseDataProviderAddress - порядок элементов возврата как в в параметрах функции MakeDataProviderAddress: param, row, col

func PollEvents

func PollEvents() <-chan Event

PollEvents gets events from termbox, converts them, then sends them to each of its channels.

func Render

func Render(items ...Drawable)

func RoundFloat64

func RoundFloat64(x float64) float64

func SplitCells

func SplitCells(cells []Cell, r rune) [][]Cell

func StyleSerializeToCode

func StyleSerializeToCode(st Style) uint32

func StyleToString

func StyleToString(style Style) string

func SumFloat64Slice

func SumFloat64Slice(data []float64) float64

func SumIntSlice

func SumIntSlice(slice []int) int

func TerminalDimensions

func TerminalDimensions() (int, int)

func TrimString

func TrimString(s string, w int) string

TrimString trims a string to a max length and adds '…' to the end if it was trimmed.

Types

type AdaptiveSize

type AdaptiveSize int

AdaptiveSize тип для указания адаптивных размеров под виджеты. числа от 10 до 100. Остальные числа ограничиваются в этом диапазоне Далее при построении сетки виджета эти размеры будут разделены на 100 что бы определить относительный размер каждой клетки в сетке

func CalcRelativeHeight

func CalcRelativeHeight(rows uint8, sizes ...AdaptiveSize) []AdaptiveSize

CalcRelativeHeight - расcчитываем относительные высоты строк. Общая сумма не должна превышать tmpl.AdaptiveSize.Max()

func NewAdaptiveSize

func NewAdaptiveSize(in int) AdaptiveSize

func NewAdaptiveSizeFirstPercentile

func NewAdaptiveSizeFirstPercentile() AdaptiveSize

func NewAdaptiveSizeMax

func NewAdaptiveSizeMax() AdaptiveSize

func NewAdaptiveSizeMin

func NewAdaptiveSizeMin() AdaptiveSize

func NewAdaptiveSizeThird

func NewAdaptiveSizeThird() AdaptiveSize

func NewAdaptiveSizeThreePercentile

func NewAdaptiveSizeThreePercentile() AdaptiveSize

func NewAdaptiveSizeTwenty

func NewAdaptiveSizeTwenty() AdaptiveSize

func NewAdaptiveSizeTwoPercentile

func NewAdaptiveSizeTwoPercentile() AdaptiveSize

func (AdaptiveSize) FloatSize

func (as AdaptiveSize) FloatSize() float64

func (AdaptiveSize) IsMax

func (as AdaptiveSize) IsMax() bool

func (AdaptiveSize) Sum

func (AdaptiveSize) ToInt

func (as AdaptiveSize) ToInt() int

func (AdaptiveSize) ToUint8

func (as AdaptiveSize) ToUint8() uint8

type Alignment

type Alignment uint
const (
	AlignLeft Alignment = iota
	AlignCenter
	AlignRight
)

type BarChartTheme

type BarChartTheme struct {
	Bars   []Color
	Nums   []Style
	Labels []Style
}

type Block

type Block struct {
	Border      bool
	BorderStyle Style

	BorderLeft, BorderRight, BorderTop, BorderBottom bool

	PaddingLeft, PaddingRight, PaddingTop, PaddingBottom int

	image.Rectangle
	Inner image.Rectangle

	Title      string
	TitleStyle Style

	sync.Mutex
	// contains filtered or unexported fields
}

Block is the base struct inherited by most widgets. Block manages size, position, border, and title. It implements all 3 of the methods needed for the `Drawable` interface. Custom widgets will override the Draw method.

func NewBlock

func NewBlock() *Block

func (*Block) Draw

func (self *Block) Draw(buf *Buffer)

Draw implements the Drawable interface.

func (*Block) GetName

func (self *Block) GetName() string

func (*Block) GetRect

func (self *Block) GetRect() image.Rectangle

GetRect implements the Drawable interface.

func (*Block) MakeGlamourTitle

func (self *Block) MakeGlamourTitle(title string)

func (*Block) SetEmptyHeader

func (self *Block) SetEmptyHeader()

func (*Block) SetHeaderWithMarker

func (self *Block) SetHeaderWithMarker(marker, suffix string)

func (*Block) SetName

func (self *Block) SetName(name string)

func (*Block) SetRect

func (self *Block) SetRect(x1, y1, x2, y2 int)

SetRect implements the Drawable interface.

func (*Block) SetUUIDName

func (self *Block) SetUUIDName()

type BlockTheme

type BlockTheme struct {
	Title  Style
	Border Style
}

type Buffer

type Buffer struct {
	image.Rectangle
	CellMap map[image.Point]Cell
}

Buffer represents a section of a terminal and is a renderable rectangle of cells.

func NewBuffer

func NewBuffer(r image.Rectangle) *Buffer

func (*Buffer) Fill

func (self *Buffer) Fill(c Cell, rect image.Rectangle)

func (*Buffer) GetCell

func (self *Buffer) GetCell(p image.Point) Cell

func (*Buffer) SetCell

func (self *Buffer) SetCell(c Cell, p image.Point)

func (*Buffer) SetString

func (self *Buffer) SetString(s string, style Style, p image.Point)

type Canvas

type Canvas struct {
	Block
	drawille.Canvas
}

func NewCanvas

func NewCanvas() *Canvas

func (*Canvas) Draw

func (self *Canvas) Draw(buf *Buffer)

func (*Canvas) SetLine

func (self *Canvas) SetLine(p0, p1 image.Point, color Color)

func (*Canvas) SetPoint

func (self *Canvas) SetPoint(p image.Point, color Color)

type Cell

type Cell struct {
	Rune  rune
	Style Style
}

Cell represents a viewable terminal cell

func NewCell

func NewCell(rune rune, args ...interface{}) Cell

NewCell takes 1 to 2 arguments 1st argument = rune 2nd argument = optional style

func ParseStyles

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

ParseStyles parses a string for embedded Styles and returns []Cell with the correct styling. Uses defaultStyle for any text without an embedded style. Syntax is of the form [text](fg:<color>,mod:<attribute>,bg:<color>). Ordering does not matter. All fields are optional.

func RunesToStyledCells

func RunesToStyledCells(runes []rune, style Style) []Cell

func TrimCells

func TrimCells(cells []Cell, w int) []Cell

func WrapCells

func WrapCells(cells []Cell, width uint) []Cell

WrapCells takes []Cell and inserts Cells containing '\n' wherever a linebreak should go.

type CellWithX

type CellWithX struct {
	X    int
	Cell Cell
}

func BuildCellWithXArray

func BuildCellWithXArray(cells []Cell) []CellWithX

type Color

type Color int

Color is an integer from -1 to 255 -1 = ColorClear 0-255 = Xterm colors

const (
	ColorBlack         Color = 0
	ColorRed           Color = 1
	ColorGreen         Color = 2
	ColorYellow        Color = 3
	ColorBlue          Color = 4
	ColorMagenta       Color = 5
	ColorCyan          Color = 6
	ColorWhite         Color = 7
	ColorGreenBgDunkel Color = 22
	ColorGreenBlue     Color = 23
	ColorBlueLightFg   Color = 30
	ColorBlueLightFg2  Color = 31
)

Basic terminal colors

const ColorClear Color = -1

ColorClear clears the Fg or Bg color of a Style

func SelectColor

func SelectColor(colors []Color, index int) Color

type DashboardLib

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

func NewDashboardLib

func NewDashboardLib() *DashboardLib

func (*DashboardLib) AddBoldNumber

func (dl *DashboardLib) AddBoldNumber(r, c uint32, numb int32, name string, styles ...Style) *DashboardLib

func (*DashboardLib) AddCircleLineItem

func (dl *DashboardLib) AddCircleLineItem(r, c uint32, name, line string, styles ...Style) *DashboardLib

func (*DashboardLib) AddFullNumber

func (dl *DashboardLib) AddFullNumber(r, c uint32, numb int32, name string, styles ...Style) *DashboardLib

func (*DashboardLib) AddIconFree

func (dl *DashboardLib) AddIconFree(r, c uint32, icon int32, name string) *DashboardLib

func (*DashboardLib) AddMonoNumber

func (dl *DashboardLib) AddMonoNumber(r, c uint32, numb int32, name string, styles ...Style) *DashboardLib

func (*DashboardLib) AddRomeNumber

func (dl *DashboardLib) AddRomeNumber(r, c uint32, numb int32, name string, styles ...Style) *DashboardLib

func (*DashboardLib) AddSquaredLineItem

func (dl *DashboardLib) AddSquaredLineItem(r, c uint32, name, line string, styles ...Style) *DashboardLib

func (*DashboardLib) AddString

func (dl *DashboardLib) AddString(r, c uint32, name, data string, styles ...Style) *DashboardLib

func (*DashboardLib) Cols

func (dl *DashboardLib) Cols() int

func (*DashboardLib) GetItem

func (dl *DashboardLib) GetItem(name string) (*DashboardLibItem, bool)

func (*DashboardLib) Idx

func (dl *DashboardLib) Idx() map[uint32]*DashboardLibItem

func (*DashboardLib) Names

func (dl *DashboardLib) Names() []string

func (*DashboardLib) Rows

func (dl *DashboardLib) Rows() int

func (*DashboardLib) Size

func (dl *DashboardLib) Size() int

type DashboardLibItem

type DashboardLibItem struct {
	P, R, C uint32
	// contains filtered or unexported fields
}

func NewDashboardLibsItem

func NewDashboardLibsItem(iconView string, r, c, p uint32, styles ...Style) *DashboardLibItem

func (*DashboardLibItem) Address

func (dli *DashboardLibItem) Address() uint32

func (*DashboardLibItem) String

func (dli *DashboardLibItem) String() string

type DataProviderDashboard

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

func NewDataProviderDashboard

func NewDataProviderDashboard(lib *DashboardLib) *DataProviderDashboard

func (*DataProviderDashboard) GetTable

func (dpd *DataProviderDashboard) GetTable() [][]string

func (*DataProviderDashboard) OFF

func (dpd *DataProviderDashboard) OFF(r, c uint32)

func (*DataProviderDashboard) ON

func (dpd *DataProviderDashboard) ON(r, c uint32)

func (*DataProviderDashboard) Off

func (dpd *DataProviderDashboard) Off(name string)

func (*DataProviderDashboard) On

func (dpd *DataProviderDashboard) On(name string)

type DataProviderList

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

func NewDataProviderList

func NewDataProviderList() *DataProviderList

func (*DataProviderList) AddData

func (dpl *DataProviderList) AddData(data string, param uint32, row uint32)

func (*DataProviderList) Caching

func (dpl *DataProviderList) Caching()

func (*DataProviderList) GetList

func (dpl *DataProviderList) GetList() []string

func (*DataProviderList) GetListPtr

func (dpl *DataProviderList) GetListPtr() *[]string

func (*DataProviderList) SetExtTarget

func (dpl *DataProviderList) SetExtTarget(t *[]string)

func (*DataProviderList) SetWidthParams

func (dpl *DataProviderList) SetWidthParams(width []uint8)

func (*DataProviderList) UpdateData

func (dpl *DataProviderList) UpdateData(data string, address ...uint32)

UpdateData - адрес подается след образом - row, col, param

func (*DataProviderList) UpdateDataFromMap

func (dpl *DataProviderList) UpdateDataFromMap(data map[uint32]string)

func (*DataProviderList) UseSplit32

func (dpl *DataProviderList) UseSplit32() *DataProviderList

type DataProviderTable

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

func NewDataProviderTable

func NewDataProviderTable() *DataProviderTable

func (*DataProviderTable) AddData

func (dpt *DataProviderTable) AddData(data string, row, col, param uint32) *DataProviderTable

AddData - добавить данные в провайдер

func (*DataProviderTable) AddStyledData

func (dpt *DataProviderTable) AddStyledData(data string, row, col, param uint32) *DataProviderTable

AddStyledData - если мы хотим вставить стилизованный текст как 2 параметра: его нужно обернуть в спец символы

func (*DataProviderTable) Caching

func (dpt *DataProviderTable) Caching()

func (*DataProviderTable) GetMaxColsCount

func (dpt *DataProviderTable) GetMaxColsCount() uint8

func (*DataProviderTable) GetRow

func (dpt *DataProviderTable) GetRow(row int) []string

func (*DataProviderTable) GetTable

func (dpt *DataProviderTable) GetTable() [][]string

func (*DataProviderTable) Off

func (dpt *DataProviderTable) Off(r, c uint32)

func (*DataProviderTable) On

func (dpt *DataProviderTable) On(r, c uint32)

func (*DataProviderTable) SetMaxColsCount

func (dpt *DataProviderTable) SetMaxColsCount(count uint8)

func (*DataProviderTable) UpdateData

func (dpt *DataProviderTable) UpdateData(data string, address ...uint32)

UpdateData - обновляем данные по указанному адресу @address: - первым всегда идет индекс параметра. Он есть у всех видов провайдеров - вторым - индекс строки, он есть у двух из трех видов провайдеров - третий - индекс колонки, он есть только у табличного провайдера

func (*DataProviderTable) UpdateDataFromMap

func (dpt *DataProviderTable) UpdateDataFromMap(data map[uint32]string) error

func (*DataProviderTable) UseSplit32

func (dpt *DataProviderTable) UseSplit32() *DataProviderTable

type DataProviderText

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

func NewDataProviderText

func NewDataProviderText() *DataProviderText

func (*DataProviderText) AddData

func (dpt *DataProviderText) AddData(data string, address uint32)

func (*DataProviderText) GetText

func (dpt *DataProviderText) GetText() string

func (*DataProviderText) UpdateData

func (dpt *DataProviderText) UpdateData(data string, address ...uint32)

type Drawable

type Drawable interface {
	GetRect() image.Rectangle
	SetRect(int, int, int, int)
	Draw(*Buffer)
	sync.Locker
}

type Event

type Event struct {
	Type    EventType
	ID      string
	Ch      rune
	Payload interface{}
}

func (*Event) Uuid

func (e *Event) Uuid() string

type EventType

type EventType uint

type FDataProviderConverter

type FDataProviderConverter func() map[uint32]string

FDataProviderConverter - тип функций сборки и конвертации данных для дата провайдеров

type GaugeTheme

type GaugeTheme struct {
	Bar   Color
	Label Style
}

type Grid

type Grid struct {
	Block
	Items []*GridItem
}

func NewGrid

func NewGrid() *Grid

func (*Grid) Draw

func (self *Grid) Draw(buf *Buffer)

func (*Grid) Set

func (self *Grid) Set(entries ...interface{})

Set is used to add Columns and Rows to the grid. It recursively searches the GridItems, adding leaves to the grid and calculating the dimensions of the leaves.

type GridItem

type GridItem struct {
	Type        gridItemType
	XRatio      float64
	YRatio      float64
	WidthRatio  float64
	HeightRatio float64
	Entry       interface{} // Entry.type == GridBufferer if IsLeaf else []GridItem
	IsLeaf      bool
	// contains filtered or unexported fields
}

GridItem represents either a Row or Column in a grid. Holds sizing information and either an []GridItems or a widget.

func NewCol

func NewCol(ratio float64, i ...interface{}) GridItem

NewCol takes a height percentage and either a widget or a Row or Column

func NewRow

func NewRow(ratio float64, i ...interface{}) GridItem

NewRow takes a width percentage and either a widget or a Row or Column

type InputPld

type InputPld struct {
	KeyStr         string
	LineText       string
	CursorPosition int
	LineIndex      int
}

type ListTheme

type ListTheme struct {
	Text Style
}

type Modifier

type Modifier uint
const (
	// ModifierClear clears any modifiers
	ModifierClear     Modifier = 0
	ModifierBold      Modifier = 1 << 9
	ModifierUnderline Modifier = 1 << 10
	ModifierReverse   Modifier = 1 << 11
)

type Mouse

type Mouse struct {
	Drag bool
	X    int
	Y    int
}

Mouse payload.

type ParagraphTheme

type ParagraphTheme struct {
	Text Style
}

type PieChartTheme

type PieChartTheme struct {
	Slices []Color
}

type PlotTheme

type PlotTheme struct {
	Lines []Color
	Axes  Color
}

type Resize

type Resize struct {
	Width  int
	Height int
}

Resize payload.

type RootTheme

type RootTheme struct {
	Default Style

	Block BlockTheme

	BarChart        BarChartTheme
	Gauge           GaugeTheme
	Plot            PlotTheme
	List            ListTheme
	Tree            TreeTheme
	Paragraph       ParagraphTheme
	PieChart        PieChartTheme
	Sparkline       SparklineTheme
	StackedBarChart StackedBarChartTheme
	Tab             TabTheme
	Table           TableTheme
}

type ServicePld

type ServicePld struct {
	Op   int
	Id   string // id widget or id dp. id widget = id dp
	Data []interface{}
}

ServicePld payload

type SparklineTheme

type SparklineTheme struct {
	Title Style
	Line  Color
}

type StackedBarChartTheme

type StackedBarChartTheme struct {
	Bars   []Color
	Nums   []Style
	Labels []Style
}

type Style

type Style struct {
	Fg       Color
	Bg       Color
	Modifier Modifier
}

Style represents the style of one terminal cell

func NewStyle

func NewStyle(fg Color, args ...interface{}) Style

NewStyle takes 1 to 3 arguments 1st argument = Fg 2nd argument = optional Bg 3rd argument = optional Modifier

func NewStyleBgFree

func NewStyleBgFree(fg Color, mod Modifier) Style

func NewStyleFromStyleCode

func NewStyleFromStyleCode(code uint32) Style

func SelectStyle

func SelectStyle(styles []Style, index int) Style

type SystemPld

type SystemPld struct {
	Op   int
	Id   string // id widget or id dp. id widget = id dp
	Data []interface{}
}

SystemPld payload

type TabTheme

type TabTheme struct {
	Active   Style
	Inactive Style
}

type TableTheme

type TableTheme struct {
	Text Style
}

type TickerPld

type TickerPld struct {
	Action uint8
}

TickerPld payload

type TreeTheme

type TreeTheme struct {
	Text      Style
	Collapsed rune
	Expanded  rune
}

type UpdatingDataProvider

type UpdatingDataProvider interface {
	UpdateData(data string, address ...uint32)
}

type WidgetTheme

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

func NewButtonDefaultTheme

func NewButtonDefaultTheme() *WidgetTheme

func NewDefWidgetTheme

func NewDefWidgetTheme() *WidgetTheme

func NewMyDefaultWidgetTheme

func NewMyDefaultWidgetTheme() *WidgetTheme

func (*WidgetTheme) GetBorderStyle

func (wt *WidgetTheme) GetBorderStyle(isActive bool) Style

GetBorderStyle - получить стиль линии обводки

func (*WidgetTheme) GetTitleStyle

func (wt *WidgetTheme) GetTitleStyle(isActive bool) Style

GetTitleStyle - получить стиль заголовка

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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