ui

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTableData

func AddTableData(table *tview.Table, headers []string, data [][]string, alignment []int, expansions []int, color tcell.Color, selectable bool)

AddTableData adds data to the table. Lets you set the headers, texts, alignment, color, and if cells are selectable. Selectable is not per cell, but a global value for the whole table. Header row is not selectable

func CreateConfirmBox

func CreateConfirmBox(content string, yes, no func())

CreateConfirmBox creates a modal message box using tview's native modal element. Two buttons are added (yes and no) for which the yes and no callback functions will be called when pressed.

func CreateMessageBox

func CreateMessageBox(content string)

CreateMessageBox creates a modal message box using tview's native modal element. Only one button is added (close) and no callback is possible. The modal is added to the provided pages view and removed when the button is pressed

func CreateModalPage

func CreateModalPage(content tview.Primitive, background tview.Primitive, width, height int, name string) *tview.Pages

CreateModalPage creates a modal window by creating a pages view and add a flex view with the specified width and height. The page is named the same as the name parameter and if the background primitive is set, it is added as a background to the modal

func PrependRowNumColumn

func PrependRowNumColumn(data [][]string) [][]string

PrependRowNumColumn prepends every slice in data with a row-number value

func RemoveFrontPage

func RemoveFrontPage(pages *tview.Pages)

Types

type Application

type Application struct {
	TviewApp    *tview.Application
	Layout      *tview.Flex
	Content     *tview.Pages
	ContentMap  map[string]ContentPage
	HeaderBar   *Header
	AccountData *data.AccountData
}
var App *Application

func NewApplication

func NewApplication(accountData *data.AccountData) *Application

func (*Application) BuildApplicationUI

func (a *Application) BuildApplicationUI()

Build the UI elements and configures the application

func (*Application) RegisterContent

func (a *Application) RegisterContent(page ContentPage)

func (*Application) RemoveContent

func (a *Application) RemoveContent(page ContentPage)

func (*Application) Run

func (a *Application) Run() error

func (*Application) ShowPage

func (a *Application) ShowPage(selectedPage ContentPage)

type ContentPage

type ContentPage interface {
	Render(accountData *data.AccountData)
	Name() string
	View() tview.Primitive
	ContextView() tview.Primitive
	Close()
	SetFocus(app *tview.Application)
	IsPersistent() bool
}
type Header struct {
	Context     tview.Primitive
	RefreshTime time.Time
	Layout      *tview.Flex
	AccountId   string
	ClusterName string
}

func NewHeader

func NewHeader(accountId, clusterName string) *Header

func (*Header) Render

func (h *Header) Render(contentMap map[string]ContentPage)

func (*Header) SetContextView

func (h *Header) SetContextView(view tview.Primitive)

func (*Header) UpdateRefreshTime

func (h *Header) UpdateRefreshTime(when time.Time)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