client

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

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

Go to latest
Published: Aug 17, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

README

Yutani Go Client Library

A high-level, idiomatic Go client library for the Yutani Terminal Display Server.

Overview

The Yutani client library provides a fluent, easy-to-use API for building terminal UIs through the Yutani server. It abstracts away the low-level gRPC details and provides a clean, builder-pattern interface for creating and managing widgets.

Features

  • Fluent Builder Pattern - Chainable methods for easy widget configuration
  • Type-Safe API - Strongly typed widget interfaces
  • Event Handling - Simple callback-based event system
  • Automatic Resource Management - Widgets are automatically registered and cleaned up
  • Comprehensive Widget Support - All Yutani widget types supported

Installation

go get industries/loosh/yutani/pkg/client

Quick Start

package main

import (
    "log"
    "industries/loosh/yutani/pkg/client"
)

func main() {
    // Connect to server
    c, err := client.Connect("localhost:7755")
    if err != nil {
        log.Fatal(err)
    }
    defer c.Close()

    // Create a list widget
    list, err := c.NewList().
        Title("Menu").
        Border(true).
        Build()
    if err != nil {
        log.Fatal(err)
    }

    // Add items
    list.AddItem("New File", "Create a new file", strPtr("n"))
    list.AddItem("Open File", "Open an existing file", strPtr("o"))

    // Handle events
    c.OnEvent(func(event *client.Event) {
        if event.IsWidget() {
            log.Printf("Widget event: %s", event.Widget.Type)
        }
    })

    // Start event stream
    c.StartEventStream()

    // Keep running...
}

func strPtr(s string) *string { return &s }

Supported Widgets

Basic Widgets
  • Box - Simple container with border and title
  • TextView - Display text with word wrap and dynamic colors
  • Button - Clickable button with label and colors
  • Checkbox - Boolean toggle with label
  • InputField - Single-line text input with label and placeholder
Complex Widgets
  • List - Scrollable list with items and shortcuts
  • Table - Grid of cells with headers and selection
  • Form - Form with input fields, checkboxes, dropdowns, and buttons
  • TreeView - Hierarchical tree structure with expandable nodes
Layout Widgets
  • Flex - Flexible box layout (row or column)
  • Grid - Grid layout with cells and spans
  • Pages - Multi-page container with page switching

Widget Examples

List Widget
list, _ := c.NewList().
    Title("File Menu").
    Border(true).
    BorderColor(client.Color("blue")).
    Build()

list.AddItem("New File", "Create a new file", strPtr("n"))
list.AddItem("Open File", "Open an existing file", strPtr("o"))
list.SetSelected(0)

selected, _ := list.GetSelected()
count, _ := list.GetItemCount()
Table Widget
table, _ := c.NewTable().
    Title("Data Table").
    Border(true).
    Build()

// Set header
table.SetCell(0, 0, client.NewTableCellWithColor("Name", client.Color("yellow")))
table.SetCell(0, 1, client.NewTableCellWithColor("Age", client.Color("yellow")))

// Set data
table.SetCells([]*pb.TableCellUpdate{
    {Row: 1, Column: 0, Cell: client.NewTableCell("Alice")},
    {Row: 1, Column: 1, Cell: client.NewTableCell("30")},
})

table.SetFixed(1, 0) // Fix header row
Form Widget
form, _ := c.NewForm().
    Title("Login").
    Border(true).
    Build()

usernameIdx, _ := form.AddInputField("Username", 30, "")
passwordIdx, _ := form.AddPasswordField("Password", 30)
rememberIdx, _ := form.AddCheckbox("Remember me", false)

form.AddButton("Login")

// Get values
username, _ := form.GetFieldValue(usernameIdx)
password, _ := form.GetFieldValue(passwordIdx)
TextView Widget
textView, _ := c.NewTextView().
    Title("Output").
    Border(true).
    Text("Hello, World!").
    WordWrap(true).
    DynamicColors(true).
    Build()

textView.SetText("Updated text")
Button Widget
button, _ := c.NewButton().
    Title("Action").
    Border(true).
    Label("Click Me!").
    LabelColor(client.Color("white")).
    BackgroundColor(client.Color("blue")).
    ActivatedColor(client.Color("green")).
    Build()

button.SetLabel("Clicked!")
Checkbox Widget
checkbox, _ := c.NewCheckbox().
    Title("Options").
    Border(true).
    Label("Enable feature").
    Checked(false).
    LabelColor(client.Color("yellow")).
    CheckedColor(client.Color("green")).
    Build()

checkbox.SetChecked(true)
checkbox.SetLabel("Feature enabled")
InputField Widget
input, _ := c.NewInputField().
    Title("User Input").
    Border(true).
    Label("Name: ").
    Placeholder("Enter your name").
    FieldWidth(30).
    LabelColor(client.Color("cyan")).
    Build()

input.SetText("John Doe")
input.SetLabel("Full Name: ")
TreeView Widget
tree, _ := c.NewTreeView().
    Title("File Browser").
    Border(true).
    NodeTextColor(client.Color("white")).
    SelectedTextColor(client.Color("black")).
    SelectedBackgroundColor(client.Color("blue")).
    ShowGraphics(true).
    Build()

// Create root node
rootNode := client.NewTreeNode("Root")
rootID, _ := tree.SetRoot(rootNode)

// Add children
child1 := client.TreeNodeWithColor("Documents", client.Color("yellow"))
child1ID, _ := tree.AddChild(rootID, child1)

child2 := client.NewTreeNode("Pictures")
tree.AddChild(rootID, child2)

// Expand/collapse nodes
tree.SetExpanded(rootID, true)

// Get selected node
nodeID, text, ref, _ := tree.GetSelected()
Flex Layout Widget
flex, _ := c.NewFlex().
    Title("Layout").
    Border(true).
    Direction(pb.FlexDirection_FLEX_COLUMN).
    Build()

// Create child widgets
header, _ := c.NewTextView().Title("Header").Build()
content, _ := c.NewTextView().Title("Content").Build()
footer, _ := c.NewTextView().Title("Footer").Build()

// Add items with proportions
flex.AddItem(header, 0, 3, false)  // Fixed 3 lines
flex.AddItem(content, 1, 0, true)  // Proportional, takes remaining space
flex.AddItem(footer, 0, 1, false)  // Fixed 1 line
Grid Layout Widget
grid, _ := c.NewGrid().
    Title("Dashboard").
    Border(true).
    Rows(2).
    Columns(2).
    Build()

// Create widgets for grid cells
topLeft, _ := c.NewTextView().Title("CPU").Build()
topRight, _ := c.NewTextView().Title("Memory").Build()
bottomLeft, _ := c.NewTextView().Title("Disk").Build()
bottomRight, _ := c.NewTextView().Title("Network").Build()

// Add items to grid (row, column, rowSpan, columnSpan, minWidth, minHeight, focus)
grid.AddItem(topLeft, 0, 0, 1, 1, 0, 0, false)
grid.AddItem(topRight, 0, 1, 1, 1, 0, 0, false)
grid.AddItem(bottomLeft, 1, 0, 1, 1, 0, 0, false)
grid.AddItem(bottomRight, 1, 1, 1, 1, 0, 0, false)
Pages Layout Widget
pages, _ := c.NewPages().
    Title("Multi-Page App").
    Border(true).
    ShowPageNames(true).
    PageNameColor(client.Color("cyan")).
    Build()

// Create pages
page1, _ := c.NewTextView().Text("Page 1 content").Build()
page2, _ := c.NewTextView().Text("Page 2 content").Build()
page3, _ := c.NewTextView().Text("Page 3 content").Build()

// Add pages
pages.AddPage("home", page1, true, true)
pages.AddPage("settings", page2, true, false)
pages.AddPage("about", page3, true, false)

// Switch pages
pages.ShowPage("settings")

// Get current page
currentPage, _ := pages.GetCurrentPage()

Event Handling

Basic Event Handling
c.OnEvent(func(event *client.Event) {
    switch {
    case event.IsKey():
        log.Printf("Key: %s (rune: %c)", event.Key.Key, event.Key.Rune)

    case event.IsMouse():
        log.Printf("Mouse: (%d,%d) button: %d", event.Mouse.X, event.Mouse.Y, event.Mouse.Button)

    case event.IsWidget():
        log.Printf("Widget %s: %s", event.Widget.WidgetID, event.Widget.Type)

    case event.IsResize():
        log.Printf("Resize: %dx%d", event.Resize.Width, event.Resize.Height)
    }
})

c.StartEventStream()
Advanced Event Handling
Event Filtering by Type
// Only handle key events
c.OnEventType(client.EventTypeKey, func(event *client.Event) {
    log.Printf("Key pressed: %c", event.Key.Rune)
})

// Only handle widget events
c.OnEventType(client.EventTypeWidget, func(event *client.Event) {
    log.Printf("Widget event: %s", event.Widget.Type)
})
Event Filtering by Widget
// Only handle events from a specific widget
list, _ := c.NewList().Title("Menu").Build()

c.OnWidgetEvent(list.ID(), func(event *client.Event) {
    log.Printf("List event: %s", event.Widget.Type)
})
Custom Event Filters
// Filter with custom logic
filter := &client.EventFilter{
    Types: []client.EventType{client.EventTypeKey},
    CustomFilter: func(e *client.Event) bool {
        // Only handle 'Enter' key
        return e.Key != nil && e.Key.Key == "KEY_ENTER"
    },
}

c.OnEventFiltered(func(event *client.Event) {
    log.Println("Enter key pressed!")
}, filter)
Event Middleware
// Add middleware to log all events
c.AddEventMiddleware(func(event *client.Event) (*client.Event, bool) {
    log.Printf("Event: %v", event.Type)
    return event, true // Continue processing
})

// Add middleware to block certain events
c.AddEventMiddleware(func(event *client.Event) (*client.Event, bool) {
    if event.Type == client.EventTypeMouse {
        return event, false // Block mouse events
    }
    return event, true
})

// Add middleware to modify events
c.AddEventMiddleware(func(event *client.Event) (*client.Event, bool) {
    if event.Type == client.EventTypeKey && event.Key != nil {
        // Convert to uppercase
        if event.Key.Rune >= 'a' && event.Key.Rune <= 'z' {
            event.Key.Rune = event.Key.Rune - 32
        }
    }
    return event, true
})
Event Batching
// Batch high-frequency events
batcher := client.NewEventBatcher(100*time.Millisecond, func(event *client.Event) {
    // This handler receives batched events every 100ms
    log.Printf("Batched event: %v", event.Type)
})
defer batcher.Close()

// Add events to the batcher
c.OnEvent(func(event *client.Event) {
    if event.Type == client.EventTypeMouse {
        batcher.Add(event)
    }
})
Event Recording and Replay
// Enable event recording
c.EnableEventRecording(1000) // Keep last 1000 events

// Get the recorder
recorder := c.GetEventRecorder()

// Get all recorded events
events := recorder.GetEvents()
log.Printf("Recorded %d events", len(events))

