view

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Key0 tcell.Key = iota + 48
	Key1
	Key2
	Key3
	Key4
	Key5
	Key6
	Key7
	Key8
	Key9
)

Defines numeric keys for container actions.

View Source
const (
	KeyShift0 tcell.Key = 41
	KeyShift1 tcell.Key = 33
	KeyShift2 tcell.Key = 64
	KeyShift3 tcell.Key = 35
	KeyShift4 tcell.Key = 36
	KeyShift5 tcell.Key = 37
	KeyShift6 tcell.Key = 94
	KeyShift7 tcell.Key = 38
	KeyShift8 tcell.Key = 42
	KeyShift9 tcell.Key = 40
)

Defines numeric keys for container actions.

View Source
const (
	KeyA tcell.Key = iota + 97
	KeyB
	KeyC
	KeyD
	KeyE
	KeyF
	KeyG
	KeyH
	KeyI
	KeyJ
	KeyK
	KeyL
	KeyM
	KeyN
	KeyO
	KeyP
	KeyQ
	KeyR
	KeyS
	KeyT
	KeyU
	KeyV
	KeyW
	KeyX
	KeyY
	KeyZ
	KeyHelp  = 63
	KeySlash = 47
	KeyColon = 58
	KeySpace = 32
)

Defines char keystrokes.

View Source
const (
	KeyShiftA tcell.Key = iota + 65
	KeyShiftB
	KeyShiftC
	KeyShiftD
	KeyShiftE
	KeyShiftF
	KeyShiftG
	KeyShiftH
	KeyShiftI
	KeyShiftJ
	KeyShiftK
	KeyShiftL
	KeyShiftM
	KeyShiftN
	KeyShiftO
	KeyShiftP
	KeyShiftQ
	KeyShiftR
	KeyShiftS
	KeyShiftT
	KeyShiftU
	KeyShiftV
	KeyShiftW
	KeyShiftX
	KeyShiftY
	KeyShiftZ
)

Define Shift Keys.

Variables

View Source
var LogoSmall = []string{
	`  ____ _   _  ___  ____  _____ ___   `,
	` / ___| | | |/ _ \|  _ \| ____/ _ \  `,
	`| |   | |_| | | | | |_) |  _|| | | | `,
	`| |___|  _  | |_| |  _ <| |__| |_| | `,
	` \____|_| |_|\___/|_| \_\_____\___/  `,
}
View Source
var NumKeys = map[int]tcell.Key{
	0: Key0,
	1: Key1,
	2: Key2,
	3: Key3,
	4: Key4,
	5: Key5,
	6: Key6,
	7: Key7,
	8: Key8,
	9: Key9,
}

NumKeys tracks number keys.

Functions

func AsKey

func AsKey(evt *tcell.EventKey) tcell.Key

AsKey converts rune to keyboard key.,.

func CalculateMaxWidths

func CalculateMaxWidths(table *tview.Table) []int

func CleanTable

func CleanTable(table *tview.Table)

func CleanTableRows

func CleanTableRows(table *tview.Table, exists func(row int) bool)

func DeleteRow

func DeleteRow(table *tview.Table, index int)

DeleteRow removes a row from the table at the specified position

func GetBranchRowData

func GetBranchRowData(branch *branchpb.BranchObject) []string

func GetResourceInstanceID

func GetResourceInstanceID(u *unstructured.Unstructured) string

func GetResourceInstanceRowData

func GetResourceInstanceRowData(u *unstructured.Unstructured) []string

func GetResourceRowData

func GetResourceRowData(resource *discoverypb.APIResource) []string

func InsertRowAt

func InsertRowAt(table *tview.Table, index int, ref any, rowData []string, style tcell.Style)

InsertRowAt inserts a new row into the table at the specified position

func LogoString

func LogoString() string

func NewHeaderTableCell

func NewHeaderTableCell(text string) *tview.TableCell

func NewTicker

func NewTicker(app *tview.Application, frequency time.Duration, f func()) *ticker

func SetMenuRow

func SetMenuRow(table *tview.Table, row int, key, val string, keyStyle, valStyle tcell.Style)

func SetTableHeader

func SetTableHeader(table *tview.Table, maxColumnWidth []int, headers ...string)

func UpdateRowAt

func UpdateRowAt(table *tview.Table, index int, ref any, rowData []string, style tcell.Style)

InsertRowAt inserts a new row into the table at the specified position

func YamlToString

func YamlToString(u *unstructured.Unstructured) string

Types

type ActionHandler

type ActionHandler func()

ActionHandler handles a keyboard command.

type App

type App struct {
	*tview.Application
	// contains filtered or unexported fields
}

