Documentation
¶
Index ¶
- Constants
- Variables
- func Backspace(value string, cursor int) (string, int)
- func ClampCursor(cursor, valueLen int) int
- func FormTheme() *huh.Styles
- func GetHelpItemAt(layout *HelpLineLayout, x, relY int) int
- func InsertRunes(value string, cursor int, runes []rune) (string, int)
- func IsMouseMsg(msg tea.Msg) bool
- func MouseXY(msg tea.Msg) (tea.Mouse, bool)
- func MoveCursorLeft(cursor int) int
- func MoveCursorRight(cursor, valueLen int) int
- func NewCustomPortsInput() textinput.Model
- func RenderHelpLine(layout *HelpLineLayout, navPrefix string, maxWidth int, hoveredIndex int) string
- func RenderHelpOverlay(view string, config HelpConfig) string
- func WrapWords(s string, maxWidth int) string
- type CustomPortInput
- func (c CustomPortInput) HandleKey(action PortInputAction, keyMsg tea.KeyPressMsg) (CustomPortInput, tea.Cmd)
- func (c CustomPortInput) Prepare(focused bool) (CustomPortInput, tea.Cmd)
- func (c CustomPortInput) SetValue(v string) CustomPortInput
- func (c CustomPortInput) UpdateNonKey(msg tea.Msg) (CustomPortInput, tea.Cmd)
- type HelpConfig
- type HelpItem
- type HelpLineLayout
- type HelpMouseResult
- type PortInputAction
Constants ¶
const CustomPortsDescription = "e.g. 22,80,443,8000-9000 (valid: 1-65535)"
const HelpSeparator = " • "
Variables ¶
var ( TitleStyle = lipgloss.NewStyle(). Bold(true). Foreground(Color.Info) // Help overlay styles HelpBoxStyle = lipgloss.NewStyle(). Border(lipgloss.RoundedBorder()). BorderForeground(Color.Selection). Padding(0, 1). Foreground(Color.Info) HelpTitleStyle = lipgloss.NewStyle(). Foreground(Color.Selection). Bold(true) HelpIconStyle = lipgloss.NewStyle(). Foreground(Color.Selection). Bold(true) // Common text styles HelpTextStyle = lipgloss.NewStyle(). Foreground(Color.Help) InfoTextStyle = lipgloss.NewStyle(). Foreground(Color.Help) ErrorStyle = lipgloss.NewStyle(). Foreground(Color.Error). Bold(true) HighlightStyle = lipgloss.NewStyle(). Foreground(Color.Selection). Bold(true) MutedStyle = lipgloss.NewStyle(). Foreground(Color.Help). Italic(true) ItalicHelpStyle = lipgloss.NewStyle(). Foreground(Color.Help). Italic(true) ProgressGreenStyle = lipgloss.NewStyle(). Foreground(Color.Scanned) WarningStyle = lipgloss.NewStyle(). Foreground(Color.Scanning). Bold(true) // Card styles - shared rounded-border card look used across views CardStyle = lipgloss.NewStyle(). Border(lipgloss.RoundedBorder()). BorderForeground(Color.Help) SelectedCardStyle = lipgloss.NewStyle(). Border(lipgloss.RoundedBorder()). BorderForeground(Color.Selection) FolderStyle = lipgloss.NewStyle(). Foreground(Color.Folder) )
var Color = struct { Black color.Color Selection color.Color Help color.Color Info color.Color Error color.Color Scanned color.Color Scanning color.Color Folder color.Color }{ Black: lipgloss.Black, Selection: lipgloss.Yellow, Help: lipgloss.BrightBlack, Info: lipgloss.White, Error: lipgloss.Red, Scanned: lipgloss.Green, Scanning: lipgloss.Cyan, Folder: lipgloss.Blue, }
Color holds the global color palette used throughout the application. Uses lipgloss v2 ANSI 4-bit constants so colors adapt to any terminal theme.
Functions ¶
func ClampCursor ¶
ClampCursor ensures cursor position is within valid bounds [0, valueLen].
func FormTheme ¶
FormTheme returns a custom huh theme using only ANSI 16 colors so it follows the user's terminal theme.
func GetHelpItemAt ¶
func GetHelpItemAt(layout *HelpLineLayout, x, relY int) int
GetHelpItemAt returns the item index at (x, relY) within the helpline, where relY=0 is the first helpline row. Returns -1 on miss.
func InsertRunes ¶
InsertRunes inserts runes at cursor position, filtering to valid port characters. Valid characters: digits (0-9), comma (,), dash (-). Enforces validation rules per token (max 5 digits, single dash).
func IsMouseMsg ¶ added in v0.7.0
IsMouseMsg reports whether msg is any type of mouse message.
func MoveCursorLeft ¶
MoveCursorLeft moves cursor one position left, clamped to 0.
func MoveCursorRight ¶
MoveCursorRight moves cursor one position right, clamped to valueLen.
func NewCustomPortsInput ¶
func RenderHelpLine ¶
func RenderHelpLine(layout *HelpLineLayout, navPrefix string, maxWidth int, hoveredIndex int) string
RenderHelpLine renders the helpline with hover highlighting on hoveredIndex (-1 = none).
func RenderHelpOverlay ¶
func RenderHelpOverlay(view string, config HelpConfig) string
RenderHelpOverlay renders a centered help overlay with consistent styling
Types ¶
type CustomPortInput ¶
CustomPortInput manages custom port text entry state.
func (CustomPortInput) HandleKey ¶
func (c CustomPortInput) HandleKey(action PortInputAction, keyMsg tea.KeyPressMsg) (CustomPortInput, tea.Cmd)
HandleKey dispatches key actions (move, delete, insert) or falls through to textinput.
func (CustomPortInput) Prepare ¶
func (c CustomPortInput) Prepare(focused bool) (CustomPortInput, tea.Cmd)
Prepare initializes or re-syncs the textinput, optionally focusing it.
func (CustomPortInput) SetValue ¶
func (c CustomPortInput) SetValue(v string) CustomPortInput
SetValue replaces value and moves cursor to end.
func (CustomPortInput) UpdateNonKey ¶
func (c CustomPortInput) UpdateNonKey(msg tea.Msg) (CustomPortInput, tea.Cmd)
UpdateNonKey forwards non-keyboard messages to the textinput.
type HelpConfig ¶
type HelpConfig struct {
Title string
Content []string
Width int // Width of help box (default 56)
ViewWidth int // Width of the view/terminal for centering
ViewHeight int // Height of the view/terminal for placement
}
HelpConfig defines the content and appearance of a help overlay
type HelpItem ¶
type HelpItem struct {
Text string
Action int // view-specific action value
StartX int // starting X position in the rendered line
EndX int // ending X position in the rendered line
Line int // line index in wrapped helpline (0-based)
}
HelpItem represents a clickable help item with its rendered position. Action is an opaque int — each view casts it to its own action type.
type HelpLineLayout ¶
HelpLineLayout stores the computed layout for a helpline.
func BuildHelpLineLayout ¶
func BuildHelpLineLayout(items []HelpItem, navPrefix string, maxWidth int) *HelpLineLayout
BuildHelpLineLayout computes item positions for the given items and navPrefix, wrapping at maxWidth. navPrefix is the non-clickable leading text (e.g. "←/→/↑/↓").
type HelpMouseResult ¶ added in v0.7.0
type HelpMouseResult struct {
NewHoveredItem int // updated hover index (-1 = none)
ClickedAction int // action value of clicked item, or -1 if no click
Consumed bool // true if the click was in the help-line area
}
HelpMouseResult describes what happened when a mouse event hit the help line.
func HandleHelpLineMouse ¶ added in v0.7.0
func HandleHelpLineMouse(mouse tea.Mouse, msg tea.Msg, items []HelpItem, prefix string, helpLineY, maxWidth int) HelpMouseResult
HandleHelpLineMouse processes a mouse event against the help line area. It updates hover state on any mouse event and detects left-clicks on items.
type PortInputAction ¶
type PortInputAction struct {
MoveLeft bool
MoveRight bool
MoveHome bool
MoveEnd bool
Backspace bool
DeleteAll bool
InsertRunes bool
}
PortInputAction describes which editing operation a key maps to.
func PortInputActionFromKey ¶
func PortInputActionFromKey(key string, isRunes bool) PortInputAction
PortInputActionFromKey maps a key string to an action.