Documentation
¶
Index ¶
- func DrawBorder(screen tcell.Screen, x, y, width, height int, style tcell.Style)
- type Alignment
- type BaseWidget
- type Column
- type Graph
- type GraphStyle
- type InfoField
- type InfoPanel
- func (p *InfoPanel) AddField(label, value string)
- func (p *InfoPanel) ClearFields()
- func (p *InfoPanel) Draw()
- func (p *InfoPanel) GetHeight() int
- func (p *InfoPanel) GetWidth() int
- func (p *InfoPanel) HandleEvent(ev *tcell.EventKey) bool
- func (p *InfoPanel) SetFields(fields []InfoField)
- func (p *InfoPanel) SetLabelWidth(width int)
- func (p *InfoPanel) SetShowBorder(show bool)
- func (p *InfoPanel) SetStyle(style tcell.Style)
- func (p *InfoPanel) SetTitle(title string)
- func (p *InfoPanel) SetTitleStyle(style tcell.Style)
- func (p *InfoPanel) UpdateField(label, value string)
- type Meter
- func (m *Meter) Draw()
- func (m *Meter) SetBlockSpacing(spacing int)
- func (m *Meter) SetBlockStyle(enabled bool)
- func (m *Meter) SetGradient(start, end tcell.Color)
- func (m *Meter) SetLabel(label string)
- func (m *Meter) SetShowPercentage(show bool)
- func (m *Meter) SetStyle(style tcell.Style)
- func (m *Meter) SetValue(value float64)
- type MeterItem
- type MultiMeter
- func (m *MultiMeter) AddItem(item MeterItem)
- func (m *MultiMeter) ClearItems()
- func (m *MultiMeter) Draw()
- func (m *MultiMeter) GetHeight() int
- func (m *MultiMeter) GetWidth() int
- func (m *MultiMeter) SetItems(items []MeterItem)
- func (m *MultiMeter) SetLabelStyle(style tcell.Style)
- func (m *MultiMeter) SetLabelWidth(width int)
- func (m *MultiMeter) SetMeterHeight(height int)
- func (m *MultiMeter) SetOrientation(orientation Orientation)
- func (m *MultiMeter) SetShowBorder(show bool)
- func (m *MultiMeter) SetShowLabels(show bool)
- func (m *MultiMeter) SetShowValues(show bool)
- func (m *MultiMeter) SetSpacing(spacing int)
- func (m *MultiMeter) SetStyle(style tcell.Style)
- func (m *MultiMeter) UpdateMeter(label string, value float64)
- type Orientation
- type StatusBar
- func (s *StatusBar) AddItem(item StatusItem)
- func (s *StatusBar) ClearItems()
- func (s *StatusBar) Draw()
- func (s *StatusBar) GetHeight() int
- func (s *StatusBar) GetWidth() int
- func (s *StatusBar) SetItems(items []StatusItem)
- func (s *StatusBar) SetPadding(padding int)
- func (s *StatusBar) SetSeparator(sep string)
- func (s *StatusBar) SetStyle(style tcell.Style)
- func (s *StatusBar) UpdateItem(index int, text string, style ...tcell.Style)
- type StatusItem
- type Table
- func (t *Table) AddRow(row []string)
- func (t *Table) ClearRows()
- func (t *Table) Draw()
- func (t *Table) GetSelectedRow() ([]string, int)
- func (t *Table) HandleEvent(ev *tcell.EventKey) bool
- func (t *Table) SetColumns(columns []Column)
- func (t *Table) SetHighlightRow(highlight bool)
- func (t *Table) SetRows(rows [][]string)
- func (t *Table) SetShowBorder(show bool)
- func (t *Table) SetShowHeader(show bool)
- func (t *Table) SetSortColumn(col int)
- func (t *Table) SetSortable(sortable bool)
- type TreeNode
- type TreeView
- func (t *TreeView) AddNode(parent *TreeNode, text string) *TreeNode
- func (t *TreeView) CollapseAll()
- func (t *TreeView) CollapseSelected() bool
- func (t *TreeView) Draw()
- func (t *TreeView) EnsureVisible()
- func (t *TreeView) ExpandAll()
- func (t *TreeView) ExpandSelected() bool
- func (t *TreeView) FindAndSelect(text string) bool
- func (t *TreeView) FindNode(text string) *TreeNode
- func (t *TreeView) GetSelected() *TreeNode
- func (t *TreeView) HandleKeyEvent(event *tcell.EventKey) bool
- func (t *TreeView) RemoveNode(node *TreeNode)
- func (t *TreeView) ScrollBy(delta int)
- func (t *TreeView) ScrollTo(offset int)
- func (t *TreeView) SelectNext() bool
- func (t *TreeView) SelectPrevious() bool
- func (t *TreeView) SetIndent(indent int)
- func (t *TreeView) SetNodeStyle(node *TreeNode, style tcell.Style)
- func (t *TreeView) SetRoot(root *TreeNode)
- func (t *TreeView) SetShowLines(show bool)
- func (t *TreeView) SetStyle(style TreeViewStyle)
- func (t *TreeView) ToggleSelected() bool
- type TreeViewStyle
- type Widget
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DrawBorder ¶
func DrawBorder(screen tcell.Screen, x, y, width, height int, style tcell.Style)
DrawBorder draws a border around the widget
Types ¶
type BaseWidget ¶
BaseWidget provides common functionality for all widgets
func NewBaseWidget ¶
func NewBaseWidget(screen tcell.Screen, x, y, width, height int) BaseWidget
NewBaseWidget creates a new base widget
func (*BaseWidget) GetBounds ¶
func (w *BaseWidget) GetBounds() (x, y, width, height int)
GetBounds returns the widget's position and size
func (*BaseWidget) SetBounds ¶
func (w *BaseWidget) SetBounds(x, y, width, height int)
SetBounds sets the widget's position and size
func (*BaseWidget) SetStyle ¶
func (w *BaseWidget) SetStyle(style tcell.Style)
SetStyle sets the widget's style
type Column ¶
type Column struct { Title string Width int MinWidth int MaxWidth int Alignment Alignment // Left, Right, Center }
Column represents a table column
type Graph ¶
type Graph struct {
X, Y int
Width, Height int
Style tcell.Style
Screen tcell.Screen
GraphStyle GraphStyle
Data []float64
MaxValue float64
MinValue float64
Inverted bool
}
Graph represents a percentage graph widget
func (*Graph) SetGraphStyle ¶
func (g *Graph) SetGraphStyle(style GraphStyle)
SetGraphStyle sets the style of graph to be drawn
func (*Graph) SetInverted ¶
SetInverted sets whether to invert the graph
type GraphStyle ¶
type GraphStyle int
GraphStyle represents the style of graph to be drawn
const ( // GraphStyleBraille uses Braille characters for drawing the graph GraphStyleBraille GraphStyle = iota // GraphStyleBlock uses block characters for drawing the graph GraphStyleBlock // GraphStyleTTY uses TTY characters for drawing the graph GraphStyleTTY )
Graph styles
type InfoPanel ¶
type InfoPanel struct {
X, Y int
Width, Height int
Screen tcell.Screen
Style tcell.Style
TitleStyle tcell.Style
Title string
Fields []InfoField
ShowBorder bool
ScrollOffset int
LabelWidth int
}
InfoPanel represents an info panel widget
func NewInfoPanel ¶
NewInfoPanel creates a new info panel widget
func (*InfoPanel) HandleEvent ¶
HandleEvent handles keyboard events for scrolling
func (*InfoPanel) SetLabelWidth ¶
SetLabelWidth sets the width of the label column
func (*InfoPanel) SetShowBorder ¶
SetShowBorder sets whether to show the border
func (*InfoPanel) SetStyle ¶
func (p *InfoPanel) SetStyle(style tcell.Style)
SetStyle sets the default style for the panel
func (*InfoPanel) SetTitleStyle ¶
func (p *InfoPanel) SetTitleStyle(style tcell.Style)
SetTitleStyle sets the style for the title
func (*InfoPanel) UpdateField ¶
UpdateField updates the value of a field with the given label
type Meter ¶
type Meter struct {
X, Y int
Width int
Style tcell.Style
Screen tcell.Screen
Value float64
ShowPct bool
Label string
// New fields for block style and gradient
BlockStyle bool
BlockSpacing int
StartColor tcell.Color
EndColor tcell.Color
UseGradient bool
}
Meter represents a percentage meter widget
func (*Meter) SetBlockSpacing ¶
SetBlockSpacing sets the spacing between blocks
func (*Meter) SetBlockStyle ¶
SetBlockStyle sets whether to use block style display
func (*Meter) SetGradient ¶
SetGradient sets the start and end colors for gradient
func (*Meter) SetShowPercentage ¶
SetShowPercentage sets whether to show the percentage value
type MeterItem ¶
type MeterItem struct { Label string Value float64 MaxValue float64 Style tcell.Style GradientColors []tcell.Color Height int }
MeterItem represents a single meter in the multi meter widget
type MultiMeter ¶
type MultiMeter struct {
X, Y int
Width, Height int
Screen tcell.Screen
Style tcell.Style
LabelStyle tcell.Style
Items []MeterItem
ShowLabels bool
ShowValues bool
ShowBorder bool
Orientation Orientation
LabelWidth int
MeterHeight int
Spacing int
}
MultiMeter represents a multi meter widget
func NewMultiMeter ¶
func NewMultiMeter(screen tcell.Screen, x, y, width, height int) *MultiMeter
NewMultiMeter creates a new multi meter widget
func (*MultiMeter) AddItem ¶
func (m *MultiMeter) AddItem(item MeterItem)
AddItem adds a meter item to the multi meter
func (*MultiMeter) GetHeight ¶
func (m *MultiMeter) GetHeight() int
GetHeight returns the total height of the widget
func (*MultiMeter) GetWidth ¶
func (m *MultiMeter) GetWidth() int
GetWidth returns the total width of the widget
func (*MultiMeter) SetItems ¶
func (m *MultiMeter) SetItems(items []MeterItem)
SetItems sets the meter items
func (*MultiMeter) SetLabelStyle ¶
func (m *MultiMeter) SetLabelStyle(style tcell.Style)
SetLabelStyle sets the style for labels
func (*MultiMeter) SetLabelWidth ¶
func (m *MultiMeter) SetLabelWidth(width int)
SetLabelWidth sets the width of labels
func (*MultiMeter) SetMeterHeight ¶
func (m *MultiMeter) SetMeterHeight(height int)
SetMeterHeight sets the height of each meter
func (*MultiMeter) SetOrientation ¶
func (m *MultiMeter) SetOrientation(orientation Orientation)
SetOrientation sets the orientation of the meters
func (*MultiMeter) SetShowBorder ¶
func (m *MultiMeter) SetShowBorder(show bool)
SetShowBorder sets whether to show the border
func (*MultiMeter) SetShowLabels ¶
func (m *MultiMeter) SetShowLabels(show bool)
SetShowLabels sets whether to show labels
func (*MultiMeter) SetShowValues ¶
func (m *MultiMeter) SetShowValues(show bool)
SetShowValues sets whether to show values
func (*MultiMeter) SetSpacing ¶
func (m *MultiMeter) SetSpacing(spacing int)
SetSpacing sets the spacing between meters
func (*MultiMeter) SetStyle ¶
func (m *MultiMeter) SetStyle(style tcell.Style)
SetStyle sets the default style for the widget
func (*MultiMeter) UpdateMeter ¶
func (m *MultiMeter) UpdateMeter(label string, value float64)
UpdateMeter updates the value of a meter with the given label
type Orientation ¶
type Orientation int
Orientation represents the orientation of the multi meter
const ( // Horizontal orientation for the multi meter Horizontal Orientation = iota // Vertical orientation for the multi meter Vertical )
Meter orientations
type StatusBar ¶
type StatusBar struct {
X, Y int
Width, Height int
Screen tcell.Screen
Style tcell.Style
Items []StatusItem
Separator string
Padding int
}
StatusBar represents a status bar widget
func NewStatusBar ¶
NewStatusBar creates a new status bar widget
func (*StatusBar) AddItem ¶
func (s *StatusBar) AddItem(item StatusItem)
AddItem adds an item to the status bar
func (*StatusBar) ClearItems ¶
func (s *StatusBar) ClearItems()
ClearItems clears all items from the status bar
func (*StatusBar) SetItems ¶
func (s *StatusBar) SetItems(items []StatusItem)
SetItems sets the status bar items
func (*StatusBar) SetPadding ¶
SetPadding sets the padding between items
func (*StatusBar) SetSeparator ¶
SetSeparator sets the separator between status items
func (*StatusBar) SetStyle ¶
func (s *StatusBar) SetStyle(style tcell.Style)
SetStyle sets the default style for the status bar
func (*StatusBar) UpdateItem ¶
UpdateItem updates an item at the specified index
type StatusItem ¶
type StatusItem struct { Text string Style tcell.Style MinWidth int MaxWidth int Alignment Alignment }
StatusItem represents a single item in the status bar
type Table ¶
type Table struct {
X, Y int
Width, Height int
Screen tcell.Screen
Style tcell.Style
HeaderStyle tcell.Style
SelectedStyle tcell.Style
Columns []Column
Rows [][]string
SelectedRow int
ShowHeader bool
ShowBorder bool
Sortable bool
SortColumn int
SortAscending bool
HighlightRow bool
ScrollOffset int
VisibleRows int
}
Table represents a table widget
func (*Table) GetSelectedRow ¶
GetSelectedRow returns the currently selected row
func (*Table) HandleEvent ¶
HandleEvent handles keyboard events
func (*Table) SetColumns ¶
SetColumns sets the table columns
func (*Table) SetHighlightRow ¶
SetHighlightRow sets whether to highlight the selected row
func (*Table) SetShowBorder ¶
SetShowBorder sets whether to show the border
func (*Table) SetShowHeader ¶
SetShowHeader sets whether to show the header
func (*Table) SetSortColumn ¶
SetSortColumn sets the column to sort by
func (*Table) SetSortable ¶
SetSortable sets whether the table is sortable
type TreeNode ¶
type TreeNode struct { Text string Children []*TreeNode Parent *TreeNode Expanded bool Data interface{} // Optional data associated with the node Style tcell.Style }
TreeNode represents a node in the tree
type TreeView ¶
type TreeView struct {
X, Y int
Width, Height int
Screen tcell.Screen
Style tcell.Style
SelectedStyle tcell.Style
Root *TreeNode
Selected *TreeNode
ScrollOffset int
VisibleNodes int
ShowLines bool
Indent int
}
TreeView represents a tree view widget
func NewTreeView ¶
NewTreeView creates a new tree view widget
func (*TreeView) AddNode ¶
AddNode adds a child node to the specified parent If parent is nil, the node will be set as the root node
func (*TreeView) CollapseAll ¶
func (t *TreeView) CollapseAll()
CollapseAll collapses all nodes in the tree
func (*TreeView) CollapseSelected ¶
CollapseSelected collapses the currently selected node
func (*TreeView) EnsureVisible ¶
func (t *TreeView) EnsureVisible()
EnsureVisible ensures the selected node is visible in the view
func (*TreeView) ExpandSelected ¶
ExpandSelected expands the currently selected node
func (*TreeView) FindAndSelect ¶
FindAndSelect searches for a node with the given text and selects it if found
func (*TreeView) GetSelected ¶
GetSelected returns the currently selected node
func (*TreeView) HandleKeyEvent ¶
HandleKeyEvent handles keyboard events for the tree view
func (*TreeView) RemoveNode ¶
RemoveNode removes a node and its children from the tree
func (*TreeView) SelectNext ¶
SelectNext selects the next visible node in the tree
func (*TreeView) SelectPrevious ¶
SelectPrevious selects the previous visible node
func (*TreeView) SetNodeStyle ¶
SetNodeStyle sets the style for a specific node
func (*TreeView) SetShowLines ¶
SetShowLines sets whether to show tree lines
func (*TreeView) SetStyle ¶
func (t *TreeView) SetStyle(style TreeViewStyle)
SetStyle sets the style configuration for the tree view
func (*TreeView) ToggleSelected ¶
ToggleSelected toggles the expanded state of the currently selected node
type TreeViewStyle ¶
type TreeViewStyle struct { NodeStyle tcell.Style // Style for normal nodes SelectedStyle tcell.Style // Style for selected node LineStyle tcell.Style // Style for tree lines ExpandedIcon rune // Icon for expanded nodes CollapsedIcon rune // Icon for collapsed nodes }
TreeViewStyle represents the style configuration for the tree view
func DefaultTreeViewStyle ¶
func DefaultTreeViewStyle() TreeViewStyle
DefaultTreeViewStyle returns the default style configuration
type Widget ¶
type Widget interface { // Draw renders the widget on the screen Draw() // Clear removes the widget from the screen Clear() // GetBounds returns the widget's position and size GetBounds() (x, y, width, height int) // SetBounds sets the widget's position and size SetBounds(x, y, width, height int) // SetStyle sets the widget's style SetStyle(style tcell.Style) }
Widget defines the interface that all widgets must implement