// Get events since a specific time
since := time.Now().Add(-5 * time.Minute)
recentEvents := recorder.GetEventsSince(since)

// Replay events
recorder.Replay(func(event *client.Event) {
    log.Printf("Replaying: %v", event.Type)
}, false) // false = replay immediately, true = replay with original timing

// Control recording
recorder.Stop()  // Pause recording
recorder.Start() // Resume recording
recorder.Clear() // Clear all recorded events
Server-Side Event Filtering
// Reduce network traffic by filtering at the server
c.SetServerEventFilterSimple(
    true,  // key events
    false, // mouse events (disabled)
    true,  // resize events
    true,  // focus events
    true,  // widget events
)

// Filter by specific widgets at the server
c.SetServerWidgetFilter([]string{
    widget1.ID(),
    widget2.ID(),
})

Helper Functions

// Color helpers
client.Color("red")                    // Named color
client.ColorRGB(255, 0, 0)            // RGB color
client.ColorHex("#ff0000")            // Hex color

// Table cell helpers
client.NewTableCell("text")                           // Simple cell
client.NewTableCellWithColor("text", client.Color("yellow"))  // Colored cell

Examples

See the examples/ directory for complete working examples:

  • examples/simple-list/ - Simple list widget demo
  • examples/data-table/ - Data table with employee directory
  • examples/login-form/ - Login form with multiple field types

API Reference

See the GoDoc for complete API documentation.

Documentation

Overview

Package client provides a high-level Go client library for the Yutani Terminal Display Server.

This package offers a fluent, idiomatic Go API for creating and managing terminal UIs through the Yutani server, abstracting away the low-level gRPC details.

Example usage:

client, err := yutani.Connect("localhost:50051")
if err != nil {
	log.Fatal(err)
}
defer client.Close()

// Create a list widget
list := client.NewList().
	Title("Menu").
	Border(true).
	Build()

list.AddItem("New File", "Create a new file", "n")
list.AddItem("Open File", "Open an existing file", "o")
list.SetSelection(0)

// Handle events
client.OnEvent(func(event *Event) {
	if event.Type == EventTypeWidget && event.Widget.Type == WidgetEventSelected {
		fmt.Printf("Selected: %s\n", event.Widget.WidgetId)
	}
})

client.Run()

Index

Constants

View Source
const (
	WidgetEventSelected           = "WIDGET_SELECTED"
	WidgetEventChanged            = "WIDGET_CHANGED"
	WidgetEventSubmitted          = "WIDGET_SUBMITTED"
	WidgetEventCancelled          = "WIDGET_CANCELLED"
	WidgetEventDone               = "WIDGET_DONE"
	WidgetEventWindowMoved        = "WIDGET_WINDOW_MOVED"
	WidgetEventWindowResized      = "WIDGET_WINDOW_RESIZED"
	WidgetEventWindowStateChanged = "WIDGET_WINDOW_STATE_CHANGED"
	WidgetEventWindowClosed       = "WIDGET_WINDOW_CLOSED"
	WidgetEventWindowActivated    = "WIDGET_WINDOW_ACTIVATED"
)

Widget event type string constants for convenience.

Variables

View Source
var DefaultTheme = &Theme{
	PrimaryColor:    NamedColor("blue"),
	SecondaryColor:  NamedColor("cyan"),
	BackgroundColor: NamedColor("black"),
	SurfaceColor:    IndexColor(235),

	TextColor:          NamedColor("white"),
	TextSecondaryColor: NamedColor("gray"),
	TextDisabledColor:  IndexColor(242),

	ButtonColor:     NamedColor("blue"),
	ButtonTextColor: NamedColor("white"),
	InputBackground: IndexColor(236),
	InputText:       NamedColor("white"),

	SuccessColor: NamedColor("green"),
	WarningColor: NamedColor("yellow"),
	ErrorColor:   NamedColor("red"),
	InfoColor:    NamedColor("blue"),

	BorderColor:  NamedColor("white"),
	DividerColor: IndexColor(238),

	SelectionColor: NamedColor("blue"),
	HighlightColor: NamedColor("yellow"),
}

DefaultTheme provides a standard dark theme.

View Source
var ForestTheme = &Theme{
	PrimaryColor:    HexColor("#2E7D32"),
	SecondaryColor:  HexColor("#558B2F"),
	BackgroundColor: HexColor("#1B2B1B"),
	SurfaceColor:    HexColor("#2A3D2A"),

	TextColor:          HexColor("#E8F5E9"),
	TextSecondaryColor: HexColor("#A5D6A7"),
	TextDisabledColor:  HexColor("#4CAF50"),

	ButtonColor:     HexColor("#2E7D32"),
	ButtonTextColor: NamedColor("white"),
	InputBackground: HexColor("#2A3D2A"),
	InputText:       HexColor("#E8F5E9"),

	SuccessColor: HexColor("#66BB6A"),
	WarningColor: HexColor("#FFCA28"),
	ErrorColor:   HexColor("#EF5350"),
	InfoColor:    HexColor("#42A5F5"),

	BorderColor:  HexColor("#388E3C"),
	DividerColor: HexColor("#1B5E20"),

	SelectionColor: HexColor("#2E7D32"),
	HighlightColor: HexColor("#FFCA28"),
}

ForestTheme provides a green nature theme.

View Source
var LightTheme = &Theme{
	PrimaryColor:    HexColor("#1976D2"),
	SecondaryColor:  HexColor("#00796B"),
	BackgroundColor: NamedColor("white"),
	SurfaceColor:    IndexColor(255),

	TextColor:          NamedColor("black"),
	TextSecondaryColor: IndexColor(240),
	TextDisabledColor:  IndexColor(245),

	ButtonColor:     HexColor("#1976D2"),
	ButtonTextColor: NamedColor("white"),
	InputBackground: IndexColor(254),
	InputText:       NamedColor("black"),

	SuccessColor: HexColor("#388E3C"),
	WarningColor: HexColor("#F57C00"),
	ErrorColor:   HexColor("#D32F2F"),
	InfoColor:    HexColor("#1976D2"),

	BorderColor:  IndexColor(240),
	DividerColor: IndexColor(250),

	SelectionColor: HexColor("#1976D2"),
	HighlightColor: HexColor("#FFC107"),
}

LightTheme provides a light color scheme.

View Source
var MonochromeTheme = &Theme{
	PrimaryColor:    NamedColor("white"),
	SecondaryColor:  NamedColor("gray"),
	BackgroundColor: NamedColor("black"),
	SurfaceColor:    NamedColor("black"),

	TextColor:          NamedColor("white"),
	TextSecondaryColor: NamedColor("gray"),
	TextDisabledColor:  NamedColor("darkgray"),

	ButtonColor:     NamedColor("white"),
	ButtonTextColor: NamedColor("black"),
	InputBackground: NamedColor("black"),
	InputText:       NamedColor("white"),

	SuccessColor: NamedColor("white"),
	WarningColor: NamedColor("white"),
	ErrorColor:   NamedColor("white"),
	InfoColor:    NamedColor("white"),

	BorderColor:  NamedColor("white"),
	DividerColor: NamedColor("gray"),

	SelectionColor: NamedColor("white"),
	HighlightColor: NamedColor("white"),
}

MonochromeTheme provides a black and white theme.

View Source
var OceanTheme = &Theme{
	PrimaryColor:    HexColor("#0288D1"),
	SecondaryColor:  HexColor("#00ACC1"),
	BackgroundColor: HexColor("#0D1B2A"),
	SurfaceColor:    HexColor("#1B2838"),

	TextColor:          HexColor("#E0E0E0"),
	TextSecondaryColor: HexColor("#90A4AE"),
	TextDisabledColor:  HexColor("#546E7A"),

	ButtonColor:     HexColor("#0288D1"),
	ButtonTextColor: NamedColor("white"),
	InputBackground: HexColor("#1B2838"),
	InputText:       HexColor("#E0E0E0"),

	SuccessColor: HexColor("#00C853"),
	WarningColor: HexColor("#FFB300"),
	ErrorColor:   HexColor("#FF5252"),
	InfoColor:    HexColor("#29B6F6"),

	BorderColor:  HexColor("#37474F"),
	DividerColor: HexColor("#263238"),

	SelectionColor: HexColor("#0288D1"),
	HighlightColor: HexColor("#FFB300"),
}

OceanTheme provides a cool blue theme.

View Source
var SunsetTheme = &Theme{
	PrimaryColor:    HexColor("#E65100"),
	SecondaryColor:  HexColor("#FF6D00"),
	BackgroundColor: HexColor("#1A0F0A"),
	SurfaceColor:    HexColor("#2D1810"),

	TextColor:          HexColor("#FFF3E0"),
	TextSecondaryColor: HexColor("#FFCC80"),
	TextDisabledColor:  HexColor("#A1887F"),

	ButtonColor:     HexColor("#E65100"),
	ButtonTextColor: NamedColor("white"),
	InputBackground: HexColor("#2D1810"),
	InputText:       HexColor("#FFF3E0"),

	SuccessColor: HexColor("#66BB6A"),
	WarningColor: HexColor("#FFA726"),
	ErrorColor:   HexColor("#EF5350"),
	InfoColor:    HexColor("#42A5F5"),

	BorderColor:  HexColor("#BF360C"),
	DividerColor: HexColor("#3E2723"),

	SelectionColor: HexColor("#E65100"),
	HighlightColor: HexColor("#FFD54F"),
}

SunsetTheme provides a warm orange/red theme.

Functions

func Color

func Color(name string) *pb.Color

Color creates a named color.

func ColorRGB

func ColorRGB(r, g, b int32) *pb.Color

ColorRGB creates an RGB color.

func HexColor

func HexColor(hex string) *pb.Color

HexColor creates a color from a hex string (e.g., "#FF0000" or "FF0000").

func IndexColor

func IndexColor(index int) *pb.Color

IndexColor creates a color from a 256-color palette index.

func NamedColor

func NamedColor(name string) *pb.Color

NamedColor creates a color from a named color string.

func NewTableCell

func NewTableCell(text string) *pb.TableCell

NewTableCell creates a new table cell with text.

func NewTableCellWithColor

func NewTableCellWithColor(text string, color *pb.Color) *pb.TableCell

NewTableCellWithColor creates a new table cell with text and color.

func NewTreeNode

func NewTreeNode(text string) *pb.TreeNode

NewTreeNode creates a new tree node with the given text.

func RGBColor

func RGBColor(r, g, b int) *pb.Color

RGBColor creates a true color from RGB values.

func TreeNodeWithColor

func TreeNodeWithColor(text string, color *pb.Color) *pb.TreeNode

TreeNodeWithColor creates a new tree node with text and color.

func TreeNodeWithOptions

func TreeNodeWithOptions(text string, color *pb.Color, selectable, expanded bool, reference string) *pb.TreeNode

TreeNodeWithOptions creates a new tree node with all options.

Types

type BackoffStrategy

type BackoffStrategy int

BackoffStrategy defines how to calculate retry delays.

