ui

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package ui provides consistent styling and components for the Waymon CLI

Index

Constants

This section is empty.

Variables

View Source
var (
	// Primary colors
	ColorPrimary   = lipgloss.Color("39")  // Bright blue
	ColorSecondary = lipgloss.Color("205") // Pink/magenta
	ColorSuccess   = lipgloss.Color("82")  // Green
	ColorWarning   = lipgloss.Color("214") // Orange
	ColorError     = lipgloss.Color("196") // Red
	ColorInfo      = lipgloss.Color("86")  // Cyan

	// Neutral colors
	ColorText      = lipgloss.Color("252") // Light gray
	ColorSubtle    = lipgloss.Color("241") // Medium gray
	ColorMuted     = lipgloss.Color("238") // Dark gray
	ColorHighlight = lipgloss.Color("255") // White

	// Status colors
	ColorConnected    = ColorSuccess
	ColorDisconnected = ColorError
	ColorActive       = ColorPrimary
	ColorInactive     = ColorSubtle
)

Color palette - consistent across the application

View Source
var (
	// Text styles
	TextStyle = lipgloss.NewStyle().
				Foreground(ColorText)

	SubtleStyle = lipgloss.NewStyle().
				Foreground(ColorSubtle)

	MutedStyle = lipgloss.NewStyle().
				Foreground(ColorMuted)

	// Emphasis styles
	BoldStyle = lipgloss.NewStyle().
				Bold(true)

	ItalicStyle = lipgloss.NewStyle().
				Italic(true)

	// Header styles
	HeaderStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(ColorPrimary).
				MarginBottom(1)

	SubheaderStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(ColorText)

	// Title styles
	TitleStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(ColorPrimary).
				Background(ColorMuted).
				Padding(0, 1)

	// Status styles
	SuccessStyle = lipgloss.NewStyle().
					Foreground(ColorSuccess)

	WarningStyle = lipgloss.NewStyle().
					Foreground(ColorWarning)

	ErrorStyle = lipgloss.NewStyle().
				Foreground(ColorError)

	InfoStyle = lipgloss.NewStyle().
				Foreground(ColorInfo)

	// Box styles
	BoxStyle = lipgloss.NewStyle().
				Border(lipgloss.RoundedBorder()).
				BorderForeground(ColorSubtle).
				Padding(1, 2)

	// List styles
	ListStyle = lipgloss.NewStyle().
				MarginLeft(2)

	ListItemStyle = lipgloss.NewStyle().
					Foreground(ColorText)

	// Spinner style
	SpinnerStyle = lipgloss.NewStyle().
					Foreground(ColorSecondary)
)

Base styles - building blocks for other styles

View Source
var (
	// Server UI styles
	ServerHeaderStyle = HeaderStyle.
						Render("Waymon Server")

	ServerStatusStyle = SubtleStyle

	// Client UI styles
	ClientHeaderStyle = HeaderStyle.
						Render("Waymon Client")

	ClientStatusStyle = SubtleStyle

	// Connection status styles
	ConnectedIndicator = lipgloss.NewStyle().
						Foreground(ColorConnected).
						Render("●")

	DisconnectedIndicator = lipgloss.NewStyle().
							Foreground(ColorDisconnected).
							Render("○")

	// Control help styles
	ControlsHeaderStyle = SubheaderStyle.
						MarginTop(1)

	ControlKeyStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(ColorPrimary)

	ControlDescStyle = lipgloss.NewStyle().
						Foreground(ColorText)
)

Component-specific styles

View Source
var (
	TableHeaderStyle = lipgloss.NewStyle().
						Bold(true).
						Foreground(ColorPrimary).
						BorderBottom(true).
						BorderStyle(lipgloss.NormalBorder()).
						BorderForeground(ColorSubtle)

	TableRowStyle = lipgloss.NewStyle().
					Foreground(ColorText)

	TableCellStyle = lipgloss.NewStyle().
					PaddingRight(2)
)

Table styles

View Source
var (
	SpinnerDot    = []string{"⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"}
	SpinnerLine   = []string{"|", "/", "-", "\\"}
	SpinnerCircle = []string{"◐", "◓", "◑", "◒"}
)

Spinner presets

