Terminal UI Engine
This section documents the internal mechanics of the lightweight terminal UI rendering engine within Aeroflare.
The terminal UI engine (internal/ui/) is a lightweight, dependency-free implementation relying solely on the standard fmt and strings packages. It does not use heavy TUI frameworks, opting instead for manual string manipulation and ANSI escape codes.
Box Rendering (internal/ui/box.go)
The PrintSummaryBox function constructs framed summary boxes for data presentation.
- Dynamic Sizing: It calculates the required box width by iterating through the
BoxFieldstructs (which containLabelandValue), determining the maximum label width, and adjusting the overall width to accommodate the longest combined line. - Unicode Borders: It uses standard Unicode box-drawing characters (
╭,─,╮,│,├,┤,╰,╯) to construct the frame. Formatting ensures labels are right-aligned to a common colon boundary.
Table Rendering (internal/ui/table.go)
The PrintTable function generates Nushell-style data tables.
- Dynamic Column Widths: It performs a pass over all headers and rows (
[][]string) to compute the maximum width (colWidths) needed for each column. - ANSI Colors: Hardcoded ANSI escape sequences (
\x1b[90mfor Gray borders,\x1b[36mfor Cyan headers, and\x1b[0mto Reset) are used to provide distinct styling without external dependencies. - Intersection Drawing: A helper function
drawLinedynamically constructs the horizontal border lines, taking care of placing intersection characters (┬,┼,┴) accurately based on the calculatedcolWidths.