func NewApp

func NewApp(f util.Factory) *App

func (*App) HandleInput

func (a *App) HandleInput(event *tcell.EventKey) *tcell.EventKey

In your page implementation

func (*App) Init

func (a *App) Init(ctx context.Context) error

func (*App) Run

func (a *App) Run(ctx context.Context) error

Run starts the application loop.

type BranchMenu

type BranchMenu struct {
	*tview.Table
	// contains filtered or unexported fields
}

func NewBranchMenu

func NewBranchMenu(app *App) *BranchMenu

NewInfo creates a new Info view.

func (*BranchMenu) ActivatePageAction

func (r *BranchMenu) ActivatePageAction()

ActivateAction propogates the actions populate the cmdMenu

func (*BranchMenu) InitPageAction

func (r *BranchMenu) InitPageAction()

type BranchPage

type BranchPage struct {
	HeaderTable *tview.Table
	DataTable   *tview.Table
	// contains filtered or unexported fields
}

func (*BranchPage) ActivatePage

func (r *BranchPage) ActivatePage(ctx context.Context)

func (*BranchPage) DeActivatePage

func (r *BranchPage) DeActivatePage(ctx context.Context)

func (*BranchPage) HandleInput

func (r *BranchPage) HandleInput(event *tcell.EventKey) *tcell.EventKey

In your page implementation

func (*BranchPage) RegisterPageAction

func (r *BranchPage) RegisterPageAction(ctx context.Context)

func (*BranchPage) SetTable

func (r *BranchPage) SetTable(ctx context.Context)

func (*BranchPage) SetView

func (r *BranchPage) SetView()

func (*BranchPage) StartStream

func (r *BranchPage) StartStream(ctx context.Context)

func (*BranchPage) StopStream

func (r *BranchPage) StopStream(ctx context.Context)

type CommandMenu

type CommandMenu struct {
	*tview.Table
	// contains filtered or unexported fields
}

func NewCommandMenu

func NewCommandMenu(app *App) *CommandMenu

NewInfo creates a new Info view.

func (*CommandMenu) ActivatePageAction

func (r *CommandMenu) ActivatePageAction()

ActivateAction propogates the actions populate the cmdMenu

func (*CommandMenu) InitPageAction

func (r *CommandMenu) InitPageAction()

type ContextKey

type ContextKey string

ContextKey represents context key.

const (
	KeyApp ContextKey = "app"
)

A collection of context keys.

type Dummy

type Dummy struct {
	*tview.TextView
	// contains filtered or unexported fields
}

func (*Dummy) ActivatePage

func (r *Dummy) ActivatePage(ctx context.Context)

func (*Dummy) DeActivatePage

func (r *Dummy) DeActivatePage(ctx context.Context)

func (*Dummy) RegisterPageAction

func (r *Dummy) RegisterPageAction(ctx context.Context)

func (*Dummy) SetTextView

func (r *Dummy) SetTextView(ctx context.Context)

func (*Dummy) SetView

func (r *Dummy) SetView()

func (*Dummy) TviewPrimitive

func (r *Dummy) TviewPrimitive() tview.Primitive

func (*Dummy) Update

func (r *Dummy) Update(ctx context.Context) error
type Header struct {
	*tview.Flex
	// contains filtered or unexported fields
}

func NewHeader

func NewHeader(app *App) *Header

func (*Header) ActivatePageAction

func (r *Header) ActivatePageAction(context string)

func (*Header) InitPageAction

func (r *Header) InitPageAction()

func (*Header) SwitchLayout

func (r *Header) SwitchLayout(context string)

type IdentifierSet

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

IdentifierSet manages a set of identifiers.

func NewIdentifierSet

func NewIdentifierSet() *IdentifierSet

NewIdentifierSet creates a new IdentifierSet.

func (*IdentifierSet) AddIdentifier

func (s *IdentifierSet) AddIdentifier(id string) (int, bool)

AddIdentifier adds a new identifier to the set and returns the position it was added at, or the existing position if it was already present.

func (*IdentifierSet) DeleteIdentifier

func (s *IdentifierSet) DeleteIdentifier(id string) int

type Info

type Info struct {
	*tview.Table
	// contains filtered or unexported fields
}

func NewInfo

func NewInfo(app *App) *Info

NewInfo creates a new Info view.

func (*Info) SetKeyValue

func (r *Info) SetKeyValue(row int, key, value string)

type KeyAction

type KeyAction struct {
	Key         tcell.Key
	Description string
	ShortName   string
	Action      ActionHandler
}

KeyAction represents a keyboard action.

type KeyActions

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

