widgets

package
v3.0.0-...-86ecd83 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogRecTypeInfo = "info"
	LogRecTypeWarn = "warn"
	LogRecTypeErr  = "err"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ATable

type ATable struct {
	Table
	WidgetTheme      *WidgetTheme
	ColSeparator     bool
	ColTextAlignment map[int]Alignment
	// contains filtered or unexported fields
}

ATable - таблица с расширенным функционалом форматирования

func MakeDefaultATable

func MakeDefaultATable(cw []int, align []Alignment, wts ...*WidgetTheme) *ATable

func MakeDefaultHotkeyWindow

func MakeDefaultHotkeyWindow(parent image.Rectangle, w, h int, cw []int, rows [][]string) *ATable

MakeDefaultHotkeyWindow - всплывающее окно со справочной информацией @parent - размер приложения на экране @w, @h - размеры в которые должно вписываться это всплывающее окно @rows - содержимое

func NewATable

func NewATable() *ATable

func (*ATable) AddCellAlignment

func (at *ATable) AddCellAlignment(idxRow, idxCol int, alignment Alignment)

func (*ATable) AddColAlignDefTheme

func (at *ATable) AddColAlignDefTheme()

AddColAlignDefTheme - желательно вызвать после того как заполнено свойство Rows подходит для таблицы в две колонки

func (*ATable) AddColAlignment

func (at *ATable) AddColAlignment(colIdx int, alignment Alignment)

func (*ATable) Draw

func (at *ATable) Draw(buf *Buffer)

func (*ATable) GetCellAlignment

func (at *ATable) GetCellAlignment(idxRow, idxCol int) Alignment

func (*ATable) UseCellAlignment

func (at *ATable) UseCellAlignment()

type BarChart

type BarChart struct {
	Block
	BarColors    []Color
	LabelStyles  []Style
	NumStyles    []Style // only Fg and Modifier are used
	NumFormatter func(float64) string
	Data         []float64
	Labels       []string
	BarWidth     int
	BarGap       int
	MaxVal       float64
}

func NewBarChart

func NewBarChart() *BarChart

func (*BarChart) Draw

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

type Button

type Button struct {
	Block
	// contains filtered or unexported fields
}

func NewButton

func NewButton(center image.Point) *Button

func (*Button) Active

func (b *Button) Active()

func (*Button) ChangeLabel

func (b *Button) ChangeLabel(label string)

func (*Button) Draw

func (b *Button) Draw(buf *Buffer)

func (*Button) NoActive

func (b *Button) NoActive()

type DialogBox

type DialogBox struct {
	Block
	// contains filtered or unexported fields
}

func NewDialogBox

func NewDialogBox(center image.Point, title, msg string) *DialogBox

func (*DialogBox) Draw

func (db *DialogBox) Draw(buf *Buffer)

func (*DialogBox) SetButtonLabel

func (db *DialogBox) SetButtonLabel(label string)

type DrawDirection

type DrawDirection uint
const (
	DrawLeft DrawDirection = iota
	DrawRight
)

type FnHlpRowMarker

type FnHlpRowMarker func(w, h *int) [][]string

type FnKBHandler

type FnKBHandler func(data ...interface{}) uint8

type Frame

type Frame struct {
	Block
	// contains filtered or unexported fields
}

Frame Окно с возможностью редактирования текста

func NewFrame

func NewFrame(center image.Point, title string) *Frame

func (*Frame) AddSymbol

func (f *Frame) AddSymbol(code string, ch rune)

func (*Frame) CaptureModeOff

func (f *Frame) CaptureModeOff()

func (*Frame) CaptureModeOn

func (f *Frame) CaptureModeOn()

func (*Frame) Draw

func (f *Frame) Draw(buf *Buffer)

func (*Frame) Input

func (f *Frame) Input() string

func (*Frame) OnlyNumbers

func (f *Frame) OnlyNumbers()

type Gauge

type Gauge struct {
	Block
	Percent    int
	BarColor   Color
	Label      string
	LabelStyle Style
}

func MakeDefaultGauge

func MakeDefaultGauge(gts ...GaugeTheme) *Gauge

func NewGauge

func NewGauge() *Gauge

func (*Gauge) Draw

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

func (*Gauge) UploadTheme

func (self *Gauge) UploadTheme(gt *GaugeTheme)

func (*Gauge) UploadWidgetTheme

func (self *Gauge) UploadWidgetTheme(wt *WidgetTheme, isActive bool)

type Image

type Image struct {
	Block
	Image               image.Image
	Monochrome          bool
	MonochromeThreshold uint8
	MonochromeInvert    bool
}

func NewImage

func NewImage(img image.Image) *Image

func (*Image) Draw

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

type List

type List struct {
	Block
	Rows        []string
	WrapText    bool
	TextStyle   Style
	SelectedRow int

	SelectedRowStyle Style
	// contains filtered or unexported fields
}

func NewList

func NewList() *List

func (*List) Draw

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

func (*List) ScrollAmount

func (self *List) ScrollAmount(amount int)

ScrollAmount scrolls by amount given. If amount is < 0, then scroll up. There is no need to set self.topRow, as this will be set automatically when drawn, since if the selected item is off screen then the topRow variable will change accordingly.

