tuiapp

package
v0.0.0-...-1e91e80 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PageLanding     = "landing"
	PageThings      = "things"
	PageDirectories = "directories"
	PageDiscovery   = "discovery"
	PageTD          = "td"
)
View Source
const (
	MenuEvClose           = "close"
	MenuEvDiscover        = "discover"
	MenuEvListTDs         = "listTDs"
	MenuEvNextPage        = "nextPage"
	MenuEvSelectTD        = "selectTD"
	MenuEvShowDiscovered  = "showDiscovered"
	MenuEvShowDirectory   = "showDirectory"
	MenuEvShowDirectories = "showDirectories"
	MenuEvShowTD          = "showTD"
	MenuEvShowThings      = "showThings"
	MenuEvQuit            = "quit"
)

menu events

Variables

This section is empty.

Functions

This section is empty.

Types

type AppFooter

type AppFooter struct {
	View *tview.Flex
	// contains filtered or unexported fields
}

The application footer are that shows the current activity and ?

func NewAppFooter

func NewAppFooter() *AppFooter

Create a new instance of the application view

func (*AppFooter) Refresh

func (footer *AppFooter) Refresh(allThings []*wot.TD)

Reload the text being shown using updated values

func (*AppFooter) SetHandler

func (footer *AppFooter) SetHandler(h func(ev ...string))

type AppHeader

type AppHeader struct {
	View *tview.Flex
	// contains filtered or unexported fields
}

The application header are that shows the connect connection and loaded status

func NewAppHeader

func NewAppHeader() *AppHeader

Create a new instance of the application view

func (*AppHeader) Refresh

func (header *AppHeader) Refresh(discoRecs []*discovery.DiscoveryResult, tdList []*wot.TD)

Reload the text being shown using updated values

func (*AppHeader) ShowStatus

func (header *AppHeader) ShowStatus(text string)

Show a status text in the header

type DirectoriesPage

type DirectoriesPage struct {
	*TuiTable
	// contains filtered or unexported fields
}

Show the loaded directories in the main view

func NewDirectoriesPage

func NewDirectoriesPage() *DirectoriesPage

Return a new page with a table of known directory TDs

func (*DirectoriesPage) GetDirectoryID

func (v *DirectoriesPage) GetDirectoryID(row int) string

Return the directoryID of the selected row, or empty string if not found

func (*DirectoriesPage) Refresh

func (v *DirectoriesPage) Refresh(dirList []*wot.TD)

Show the loaded directories in the main view

func (*DirectoriesPage) SetHandler

func (footer *DirectoriesPage) SetHandler(h func(ev ...string))

type DirectoryInfo

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

DirInfo is the discovered directory information

type DiscoPage

type DiscoPage struct {
	*TuiTable
	// contains filtered or unexported fields
}

Page with discovery records

func NewDiscoPage

func NewDiscoPage() *DiscoPage

Create a new discovery table page

func (*DiscoPage) Refresh

func (page *DiscoPage) Refresh(dirRecs, deviceRecs []*discovery.DiscoveryResult)

Show a table of discovered directory and device records. records can be nil for initial display.

type TDInfoPanel

type TDInfoPanel struct {
	*TuiTable
}

TD Info panel for show selected affordance details

func NewTDInfoPanel

func NewTDInfoPanel() *TDInfoPanel

func (*TDInfoPanel) ShowActionAff

func (infoPanel *TDInfoPanel) ShowActionAff(actionName string, aff *wot.ActionAffordance)

Show a basic description of the selected action affordance

func (*TDInfoPanel) ShowEventAff

func (infoPanel *TDInfoPanel) ShowEventAff(eventName string, aff *wot.EventAffordance)

Show a basic description of the selected event affordance

func (*TDInfoPanel) ShowForm

func (infoPanel *TDInfoPanel) ShowForm(row int, form wot.Form, i int) int

Add a form section to the table at the row This returns the last row+1.

func (*TDInfoPanel) ShowForms

func (infoPanel *TDInfoPanel) ShowForms(forms []wot.Form)

func (*TDInfoPanel) ShowPropAff

func (infoPanel *TDInfoPanel) ShowPropAff(propName string, aff *wot.PropertyAffordance)

Show a basic description of the selected property affordance

type TDPage

type TDPage struct {
	tview.Flex
	// contains filtered or unexported fields
}

Page for showing details of a TD document: - header area with thingID, title, base URL, ... - list of properties and latest value (if available) - list of events and latest value (if available) - list of actions - bottom info on selected affordance: forms

func NewTDPage

func NewTDPage(invokeActionCb func(thingID, name string, input any)) *TDPage

return a new TD Page that shows the content of a TD document.

func (*TDPage) Refresh

func (page *TDPage) Refresh(thingID string,
	tdoc *wot.TD, propsMap map[string]msg.ThingValue, events map[string]msg.ThingValue)

redraw the TD page TODO: Change to grid and use a tree menu for properties, events, and actions TODO: table should have scroll indicators

func (*TDPage) SetHandler

func (page *TDPage) SetHandler(h func(ev ...string))

set the handler for page events

type ThingsPage

