utils

package
v0.0.0-...-9e6775c Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UpArrow is a symbol used when sorting tables
	UpArrow = "▲"
	// DownArrow is a symbol used when sorting tables
	DownArrow = "▼"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BarChart

type BarChart struct {
	NumFormatter func(float64) string
	Labels       []string
	BarColors    []ui.Color
	LabelStyles  []ui.Style
	NumStyles    []ui.Style
	Data         []float64
	ui.Block
	BarWidth int
	BarGap   int
	MaxVal   float64
}

BarChart is a widget to display Bar Graphs

func NewBarChart

func NewBarChart() *BarChart

NewBarChart is a constructor for BarChart type

func (*BarChart) Draw

func (b *BarChart) Draw(buf *ui.Buffer)

Draw helps draw the bar chart widget onto the UI buffer

type CPUTableChart

type CPUTableChart struct {
	*ui.Block
	Data               []float64
	NumCores           int
	CellSize           int
	TopRow             int
	StatusColor        []ui.Color
	NumRows            int
	NumCols            int
	DefaultBorderColor ui.Color // indicates default border color
	ActiveBorderColor  ui.Color // indicates active border color
}

CPUTableChart is a custom widget to display a CPU Table

func NewCPUTableChart

func NewCPUTableChart() *CPUTableChart

NewCPUTableChart is a constructor for type CPUTableChart

func (*CPUTableChart) DisableCursor

func (c *CPUTableChart) DisableCursor()

DisableCursor turns off the cursor and un highlights the table

func (*CPUTableChart) Draw

func (c *CPUTableChart) Draw(buf *ui.Buffer)

Draw helps draw the CPU table Chart widget onto the UI buffer

func (*CPUTableChart) EnableCursor

func (c *CPUTableChart) EnableCursor()

EnableCursor turns on the cursor and highlights the table

func (*CPUTableChart) ScrollBottom

func (c *CPUTableChart) ScrollBottom()

ScrollBottom moves the cursor to the bottom

func (*CPUTableChart) ScrollDown

func (c *CPUTableChart) ScrollDown()

ScrollDown moves the cursor one position downwards

func (*CPUTableChart) ScrollHalfPageDown

func (c *CPUTableChart) ScrollHalfPageDown()

ScrollHalfPageDown moves the cursor half a page down

func (*CPUTableChart) ScrollHalfPageUp

func (c *CPUTableChart) ScrollHalfPageUp()

ScrollHalfPageUp moves the cursor half a page up

func (*CPUTableChart) ScrollPageDown

func (c *CPUTableChart) ScrollPageDown()

ScrollPageDown moves the cursor a page down

func (*CPUTableChart) ScrollPageUp

func (c *CPUTableChart) ScrollPageUp()

ScrollPageUp moves the cursor a page up

func (*CPUTableChart) ScrollToIndex

func (c *CPUTableChart) ScrollToIndex(idx int)

ScrollToIndex moves the cursor to a specified index

func (*CPUTableChart) ScrollTop

func (c *CPUTableChart) ScrollTop()

ScrollTop moves the cursor to the top

func (*CPUTableChart) ScrollUp

func (c *CPUTableChart) ScrollUp()

ScrollUp moves the cursor one position upwards

type HorizontalBarChart

type HorizontalBarChart struct {
	*ui.Block
	BarColors   []ui.Color // Custom bar colors
	LabelStyles []ui.Style // Styles label styles
	Data        []float64
	Labels      []string
	MaxVal      float64
	BarGap      int    // Gap between bars
	BarWidth    int    // Width of each bar
	ColResizer  func() // Function to resize bar
}

HorizontalBarChart is a custom widget to display a horizontal bar graph

func NewHorizontalBarChart

func NewHorizontalBarChart() *HorizontalBarChart

NewHorizontalBarChart is a constructor for the type HorizontalBarChart

func (*HorizontalBarChart) Draw

func (h *HorizontalBarChart) Draw(buf *ui.Buffer)

