tvxwidgets

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 7 Imported by: 8

README

tvxwidgets

PkgGoDev Go codecov Go Report

tvxwidgets provides extra widgets for tview.

Screenshot

Widgets

Example

package main

import (
	"time"

	"github.com/gdamore/tcell/v2"
	"github.com/navidys/tvxwidgets"
	"github.com/rivo/tview"
)

func main() {
	app := tview.NewApplication()
	gauge := tvxwidgets.NewActivityModeGauge()
	gauge.SetTitle("activity mode gauge")
	gauge.SetPgBgColor(tcell.ColorOrange)
	gauge.SetRect(10, 4, 50, 3)
	gauge.SetBorder(true)

	update := func() {
		tick := time.NewTicker(500 * time.Millisecond)
		for {
			select {
			case <-tick.C:
				gauge.Pulse()
				app.Draw()
			}
		}
	}
	go update()

	if err := app.SetRoot(gauge, false).EnableMouse(true).Run(); err != nil {
		panic(err)
	}
}

Documentation

Index

Constants

View Source
const (
	InfoDialog = 0 + iota
	ErrorDailog
)

represents dialog type.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivityModeGauge

type ActivityModeGauge struct {
	*tview.Box
	// contains filtered or unexported fields
}

ActivityModeGauge represents activity mode gauge permitive.

func NewActivityModeGauge

func NewActivityModeGauge() *ActivityModeGauge

NewActivityModeGauge returns new activity mode gauge permitive.

func (*ActivityModeGauge) Draw

func (g *ActivityModeGauge) Draw(screen tcell.Screen)

Draw draws this primitive onto the screen.

func (*ActivityModeGauge) Focus

func (g *ActivityModeGauge) Focus(delegate func(p tview.Primitive))

Focus is called when this primitive receives focus.

func (*ActivityModeGauge) GetRect

func (g *ActivityModeGauge) GetRect() (int, int, int, int)

GetRect return primitive current rect.

func (*ActivityModeGauge) HasFocus

func (g *ActivityModeGauge) HasFocus() bool

HasFocus returns whether or not this primitive has focus.

func (*ActivityModeGauge) Pulse

func (g *ActivityModeGauge) Pulse()

Pulse pulse update the gauge progress bar.

func (*ActivityModeGauge) Reset

func (g *ActivityModeGauge) Reset()

Reset resets the gauge counter (set to 0).

func (*ActivityModeGauge) SetPgBgColor

func (g *ActivityModeGauge) SetPgBgColor(color tcell.Color)

SetPgBgColor sets progress block background color.

func (*ActivityModeGauge) SetRect

func (g *ActivityModeGauge) SetRect(x, y, width, height int)

SetRect sets rect for this primitive.

type BarChart

type BarChart struct {
	*tview.Box
	// contains filtered or unexported fields
}

BarChart represents bar chart primitive.

func NewBarChart

func NewBarChart() *BarChart

NewBarChart returns a new bar chart primitive.

func (*BarChart) AddBar

func (c *BarChart) AddBar(label string, value int, color tcell.Color)

AddBar adds new bar item to the bar chart primitive.

func (*BarChart) Draw

func (c *BarChart) Draw(screen tcell.Screen)

Draw draws this primitive onto the screen.

func (*BarChart) Focus

func (c *BarChart) Focus(delegate func(p tview.Primitive))

Focus is called when this primitive receives focus.

func (*BarChart) GetRect

func (c *BarChart) GetRect() (int, int, int, int)

GetRect return primitive current rect.

func (*BarChart) HasFocus

func (c *BarChart) HasFocus() bool

HasFocus returns whether or not this primitive has focus.

func (*BarChart) SetAxesColor added in v0.4.0

func (c *BarChart) SetAxesColor(color tcell.Color)

SetAxesColor sets axes x and y lines color.

func (*BarChart) SetAxesLabelColor added in v0.4.0

func (c *BarChart) SetAxesLabelColor(color tcell.Color)

SetAxesLabelColor sets axes x and y label color.

func (*BarChart) SetBarValue

func (c *BarChart) SetBarValue(name string, value int)

SetBarValue sets bar values.

func (*BarChart) SetBorder

func (c *BarChart) SetBorder(status bool)

SetBorder sets border for this primitive.

func (*BarChart) SetMaxValue

func (c *BarChart) SetMaxValue(max int)

SetMaxValue sets maximum value of bars.

