view

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2020 License: MPL-2.0 Imports: 12 Imported by: 87

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildStars

func BuildStars(data []Bar, maxStars int, starChar string) string

BuildStars build the string to display

func NewBillboardModal added in v0.25.0

func NewBillboardModal(text string, closeFunc func()) *tview.Frame

NewBillboardModal creates and returns a modal dialog suitable for displaying a wall of text An example of this is the keyboard help modal that shows up for all widgets that support keyboard control when '/' is pressed

Types

type Bar

type Bar struct {
	Label      string
	Percent    int
	ValueLabel string
	LabelColor string
}

Bar defines a single row in the bar graph

type BarGraph

type BarGraph struct {
	Base
	View *tview.TextView
	// contains filtered or unexported fields
}

BarGraph defines the data required to make a bar graph

func NewBarGraph

func NewBarGraph(app *tview.Application, name string, commonSettings *cfg.Common) BarGraph

NewBarGraph creates and returns an instance of BarGraph

func (*BarGraph) BuildBars

func (widget *BarGraph) BuildBars(data []Bar)

BuildBars will build a string of * to represent your data of time[value] time should be passed as a int64

func (*BarGraph) TextView

func (widget *BarGraph) TextView() *tview.TextView

type Base

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

func NewBase

func NewBase(app *tview.Application, commonSettings *cfg.Common) Base

func (*Base) BorderColor

func (base *Base) BorderColor() string

BorderColor returns the color that the border of this widget should be drawn in

func (*Base) Bordered

func (base *Base) Bordered() bool

Bordered returns whether or not this widget should be drawn with a border

func (*Base) CommonSettings

func (base *Base) CommonSettings() *cfg.Common

func (*Base) ConfigText

func (base *Base) ConfigText() string

func (*Base) ContextualTitle

func (base *Base) ContextualTitle(defaultStr string) string

func (*Base) Disable

func (base *Base) Disable()

func (*Base) Disabled

func (base *Base) Disabled() bool

func (*Base) Enabled

func (base *Base) Enabled() bool

func (*Base) FocusChar

func (base *Base) FocusChar() string

func (*Base) Focusable

func (base *Base) Focusable() bool

func (*Base) HelpText

func (base *Base) HelpText() string

func (*Base) Name

func (base *Base) Name() string

func (*Base) QuitChan

func (base *Base) QuitChan() chan bool

func (*Base) RefreshInterval

func (base *Base) RefreshInterval() int

RefreshInterval returns how often, in seconds, the base will return its data

func (*Base) Refreshing

func (base *Base) Refreshing() bool

Refreshing returns TRUE if the base is currently refreshing its data, FALSE if it is not

func (*Base) SetFocusChar

func (base *Base) SetFocusChar(char string)

func (*Base) Stop

func (base *Base) Stop()

func (*Base) String

func (base *Base) String() string

type InfoTable added in v0.25.0

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

InfoTable contains the internal guts of an InfoTable

func NewInfoTable added in v0.25.0

func NewInfoTable(headers []string, dataMap map[string]string, colWidth0, colWidth1, tableHeight int) *InfoTable

NewInfoTable creates and returns the stringified contents of a two-column table

func (*InfoTable) Render added in v0.25.0

func (tbl *InfoTable) Render() string

Render returns the stringified version of the table

type KeyboardWidget

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

KeyboardWidget manages keyboard control for a widget

func NewKeyboardWidget

func NewKeyboardWidget(app *tview.Application, pages *tview.Pages, settings *cfg.Common) KeyboardWidget

NewKeyboardWidget creates and returns a new instance of KeyboardWidget

func (*KeyboardWidget) HelpText

func (widget *KeyboardWidget) HelpText() string

HelpText returns the help text and keyboard command info for this widget

func (*KeyboardWidget) InitializeCommonControls added in v0.21.0

func (widget *KeyboardWidget) InitializeCommonControls(refreshFunc func())

InitializeCommonControls sets up the keyboard controls that are common to all widgets that accept keyboard input

func (*KeyboardWidget) InputCapture

func (widget *KeyboardWidget) InputCapture(event *tcell.EventKey) *tcell.EventKey