const (
	// ConstantBackoff uses a constant delay between retries.
	ConstantBackoff BackoffStrategy = iota
	// LinearBackoff increases delay linearly with each retry.
	LinearBackoff
	// ExponentialBackoff doubles delay with each retry.
	ExponentialBackoff
)

type Box

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

Box represents a box widget.

func (*Box) Delete

func (w *Box) Delete() error

Delete removes the widget from the server.

func (*Box) GetProperties

func (w *Box) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (*Box) ID

func (w *Box) ID() string

ID returns the widget's unique identifier.

func (*Box) SetBorder

func (w *Box) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (*Box) SetFocus

func (w *Box) SetFocus() error

SetFocus sets focus to this widget.

func (*Box) SetTitle

func (w *Box) SetTitle(title string) error

SetTitle sets the widget's title.

type BoxBuilder

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

BoxBuilder provides a fluent interface for creating box widgets.

func (*BoxBuilder) BackgroundColor

func (b *BoxBuilder) BackgroundColor(color *pb.Color) *BoxBuilder

BackgroundColor sets the background color.

func (*BoxBuilder) Border

func (b *BoxBuilder) Border(border bool) *BoxBuilder

Border sets whether the box has a border.

func (*BoxBuilder) Build

func (b *BoxBuilder) Build() (*Box, error)

Build creates the box widget on the server.

func (*BoxBuilder) Title

func (b *BoxBuilder) Title(title string) *BoxBuilder

Title sets the box title.

type Button

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

Button represents a button widget.

func (*Button) Delete

func (w *Button) Delete() error

Delete removes the widget from the server.

func (*Button) GetLabel

func (btn *Button) GetLabel() (string, error)

GetLabel returns the current label of the button.

func (*Button) GetProperties

func (w *Button) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (*Button) ID

func (w *Button) ID() string

ID returns the widget's unique identifier.

func (*Button) SetBorder

func (w *Button) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (*Button) SetFocus

func (w *Button) SetFocus() error

SetFocus sets focus to this widget.

func (*Button) SetLabel

func (btn *Button) SetLabel(label string) error

SetLabel sets the button label.

func (*Button) SetTitle

func (w *Button) SetTitle(title string) error

SetTitle sets the widget's title.

type ButtonBuilder

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

ButtonBuilder provides a fluent interface for creating button widgets.

func (*ButtonBuilder) ActivatedColor

func (b *ButtonBuilder) ActivatedColor(color *pb.Color) *ButtonBuilder

ActivatedColor sets the button color when activated.

func (*ButtonBuilder) BackgroundColor

func (b *ButtonBuilder) BackgroundColor(color *pb.Color) *ButtonBuilder

BackgroundColor sets the button background color.

func (*ButtonBuilder) Border

func (b *ButtonBuilder) Border(border bool) *ButtonBuilder

Border sets whether the button has a border.

func (*ButtonBuilder) Build

func (b *ButtonBuilder) Build() (*Button, error)

Build creates the button widget on the server.

func (*ButtonBuilder) Label

func (b *ButtonBuilder) Label(label string) *ButtonBuilder

Label sets the button label text.

func (*ButtonBuilder) LabelColor

func (b *ButtonBuilder) LabelColor(color *pb.Color) *ButtonBuilder

LabelColor sets the button label color.

func (*ButtonBuilder) Title

func (b *ButtonBuilder) Title(title string) *ButtonBuilder

Title sets the button's title (border title).

type Checkbox

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

Checkbox represents a checkbox widget.

func (*Checkbox) Delete

func (w *Checkbox) Delete() error

Delete removes the widget from the server.

func (*Checkbox) GetLabel

func (cb *Checkbox) GetLabel() (string, error)

GetLabel returns the current label of the checkbox.

func (*Checkbox) GetProperties

func (w *Checkbox) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (*Checkbox) ID

func (w *Checkbox) ID() string

ID returns the widget's unique identifier.

func (*Checkbox) IsChecked

func (cb *Checkbox) IsChecked() (bool, error)

IsChecked returns the current checked state of the checkbox.

func (*Checkbox) SetBorder

func (w *Checkbox) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (*Checkbox) SetChecked

func (cb *Checkbox) SetChecked(checked bool) error

SetChecked sets the checkbox checked state.

func (*Checkbox) SetFocus

func (w *Checkbox) SetFocus() error

SetFocus sets focus to this widget.

func (*Checkbox) SetLabel

func (cb *Checkbox) SetLabel(label string) error

SetLabel sets the checkbox label.

func (*Checkbox) SetTitle

func (w *Checkbox) SetTitle(title string) error

SetTitle sets the widget's title.

type CheckboxBuilder

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

CheckboxBuilder provides a fluent interface for creating checkbox widgets.

func (*CheckboxBuilder) Border

func (b *CheckboxBuilder) Border(border bool) *CheckboxBuilder

Border sets whether the checkbox has a border.

func (*CheckboxBuilder) Build

func (b *CheckboxBuilder) Build() (*Checkbox, error)

Build creates the checkbox widget on the server.

func (*CheckboxBuilder) Checked

func (b *CheckboxBuilder) Checked(checked bool) *CheckboxBuilder

Checked sets the initial checked state.

func (*CheckboxBuilder) CheckedColor

func (b *CheckboxBuilder) CheckedColor(color *pb.Color) *CheckboxBuilder

CheckedColor sets the checkbox color when checked.

func (*CheckboxBuilder) Label

func (b *CheckboxBuilder) Label(label string) *CheckboxBuilder

Label sets the checkbox label text.

func (*CheckboxBuilder) LabelColor

func (b *CheckboxBuilder) LabelColor(color *pb.Color) *CheckboxBuilder

LabelColor sets the checkbox label color.

func (*CheckboxBuilder) Title

func (b *CheckboxBuilder) Title(title string) *CheckboxBuilder

Title sets the checkbox's title (border title).

type Client

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

Client represents a connection to the Yutani server.

func Connect

func Connect(address string) (*Client, error)

Connect creates a new client connection to the Yutani server.

func ConnectWithConn

func ConnectWithConn(conn *grpc.ClientConn) (*Client, error)

ConnectWithConn creates a new client using an existing gRPC connection. This is useful for testing with a test server.

func ConnectWithOptions

func ConnectWithOptions(address string, opts ...grpc.DialOption) (*Client, error)

ConnectWithOptions creates a new client connection with custom gRPC dial options.

func ConnectWithRetry

func ConnectWithRetry(address string, opts RetryOptions) (*Client, error)

ConnectWithRetry creates a client connection with automatic retry.

func ConnectWithRetryAndOptions

func ConnectWithRetryAndOptions(address string, retryOpts RetryOptions, grpcOpts ...grpc.DialOption) (*Client, error)

ConnectWithRetryAndOptions creates a client connection with retry and custom gRPC options.

func (*Client) AddEventMiddleware

func (c *Client) AddEventMiddleware(middleware EventMiddleware)

AddEventMiddleware adds middleware to the event processing pipeline.

func (*Client) ClearScreen

func (c *Client) ClearScreen() error

ClearScreen clears the screen.

func (*Client) Close

func (c *Client) Close() error

Close closes the client connection and cleans up resources.

func (*Client) Context

func (c *Client) Context() context.Context

Context returns the client's context.

func (*Client) EnableEventRecording

func (c *Client) EnableEventRecording(maxEvents int)

EnableEventRecording enables event recording with the specified max events.

func (*Client) GetConnectionState

func (c *Client) GetConnectionState() ConnectionState

GetConnectionState returns the current connection state.

func (*Client) GetEventRecorder

func (c *Client) GetEventRecorder() *EventRecorder

GetEventRecorder returns the event recorder if enabled.

func (*Client) GetScreenSize

func (c *Client) GetScreenSize() (width, height int, err error)

GetScreenSize returns the current screen dimensions.

func (*Client) GetWidget

func (c *Client) GetWidget(widgetID string) (Widget, bool)

GetWidget returns a widget by ID.

func (*Client) IsConnected

func (c *Client) IsConnected() bool

IsConnected returns true if the client is connected.

func (*Client) IsHealthy

func (c *Client) IsHealthy() bool

IsHealthy checks if the connection is healthy by pinging the server.

func (*Client) NewBox

func (c *Client) NewBox() *BoxBuilder

NewBox creates a new box builder.

func (*Client) NewButton

func (c *Client) NewButton() *ButtonBuilder

NewButton creates a new button builder.

func (*Client) NewCheckbox

func (c *Client) NewCheckbox() *CheckboxBuilder

NewCheckbox creates a new checkbox builder.

func (*Client) NewDropdown

func (c *Client) NewDropdown() *DropdownBuilder

NewDropdown creates a new dropdown builder.

func (*Client) NewFlex

func (c *Client) NewFlex() *FlexBuilder

NewFlex creates a new flex builder.

func (*Client) NewForm

func (c *Client) NewForm() *FormBuilder

NewForm creates a new form builder.

func (*Client) NewGrid

func (c *Client) NewGrid() *GridBuilder

NewGrid creates a new grid builder.

func (*Client) NewImage

func (c *Client) NewImage() *ImageBuilder

NewImage creates a new image builder.

func (*Client) NewInputField

func (c *Client) NewInputField() *InputFieldBuilder

NewInputField creates a new input field builder.

func (*Client) NewList

func (c *Client) NewList() *ListBuilder

NewList creates a new list builder.

func (*Client) NewMenu

func (c *Client) NewMenu() *MenuBuilder

NewMenu creates a new menu builder.

func (*Client) NewMenuBar

func (c *Client) NewMenuBar() *MenuBarBuilder

NewMenuBar creates a new menu bar builder.

func (*Client) NewMenuItem

func (c *Client) NewMenuItem() *MenuItemBuilder

NewMenuItem creates a new menu item builder.

func (*Client) NewModal

func (c *Client) NewModal() *ModalBuilder

NewModal creates a new modal builder.

func (*Client) NewPages

func (c *Client) NewPages() *PagesBuilder

NewPages creates a new pages builder.

func (*Client) NewProgressBar

func (c *Client) NewProgressBar() *ProgressBarBuilder

NewProgressBar creates a new progress bar builder.

func (*Client) NewTable

func (c *Client) NewTable() *TableBuilder

NewTable creates a new table builder.

func (*Client) NewTextArea

func (c *Client) NewTextArea() *TextAreaBuilder

NewTextArea creates a new text area builder.

func (*Client) NewTextView

func (c *Client) NewTextView() *TextViewBuilder

NewTextView creates a new text view builder.

func (*Client) NewTreeView

func (c *Client) NewTreeView() *TreeViewBuilder

NewTreeView creates a new tree view builder.

func (*Client) NewWindow

func (c *Client) NewWindow() *WindowBuilder

NewWindow creates a new window builder.

func (*Client) NewWindowManager

func (c *Client) NewWindowManager() *WindowManagerBuilder

NewWindowManager creates a new window manager builder.

func (*Client) OnConnectionStateChange

func (c *Client) OnConnectionStateChange(callback ConnectionStateCallback)