func (*BarChart) SetRect

func (c *BarChart) SetRect(x, y, width, height int)

SetRect sets rect for this primitive.

type BarChartItem

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

BarChartItem represents a single bar in bar chart.

type Marker added in v0.3.0

type Marker uint

Marker represents plot drawing marker (braille or dot).

const (
	// plot marker.
	PlotMarkerBraille Marker = iota
	PlotMarkerDot
)

type MessageDialog

type MessageDialog struct {
	*tview.Box
	// contains filtered or unexported fields
}

MessageDialog represents message dialog primitive.

func NewMessageDialog

func NewMessageDialog(dtype int) *MessageDialog

NewMessageDialog returns a new message dialog primitive.

func (*MessageDialog) Draw

func (d *MessageDialog) Draw(screen tcell.Screen)

Draw draws this primitive onto the screen.

func (*MessageDialog) Focus

func (d *MessageDialog) Focus(delegate func(p tview.Primitive))

Focus is called when this primitive receives focus.

func (*MessageDialog) GetBackgroundColor added in v0.5.0

func (d *MessageDialog) GetBackgroundColor() tcell.Color

GetBackgroundColor returns dialog background color.

func (*MessageDialog) HasFocus

func (d *MessageDialog) HasFocus() bool

HasFocus returns whether or not this primitive has focus.

func (*MessageDialog) InputHandler

func (d *MessageDialog) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler returns input handler function for this primitive.

func (*MessageDialog) MouseHandler

func (d *MessageDialog) MouseHandler() func(action tview.MouseAction, event *tcell.EventMouse, setFocus func(p tview.Primitive)) (consumed bool, capture tview.Primitive)

MouseHandler returns the mouse handler for this primitive.

func (*MessageDialog) SetBackgroundColor

func (d *MessageDialog) SetBackgroundColor(color tcell.Color)

SetBackgroundColor sets dialog background color.

func (*MessageDialog) SetDoneFunc

func (d *MessageDialog) SetDoneFunc(handler func()) *MessageDialog

SetDoneFunc sets callback function for when user clicked on the button or presses "enter" or "esc".

func (*MessageDialog) SetMessage

func (d *MessageDialog) SetMessage(message string)

SetMessage sets the dialog message to display.

func (*MessageDialog) SetRect

func (d *MessageDialog) SetRect(x, y, width, height int)

SetRect sets rect for this primitive.

func (*MessageDialog) SetTextColor

func (d *MessageDialog) SetTextColor(color tcell.Color)

SetTextColor sets dialog's message text color.

func (*MessageDialog) SetType

func (d *MessageDialog) SetType(dtype int)

SetType sets dialog type to info or error.

type PercentageModeGauge

type PercentageModeGauge struct {
	*tview.Box
	// contains filtered or unexported fields
}

PercentageModeGauge represents percentage mode gauge permitive.

func NewPercentageModeGauge

func NewPercentageModeGauge() *PercentageModeGauge

NewPercentageModeGauge returns new percentage mode gauge permitive.

func (*PercentageModeGauge) Draw

func (g *PercentageModeGauge) Draw(screen tcell.Screen)

Draw draws this primitive onto the screen.

func (*PercentageModeGauge) Focus

func (g *PercentageModeGauge) Focus(delegate func(p tview.Primitive))

Focus is called when this primitive receives focus.

func (*PercentageModeGauge) GetMaxValue

func (g *PercentageModeGauge) GetMaxValue() int

GetMaxValue returns maximum allows value for the gauge.

func (*PercentageModeGauge) GetRect

func (g *PercentageModeGauge) GetRect() (int, int, int, int)

GetRect return primitive current rect.

func (*PercentageModeGauge) GetValue

func (g *PercentageModeGauge) GetValue() int

GetValue returns current gauge value.

func (*PercentageModeGauge) HasFocus

func (g *PercentageModeGauge) HasFocus() bool

HasFocus returns whether or not this primitive has focus.

func (*PercentageModeGauge) Reset

func (g *PercentageModeGauge) Reset()

Reset resets the gauge counter (set to 0).

func (*PercentageModeGauge) SetMaxValue

func (g *PercentageModeGauge) SetMaxValue(value int)

SetMaxValue set maximum allows value for the gauge.

func (*PercentageModeGauge) SetPgBgColor

func (g *PercentageModeGauge) SetPgBgColor(color tcell.Color)

SetPgBgColor sets progress block background color.