func (*List) ScrollBottom

func (self *List) ScrollBottom()

func (*List) ScrollDown

func (self *List) ScrollDown()

func (*List) ScrollHalfPageDown

func (self *List) ScrollHalfPageDown()

func (*List) ScrollHalfPageUp

func (self *List) ScrollHalfPageUp()

func (*List) ScrollPageDown

func (self *List) ScrollPageDown()

func (*List) ScrollPageUp

func (self *List) ScrollPageUp()

func (*List) ScrollTop

func (self *List) ScrollTop()

func (*List) ScrollUp

func (self *List) ScrollUp()

type ListES

type ListES struct {
	Block
	Rows        *[]string
	WrapText    bool
	TextStyle   Style
	SelectedRow int

	SelectedRowStyle Style
	// contains filtered or unexported fields
}

ListES - список со ссылкой на источник

func MakeDefaultListES

func MakeDefaultListES() *ListES

func NewListES

func NewListES() *ListES

func (*ListES) Draw

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

func (*ListES) ScrollAmount

func (self *ListES) ScrollAmount(amount int)

ScrollAmount scrolls by amount given. If amount is < 0, then scroll up. There is no need to set self.topRow, as this will be set automatically when drawn, since if the selected item is off screen then the topRow variable will change accordingly.

func (*ListES) ScrollBottom

func (self *ListES) ScrollBottom()

func (*ListES) ScrollDown

func (self *ListES) ScrollDown()

func (*ListES) ScrollHalfPageDown

func (self *ListES) ScrollHalfPageDown()

func (*ListES) ScrollHalfPageUp

func (self *ListES) ScrollHalfPageUp()

func (*ListES) ScrollPageDown

func (self *ListES) ScrollPageDown()

func (*ListES) ScrollPageUp

func (self *ListES) ScrollPageUp()

func (*ListES) ScrollTop

func (self *ListES) ScrollTop()

func (*ListES) ScrollUp

func (self *ListES) ScrollUp()

type LogRecord

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

func NewLogRecord

func NewLogRecord(mes, t string) LogRecord

func NewLogRecordPtr

func NewLogRecordPtr(mes, t string) *LogRecord

func (*LogRecord) Copy

func (lr *LogRecord) Copy() LogRecord

func (*LogRecord) GetMomentFormat

func (lr *LogRecord) GetMomentFormat() string

func (*LogRecord) GetMsg

func (lr *LogRecord) GetMsg() string

func (*LogRecord) GetRecType

func (lr *LogRecord) GetRecType() string

type LogStack

type LogStack struct {
	Block
	// contains filtered or unexported fields
}

func NewLogStack

func NewLogStack(depth ...uint8) *LogStack

func (*LogStack) AddErrLogRecord

func (ls *LogStack) AddErrLogRecord(err error)

func (*LogStack) AddInfoLogRecord

func (ls *LogStack) AddInfoLogRecord(message string)

func (*LogStack) AddLogRecordAsIs

func (ls *LogStack) AddLogRecordAsIs(lr LogRecord)

func (*LogStack) AddWarnLogRecord

func (ls *LogStack) AddWarnLogRecord(message string)

func (*LogStack) Draw

func (ls *LogStack) Draw(buf *Buffer)

func (*LogStack) GetId

func (ls *LogStack) GetId() string

func (*LogStack) SetId

func (ls *LogStack) SetId(name string)

type Paragraph

type Paragraph struct {
	Block
	Text      string
	TextStyle Style
	WrapText  bool
}

func NewParagraph

func NewParagraph() *Paragraph

func (*Paragraph) Draw

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

type PieChart

type PieChart struct {
	Block
	Data           []float64     // list of data items
	Colors         []Color       // colors to by cycled through
	LabelFormatter PieChartLabel // callback function for labels
	AngleOffset    float64       // which angle to start drawing at? (see piechartOffsetUp)
}

func NewPieChart

func NewPieChart() *PieChart

NewPieChart Creates a new pie chart with reasonable defaults and no labels.

func (*PieChart) Draw

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

type PieChartLabel

type PieChartLabel func(dataIndex int, currentValue float64) string

PieChartLabel callback

type Plot

type Plot struct {
	Block

	Data       [][]float64
	DataLabels []string
	MaxVal     float64

	LineColors []Color
	AxesColor  Color // TODO
	ShowAxes   bool

	Marker          PlotMarker
	DotMarkerRune   rune
	PlotType        PlotType
	HorizontalScale int
	DrawDirection   DrawDirection // TODO
}

Plot has two modes: line(default) and scatter. Plot also has two marker types: braille(default) and dot. A single braille character is a 2x4 grid of dots, so using braille gives 2x X resolution and 4x Y resolution over dot mode.

func NewPlot

func NewPlot() *Plot

func (*Plot) Draw

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

type PlotMarker

type PlotMarker uint
const (
	MarkerBraille PlotMarker = iota
	MarkerDot
)

type PlotType

type PlotType uint
const (
	LineChart PlotType = iota
	ScatterPlot
)

type Sparkline

