tvxwidgets

package module
v0.0.0-...-6bf5ddd Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: MIT Imports: 6 Imported by: 1

README

tvxwidgets

PkgGoDev 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.

func (*ActivityModeGauge) SetTitle

func (g *ActivityModeGauge) SetTitle(title string)

SetTitle sets title 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) 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

type Marker uint

Marker represents plot drawing marker (brialle 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) 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) SetBorder

func (d *MessageDialog) SetBorder(status bool)

SetBorder sets dialogs border - no effect always true.

func (*MessageDialog) SetDoneFunc

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

SetDoneFunc sets callback function for when user clicked on the 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) SetTitle

func (d *MessageDialog) SetTitle(title string)

SetTitle sets title for this primitive.

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

func (g *PercentageModeGauge) SetTitle(title string)

SetTitle sets title for this primitive.

func (*PercentageModeGauge) SetValue

func (g *PercentageModeGauge) SetValue(value int)

SetValue update the gauge progress.

type Plot

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

Plot represents a plot primitive used for different charts.

func NewPlot

func NewPlot() *Plot

NewPlot returns a plot widget.

func (*Plot) Draw

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

Draw draws this primitive onto the screen.

func (*Plot) SetAxesColor

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

SetAxesColor sets axes x and y lines color.

func (*Plot) SetAxesLabelColor

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

SetAxesLabelColor sets axes x and y label color.

func (*Plot) SetData

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

SetData sets plot data.

func (*Plot) SetDotMarkerRune

func (plot *Plot) SetDotMarkerRune(r rune)

SetDotMarkerRune sets dot marker rune.

func (*Plot) SetDrawAxes

func (plot *Plot) SetDrawAxes(draw bool)

SetDrawAxes set true in order to draw axes to screen.

func (*Plot) SetLineColor

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

SetLineColor sets chart line color.

func (*Plot) SetMarker

func (plot *Plot) SetMarker(marker Marker)

SetMarker sets marker type braille or dot mode.

func (*Plot) SetPlotType

func (plot *Plot) SetPlotType(ptype PlotType)

SetPlotType sets plot type (linechart or scatter).

func (*Plot) SetRect

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

SetRect sets rect for this primitive.

type PlotType

type PlotType uint

PlotType represents plot type (line chart or scatter).

const (
	PlotTypeLineChart PlotType = iota
	PlotTypeScatter
)

type Spinner

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

Spinner represents a spinner widget.

func NewSpinner

func NewSpinner() *Spinner

NewSpinner returns a new spinner widget.

func (*Spinner) Draw

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

Draw draws this primitive onto the screen.

func (*Spinner) Pulse

func (s *Spinner) Pulse()

Pulse updates the spinner to the next frame.

func (*Spinner) Reset

func (s *Spinner) Reset()

Reset sets the frame counter to 0.

func (*Spinner) SetCustomStyle

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

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

func (*Spinner) SetStyle

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

SetStyle sets the spinner style.

type SpinnerStyle

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

func (g *UtilModeGauge) SetTitle(title string)

SetTitle sets title 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.

Jump to

Keyboard shortcuts

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