func (*PercentageModeGauge) SetRect

func (g *PercentageModeGauge) SetRect(x, y, width, height int)

SetRect sets rect for this primitive.

func (*PercentageModeGauge) SetValue

func (g *PercentageModeGauge) SetValue(value int)

SetValue update the gauge progress.

type Plot added in v0.3.0

type Plot struct {
	*tview.Box
	// contains filtered or unexported fields
}

Plot represents a plot primitive used for different charts.

func NewPlot added in v0.3.0

func NewPlot() *Plot

NewPlot returns a plot widget.

func (*Plot) Draw added in v0.3.0

func (plot *Plot) Draw(screen tcell.Screen)

Draw draws this primitive onto the screen.

func (*Plot) SetAxesColor added in v0.3.0

func (plot *Plot) SetAxesColor(color tcell.Color)

SetAxesColor sets axes x and y lines color.

func (*Plot) SetAxesLabelColor added in v0.3.0

func (plot *Plot) SetAxesLabelColor(color tcell.Color)

SetAxesLabelColor sets axes x and y label color.

func (*Plot) SetData added in v0.3.0

func (plot *Plot) SetData(data [][]float64)

SetData sets plot data.

func (*Plot) SetDotMarkerRune added in v0.3.0

func (plot *Plot) SetDotMarkerRune(r rune)

SetDotMarkerRune sets dot marker rune.

func (*Plot) SetDrawAxes added in v0.3.0

func (plot *Plot) SetDrawAxes(draw bool)

SetDrawAxes set true in order to draw axes to screen.

func (*Plot) SetDrawXAxisLabel added in v0.6.0

func (plot *Plot) SetDrawXAxisLabel(draw bool)

SetDrawXAxisLabel set true in order to draw x axis label to screen.

func (*Plot) SetDrawYAxisLabel added in v0.6.0

func (plot *Plot) SetDrawYAxisLabel(draw bool)

SetDrawYAxisLabel set true in order to draw y axis label to screen.

func (*Plot) SetLineColor added in v0.3.0

func (plot *Plot) SetLineColor(color []tcell.Color)

SetLineColor sets chart line color.

func (*Plot) SetMarker added in v0.3.0

func (plot *Plot) SetMarker(marker Marker)

SetMarker sets marker type braille or dot mode.

func (*Plot) SetPlotType added in v0.3.0

func (plot *Plot) SetPlotType(ptype PlotType)

SetPlotType sets plot type (linechart or scatter).

func (*Plot) SetRect added in v0.3.0

func (plot *Plot) SetRect(x, y, width, height int)

SetRect sets rect for this primitive.

type PlotType added in v0.3.0

type PlotType uint

PlotType represents plot type (line chart or scatter).

const (
	PlotTypeLineChart PlotType = iota
	PlotTypeScatter
)

type Sparkline added in v0.3.0

type Sparkline struct {
	*tview.Box
	// contains filtered or unexported fields
}

Spartline represents a sparkline widgets.

func NewSparkline added in v0.3.0

func NewSparkline() *Sparkline

NewSparkline returns a new sparkline widget.

func (*Sparkline) Draw added in v0.3.0

func (sl *Sparkline) Draw(screen tcell.Screen)

Draw draws this primitive onto the screen.

func (*Sparkline) GetRect added in v0.3.0

func (sl *Sparkline) GetRect() (int, int, int, int)

GetRect return primitive current rect.

func (*Sparkline) HasFocus added in v0.3.0

func (sl *Sparkline) HasFocus() bool

HasFocus returns whether or not this primitive has focus.

func (*Sparkline) SetData added in v0.3.0

func (sl *Sparkline) SetData(data []float64)

SetData sets sparkline data.

func (*Sparkline) SetDataTitle added in v0.3.0

func (sl *Sparkline) SetDataTitle(title string)

SetDataTitle sets sparkline data title.

func (*Sparkline) SetDataTitleColor added in v0.3.0

func (sl *Sparkline) SetDataTitleColor(color tcell.Color)

SetDataTitleColor sets sparkline data title color.

func (*Sparkline) SetLineColor added in v0.3.0

func (sl *Sparkline) SetLineColor(color tcell.Color)

SetLineColor sets sparkline line color.

func (*Sparkline) SetRect added in v0.3.0

func (sl *Sparkline) SetRect(x, y, width, height int)

SetRect sets rect for this primitive.

type Spinner added in v0.2.0