View Source
var (
	// Status icons
	IconSuccess    = "✓"
	IconError      = "✗"
	IconWarning    = "!"
	IconInfo       = "i"
	IconProcessing = "~"
	IconCheck      = "✓"
	IconCross      = "✗"

	// Application icons
	IconSetup   = "»"
	IconServer  = "S"
	IconClient  = "C"
	IconConfig  = "*"
	IconNetwork = "#"
	IconSummary = "="
	IconSteps   = "→"
	IconPhase   = "·"

	// Progress icons
	IconProgress = "..."
	IconDone     = "✓"
	IconPending  = "·"
)

Icons and indicators for consistent app-wide usage (using simple ASCII/Unicode symbols)

View Source
var (
	// Setup header styles
	SetupHeaderStyle = lipgloss.NewStyle().
						Bold(true).
						Foreground(ColorPrimary)

	SetupPhaseStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(ColorInfo)

	// Setup result styles
	SetupSuccessStyle = lipgloss.NewStyle().
						Foreground(ColorSuccess)

	SetupErrorStyle = lipgloss.NewStyle().
					Foreground(ColorError)

	SetupWarningStyle = lipgloss.NewStyle().
						Foreground(ColorWarning)

	// Setup summary styles
	SummaryHeaderStyle = lipgloss.NewStyle().
						Bold(true).
						Foreground(ColorPrimary)

	SummarySuccessStyle = lipgloss.NewStyle().
						Foreground(ColorSuccess).
						Bold(true)

	SummaryWarningStyle = lipgloss.NewStyle().
						Foreground(ColorWarning).
						Bold(true)

	SummaryErrorStyle = lipgloss.NewStyle().
						Foreground(ColorError).
						Bold(true)

	// Action item styles
	ActionItemStyle = lipgloss.NewStyle().
					Foreground(ColorText).
					MarginLeft(1)
)

Setup-specific styles

Functions

func Center

func Center(width int, content string) string

Layout helpers

func CreateSeparator

func CreateSeparator(width int, char string) string

CreateSeparator creates a horizontal line separator

func FormatActionItem

func FormatActionItem(index int, action string) string

func FormatAppHeader

func FormatAppHeader(mode, status string) string

FormatAppHeader creates a uniform header in format: WAYMON | MODE | STATUS

func FormatControl

func FormatControl(key, desc string) string

Helper functions for consistent formatting

func FormatListItem

func FormatListItem(item string, active bool) string

func FormatNextStepsHeader

func FormatNextStepsHeader() string

func FormatSetupHeader

func FormatSetupHeader(title string) string

Setup formatting functions

func FormatSetupPhase

func FormatSetupPhase(phase string) string

func FormatSetupResult

func FormatSetupResult(success bool, step, message string) string

func FormatStatus

func FormatStatus(connected bool, status string) string

func FormatSummaryHeader

func FormatSummaryHeader(title string) string

func FormatSummaryStatus

func FormatSummaryStatus(allSuccess, needsRelogin bool) string
func Right(width int, content string) string

Types

type CaptureStartMsg

type CaptureStartMsg struct{}

Message types for reactive updates

type CaptureStopMsg

type CaptureStopMsg struct{}

Message types for reactive updates

type ClientConnectedMsg

type ClientConnectedMsg struct{ ClientAddr string }

Message types for reactive updates

type ClientDisconnectedMsg

type ClientDisconnectedMsg struct{ ClientAddr string }

Message types for reactive updates

type ClientModel

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

ClientModel represents the UI model for the client

func NewClientModel

func NewClientModel(serverAddr string, inputReceiver *client.InputReceiver, version string) *ClientModel

NewClientModel creates a new client UI model

func (*ClientModel) AddLogEntry

func (m *ClientModel) AddLogEntry(entry LogEntry)

AddLogEntry adds a new log entry to the client buffer

func (*ClientModel) Init

func (m *ClientModel) Init() tea.Cmd

Init initializes the client model

func (*ClientModel) SetMessage

func (m *ClientModel) SetMessage(msgType, message string)

SetMessage sets a temporary message

func (*ClientModel) SetProgram

func (m *ClientModel) SetProgram(p *tea.Program)

SetProgram sets the tea.Program for sending updates

func (*ClientModel) Update