InputCapture is the function passed to tview's SetInputCapture() function This is done during the main widget's creation process using the following code:

widget.View.SetInputCapture(widget.InputCapture)

func (*KeyboardWidget) SetKeyboardChar

func (widget *KeyboardWidget) SetKeyboardChar(char string, fn func(), helpText string)

SetKeyboardChar sets a character/function combination that responds to key presses Example:

widget.SetKeyboardChar("d", widget.deleteSelectedItem)

func (*KeyboardWidget) SetKeyboardKey

func (widget *KeyboardWidget) SetKeyboardKey(key tcell.Key, fn func(), helpText string)

SetKeyboardKey sets a tcell.Key/function combination that responds to key presses Example:

widget.SetKeyboardKey(tcell.KeyCtrlD, widget.deleteSelectedItem)

func (*KeyboardWidget) SetView

func (widget *KeyboardWidget) SetView(view *tview.TextView)

func (*KeyboardWidget) ShowHelp

func (widget *KeyboardWidget) ShowHelp()

type MultiSourceWidget

type MultiSourceWidget struct {
	DisplayFunction func()
	Idx             int
	Sources         []string
	// contains filtered or unexported fields
}

MultiSourceWidget is a widget that supports displaying data from multiple sources

func NewMultiSourceWidget

func NewMultiSourceWidget(moduleConfig *cfg.Common, singular, plural string) MultiSourceWidget

NewMultiSourceWidget creates and returns an instance of MultiSourceWidget

func (*MultiSourceWidget) CurrentSource

func (widget *MultiSourceWidget) CurrentSource() string

CurrentSource returns the string representations of the currently-displayed source

func (*MultiSourceWidget) NextSource

func (widget *MultiSourceWidget) NextSource()

NextSource displays the next source in the source list. If the current source is the last source it wraps around to the first source

func (*MultiSourceWidget) PrevSource

func (widget *MultiSourceWidget) PrevSource()

PrevSource displays the previous source in the source list. If the current source is the first source, it wraps around to the last source

func (*MultiSourceWidget) SetDisplayFunction

func (widget *MultiSourceWidget) SetDisplayFunction(displayFunc func())

SetDisplayFunction stores the function that should be called when the source is changed. This is typically called from within the initializer for the struct that embeds MultiSourceWidget

Example:

widget := Widget{
  MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "person", "people")
}

widget.SetDisplayFunction(widget.display)

type ScrollableWidget

type ScrollableWidget struct {
	TextWidget

	Selected int

	RenderFunction func()
	// contains filtered or unexported fields
}

func NewScrollableWidget

func NewScrollableWidget(app *tview.Application, commonSettings *cfg.Common) ScrollableWidget

func (*ScrollableWidget) GetSelected

func (widget *ScrollableWidget) GetSelected() int

func (*ScrollableWidget) Next

func (widget *ScrollableWidget) Next()

func (*ScrollableWidget) Prev

func (widget *ScrollableWidget) Prev()

func (*ScrollableWidget) Redraw

func (widget *ScrollableWidget) Redraw(data func() (string, string, bool))

func (*ScrollableWidget) RowColor

func (widget *ScrollableWidget) RowColor(idx int) string

func (*ScrollableWidget) SetItemCount

func (widget *ScrollableWidget) SetItemCount(items int)

func (*ScrollableWidget) SetRenderFunction

func (widget *ScrollableWidget) SetRenderFunction(displayFunc func())

func (*ScrollableWidget) Unselect

func (widget *ScrollableWidget) Unselect()

type TextWidget

type TextWidget struct {
	Base
	View *tview.TextView
}

TextWidget defines the data necessary to make a text widget

func NewTextWidget

func NewTextWidget(app *tview.Application, commonSettings *cfg.Common) TextWidget

NewTextWidget creates and returns an instance of TextWidget

func (*TextWidget) Redraw

func (widget *TextWidget) Redraw(data func() (string, string, bool))

func (*TextWidget) TextView

func (widget *TextWidget) TextView() *tview.TextView

Jump to

Keyboard shortcuts

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