OnConnectionStateChange registers a callback for connection state changes.

func (*Client) OnEvent

func (c *Client) OnEvent(handler EventHandler)

OnEvent registers an event handler.

func (*Client) OnEventFiltered

func (c *Client) OnEventFiltered(handler EventHandler, filter *EventFilter)

OnEventFiltered registers an event handler with a filter.

func (*Client) OnEventType

func (c *Client) OnEventType(eventType EventType, handler EventHandler)

OnEventType registers a handler for specific event types.

func (*Client) OnWidgetEvent

func (c *Client) OnWidgetEvent(widgetID string, handler EventHandler)

OnWidgetEvent registers a handler for events from a specific widget.

func (*Client) Reconnect

func (c *Client) Reconnect() error

Reconnect manually triggers a reconnection attempt.

func (*Client) SessionID

func (c *Client) SessionID() *pb.SessionId

SessionID returns the current session ID.

func (*Client) SetRoot

func (c *Client) SetRoot(widget Widget) error

SetRoot sets a widget as the root widget displayed on the server. This makes the widget visible on the server's terminal.

func (*Client) SetServerEventFilter

func (c *Client) SetServerEventFilter(filter *pb.EventFilter) error

SetServerEventFilter updates the server-side event filter. This controls which events are sent from the server to the client.

func (*Client) SetServerEventFilterSimple

func (c *Client) SetServerEventFilterSimple(key, mouse, resize, focus, widget bool) error

SetServerEventFilterSimple is a convenience method to set basic event type filters.

func (*Client) SetServerWidgetFilter

func (c *Client) SetServerWidgetFilter(widgetIDs []string) error

SetServerWidgetFilter sets the server to only send events for specific widgets.

func (*Client) StartEventStream

func (c *Client) StartEventStream() error

StartEventStream starts listening for events from the server.

func (*Client) StartHealthCheck

func (c *Client) StartHealthCheck(interval time.Duration)

StartHealthCheck starts periodic health checks.

func (*Client) StopHealthCheck

func (c *Client) StopHealthCheck()

StopHealthCheck stops periodic health checks.

func (*Client) Sync

func (c *Client) Sync() error

Sync synchronizes the screen display.

type ConnectionState

type ConnectionState int

ConnectionState represents the current connection state.

const (
	// StateConnected indicates the client is connected.
	StateConnected ConnectionState = iota
	// StateDisconnected indicates the client is disconnected.
	StateDisconnected
	// StateReconnecting indicates the client is attempting to reconnect.
	StateReconnecting
)

func (ConnectionState) String

func (s ConnectionState) String() string

String returns the string representation of the connection state.

type ConnectionStateCallback

type ConnectionStateCallback func(oldState, newState ConnectionState)

ConnectionStateCallback is called when connection state changes.

type CursorPosition

type CursorPosition struct {
	Row          int
	Column       int
	ToRow        int
	ToColumn     int
	HasSelection bool
}

CursorPosition holds cursor and optional selection endpoint coordinates.

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

Dropdown represents a dropdown widget.

func (w *Dropdown) Delete() error

Delete removes the widget from the server.

func (dd *Dropdown) GetLabel() (string, error)

GetLabel returns the current label of the dropdown.

func (dd *Dropdown) GetOptions() ([]string, error)

GetOptions returns the dropdown options.

func (w *Dropdown) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (dd *Dropdown) GetSelectedIndex() (int, error)

GetSelectedIndex returns the currently selected index.

func (dd *Dropdown) GetSelectedText() (string, error)

GetSelectedText returns the currently selected text.

func (w *Dropdown) ID() string

ID returns the widget's unique identifier.

func (w *Dropdown) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (w *Dropdown) SetFocus() error

SetFocus sets focus to this widget.

func (dd *Dropdown) SetLabel(label string) error

SetLabel sets the dropdown label.

func (dd *Dropdown) SetOptions(options []string) error

SetOptions sets the dropdown options.

func (dd *Dropdown) SetSelectedIndex(index int) error

SetSelectedIndex sets the selected index.

func (w *Dropdown) SetTitle(title string) error

SetTitle sets the widget's title.

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

DropdownBuilder provides a fluent interface for creating dropdown widgets.

func (b *DropdownBuilder) Border(border bool) *DropdownBuilder

Border sets whether the dropdown has a border.

func (b *DropdownBuilder) Build() (*Dropdown, error)

Build creates the dropdown widget on the server.

func (b *DropdownBuilder) FieldBackgroundColor(color *pb.Color) *DropdownBuilder

FieldBackgroundColor sets the field background color.

func (b *DropdownBuilder) FieldTextColor(color *pb.Color) *DropdownBuilder

FieldTextColor sets the field text color.

func (b *DropdownBuilder) FieldWidth(width int) *DropdownBuilder

FieldWidth sets the field width.

func (b *DropdownBuilder) Label(label string) *DropdownBuilder

Label sets the dropdown label text.

func (b *DropdownBuilder) LabelColor(color *pb.Color) *DropdownBuilder

LabelColor sets the label color.

func (b *DropdownBuilder) Options(options []string) *DropdownBuilder

Options sets the dropdown options.

func (b *DropdownBuilder) SelectedIndex(index int) *DropdownBuilder

SelectedIndex sets the initially selected index.

func (b *DropdownBuilder) Title(title string) *DropdownBuilder

Title sets the dropdown's title (border title).

type Event

type Event struct {
	Type   EventType
	Key    *KeyEvent
	Mouse  *MouseEvent
	Resize *ResizeEvent
	Focus  *FocusEvent
	Widget *WidgetEvent
}

Event represents an event from the server.

func (*Event) IsFocus

func (e *Event) IsFocus() bool

IsFocus returns true if this is a focus event.

func (*Event) IsKey

func (e *Event) IsKey() bool

IsKey returns true if this is a key event.

func (*Event) IsMouse

func (e *Event) IsMouse() bool

IsMouse returns true if this is a mouse event.

func (*Event) IsResize

func (e *Event) IsResize() bool

IsResize returns true if this is a resize event.

func (*Event) IsWidget

func (e *Event) IsWidget() bool

IsWidget returns true if this is a widget event.

func (*Event) IsWidgetEvent

func (e *Event) IsWidgetEvent(widgetID string) bool

IsWidgetEvent returns true if this is a widget event for the specified widget.

func (*Event) IsWidgetEventType

func (e *Event) IsWidgetEventType(eventType string) bool

IsWidgetEventType returns true if this is a widget event of the specified type.

type EventBatcher

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

EventBatcher batches high-frequency events.

func NewEventBatcher

func NewEventBatcher(interval time.Duration, handler EventHandler) *EventBatcher

NewEventBatcher creates a new event batcher.

func (*EventBatcher) Add

func (b *EventBatcher) Add(event *Event)

Add adds an event to the batch.

func (*EventBatcher) Close

func (b *EventBatcher) Close()

Close stops the batcher.

type EventFilter

type EventFilter struct {
	// Filter by event type
	Types []EventType

	// Filter by widget ID
	WidgetIDs []string

	// Filter by widget event type
	WidgetEventTypes []string

	// Custom filter function
	CustomFilter func(*Event) bool
}

EventFilter provides advanced filtering for events.

func (*EventFilter) Matches

func (f *EventFilter) Matches(event *Event) bool

Matches returns true if the event passes this filter.

type EventHandler

type EventHandler func(*Event)

EventHandler is a function that handles events from the server.

type EventMiddleware

type EventMiddleware func(*Event) (*Event, bool)

EventMiddleware is a function that can intercept and modify events.

type EventRecorder

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

EventRecorder records events for replay and debugging.

func NewEventRecorder

func NewEventRecorder(maxEvents int) *EventRecorder

NewEventRecorder creates a new event recorder.

func (*EventRecorder) Clear

func (r *EventRecorder) Clear()

Clear clears all recorded events.

func (*EventRecorder) GetEvents

func (r *EventRecorder) GetEvents() []*RecordedEvent

GetEvents returns all recorded events.

func (*EventRecorder) GetEventsSince

func (r *EventRecorder) GetEventsSince(since time.Time) []*RecordedEvent

GetEventsSince returns events since a specific time.

func (*EventRecorder) IsRecording

func (r *EventRecorder) IsRecording() bool

IsRecording returns true if currently recording.

func (*EventRecorder) Record

func (r *EventRecorder) Record(event *Event)

Record records an event.

func (*EventRecorder) Replay

func (r *EventRecorder) Replay(handler EventHandler, realtime bool)

Replay replays recorded events to a handler.

func (*EventRecorder) Start

func (r *EventRecorder) Start()

Start starts recording.

func (*EventRecorder) Stop

func (r *EventRecorder) Stop()

Stop stops recording.

type EventType

type EventType int

EventType represents the type of event.

const (
	EventTypeKey EventType = iota
	EventTypeMouse
	EventTypeResize
	EventTypeFocus
	EventTypeWidget
)

type Flex

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

Flex represents a flex layout widget.

func (*Flex) AddItem

func (f *Flex) AddItem(widget Widget, proportion, fixedSize int, focus bool) error

AddItem adds a widget to the flex layout.

func (*Flex) Delete

func (w *Flex) Delete() error

Delete removes the widget from the server.

func (*Flex) GetProperties

func (w *Flex) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (*Flex) ID

func (w *Flex) ID() string

ID returns the widget's unique identifier.

func (*Flex) RemoveItem

func (f *Flex) RemoveItem(widget Widget) error

RemoveItem removes a widget from the flex layout.

func (*Flex) SetBorder

func (w *Flex) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (*Flex) SetDirection

func (f *Flex) SetDirection(direction pb.FlexDirection) error

SetDirection sets the flex direction.

func (*Flex) SetFocus

func (w *Flex) SetFocus() error

SetFocus sets focus to this widget.

func (*Flex) SetTitle

func (w *Flex) SetTitle(title string) error

SetTitle sets the widget's title.

type FlexBuilder

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

FlexBuilder provides a fluent interface for creating flex widgets.

func (*FlexBuilder) Border

func (b *FlexBuilder) Border(border bool) *FlexBuilder

Border sets whether the flex has a border.

func (*FlexBuilder) Build

func (b *FlexBuilder) Build() (*Flex, error)

Build creates the flex widget on the server.

func (*FlexBuilder) Direction

func (b *FlexBuilder) Direction(direction pb.FlexDirection) *FlexBuilder

Direction sets the flex direction (row or column).

func (*FlexBuilder) FullScreen

func (b *FlexBuilder) FullScreen(fullScreen bool) *FlexBuilder

FullScreen sets whether the flex is full screen.

func (*FlexBuilder) Title

func (b *FlexBuilder) Title(title string) *FlexBuilder

Title sets the flex title.

type FocusEvent

type FocusEvent struct {
	Focused bool
}

FocusEvent represents a focus change event.

type Form

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

Form represents a form widget.

func (*Form) AddButton

func (f *Form) AddButton(label string) error

AddButton adds a button to the form.

func (*Form) AddCheckbox

