widgets

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DrawEdit

func DrawEdit(ev <-chan ui.Event, symbol string) string

DrawEdit draws an editbox and returns input passed to the box

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 represnts a custom UI widget

func NewBarChart

func NewBarChart() *BarChart

NewBarChart initialises and returns a pointer to a BarChart instance

func (*BarChart) Draw

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

Draw helps draw the barChart onto the UI

type EditBox

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

EditBox helps user provide input through a text box like widget

func (*EditBox) AdjustVOffset

func (eb *EditBox) AdjustVOffset(width int)

AdjustVOffset adjusts line visual offset to a proper value depending on width

func (*EditBox) Draw

func (eb *EditBox) Draw(x, y, w, h int)

Draw helps draw the EditBox in the given location, 'h' is not used at the moment

type HelpMenu

type HelpMenu struct {
	*Table
	Keybindings [][]string
}

HelpMenu is a wrapper widget around a List meant to display the help menu for a command

func NewHelpMenu

func NewHelpMenu() *HelpMenu

NewHelpMenu is a constructor for the HelpMenu type

func (*HelpMenu) Draw

func (help *HelpMenu) Draw(buf *ui.Buffer)

Draw puts the required text into the widget

func (*HelpMenu) Resize

func (help *HelpMenu) Resize(termWidth, termHeight int)

Resize resizes the widget based on specified width and height

func (*HelpMenu) SelectHelpMenu

func (help *HelpMenu) SelectHelpMenu(page string)

SelectHelpMenu selects the appropriate text based on the command for which the help page is needed

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 draws the LineGraph onto the UI

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
	ChangeCol    map[int]bool     // Used to set if a column represents change
	ColColor     map[int]ui.Color // Set a custom colour to a column
	ColResizer   func()

	IsHelp bool
}

Table represents a custom table widget

func NewTable

func NewTable() *Table

NewTable returns a new Table instance

func (*Table) Draw

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

Draw helps draw the Table onto the UI

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