How Ultraviolet's layered primitives work together
mainUltraviolet is built as a stack of abstractions to decouple application logic from terminal-specific details:
- Terminal: The top-level manager for the application lifecycle (raw mode, input loop, start/stop). Use
uv.DefaultTerminal()oruv.NewTerminal(console, opts). - TerminalScreen: The concrete implementation of the screen state. It manages the alternate buffer, cursor, mouse modes, and window titles. Access it via
terminal.Screen(). - Screen (Interface): A minimal interface (
Bounds,CellAt,SetCell,WidthMethod) that allows you to write decoupled code.TerminalScreen,Buffer,Window, andScreenBufferall implement this. - Buffer / Window: Off-screen cell buffers.
Bufferis a flat grid;Windowadds hierarchical relationships and shared-buffer views. Both implementScreenandDrawable. - screen package: Drawing helpers that operate on any
Screen. IncludesContextfor styled text (Print,DrawString) and utilities likeClearandFill. - layout package: A constraint-based layout solver using the Cassowary algorithm. It allows partitioning space using constraints like
Len,Min,Max,Percent,Ratio, andFill.