func (f *Form) AddCheckbox(label string, initialValue bool) (int, error)

AddCheckbox adds a checkbox to the form.

func (*Form) AddDropdown

func (f *Form) AddDropdown(label string, options []string, initialValue string) (int, error)

AddDropdown adds a dropdown to the form.

func (*Form) AddInputField

func (f *Form) AddInputField(label string, fieldWidth int, initialValue string) (int, error)

AddInputField adds an input field to the form.

func (*Form) AddPasswordField

func (f *Form) AddPasswordField(label string, fieldWidth int) (int, error)

AddPasswordField adds a password field to the form.

func (*Form) Clear

func (f *Form) Clear() error

Clear clears all form fields.

func (*Form) Delete

func (w *Form) Delete() error

Delete removes the widget from the server.

func (*Form) GetFieldValue

func (f *Form) GetFieldValue(fieldIndex int) (string, error)

GetFieldValue gets a field's current value.

func (*Form) GetItemCount

func (f *Form) GetItemCount() (int, error)

GetItemCount returns the number of form items.

func (*Form) GetProperties

func (w *Form) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (*Form) ID

func (w *Form) ID() string

ID returns the widget's unique identifier.

func (*Form) SetBorder

func (w *Form) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (*Form) SetFieldValue

func (f *Form) SetFieldValue(fieldIndex int, value string) error

SetFieldValue sets a field's value.

func (*Form) SetFocus

func (w *Form) SetFocus() error

SetFocus sets focus to this widget.

func (*Form) SetTitle

func (w *Form) SetTitle(title string) error

SetTitle sets the widget's title.

type FormBuilder

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

FormBuilder provides a fluent interface for creating form widgets.

func (*FormBuilder) Border

func (b *FormBuilder) Border(border bool) *FormBuilder

Border sets whether the form has a border.

func (*FormBuilder) Build

func (b *FormBuilder) Build() (*Form, error)

Build creates the form widget on the server.

func (*FormBuilder) Title

func (b *FormBuilder) Title(title string) *FormBuilder

Title sets the form title.

type Grid

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

Grid represents a grid layout widget.

func (*Grid) AddItem

func (g *Grid) AddItem(widget Widget, row, column, rowSpan, columnSpan, minWidth, minHeight int, focus bool) error

AddItem adds a widget to the grid layout.

func (*Grid) Delete

func (w *Grid) Delete() error

Delete removes the widget from the server.

func (*Grid) GetProperties

func (w *Grid) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (*Grid) ID

func (w *Grid) ID() string

ID returns the widget's unique identifier.

func (*Grid) RemoveItem

func (g *Grid) RemoveItem(widget Widget) error

RemoveItem removes a widget from the grid layout.

func (*Grid) SetBorder

func (w *Grid) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (*Grid) SetColumns

func (g *Grid) SetColumns(columnSizes []int32) error

SetColumns sets the column sizes (negative for proportional, positive for fixed).

func (*Grid) SetFocus

func (w *Grid) SetFocus() error

SetFocus sets focus to this widget.

func (*Grid) SetRows

func (g *Grid) SetRows(rowSizes []int32) error

SetRows sets the row sizes (negative for proportional, positive for fixed).

func (*Grid) SetTitle

func (w *Grid) SetTitle(title string) error

SetTitle sets the widget's title.

type GridBuilder

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

GridBuilder provides a fluent interface for creating grid widgets.

func (*GridBuilder) Border

func (b *GridBuilder) Border(border bool) *GridBuilder

Border sets whether the grid has a border.

func (*GridBuilder) Build

func (b *GridBuilder) Build() (*Grid, error)

Build creates the grid widget on the server.

func (*GridBuilder) Columns

func (b *GridBuilder) Columns(columns int) *GridBuilder

Columns sets the number of columns.

func (*GridBuilder) MinHeight

func (b *GridBuilder) MinHeight(height int) *GridBuilder

MinHeight sets the minimum height.

func (*GridBuilder) MinWidth

func (b *GridBuilder) MinWidth(width int) *GridBuilder

MinWidth sets the minimum width.

func (*GridBuilder) Rows

func (b *GridBuilder) Rows(rows int) *GridBuilder

Rows sets the number of rows.

func (*GridBuilder) Title

func (b *GridBuilder) Title(title string) *GridBuilder

Title sets the grid title.

type Image

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

Image represents an image display widget.

func (*Image) Delete

func (w *Image) Delete() error

Delete removes the widget from the server.

func (*Image) GetColors

func (img *Image) GetColors() (int, error)

GetColors returns the current color count setting.

func (*Image) GetProperties

func (w *Image) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (*Image) ID

func (w *Image) ID() string

ID returns the widget's unique identifier.

func (*Image) SetBorder

func (w *Image) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (*Image) SetColors

func (img *Image) SetColors(colors int) error

SetColors sets the number of colors for rendering.

func (*Image) SetDithering

func (img *Image) SetDithering(enabled bool) error

SetDithering enables or disables dithering.

func (*Image) SetFocus

func (w *Image) SetFocus() error

SetFocus sets focus to this widget.

func (*Image) SetImageData

func (img *Image) SetImageData(data []byte) error

SetImageData sets the image data.

func (*Image) SetTitle

func (w *Image) SetTitle(title string) error

SetTitle sets the widget's title.

type ImageBuilder

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

ImageBuilder provides a fluent interface for creating image widgets.

func (*ImageBuilder) AspectRatio

func (b *ImageBuilder) AspectRatio(ratio pb.ImageAspectRatio) *ImageBuilder

AspectRatio sets how aspect ratio is handled.

func (*ImageBuilder) Border

func (b *ImageBuilder) Border(border bool) *ImageBuilder

Border sets whether the image has a border.

func (*ImageBuilder) Build

func (b *ImageBuilder) Build() (*Image, error)

Build creates the image widget on the server.

func (*ImageBuilder) Colors

func (b *ImageBuilder) Colors(colors int) *ImageBuilder

Colors sets the number of colors to use for rendering.

func (*ImageBuilder) Dithering

func (b *ImageBuilder) Dithering(enabled bool) *ImageBuilder

Dithering enables or disables dithering.

func (*ImageBuilder) ImageData

func (b *ImageBuilder) ImageData(data []byte) *ImageBuilder

ImageData sets the image data (raw bytes).

func (*ImageBuilder) ImagePath

func (b *ImageBuilder) ImagePath(path string) *ImageBuilder

ImagePath sets the path to an image file.

func (*ImageBuilder) Title

func (b *ImageBuilder) Title(title string) *ImageBuilder

Title sets the image's title (border title).

type InputField

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

InputField represents an input field widget.

func (*InputField) Delete

func (w *InputField) Delete() error

Delete removes the widget from the server.

func (*InputField) GetLabel

func (i *InputField) GetLabel() (string, error)

GetLabel returns the current label of the input field.

func (*InputField) GetProperties

func (w *InputField) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (*InputField) GetText

func (i *InputField) GetText() (string, error)

GetText returns the current text content of the input field.

func (*InputField) ID

func (w *InputField) ID() string

ID returns the widget's unique identifier.

func (*InputField) SetBorder

func (w *InputField) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (*InputField) SetFocus

func (w *InputField) SetFocus() error

SetFocus sets focus to this widget.

func (*InputField) SetLabel

func (i *InputField) SetLabel(label string) error

SetLabel sets the input field label.

func (*InputField) SetText

func (i *InputField) SetText(text string) error

SetText sets the input field text.

func (*InputField) SetTitle

func (w *InputField) SetTitle(title string) error

SetTitle sets the widget's title.

type InputFieldBuilder

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

InputFieldBuilder provides a fluent interface for creating input field widgets.

func (*InputFieldBuilder) Border

func (b *InputFieldBuilder) Border(border bool) *InputFieldBuilder

Border sets whether the input field has a border.

func (*InputFieldBuilder) Build

func (b *InputFieldBuilder) Build() (*InputField, error)

Build creates the input field widget on the server.

func (*InputFieldBuilder) FieldBackgroundColor

func (b *InputFieldBuilder) FieldBackgroundColor(color *pb.Color) *InputFieldBuilder

FieldBackgroundColor sets the field background color.

func (*InputFieldBuilder) FieldTextColor

func (b *InputFieldBuilder) FieldTextColor(color *pb.Color) *InputFieldBuilder

FieldTextColor sets the field text color.

func (*InputFieldBuilder) FieldWidth

func (b *InputFieldBuilder) FieldWidth(width int) *InputFieldBuilder

FieldWidth sets the field width.

func (*InputFieldBuilder) Label

func (b *InputFieldBuilder) Label(label string) *InputFieldBuilder

Label sets the input field label text.

func (*InputFieldBuilder) LabelColor

func (b *InputFieldBuilder) LabelColor(color *pb.Color) *InputFieldBuilder

LabelColor sets the label color.

func (*InputFieldBuilder) Masked

func (b *InputFieldBuilder) Masked(masked bool) *InputFieldBuilder

Masked sets whether the input is masked (password field).

func (*InputFieldBuilder) Placeholder

func (b *InputFieldBuilder) Placeholder(placeholder string) *InputFieldBuilder

Placeholder sets the placeholder text.

func (*InputFieldBuilder) Text

Text sets the initial text content.

func (*InputFieldBuilder) Title

func (b *InputFieldBuilder) Title(title string) *InputFieldBuilder

Title sets the input field's title (border title).

type KeyEvent

type KeyEvent struct {
	Key  string
	Rune rune
	Mod  int
}

KeyEvent represents a keyboard event.

type List

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

List represents a list widget.

func (*List) AddItem

func (l *List) AddItem(mainText, secondaryText string, shortcut *string) (int, error)

AddItem adds an item to the list.

func (*List) Clear

func (l *List) Clear() error

Clear removes all items from the list.

func (*List) Delete

func (w *List) Delete() error

Delete removes the widget from the server.

func (*List) GetItem

func (l *List) GetItem(index int) (mainText, secondaryText, shortcut string, err error)

GetItem returns an item's text by index.

func (*List) GetItemCount

func (l *List) GetItemCount() (int, error)

GetItemCount returns the number of items in the list.

func (*List) GetProperties

func (w *List) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (*List) GetSelection

func (l *List) GetSelection() (int, error)

GetSelection returns the index of the currently selected item.

func (*List) ID

func (w *List) ID() string

ID returns the widget's unique identifier.

func (*List) RemoveItem

func (l *List) RemoveItem(index int) error

RemoveItem removes an item from the list by index.

func (*List) SetBorder

func (w *List) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (*List) SetFocus

func (w *List) SetFocus() error

SetFocus sets focus to this widget.

func (*List) SetSelection

func (l *List) SetSelection(index int) error

SetSelection sets the selected item by index.

func (*List) SetTitle

func (w *List) SetTitle(title string) error

SetTitle sets the widget's title.

type ListBuilder

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

ListBuilder provides a fluent interface for creating list widgets.

func (*ListBuilder) BackgroundColor

func (b *ListBuilder) BackgroundColor(color *pb.Color) *ListBuilder