KeyActions tracks mappings between keystrokes and actions.

func NewKeyActions

func NewKeyActions() *KeyActions

func (*KeyActions) Add

func (a *KeyActions) Add(ka KeyAction)

Add adds a new key action.

func (*KeyActions) Get

func (a *KeyActions) Get(k string) (KeyAction, bool)

func (*KeyActions) List

func (a *KeyActions) List(visitorFunc func(string, KeyAction))

func (*KeyActions) MapKeys

func (r *KeyActions) MapKeys() map[string]int
type Logo struct {
	*tview.TextView
	// contains filtered or unexported fields
}
func NewLogo(app *App) *Logo

NewLogo returns a new logo.

type Page

type Page interface {
	ActivatePage(ctx context.Context)

	// registers the keys of the page to the
	// actions per app and the cmd header
	RegisterPageAction(ctx context.Context)
}

func NewBranchPage

func NewBranchPage(ctx context.Context, pages *Pages) Page

func NewDummy

func NewDummy(ctx context.Context, pages *Pages) Page

func NewResource

func NewResource(ctx context.Context, parent Page, apiGroup *discoverypb.APIResource) Page

func NewResourceInstance

func NewResourceInstance(ctx context.Context, parent Page, u *unstructured.Unstructured) Page

func NewResources

func NewResources(ctx context.Context, pages *Pages) Page

type Pages

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

func NewPages

func NewPages(ctx context.Context) *Pages

func (*Pages) RegisterPageAction

func (r *Pages) RegisterPageAction(ctx context.Context)

type Resource

type Resource struct {
	HeaderTable *tview.Table
	DataTable   *tview.Table
	// contains filtered or unexported fields
}

func (*Resource) ActivatePage

func (r *Resource) ActivatePage(ctx context.Context)

func (*Resource) DeActivatePage

func (r *Resource) DeActivatePage(ctx context.Context)

func (*Resource) HandleInput

func (r *Resource) HandleInput(event *tcell.EventKey) *tcell.EventKey

In your page implementation

func (*Resource) RegisterPageAction

func (r *Resource) RegisterPageAction(ctx context.Context)

func (*Resource) SetTable

func (r *Resource) SetTable(ctx context.Context)

func (*Resource) SetView

func (r *Resource) SetView()

func (*Resource) StartStream

func (r *Resource) StartStream(ctx context.Context)

func (*Resource) StopStream

func (r *Resource) StopStream(ctx context.Context)

type ResourceInstance

type ResourceInstance struct {
	*tview.TextView
	// contains filtered or unexported fields
}

func (*ResourceInstance) ActivatePage

func (r *ResourceInstance) ActivatePage(ctx context.Context)

func (*ResourceInstance) DeActivatePage

func (r *ResourceInstance) DeActivatePage(ctx context.Context)

func (*ResourceInstance) HandleInput

func (r *ResourceInstance) HandleInput(event *tcell.EventKey) *tcell.EventKey

In your page implementation

func (*ResourceInstance) RegisterPageAction

func (r *ResourceInstance) RegisterPageAction(ctx context.Context)

func (*ResourceInstance) SetTextView

func (r *ResourceInstance) SetTextView(ctx context.Context)

func (*ResourceInstance) SetView

func (r *ResourceInstance) SetView()

func (*ResourceInstance) Update

func (r *ResourceInstance) Update(ctx context.Context) error

type Resources

type Resources struct {
	HeaderTable *tview.Table
	DataTable   *tview.Table
	// contains filtered or unexported fields
}

func (*Resources) ActivatePage

func (r *Resources) ActivatePage(ctx context.Context)

func (*Resources) DeActivatePage

func (r *Resources) DeActivatePage(ctx context.Context)

func (*Resources) HandleInput

func (r *Resources) HandleInput(event *tcell.EventKey) *tcell.EventKey

In your page implementation

func (*Resources) RegisterPageAction

func (r *Resources) RegisterPageAction(ctx context.Context)

func (*Resources) SetTable

func (r *Resources) SetTable(ctx context.Context)

func (*Resources) SetView

func (r *Resources) SetView()

func (*Resources) StartStream

func (r *Resources) StartStream(parentCtx context.Context)

func (*Resources) StopStream

func (r *Resources) StopStream(ctx context.Context)

type YAMLStyle

type YAMLStyle struct {
	KeyColor   tcell.Color `json:"keyColor" yaml:"keyColor"`
	ValueColor tcell.Color `json:"valueColor" yaml:"valueColor"`
	ColonColor tcell.Color `json:"colonColor" yaml:"colonColor"`
}

Jump to

Keyboard shortcuts

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