widgets

package
v3.1.1-0...-cff20d4 Latest Latest
Warning

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

Go to latest
Published: May 6, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 DrawDirection

type DrawDirection uint
const (
	DrawLeft DrawDirection = iota
	DrawRight
)

type Gauge

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

func NewGauge

func NewGauge() *Gauge

func (*Gauge) Draw

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

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 Input

type Input struct {
	Block
	Text      string
	TextStyle Style
	WrapText  bool
	Focusing  bool
}

func NewInput

func NewInput() *Input

Create new Input widget. Somehow similar to Paragraph.

func (*Input) Draw

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

func (*Input) Focus

func (i *Input) Focus()

Focus on input field and start typing.

func (*Input) NoFocus

func (i *Input) NoFocus()

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 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.

Jump to

Keyboard shortcuts

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