BackgroundColor sets the background color.

func (*ListBuilder) Border

func (b *ListBuilder) Border(border bool) *ListBuilder

Border sets whether the list has a border.

func (*ListBuilder) BorderColor

func (b *ListBuilder) BorderColor(color *pb.Color) *ListBuilder

BorderColor sets the border color.

func (*ListBuilder) Build

func (b *ListBuilder) Build() (*List, error)

Build creates the list widget on the server.

func (*ListBuilder) Title

func (b *ListBuilder) Title(title string) *ListBuilder

Title sets the list title.

func (*ListBuilder) TitleColor

func (b *ListBuilder) TitleColor(color *pb.Color) *ListBuilder

TitleColor sets the title color.

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

Menu represents a menu widget (container for menu items).

func (m *Menu) AddItem(item *MenuItem) error

AddItem adds a menu item to the menu.

func (w *Menu) Delete() error

Delete removes the widget from the server.

func (w *Menu) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (w *Menu) ID() string

ID returns the widget's unique identifier.

func (m *Menu) RemoveItem(item *MenuItem) error

RemoveItem removes a menu item from the menu.

func (w *Menu) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (w *Menu) SetFocus() error

SetFocus sets focus to this widget.

func (w *Menu) SetTitle(title string) error

SetTitle sets the widget's title.

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

MenuBar represents a menu bar widget.

func (mb *MenuBar) AddMenu(menu *Menu) error

AddMenu adds a menu to the menu bar.

func (w *MenuBar) Delete() error

Delete removes the widget from the server.

func (w *MenuBar) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (w *MenuBar) ID() string

ID returns the widget's unique identifier.

func (w *MenuBar) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (w *MenuBar) SetFocus() error

SetFocus sets focus to this widget.

func (w *MenuBar) SetTitle(title string) error

SetTitle sets the widget's title.

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

MenuBarBuilder provides a fluent interface for creating menu bar widgets.

func (b *MenuBarBuilder) ActiveBackgroundColor(color *pb.Color) *MenuBarBuilder

ActiveBackgroundColor sets the active menu title background.

func (b *MenuBarBuilder) ActiveTextColor(color *pb.Color) *MenuBarBuilder

ActiveTextColor sets the active menu title text color.

func (b *MenuBarBuilder) BackgroundColor(color *pb.Color) *MenuBarBuilder

BackgroundColor sets the menu bar background color.

func (b *MenuBarBuilder) Build() (*MenuBar, error)

Build creates the menu bar widget on the server.

func (b *MenuBarBuilder) TextColor(color *pb.Color) *MenuBarBuilder

TextColor sets the menu bar text color.

func (b *MenuBarBuilder) Title(title string) *MenuBarBuilder

Title sets the menu bar title.

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

MenuBuilder provides a fluent interface for creating menu widgets.

func (b *MenuBuilder) Build() (*Menu, error)

Build creates the menu widget on the server.

func (b *MenuBuilder) Title(title string) *MenuBuilder

Title sets the menu title (displayed in the menu bar).

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

MenuItem represents a menu item widget.

func (w *MenuItem) Delete() error

Delete removes the widget from the server.

func (w *MenuItem) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (w *MenuItem) ID() string

ID returns the widget's unique identifier.

func (w *MenuItem) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (w *MenuItem) SetFocus() error

SetFocus sets focus to this widget.

func (w *MenuItem) SetTitle(title string) error

SetTitle sets the widget's title.

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

MenuItemBuilder provides a fluent interface for creating menu item widgets.

func (b *MenuItemBuilder) Build() (*MenuItem, error)

Build creates the menu item widget on the server.

func (b *MenuItemBuilder) Disabled() *MenuItemBuilder

Disabled marks this item as disabled.

func (b *MenuItemBuilder) Label(label string) *MenuItemBuilder

Label sets the menu item label.

func (b *MenuItemBuilder) Separator() *MenuItemBuilder

Separator marks this item as a separator.

func (b *MenuItemBuilder) ShortcutDisplay(shortcut string) *MenuItemBuilder

ShortcutDisplay sets the shortcut display text (cosmetic only).

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

Modal represents a modal dialog widget.

func (*Modal) Delete

func (w *Modal) Delete() error

Delete removes the widget from the server.

func (*Modal) GetButtons

func (m *Modal) GetButtons() ([]string, error)

GetButtons returns the current modal buttons.

func (*Modal) GetProperties

func (w *Modal) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (*Modal) GetText

func (m *Modal) GetText() (string, error)

GetText returns the current modal message text.

func (*Modal) ID

func (w *Modal) ID() string

ID returns the widget's unique identifier.

func (*Modal) SetBorder

func (w *Modal) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (*Modal) SetButtons

func (m *Modal) SetButtons(buttons ...string) error

SetButtons sets the modal buttons.

func (*Modal) SetFocus

func (w *Modal) SetFocus() error

SetFocus sets focus to this widget.

func (*Modal) SetText

func (m *Modal) SetText(text string) error

SetText sets the modal message text.

func (*Modal) SetTitle

func (w *Modal) SetTitle(title string) error

SetTitle sets the widget's title.

type ModalBuilder

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

ModalBuilder provides a fluent interface for creating modal widgets.

func (*ModalBuilder) BackgroundColor

func (b *ModalBuilder) BackgroundColor(color *pb.Color) *ModalBuilder

BackgroundColor sets the modal background color.

func (*ModalBuilder) Border

func (b *ModalBuilder) Border(border bool) *ModalBuilder

Border sets whether the modal has a border.

func (*ModalBuilder) Build

func (b *ModalBuilder) Build() (*Modal, error)

Build creates the modal widget on the server.

func (*ModalBuilder) ButtonBackgroundColor

func (b *ModalBuilder) ButtonBackgroundColor(color *pb.Color) *ModalBuilder

ButtonBackgroundColor sets the button background color.

func (*ModalBuilder) ButtonTextColor

func (b *ModalBuilder) ButtonTextColor(color *pb.Color) *ModalBuilder

ButtonTextColor sets the button text color.

func (*ModalBuilder) Buttons

func (b *ModalBuilder) Buttons(buttons ...string) *ModalBuilder

Buttons sets the modal buttons.

func (*ModalBuilder) Text

func (b *ModalBuilder) Text(text string) *ModalBuilder

Text sets the modal message text.

func (*ModalBuilder) TextColor

func (b *ModalBuilder) TextColor(color *pb.Color) *ModalBuilder

TextColor sets the modal text color.

func (*ModalBuilder) Title

func (b *ModalBuilder) Title(title string) *ModalBuilder

Title sets the modal's title (border title).

type MouseEvent

type MouseEvent struct {
	X       int
	Y       int
	Button  int
	Action  string
	Buttons int
	Mod     int
}

MouseEvent represents a mouse event.

type Pages

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

Pages represents a pages layout widget.

func (*Pages) AddPage

func (p *Pages) AddPage(pageName string, widget Widget, resize, visible bool) error

AddPage adds a page to the pages widget.

func (*Pages) Delete

func (w *Pages) Delete() error

Delete removes the widget from the server.

func (*Pages) GetCurrentPage

func (p *Pages) GetCurrentPage() (string, error)

GetCurrentPage gets the currently visible page name.

func (*Pages) GetProperties

func (w *Pages) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (*Pages) ID

func (w *Pages) ID() string

ID returns the widget's unique identifier.

func (*Pages) RemovePage

func (p *Pages) RemovePage(pageName string) error

RemovePage removes a page from the pages widget.

func (*Pages) SetBorder

func (w *Pages) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (*Pages) SetFocus

func (w *Pages) SetFocus() error

SetFocus sets focus to this widget.

func (*Pages) SetTitle

func (w *Pages) SetTitle(title string) error

SetTitle sets the widget's title.

func (*Pages) ShowPage

func (p *Pages) ShowPage(pageName string) error

ShowPage shows a specific page.

type PagesBuilder

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

PagesBuilder provides a fluent interface for creating pages widgets.

func (*PagesBuilder) Border

func (b *PagesBuilder) Border(border bool) *PagesBuilder

Border sets whether the pages has a border.

func (*PagesBuilder) Build

func (b *PagesBuilder) Build() (*Pages, error)

Build creates the pages widget on the server.

func (*PagesBuilder) PageNameColor

func (b *PagesBuilder) PageNameColor(color *pb.Color) *PagesBuilder

PageNameColor sets the page name color.

func (*PagesBuilder) ShowPageNames

func (b *PagesBuilder) ShowPageNames(show bool) *PagesBuilder

ShowPageNames sets whether to show page names.

func (*PagesBuilder) Title

func (b *PagesBuilder) Title(title string) *PagesBuilder

Title sets the pages title.

type ProgressBar

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

ProgressBar represents a progress bar widget.

func (*ProgressBar) Delete

func (w *ProgressBar) Delete() error

Delete removes the widget from the server.

func (*ProgressBar) GetLabel

func (pbar *ProgressBar) GetLabel() (string, error)

GetLabel returns the progress bar label.

func (*ProgressBar) GetMax

func (pbar *ProgressBar) GetMax() (int, error)

GetMax returns the maximum progress value.

func (*ProgressBar) GetProgress

func (pbar *ProgressBar) GetProgress() (int, error)

GetProgress returns the current progress value.

func (*ProgressBar) GetProperties

func (w *ProgressBar) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (*ProgressBar) ID

func (w *ProgressBar) ID() string

ID returns the widget's unique identifier.

func (*ProgressBar) SetBorder

func (w *ProgressBar) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (*ProgressBar) SetFocus

func (w *ProgressBar) SetFocus() error

SetFocus sets focus to this widget.

func (*ProgressBar) SetLabel

func (pbar *ProgressBar) SetLabel(label string) error

SetLabel sets the progress bar label.

func (*ProgressBar) SetMax

func (pbar *ProgressBar) SetMax(max int) error

SetMax sets the maximum progress value.

func (*ProgressBar) SetProgress

func (pbar *ProgressBar) SetProgress(progress int) error

SetProgress sets the current progress value.

func (*ProgressBar) SetShowPercentage

func (pbar *ProgressBar) SetShowPercentage(show bool) error

SetShowPercentage enables or disables percentage display.

func (*ProgressBar) SetTitle

func (w *ProgressBar) SetTitle(title string) error

SetTitle sets the widget's title.

type ProgressBarBuilder

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

ProgressBarBuilder provides a fluent interface for creating progress bar widgets.

func (*ProgressBarBuilder) Border

func (b *ProgressBarBuilder) Border(border bool) *ProgressBarBuilder

Border sets whether the progress bar has a border.

func (*ProgressBarBuilder) Build

func (b *ProgressBarBuilder) Build() (*ProgressBar, error)

Build creates the progress bar widget on the server.

func (*ProgressBarBuilder) EmptyChar

func (b *ProgressBarBuilder) EmptyChar(char string) *ProgressBarBuilder

EmptyChar sets the character used for the empty portion.

func (*ProgressBarBuilder) EmptyColor