type Sparkline struct {
	Data       []float64
	Title      string
	TitleStyle Style
	LineColor  Color
	MaxVal     float64
	MaxHeight  int // TODO
}

Sparkline is like: ▅▆▂▂▅▇▂▂▃▆▆▆▅▃. The data points should be non-negative integers.

func NewSparkline

func NewSparkline() *Sparkline

NewSparkline returns a unrenderable single sparkline that needs to be added to a SparklineGroup

type SparklineGroup

type SparklineGroup struct {
	Block
	Sparklines []*Sparkline
}

SparklineGroup is a renderable widget which groups together the given sparklines.

func NewSparklineGroup

func NewSparklineGroup(sls ...*Sparkline) *SparklineGroup

func (*SparklineGroup) Draw

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

type StackedBarChart

type StackedBarChart struct {
	Block
	BarColors    []Color
	LabelStyles  []Style
	NumStyles    []Style // only Fg and Modifier are used
	NumFormatter func(float64) string
	Data         [][]float64
	Labels       []string
	BarWidth     int
	BarGap       int
	MaxVal       float64
}

func NewStackedBarChart

func NewStackedBarChart() *StackedBarChart

func (*StackedBarChart) Draw

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

type TabPane

type TabPane struct {
	Block
	TabNames         []string
	ActiveTabIndex   int
	ActiveTabStyle   Style
	InactiveTabStyle Style
}

TabPane is a renderable widget which can be used to conditionally render certain tabs/views. TabPane shows a list of Tab names. The currently selected tab can be found through the `ActiveTabIndex` field.

func NewTabPane

func NewTabPane(names ...string) *TabPane

func (*TabPane) Draw

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

func (*TabPane) FocusLeft

func (self *TabPane) FocusLeft()

func (*TabPane) FocusRight

func (self *TabPane) FocusRight()

type Table

type Table struct {
	Block
	Rows          [][]string
	ColumnWidths  []int
	TextStyle     Style
	RowSeparator  bool
	TextAlignment Alignment
	RowStyles     map[int]Style
	FillRow       bool

	// ColumnResizer is called on each Draw. Can be used for custom column sizing.
	ColumnResizer func()
}

Table is like: ┌ Awesome Table ───────────────────────────────────────────────┐ │ Col0 | Col1 | Col2 | Col3 | Col4 | Col5 | Col6 | │──────────────────────────────────────────────────────────────│ │ Some Item #1 | AAA | 123 | CCCCC | EEEEE | GGGGG | IIIII | │──────────────────────────────────────────────────────────────│ │ Some Item #2 | BBB | 456 | DDDDD | FFFFF | HHHHH | JJJJJ | └──────────────────────────────────────────────────────────────┘

func NewTable

func NewTable() *Table

func (*Table) Draw

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

type Tree

type Tree struct {
	Block
	TextStyle        Style
	SelectedRowStyle Style
	WrapText         bool
	SelectedRow      int
	// contains filtered or unexported fields
}

Tree is a tree widget.

func NewTree

func NewTree() *Tree

NewTree creates a new Tree widget.

func (*Tree) Collapse

func (self *Tree) Collapse()

func (*Tree) CollapseAll

func (self *Tree) CollapseAll()

func (*Tree) Draw

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

func (*Tree) Expand

func (self *Tree) Expand()

func (*Tree) ExpandAll

func (self *Tree) ExpandAll()

func (*Tree) ScrollAmount

func (self *Tree) ScrollAmount(amount int)

ScrollAmount scrolls by amount given. If amount is < 0, then scroll up. There is no need to set self.topRow, as this will be set automatically when drawn, since if the selected item is off screen then the topRow variable will change accordingly.

func (*Tree) ScrollBottom

func (self *Tree) ScrollBottom()

func (*Tree) ScrollDown

func (self *Tree) ScrollDown()

func (*Tree) ScrollHalfPageDown

func (self *Tree) ScrollHalfPageDown()

func (*Tree) ScrollHalfPageUp

func (self *Tree) ScrollHalfPageUp()

func (*Tree) ScrollPageDown

func (self *Tree) ScrollPageDown()

func (*Tree) ScrollPageUp

func (self *Tree) ScrollPageUp()

func (*Tree) ScrollTop

func (self *Tree) ScrollTop()

func (*Tree) ScrollUp

func (self *Tree) ScrollUp()

func (*Tree) SelectedNode

func (self *Tree) SelectedNode() *TreeNode

func (*Tree) SetNodes

func (self *Tree) SetNodes(nodes []*TreeNode)

func (*Tree) ToggleExpand

func (self *Tree) ToggleExpand()

func (*Tree) Walk

func (self *Tree) Walk(fn TreeWalkFn)

type TreeNode

type TreeNode struct {
	Value    fmt.Stringer
	Expanded bool
	Nodes    []*TreeNode
	// contains filtered or unexported fields
}

TreeNode is a tree node.

type TreeWalkFn

type TreeWalkFn func(*TreeNode) bool

TreeWalkFn is a function used for walking a Tree. To interrupt the walking process function should return false.

type Widget

type Widget interface {
	Drawable
	GetId() string
}

Jump to

Keyboard shortcuts

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