func (m *ClientModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages for the client model

func (*ClientModel) View

func (m *ClientModel) View() string

View renders the client UI

type ConnectedMsg

type ConnectedMsg struct{}

Message types for reactive updates

type Connection

type Connection struct {
	Name      string
	Address   string
	Connected bool
	Active    bool
}

Connection represents a connection entry

type ConnectionList

type ConnectionList struct {
	Title       string
	Connections []Connection
	Width       int
}

ConnectionList shows a list of connections

func (*ConnectionList) View

func (c *ConnectionList) View() string

View renders the connection list

type Control

type Control struct {
	Key  string
	Desc string
}

Control represents a keyboard control

type ControlStatusMsg

type ControlStatusMsg struct {
	Status client.ControlStatus
}

ControlStatusMsg is sent when control status changes

type ControlsHelp

type ControlsHelp struct {
	Controls []Control
	Width    int
}

ControlsHelp displays keyboard controls

func (*ControlsHelp) View

func (c *ControlsHelp) View() string

View renders the controls help

type DebugServerModel

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

DebugServerModel is a minimal TUI for debugging

func NewDebugServerModel

func NewDebugServerModel() *DebugServerModel

NewDebugServerModel creates a debug server UI

func (*DebugServerModel) Init

func (m *DebugServerModel) Init() tea.Cmd

func (*DebugServerModel) Update

func (m *DebugServerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*DebugServerModel) View

func (m *DebugServerModel) View() string

type DisconnectedMsg

type DisconnectedMsg struct{}

Message types for reactive updates

type FullscreenServerModel

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

FullscreenServerModel represents the full-screen TUI model for the server

func NewFullscreenServerModel

func NewFullscreenServerModel(port int, serverName string) *FullscreenServerModel

NewFullscreenServerModel creates a new server UI model

func (*FullscreenServerModel) Init

func (m *FullscreenServerModel) Init() tea.Cmd

Init initializes the model

func (*FullscreenServerModel) Update

func (m *FullscreenServerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages

func (*FullscreenServerModel) View

func (m *FullscreenServerModel) View() string

View renders the UI

type InfoPanel

type InfoPanel struct {
	Title   string
	Content []string
	Width   int
}

InfoPanel represents a panel with information

func (*InfoPanel) View

func (p *InfoPanel) View() string

View renders the info panel

type InlineClientModel

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

InlineClientModel represents the inline UI model for the client

func NewInlineClientModel

func NewInlineClientModel(serverAddr string) *InlineClientModel

NewInlineClientModel creates a new inline client UI model

func (*InlineClientModel) AddLogEntry

func (m *InlineClientModel) AddLogEntry(entry LogEntry)

AddLogEntry adds a new log entry to the client buffer

func (*InlineClientModel) Init

func (m *InlineClientModel) Init() tea.Cmd

Init initializes the inline client model

func (*InlineClientModel) SetMessage

func (m *InlineClientModel) SetMessage(msgType, message string)

SetMessage sets a temporary message

func (*InlineClientModel) Update

func (m *InlineClientModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages for the inline client model

func (*InlineClientModel) View

func (m *InlineClientModel) View() string

View renders the inline client UI with status bar + logs

type InlineServerModel

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

InlineServerModel represents the inline UI model for the server

func NewInlineServerModel

func NewInlineServerModel(port int, serverName string) *InlineServerModel

NewInlineServerModel creates a new inline server UI model

func (*InlineServerModel) AddLogEntry

func (m *InlineServerModel) AddLogEntry(entry LogEntry)

AddLogEntry adds a new log entry to the buffer

func (*InlineServerModel) GetAuthChannel

func (m *InlineServerModel) GetAuthChannel() chan bool

GetAuthChannel returns the current auth channel for approval responses

func (*InlineServerModel) Init

func (m *InlineServerModel) Init() tea.Cmd

Init initializes the inline server model

func (*InlineServerModel) SetMessage

func (m *InlineServerModel) SetMessage(msgType, message string)

SetMessage sets a temporary message

func (*InlineServerModel) Update

func (m *InlineServerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages for the inline server model

func (*InlineServerModel) View

func (m *InlineServerModel) View() string

View renders the inline server UI with status bar + logs

type LogEntry

type LogEntry struct {
	Timestamp time.Time
	Level     string
	Message   string
}

LogEntry represents a single log entry with timestamp and content

type LogMsg

type LogMsg struct{ Entry LogEntry }

Message types for reactive updates

type Message

type Message struct {
	Type    MessageType
	Content string
}

Message displays a styled message

func (*Message) View

func (m *Message) View() string

View renders the message

type MessageType

type MessageType int

MessageType represents the type of message

const (
	MessageInfo MessageType = iota
	MessageSuccess
	MessageWarning
	MessageError
)

type Monitor

type Monitor struct {
	Name     string
	Size     string
	Position string
	Primary  bool
}

Monitor represents display information

type MonitorInfo

type MonitorInfo struct {
	Monitors []Monitor
	Width    int
}

MonitorInfo displays monitor configuration

func (*MonitorInfo) View

func (m *MonitorInfo) View() string

View renders the monitor info

type ProgressIndicator

type ProgressIndicator struct {
	Label          string
	Current        int
	Total          int
	Width          int
	ShowPercentage bool
}

ProgressIndicator shows progress

func (*ProgressIndicator) View

func (p *ProgressIndicator) View() string

View renders the progress indicator

type ReconnectingMsg

type ReconnectingMsg struct{ Status string }

Message types for reactive updates

type SSHAuthApprovedMsg

type SSHAuthApprovedMsg struct{ Fingerprint string }

Message types for reactive updates

type SSHAuthDeniedMsg

type SSHAuthDeniedMsg struct{ Fingerprint string }

Message types for reactive updates

type SSHAuthRequestMsg

type SSHAuthRequestMsg struct {
	ClientAddr   string
	PublicKey    string
	Fingerprint  string
	ResponseChan chan bool
}

Message types for reactive updates

type ServerModel

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

ServerModel represents the redesigned server UI model where server is the controller

func NewServerModel

func NewServerModel(port int, serverName, version string) *ServerModel

NewServerModel creates a new redesigned server UI model

func (*ServerModel) AddLogEntry

func (m *ServerModel) AddLogEntry(entry LogEntry)

AddLogEntry adds a new log entry to the buffer

func (*ServerModel) Init

func (m *ServerModel) Init() tea.Cmd

Init initializes the redesigned model

func (*ServerModel) SetClientManager

func (m *ServerModel) SetClientManager(cm *server.ClientManager)

SetClientManager sets the client manager for real-time updates

func (*ServerModel) SetServer

func (m *ServerModel) SetServer(srv interface{ Stop() })

SetServer sets the server instance for proper shutdown handling

func (*ServerModel) Update

func (m *ServerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages for the redesigned server UI

func (*ServerModel) View

func (m *ServerModel) View() string

View renders the redesigned server UI

type SetClientManagerMsg

type SetClientManagerMsg struct{ ClientManager interface{} }

Message types for reactive updates

type SetServerMsg

type SetServerMsg struct{ Server interface{ Stop() } }

Message types for reactive updates

type SimpleClientModel

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

SimpleClientModel is a simplified client UI

func NewSimpleClientModel

func NewSimpleClientModel(serverAddress, serverName string) *SimpleClientModel

NewSimpleClientModel creates a new simple client model

func (*SimpleClientModel) Init

func (m *SimpleClientModel) Init() tea.Cmd

func (*SimpleClientModel) SetCapturing

func (m *SimpleClientModel) SetCapturing(capturing bool)

SetCapturing updates the capturing state

func (*SimpleClientModel) SetEdgeDetector

func (m *SimpleClientModel) SetEdgeDetector(ed *input.EdgeDetector)

SetEdgeDetector sets the edge detector for the model

func (*SimpleClientModel) Update

func (m *SimpleClientModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*SimpleClientModel) View

func (m *SimpleClientModel) View() string

type SimpleServerModel

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

SimpleServerModel is a simplified server UI

func NewSimpleServerModel

func NewSimpleServerModel(port int, name string) *SimpleServerModel

NewSimpleServerModel creates a new simple server model

func (*SimpleServerModel) Init

func (m *SimpleServerModel) Init() tea.Cmd

func (*SimpleServerModel) Update

func (m *SimpleServerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*SimpleServerModel) View

func (m *SimpleServerModel) View() string

type StatusBar

type StatusBar struct {
	Width       int
	Title       string
	Status      string
	Connected   bool
	ShowSpinner bool
	// contains filtered or unexported fields
}

StatusBar represents a reusable status bar component

func NewStatusBar

func NewStatusBar(title string) *StatusBar

NewStatusBar creates a new status bar

func (*StatusBar) Init

func (s *StatusBar) Init() tea.Cmd

Init implements tea.Model

func (*StatusBar) Update

func (s *StatusBar) Update(msg tea.Msg) (*StatusBar, tea.Cmd)

Update implements tea.Model

func (*StatusBar) View

func (s *StatusBar) View() string

View renders the status bar

type TickMsg

type TickMsg time.Time

type WaitingApprovalMsg

type WaitingApprovalMsg struct{}

Message types for reactive updates

Jump to

Keyboard shortcuts

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