func (b *ProgressBarBuilder) EmptyColor(color *pb.Color) *ProgressBarBuilder

EmptyColor sets the color of the empty portion.

func (*ProgressBarBuilder) FilledChar

func (b *ProgressBarBuilder) FilledChar(char string) *ProgressBarBuilder

FilledChar sets the character used for the filled portion.

func (*ProgressBarBuilder) FilledColor

func (b *ProgressBarBuilder) FilledColor(color *pb.Color) *ProgressBarBuilder

FilledColor sets the color of the filled portion.

func (*ProgressBarBuilder) Label

func (b *ProgressBarBuilder) Label(label string) *ProgressBarBuilder

Label sets the progress bar label.

func (*ProgressBarBuilder) Max

Max sets the maximum progress value.

func (*ProgressBarBuilder) Progress

func (b *ProgressBarBuilder) Progress(progress int) *ProgressBarBuilder

Progress sets the current progress value.

func (*ProgressBarBuilder) ShowPercentage

func (b *ProgressBarBuilder) ShowPercentage(show bool) *ProgressBarBuilder

ShowPercentage enables or disables percentage display.

func (*ProgressBarBuilder) Title

func (b *ProgressBarBuilder) Title(title string) *ProgressBarBuilder

Title sets the progress bar's title (border title).

type RecordedEvent

type RecordedEvent struct {
	Event     *Event
	Timestamp time.Time
}

RecordedEvent is an event with timestamp.

type ResizeEvent

type ResizeEvent struct {
	Width  int
	Height int
}

ResizeEvent represents a screen resize event.

type RetryOptions

type RetryOptions struct {
	// MaxRetries is the maximum number of retry attempts (0 = infinite).
	MaxRetries int

	// InitialDelay is the initial delay before first retry.
	InitialDelay time.Duration

	// MaxDelay is the maximum delay between retries.
	MaxDelay time.Duration

	// BackoffStrategy determines how delays increase.
	BackoffStrategy BackoffStrategy

	// Multiplier for exponential/linear backoff (default: 2.0).
	Multiplier float64

	// JitterFactor adds randomness to delays to prevent thundering herd.
	// A value of 0.2 means delays vary by ±20% (e.g., 1s becomes 0.8-1.2s).
	// Default: 0.2 (20% jitter).
	JitterFactor float64

	// OnReconnecting is called when reconnection starts.
	OnReconnecting func(attempt int, delay time.Duration)

	// OnReconnected is called when reconnection succeeds.
	OnReconnected func(attempt int)

	// OnReconnectFailed is called when reconnection fails.
	OnReconnectFailed func(attempt int, err error)
}

RetryOptions configures reconnection behavior.

func DefaultRetryOptions

func DefaultRetryOptions() RetryOptions

DefaultRetryOptions returns sensible default retry options.

type Selection

type Selection struct {
	HasSelection bool
	SelectedText string
	Start        int
	End          int
	FromRow      int
	FromColumn   int
	ToRow        int
	ToColumn     int
}

Selection holds selection state including text, byte offsets, and row/column coordinates.

type Table

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

Table represents a table widget.

func (*Table) Clear

func (t *Table) Clear() error

Clear clears the entire table.

func (*Table) Delete

func (w *Table) Delete() error

Delete removes the widget from the server.

func (*Table) GetCell

func (t *Table) GetCell(row, column int) (*pb.TableCell, error)

GetCell gets a single cell's content.

func (*Table) GetDimensions

func (t *Table) GetDimensions() (rows, columns int, err error)

GetDimensions returns the table dimensions.

func (*Table) GetProperties

func (w *Table) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (*Table) GetSelection

func (t *Table) GetSelection() (row, column int, err error)

GetSelection returns the current cell selection.

func (*Table) ID

func (w *Table) ID() string

ID returns the widget's unique identifier.

func (*Table) SetBorder

func (w *Table) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (*Table) SetCell

func (t *Table) SetCell(row, column int, cell *pb.TableCell) error

SetCell sets a single cell's content.

func (*Table) SetCells

func (t *Table) SetCells(cells []*pb.TableCellUpdate) (int, error)

SetCells sets multiple cells at once.

func (*Table) SetFixed

func (t *Table) SetFixed(fixedRows, fixedColumns int) error

SetFixed sets the number of fixed rows and columns.

func (*Table) SetFocus

func (w *Table) SetFocus() error

SetFocus sets focus to this widget.

func (*Table) SetSelection

func (t *Table) SetSelection(row, column int) error

SetSelection sets the current cell selection.

func (*Table) SetTitle

func (w *Table) SetTitle(title string) error

SetTitle sets the widget's title.

type TableBuilder

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

TableBuilder provides a fluent interface for creating table widgets.

func (*TableBuilder) Border

func (b *TableBuilder) Border(border bool) *TableBuilder

Border sets whether the table has a border.

func (*TableBuilder) Build

func (b *TableBuilder) Build() (*Table, error)

Build creates the table widget on the server.

func (*TableBuilder) Title

func (b *TableBuilder) Title(title string) *TableBuilder

Title sets the table title.

type TextArea

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

TextArea represents a multi-line text editor widget.

func (*TextArea) Delete

func (w *TextArea) Delete() error

Delete removes the widget from the server.

func (*TextArea) GetCursorPosition

func (ta *TextArea) GetCursorPosition() (*CursorPosition, error)

GetCursorPosition returns the current cursor position.

func (*TextArea) GetPlaceholder

func (ta *TextArea) GetPlaceholder() (string, error)

GetPlaceholder returns the current placeholder text.

func (*TextArea) GetProperties

func (w *TextArea) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (*TextArea) GetSelectedText

func (ta *TextArea) GetSelectedText() (string, error)

GetSelectedText returns the currently selected text.

func (*TextArea) GetSelection

func (ta *TextArea) GetSelection() (*Selection, error)

GetSelection returns the current selection range and text.

func (*TextArea) GetText

func (ta *TextArea) GetText() (string, error)

GetText returns the current text content.

func (*TextArea) HasSelection

func (ta *TextArea) HasSelection() (bool, error)

HasSelection checks if text is currently selected.

func (*TextArea) ID

func (w *TextArea) ID() string

ID returns the widget's unique identifier.

func (*TextArea) InsertTextAtCursor

func (ta *TextArea) InsertTextAtCursor(text string) error

InsertTextAtCursor inserts text at the current cursor position, replacing any selection.

func (*TextArea) SetBorder

func (w *TextArea) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (*TextArea) SetCursorPosition

func (ta *TextArea) SetCursorPosition(row, column int) error

SetCursorPosition moves the cursor to the specified row and column.

func (*TextArea) SetFocus

func (w *TextArea) SetFocus() error

SetFocus sets focus to this widget.

func (*TextArea) SetPlaceholder

func (ta *TextArea) SetPlaceholder(placeholder string) error

SetPlaceholder sets the placeholder text.

func (*TextArea) SetSelection

func (ta *TextArea) SetSelection(start, end int) error

SetSelection sets the selection range by byte offsets.

func (*TextArea) SetSuppressedKeys

func (ta *TextArea) SetSuppressedKeys(keys []string) error

SetSuppressedKeys configures keys that are suppressed from widget processing but still emitted as events. Format: "ctrl+d", "ctrl+p", "ctrl+i", etc.

func (*TextArea) SetText

func (ta *TextArea) SetText(text string) error

SetText sets the text area content.

func (*TextArea) SetTitle

func (w *TextArea) SetTitle(title string) error

SetTitle sets the widget's title.

type TextAreaBuilder

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

TextAreaBuilder provides a fluent interface for creating text area widgets.

func (*TextAreaBuilder) Border

func (b *TextAreaBuilder) Border(border bool) *TextAreaBuilder

Border sets whether the text area has a border.

func (*TextAreaBuilder) Build

func (b *TextAreaBuilder) Build() (*TextArea, error)

Build creates the text area widget on the server.

func (*TextAreaBuilder) MaxLength

func (b *TextAreaBuilder) MaxLength(maxLength int) *TextAreaBuilder

MaxLength sets the maximum text length.

func (*TextAreaBuilder) Placeholder

func (b *TextAreaBuilder) Placeholder(placeholder string) *TextAreaBuilder

Placeholder sets the placeholder text.

func (*TextAreaBuilder) PlaceholderColor

func (b *TextAreaBuilder) PlaceholderColor(color *pb.Color) *TextAreaBuilder

PlaceholderColor sets the placeholder text color.

func (*TextAreaBuilder) SuppressedKeys

func (b *TextAreaBuilder) SuppressedKeys(keys ...string) *TextAreaBuilder

SuppressedKeys sets keys that are suppressed from widget processing but still emitted as events. Format: "ctrl+d", "ctrl+p", "ctrl+i", "ctrl+space", etc.

func (*TextAreaBuilder) Text

func (b *TextAreaBuilder) Text(text string) *TextAreaBuilder

Text sets the initial text content.

func (*TextAreaBuilder) TextColor

func (b *TextAreaBuilder) TextColor(color *pb.Color) *TextAreaBuilder

TextColor sets the text color.

func (*TextAreaBuilder) Title

func (b *TextAreaBuilder) Title(title string) *TextAreaBuilder

Title sets the text area's title (border title).

func (*TextAreaBuilder) WordWrap

func (b *TextAreaBuilder) WordWrap(wrap bool) *TextAreaBuilder

WordWrap sets whether text wraps at word boundaries.

type TextView

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

TextView represents a text view widget.

func (*TextView) Delete

func (w *TextView) Delete() error

Delete removes the widget from the server.

func (*TextView) GetProperties

func (w *TextView) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (*TextView) GetText

func (tv *TextView) GetText() (string, error)

GetText returns the current text content of the text view.

func (*TextView) ID

func (w *TextView) ID() string

ID returns the widget's unique identifier.

func (*TextView) SetBorder

func (w *TextView) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (*TextView) SetFocus

func (w *TextView) SetFocus() error

SetFocus sets focus to this widget.

func (*TextView) SetText

func (tv *TextView) SetText(text string) error

SetText sets the text content.

func (*TextView) SetTitle

func (w *TextView) SetTitle(title string) error

SetTitle sets the widget's title.

type TextViewBuilder

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

TextViewBuilder provides a fluent interface for creating text view widgets.

func (*TextViewBuilder) Border

func (b *TextViewBuilder) Border(border bool) *TextViewBuilder

Border sets whether the text view has a border.

func (*TextViewBuilder) Build

func (b *TextViewBuilder) Build() (*TextView, error)

Build creates the text view widget on the server.

func (*TextViewBuilder) DynamicColors

func (b *TextViewBuilder) DynamicColors(enabled bool) *TextViewBuilder

DynamicColors enables dynamic color tags.

func (*TextViewBuilder) Text

func (b *TextViewBuilder) Text(text string) *TextViewBuilder

Text sets the initial text content.

func (*TextViewBuilder) Title

func (b *TextViewBuilder) Title(title string) *TextViewBuilder

Title sets the text view title.

func (*TextViewBuilder) WordWrap