Draw helps draw the Horizontal Bar Chart widget onto the UI buffer

type LineGraph

type LineGraph struct {
	*ui.Block

	Data   map[string][]float64
	Labels map[string]string

	HorizontalScale int
	MaxVal          float64

	LineColors       map[string]ui.Color
	DefaultLineColor ui.Color
}

LineGraph implements a line graph of data points.

func NewLineGraph

func NewLineGraph() *LineGraph

NewLineGraph creates and returns a lineGraph instance

func (*LineGraph) Draw

func (l *LineGraph) Draw(buf *ui.Buffer)

Draw helps draw the Line Graph widget onto the UI buffer

type ScrollableWidget

type ScrollableWidget interface {
	ScrollUp()
	ScrollDown()
	ScrollTop()
	ScrollBottom()
	ScrollHalfPageUp()
	ScrollHalfPageDown()
	ScrollPageUp()
	ScrollPageDown()
	DisableCursor()
	EnableCursor()
}

ScrollableWidget is any widget that can have it's cursor scrolled, enabled and disabled

type Sparkline

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

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 {
	*ui.Block
	Sparklines []*Sparkline
}

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

func NewSparklineGroup

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

NewSparklineGroup is a constructor for the type SparklineGroup

func (*SparklineGroup) Draw

func (s *SparklineGroup) Draw(buf *ui.Buffer)

Draw helps draw the Sparkline widget onto the UI buffer

type Table

type Table struct {
	*ui.Block

	Header []string
	Rows   [][]string

	// Different Styles for Header and Rows
	HeaderStyle ui.Style
	RowStyle    ui.Style

	ColWidths []int
	ColGap    int
	PadLeft   int

	ShowCursor  bool
	CursorColor ui.Color

	ShowLocation bool

	UniqueCol    int    // the column used to uniquely identify each table row
	SelectedItem string // used to keep the cursor on the correct item if the data changes
	SelectedRow  int
	TopRow       int // used to indicate where in the table we are scrolled at
	// Map that stores custom column colors
	ColColor   map[int]ui.Color
	ColResizer func()

	IsHelp             bool     // indicates if table is a help widget
	DefaultBorderColor ui.Color // indicates default border color
	ActiveBorderColor  ui.Color // indicates active border color
}

Table is a custom table widget

func NewTable

func NewTable() *Table

NewTable returns a new Table instance

func (*Table) DisableCursor

func (t *Table) DisableCursor()

DisableCursor turns off the cursor and un highlights the table

func (*Table) Draw

func (t *Table) Draw(buf *ui.Buffer)

Draw helps draw the Table widget onto the UI buffer

func (*Table) EnableCursor

func (t *Table) EnableCursor()

EnableCursor turns on the cursor and highlights the table

func (*Table) ScrollBottom

func (t *Table) ScrollBottom()

ScrollBottom moves the cursor to the bottom

func (*Table) ScrollDown

func (t *Table) ScrollDown()

ScrollDown moves the cursor one position downwards

func (*Table) ScrollHalfPageDown

func (t *Table) ScrollHalfPageDown()

ScrollHalfPageDown moves the cursor half a page down

func (*Table) ScrollHalfPageUp

func (t *Table) ScrollHalfPageUp()

ScrollHalfPageUp moves the cursor half a page up

func (*Table) ScrollPageDown

func (t *Table) ScrollPageDown()

ScrollPageDown moves the cursor a page down

func (*Table) ScrollPageUp

func (t *Table) ScrollPageUp()

ScrollPageUp moves the cursor a page up

func (*Table) ScrollToIndex

func (t *Table) ScrollToIndex(idx int)

ScrollToIndex moves the cursor to a specified index

func (*Table) ScrollTop

func (t *Table) ScrollTop()

ScrollTop moves the cursor to the top

func (*Table) ScrollUp

func (t *Table) ScrollUp()

ScrollUp moves the cursor one position upwards

Jump to

Keyboard shortcuts

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