view

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: MPL-2.0 Imports: 15 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
	*KeyboardWidget

	View *tview.TextView
	// contains filtered or unexported fields
}

BarGraph defines the data required to make a bar graph

func NewBarGraph

func NewBarGraph(tviewApp *tview.Application, redrawChan chan bool, _ 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 {
	RedrawChan chan bool
	// contains filtered or unexported fields
}

func NewBase

func NewBase(tviewApp *tview.Application, redrawChan chan bool, pages *tview.Pages, commonSettings *cfg.Common) *Base

NewBase creates and returns an instance of the Base module, the lowest-level primitive module from which all others are derived

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

func (base *Base) Name() string

func (*Base) QuitChan

func (base *Base) QuitChan() chan bool

func (*Base) RefreshInterval

func (base *Base) RefreshInterval() time.Duration

RefreshInterval returns how often 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) SetView added in v0.35.0

func (base *Base) SetView(view *tview.TextView)

SetView assigns the passed-in tview.TextView view to this widget

func (*Base) ShowHelp added in v0.35.0

func (base *Base) ShowHelp()

ShowHelp displays the modal help dialog for a module

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(settings *cfg.Common) *KeyboardWidget

NewKeyboardWidget creates and returns a new instance of KeyboardWidget func NewKeyboardWidget(tviewApp *tview.Application, pages *tview.Pages, settings *cfg.Common) *KeyboardWidget {

func (*KeyboardWidget) AssignedChars added in v0.35.0

func (widget *KeyboardWidget) AssignedChars() []string

AssignedChars returns a list of all the text characters assigned to an operation

func (*KeyboardWidget) HelpText

func (widget *KeyboardWidget) HelpText() string

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

func (*KeyboardWidget) InitializeHelpTextKeyboardControl added in v0.35.0

func (widget *KeyboardWidget) InitializeHelpTextKeyboardControl(helpFunc func())

InitializeHelpTextKeyboardControl assigns the function that displays help text to the common help text key value

func (*KeyboardWidget) InitializeRefreshKeyboardControl added in v0.35.0

func (widget *KeyboardWidget) InitializeRefreshKeyboardControl(refreshFunc func())

InitializeRefreshKeyboardControl assigns the module's explicit refresh function to the commom refresh key value

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) LaunchDocumentation added in v0.35.0

func (widget *KeyboardWidget) LaunchDocumentation()

LaunchDocumentation opens the module docs in a browser

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)

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(tviewApp *tview.Application, redrawChan chan bool, pages *tview.Pages, 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
	*KeyboardWidget

	View *tview.TextView
}

TextWidget defines the data necessary to make a text widget

func NewTextWidget

func NewTextWidget(tviewApp *tview.Application, redrawChan chan bool, pages *tview.Pages, commonSettings *cfg.Common) TextWidget

NewTextWidget creates and returns an instance of TextWidget

func (*TextWidget) Redraw

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

Redraw forces a refresh of the onscreen text content of this widget

func (*TextWidget) TextView

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

TextView returns the tview.TextView instance

Jump to

Keyboard shortcuts

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