func (b *TextViewBuilder) WordWrap(wrap bool) *TextViewBuilder

WordWrap sets whether text wraps.

type Theme

type Theme struct {
	// Primary colors
	PrimaryColor    *pb.Color
	SecondaryColor  *pb.Color
	BackgroundColor *pb.Color
	SurfaceColor    *pb.Color

	// Text colors
	TextColor          *pb.Color
	TextSecondaryColor *pb.Color
	TextDisabledColor  *pb.Color

	// Interactive element colors
	ButtonColor     *pb.Color
	ButtonTextColor *pb.Color
	InputBackground *pb.Color
	InputText       *pb.Color

	// Status colors
	SuccessColor *pb.Color
	WarningColor *pb.Color
	ErrorColor   *pb.Color
	InfoColor    *pb.Color

	// Border and divider colors
	BorderColor  *pb.Color
	DividerColor *pb.Color

	// Selection colors
	SelectionColor *pb.Color
	HighlightColor *pb.Color
}

Theme defines a consistent color scheme for widgets.

type TreeView

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

TreeView represents a tree view widget.

func (*TreeView) AddChild

func (tv *TreeView) AddChild(parentID *pb.TreeNodeId, node *pb.TreeNode) (*pb.TreeNodeId, error)

AddChild adds a child node to a parent node.

func (*TreeView) Delete

func (w *TreeView) Delete() error

Delete removes the widget from the server.

func (*TreeView) GetChildren

func (tv *TreeView) GetChildren(nodeID *pb.TreeNodeId) ([]*pb.TreeNodeInfo, error)

GetChildren gets the children of a node.

func (*TreeView) GetProperties

func (w *TreeView) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (*TreeView) GetSelection

func (tv *TreeView) GetSelection() (*pb.TreeNodeId, string, string, error)

GetSelection gets the currently selected node.

func (*TreeView) ID

func (w *TreeView) ID() string

ID returns the widget's unique identifier.

func (*TreeView) RemoveNode

func (tv *TreeView) RemoveNode(nodeID *pb.TreeNodeId) error

RemoveNode removes a node from the tree.

func (*TreeView) SetBorder

func (w *TreeView) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (*TreeView) SetExpanded

func (tv *TreeView) SetExpanded(nodeID *pb.TreeNodeId, expanded bool) error

SetExpanded expands or collapses a node.

func (*TreeView) SetFocus

func (w *TreeView) SetFocus() error

SetFocus sets focus to this widget.

func (*TreeView) SetRoot

func (tv *TreeView) SetRoot(node *pb.TreeNode) (*pb.TreeNodeId, error)

SetRoot sets the root node of the tree.

func (*TreeView) SetSelection

func (tv *TreeView) SetSelection(nodeID *pb.TreeNodeId) error

SetSelection sets the currently selected node.

func (*TreeView) SetTitle

func (w *TreeView) SetTitle(title string) error

SetTitle sets the widget's title.

type TreeViewBuilder

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

TreeViewBuilder provides a fluent interface for creating tree view widgets.

func (*TreeViewBuilder) Border

func (b *TreeViewBuilder) Border(border bool) *TreeViewBuilder

Border sets whether the tree view has a border.

func (*TreeViewBuilder) Build

func (b *TreeViewBuilder) Build() (*TreeView, error)

Build creates the tree view widget on the server.

func (*TreeViewBuilder) NodeTextColor

func (b *TreeViewBuilder) NodeTextColor(color *pb.Color) *TreeViewBuilder

NodeTextColor sets the node text color.

func (*TreeViewBuilder) SelectedBackgroundColor

func (b *TreeViewBuilder) SelectedBackgroundColor(color *pb.Color) *TreeViewBuilder

SelectedBackgroundColor sets the selected node background color.

func (*TreeViewBuilder) SelectedTextColor

func (b *TreeViewBuilder) SelectedTextColor(color *pb.Color) *TreeViewBuilder

SelectedTextColor sets the selected node text color.

func (*TreeViewBuilder) ShowGraphics

func (b *TreeViewBuilder) ShowGraphics(show bool) *TreeViewBuilder

ShowGraphics sets whether to show tree graphics.

func (*TreeViewBuilder) Title

func (b *TreeViewBuilder) Title(title string) *TreeViewBuilder

Title sets the tree view title.

func (*TreeViewBuilder) TopLevelPrefix

func (b *TreeViewBuilder) TopLevelPrefix(prefix string) *TreeViewBuilder

TopLevelPrefix sets the prefix for top-level nodes.

type Widget

type Widget interface {
	// ID returns the widget's unique identifier.
	ID() string

	// Delete removes the widget from the server.
	Delete() error

	// SetTitle sets the widget's title.
	SetTitle(title string) error

	// SetBorder sets whether the widget has a border.
	SetBorder(border bool) error

	// SetFocus sets focus to this widget.
	SetFocus() error

	// GetProperties returns the widget's current properties.
	GetProperties() (*pb.WidgetProperties, error)
}

Widget is the interface that all widgets implement.

type WidgetEvent

type WidgetEvent struct {
	WidgetID string
	Type     string
	Data     map[string]string
}

WidgetEvent represents a widget-specific event.

type Window

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

Window represents a window widget.

func (*Window) Delete

func (w *Window) Delete() error

Delete removes the widget from the server.

func (*Window) GetProperties

func (w *Window) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (*Window) GetState

func (w *Window) GetState() (*pb.WindowGetStateResponse, error)

GetState returns the window state and geometry.

func (*Window) ID

func (w *Window) ID() string

ID returns the widget's unique identifier.

func (*Window) Maximize

func (w *Window) Maximize() error

Maximize maximizes the window.

func (*Window) Minimize

func (w *Window) Minimize() error

Minimize minimizes the window.

func (*Window) Move

func (w *Window) Move(x, y int32) error

Move moves the window to the given position.

func (*Window) Resize

func (w *Window) Resize(width, height int32) error

Resize resizes the window.

func (*Window) Restore

func (w *Window) Restore() error

Restore restores the window to normal state.

func (*Window) SetBorder

func (w *Window) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (*Window) SetConstraints

func (w *Window) SetConstraints(constraints *pb.WindowConstraints) error

SetConstraints sets window constraints.

func (*Window) SetContent

func (w *Window) SetContent(child *baseWidget) error

SetContent sets the child widget content of the window.

func (*Window) SetFocus

func (w *Window) SetFocus() error

SetFocus sets focus to this widget.

func (*Window) SetTitle

func (w *Window) SetTitle(title string) error

SetTitle sets the widget's title.

type WindowBuilder

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

WindowBuilder provides a fluent interface for creating window widgets.

func (*WindowBuilder) ActiveBorderColor

func (b *WindowBuilder) ActiveBorderColor(color *pb.Color) *WindowBuilder

ActiveBorderColor sets the border color when active.

func (*WindowBuilder) Build

func (b *WindowBuilder) Build() (*Window, error)

Build creates the window widget on the server.

func (*WindowBuilder) Closable

func (b *WindowBuilder) Closable(v bool) *WindowBuilder

Closable sets whether the window has a close button.

func (*WindowBuilder) InactiveBorderColor

func (b *WindowBuilder) InactiveBorderColor(color *pb.Color) *WindowBuilder

InactiveBorderColor sets the border color when inactive.

func (*WindowBuilder) MaxSize

func (b *WindowBuilder) MaxSize(width, height int32) *WindowBuilder

MaxSize sets the maximum window size.

func (*WindowBuilder) Maximizable

func (b *WindowBuilder) Maximizable(v bool) *WindowBuilder

Maximizable sets whether the window has a maximize button.

func (*WindowBuilder) MinSize

func (b *WindowBuilder) MinSize(width, height int32) *WindowBuilder

MinSize sets the minimum window size.

func (*WindowBuilder) Minimizable

func (b *WindowBuilder) Minimizable(v bool) *WindowBuilder

Minimizable sets whether the window has a minimize button.

func (*WindowBuilder) Movable

func (b *WindowBuilder) Movable(v bool) *WindowBuilder

Movable sets whether the window can be moved.

func (*WindowBuilder) Rect

func (b *WindowBuilder) Rect(x, y, width, height int32) *WindowBuilder

Rect sets the initial window position and size.

func (*WindowBuilder) Resizable

func (b *WindowBuilder) Resizable(v bool) *WindowBuilder

Resizable sets whether the window can be resized.

func (*WindowBuilder) Title

func (b *WindowBuilder) Title(title string) *WindowBuilder

Title sets the window title.

func (*WindowBuilder) TitleBarColor

func (b *WindowBuilder) TitleBarColor(color *pb.Color) *WindowBuilder

TitleBarColor sets the title bar background color.

func (*WindowBuilder) TitleBarTextColor

func (b *WindowBuilder) TitleBarTextColor(color *pb.Color) *WindowBuilder

TitleBarTextColor sets the title bar text color.

type WindowManager

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

WindowManager represents a window manager widget.

func (*WindowManager) AddWindow

func (wm *WindowManager) AddWindow(win *Window) error

AddWindow adds a window to the manager.

func (*WindowManager) BringToFront

func (wm *WindowManager) BringToFront(win *Window) error

BringToFront brings a window to the front.

func (*WindowManager) Delete

func (w *WindowManager) Delete() error

Delete removes the widget from the server.

func (*WindowManager) GetProperties

func (w *WindowManager) GetProperties() (*pb.WidgetProperties, error)

GetProperties returns the widget's current properties.

func (*WindowManager) GetZOrder

func (wm *WindowManager) GetZOrder() ([]string, error)

GetZOrder returns the z-order of windows (front to back).

func (*WindowManager) ID

func (w *WindowManager) ID() string

ID returns the widget's unique identifier.

func (*WindowManager) RemoveWindow

func (wm *WindowManager) RemoveWindow(win *Window) error

RemoveWindow removes a window from the manager.

func (*WindowManager) SendToBack

func (wm *WindowManager) SendToBack(win *Window) error

SendToBack sends a window to the back.

func (*WindowManager) SetBorder

func (w *WindowManager) SetBorder(border bool) error

SetBorder sets whether the widget has a border.

func (*WindowManager) SetFocus

func (w *WindowManager) SetFocus() error

SetFocus sets focus to this widget.

func (*WindowManager) SetTitle

func (w *WindowManager) SetTitle(title string) error

SetTitle sets the widget's title.

type WindowManagerBuilder

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

WindowManagerBuilder provides a fluent interface for creating window manager widgets.

func (*WindowManagerBuilder) BackgroundColor

func (b *WindowManagerBuilder) BackgroundColor(color *pb.Color) *WindowManagerBuilder

BackgroundColor sets the background color.

func (*WindowManagerBuilder) Build

func (b *WindowManagerBuilder) Build() (*WindowManager, error)

Build creates the window manager widget on the server.

func (*WindowManagerBuilder) Title

Title sets the window manager title.

Directories

Path Synopsis
Package testing provides testing utilities for Yutani applications.
Package testing provides testing utilities for Yutani applications.

Jump to

Keyboard shortcuts

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