type ThingsPage struct {
	*TuiTable
	// contains filtered or unexported fields
}

Show the loaded things in the main view

func NewThingsPage

func NewThingsPage() *ThingsPage

Return a new page with a table of known thing TDs

func (*ThingsPage) GetThingID

func (page *ThingsPage) GetThingID(row int) string

Return the thingID of the selected row, or empty string if not found

func (*ThingsPage) Refresh

func (page *ThingsPage) Refresh(tdList []*wot.TD)

Show the loaded things in the main view this rotates through different tables

func (*ThingsPage) SetHandler

func (page *ThingsPage) SetHandler(h func(ev ...string))

type TreeMenu

type TreeMenu struct {
	tview.TreeView
	// contains filtered or unexported fields
}

func NewTreeMenu

func NewTreeMenu() *TreeMenu

Show a tree menu with discovered directories and things

func (*TreeMenu) HandleSelection

func (m *TreeMenu) HandleSelection(node *tview.TreeNode)

func (*TreeMenu) Refresh

func (m *TreeMenu) Refresh(dirList []DirectoryInfo, discoveredThings map[string]*wot.TD)

Refresh the menu with the latest discovered things and directories

func (*TreeMenu) SelectDiscovery

func (m *TreeMenu) SelectDiscovery()

Select the Discovery entry in the tree view

func (*TreeMenu) SelectThing

func (m *TreeMenu) SelectThing(thingID string)

Select the Thing in the tree view

func (*TreeMenu) SetHandler

func (m *TreeMenu) SetHandler(h func(ev ...string))

type TuiApp

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

The main application view with panels for header, menu main view and footer - header shows the current status - menu shows quick actions for discovery and viewing TDs - main shows details - footer shows last action

func NewTuiApp

func NewTuiApp(f api.ICellFactory) (*TuiApp, *consumer.Consumer)

Return a new instance of the tui app along with the consumer to link to. Call Start to run.

func (*TuiApp) HandleNotification

func (tuiApp *TuiApp) HandleNotification(notif *msg.NotificationMessage)

Handle notifications

func (*TuiApp) NextPage

func (tuiApp *TuiApp) NextPage()

func (*TuiApp) QueueSwitchToPage

func (tuiApp *TuiApp) QueueSwitchToPage(pageName string)

Show to page. This is queued to avoid deadlock when invoking from the event handler. This can be called from the background or the main thread.

func (*TuiApp) SelectTD

func (tuiApp *TuiApp) SelectTD(thingID string)

Select a TD in the menu. This is called by the ThingList to select a thing in the menu which in turn updates the TD view.

func (*TuiApp) ShowDirectories

func (tuiApp *TuiApp) ShowDirectories()

func (*TuiApp) ShowDiscovery

func (tuiApp *TuiApp) ShowDiscovery()

Switch to the the discovery page

func (*TuiApp) ShowError

func (tuiApp *TuiApp) ShowError(err error)

Show an error message in the header

func (*TuiApp) ShowTD

func (tuiApp *TuiApp) ShowTD(thingID string)

Show the TD page with the thingID details This reads and subscribes to properties and events

func (*TuiApp) ShowThings

func (tuiApp *TuiApp) ShowThings()

Show the loaded things in the main view

func (*TuiApp) Start

func (tuiApp *TuiApp) Start()

Run the application autonomous processes

func (*TuiApp) StartDiscovery

func (tuiApp *TuiApp) StartDiscovery()

Restart a discovery and update the cached TDs. If a directory is found, set the TDD for the directory service.

type TuiTable

type TuiTable struct {
	tview.Table
	TitleColor      tcell.Color
	DataColor       tcell.Color
	TextColor       tcell.Color
	SelectableColor tcell.Color
}

A simple table with boilerplate code for adding titles and data rows and some bug fixes.

TODO: add paging indicators if the table is longer than available rows

func NewTuiTable

func NewTuiTable() *TuiTable

func (*TuiTable) Clear

func (t *TuiTable) Clear() *tview.Table

Clear removes all table data. Workaround for bug #1146, race causing endless loop after pressing 'down' when repopulating the table after calling Clear in a fixed table. This ensure the row exists.

func (*TuiTable) SetSelectableCell

func (tbl *TuiTable) SetSelectableCell(row int, col int, content string) *tview.TableCell

Add a selectable data cell to the table, and return the tabel cell Row should start at 1, as row 0 is for the titles

func (*TuiTable) SetTextCell

func (tbl *TuiTable) SetTextCell(row int, col int, content ...string) int

Set plain text in the table and return the cell multiple text strings can be passed this returns the next column number

func (*TuiTable) SetTextRow

func (tbl *TuiTable) SetTextRow(row int, texts ...string)

Add a text row to the table Row should start at 1, as row 0 is for the titles

func (*TuiTable) SetTitleCell

func (tbl *TuiTable) SetTitleCell(row int, col int, title string, text string) *tview.TableCell

Set a cell table in title color and text in text color This returns the text cell

func (*TuiTable) SetTitleRow

func (tbl *TuiTable) SetTitleRow(row int, titles ...string)

Add the column titles to the table These use the titleColor and are not selectable

Jump to

Keyboard shortcuts

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