type Spinner struct {
	*tview.Box
	// contains filtered or unexported fields
}

Spinner represents a spinner widget.

func NewSpinner added in v0.2.0

func NewSpinner() *Spinner

NewSpinner returns a new spinner widget.

func (*Spinner) Draw added in v0.2.0

func (s *Spinner) Draw(screen tcell.Screen)

Draw draws this primitive onto the screen.

func (*Spinner) Pulse added in v0.2.0

func (s *Spinner) Pulse()

Pulse updates the spinner to the next frame.

func (*Spinner) Reset added in v0.2.0

func (s *Spinner) Reset()

Reset sets the frame counter to 0.

func (*Spinner) SetCustomStyle added in v0.2.0

func (s *Spinner) SetCustomStyle(frames []rune) *Spinner

SetCustomStyle sets a list of runes as custom frames to show as the spinner.

func (*Spinner) SetStyle added in v0.2.0

func (s *Spinner) SetStyle(style SpinnerStyle) *Spinner

SetStyle sets the spinner style.

type SpinnerStyle added in v0.2.0

type SpinnerStyle int
const (
	SpinnerDotsCircling SpinnerStyle = iota
	SpinnerDotsUpDown
	SpinnerBounce
	SpinnerLine
	SpinnerCircleQuarters
	SpinnerSquareCorners
	SpinnerCircleHalves
	SpinnerCorners
	SpinnerArrows
	SpinnerHamburger
	SpinnerStack
	SpinnerGrowHorizontal
	SpinnerGrowVertical
	SpinnerStar
	SpinnerBoxBounce
)

type UtilModeGauge

type UtilModeGauge struct {
	*tview.Box
	// contains filtered or unexported fields
}

UtilModeGauge represents utilisation mode gauge permitive.

func NewUtilModeGauge

func NewUtilModeGauge() *UtilModeGauge

NewUtilModeGauge returns new utilisation mode gauge permitive.

func (*UtilModeGauge) Draw

func (g *UtilModeGauge) Draw(screen tcell.Screen)

Draw draws this primitive onto the screen.

func (*UtilModeGauge) Focus

func (g *UtilModeGauge) Focus(delegate func(p tview.Primitive))

Focus is called when this primitive receives focus.

func (*UtilModeGauge) GetRect

func (g *UtilModeGauge) GetRect() (int, int, int, int)

GetRect return primitive current rect.

func (*UtilModeGauge) GetValue

func (g *UtilModeGauge) GetValue() float64

GetValue returns current gauge value.

func (*UtilModeGauge) HasFocus

func (g *UtilModeGauge) HasFocus() bool

HasFocus returns whether or not this primitive has focus.

func (*UtilModeGauge) SetCritPercentage

func (g *UtilModeGauge) SetCritPercentage(percentage float64)

SetCritPercentage sets critical percentage start range.

func (*UtilModeGauge) SetEmptyColor added in v0.4.0

func (g *UtilModeGauge) SetEmptyColor(color tcell.Color)

SetEmptyColor sets empty gauge color.

func (*UtilModeGauge) SetLabel

func (g *UtilModeGauge) SetLabel(label string)

SetLabel sets label for this primitive.

func (*UtilModeGauge) SetLabelColor

func (g *UtilModeGauge) SetLabelColor(color tcell.Color)

SetLabelColor sets label text color.

func (*UtilModeGauge) SetRect

func (g *UtilModeGauge) SetRect(x, y, width, height int)

SetRect sets rect for this primitive.

func (*UtilModeGauge) SetValue

func (g *UtilModeGauge) SetValue(value float64)

SetValue update the gauge progress.

func (*UtilModeGauge) SetWarnPercentage

func (g *UtilModeGauge) SetWarnPercentage(percentage float64)

SetWarnPercentage sets warning percentage start range.

Directories

Path Synopsis
demos
barchart
Demo code for the bar chart primitive.
Demo code for the bar chart primitive.
demo
Demo code for the bar chart primitive.
Demo code for the bar chart primitive.
dialog
Demo code for the bar chart primitive.
Demo code for the bar chart primitive.
gauge_am
Demo code for the bar chart primitive.
Demo code for the bar chart primitive.
gauge_pm
Demo code for the bar chart primitive.
Demo code for the bar chart primitive.
gauge_um
Demo code for the bar chart primitive.
Demo code for the bar chart primitive.

Jump to

Keyboard shortcuts

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