tui

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package tui implements the interactive terminal dashboard for portctl.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HelpEntries

func HelpEntries() []struct{ Key, Desc string }

HelpEntries returns ordered help text for the help overlay.

func RenderGroupHeader

func RenderGroupHeader(g ProcessGroup, width int, selected bool) string

RenderGroupHeader renders one collapsed group row: "node (5 ports: 3000, 3001, 5173, 5174, 8080)"

func RenderTableHeader

func RenderTableHeader(width int) string

RenderTableHeader returns the styled header row.

func RenderTableRow

func RenderTableRow(e *scanner.PortEntry, width int, selected bool) string

RenderTableRow returns a styled row for a single entry.

func SortEntries

func SortEntries(entries []scanner.PortEntry, col SortColumn)

SortEntries sorts entries by the given column.

Types

type Config

type Config struct {
	DockerClient docker.Client
	Interval     time.Duration
}

Config holds TUI configuration.

type DetailModel

type DetailModel struct {
	Entry   *scanner.PortEntry
	Visible bool
}

DetailModel holds the detail panel state.

func (*DetailModel) View

func (d *DetailModel) View(height int) string

View renders the detail panel for the selected entry.

type FilterModel

type FilterModel struct {
	Input  string
	Active bool
}

FilterModel holds the state of the inline filter bar.

func (*FilterModel) Apply

func (f *FilterModel) Apply(entries []scanner.PortEntry) []scanner.PortEntry

Apply returns only entries matching the filter text. Matches against port number (prefix) or process name (substring, case-insensitive).

func (*FilterModel) View

func (f *FilterModel) View(totalCount, matchCount int) string

View renders the filter bar.

type KeyMap

type KeyMap struct {
	Up      key.Binding
	Down    key.Binding
	Filter  key.Binding
	Escape  key.Binding
	Enter   key.Binding
	Kill    key.Binding
	Sort    key.Binding
	Group   key.Binding
	Refresh key.Binding
	Help    key.Binding
	Quit    key.Binding
	Yes     key.Binding
	No      key.Binding
}

KeyMap holds all keybindings for the TUI.

func DefaultKeyMap

func DefaultKeyMap() KeyMap

DefaultKeyMap returns the standard keybindings.

type Model

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

Model is the top-level bubbletea model for the TUI dashboard.

func NewModel

func NewModel(s scanner.PortScanner, k *killer.DefaultKiller, cfg Config) Model

NewModel creates a new TUI model.

func (Model) Init

func (m Model) Init() tea.Cmd

Init starts the first scan and the tick timer.

func (Model) Update

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

Update handles all messages.

func (Model) View

func (m Model) View() string

View renders the entire TUI.

type ProcessGroup

type ProcessGroup struct {
	Name    string
	Entries []scanner.PortEntry
}

ProcessGroup is a set of entries collapsed under one process name.

func GroupByProcess

func GroupByProcess(entries []scanner.PortEntry) []ProcessGroup

GroupByProcess collapses entries by process name, preserving order of first appearance.

type SortColumn

type SortColumn int

SortColumn identifies which column the table is sorted by.

const (
	SortPort SortColumn = iota
	SortPID
	SortProcess
	SortUser
	SortUptime
)

Sort column constants.

func NextSortColumn

func NextSortColumn(c SortColumn) SortColumn

NextSortColumn cycles to the next sort column.

func (SortColumn) String

func (s SortColumn) String() string

String returns the display label for a sort column.

Jump to

Keyboard shortcuts

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