Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Gaurav-Gosain/tuios/llms.txt
Use this file to discover all available pages before exploring further.
Window Manager
OS Struct
Location:internal/app/os.go:80-217
The OS struct is the central application state managing all windows, workspaces, and user interactions:
- Window lifecycle: Create, focus, close windows (
os.go:471-562,os.go:574-688) - Workspace management: Switch workspaces, move windows between them (
internal/app/workspace.go) - Mode switching: Toggle between Window Management and Terminal modes (
os.go:23-31) - State synchronization: Sync state to daemon for multi-client sessions (
os.go:114-115)
Window Lifecycle
Creation (internal/app/os.go:471-562):
internal/app/os.go:574-688):
Terminal Emulation
Window Component
Location:internal/terminal/window.go
Each terminal window manages:
- PTY lifecycle: Spawn, resize, close pseudo-terminal
- VT emulator: Parse ANSI output and maintain screen buffer
- Content caching: Cache rendered output to avoid redundant parsing
- Selection state: Track text selection for copy mode
VT Emulator
Location:internal/vt/emulator.go:21-100
The VT emulator implements ANSI/VT100 terminal emulation:
- ANSI parser: State machine for control sequences (
internal/vt/emulator.go) - Screen buffers: Main and alternate screen support (
internal/vt/screen.go) - Scrollback: 10,000 line history buffer (
internal/vt/scrollback.go) - CSI handlers: Cursor movement, colors, attributes (
internal/vt/csi_*.go)
- Cursor positioning (CUP, CUU, CUD, CUF, CUB)
- Erase operations (ED, EL)
- SGR attributes (colors, bold, italic, underline)
- Scrolling regions (DECSTBM)
- Alternate screen (DECSET/DECRST 1049)
internal/vt/csi.go for CSI sequence routing.
PTY Interface
Platform-specific implementations: Unix (internal/terminal/pty_unix.go):
- Uses
/dev/ptmxfor PTY allocation termiosfor terminal attributesSIGWINCHfor window size changes
internal/terminal/pty_windows.go):
- Uses ConPTY API (Windows 10+)
- Automatic shell detection (PowerShell, cmd.exe)
- Resize via ConPTY resize API
- Check
$SHELLenvironment variable (Unix) - Fallback to
/bin/bash,/bin/sh(Unix) - Fallback to
powershell.exe,cmd.exe(Windows)
Rendering Engine
Layer Composition
Location:internal/app/render.go:14-144
The rendering engine uses Lipgloss layers for compositing:
- Viewport culling: Skip windows outside visible area (
render.go:57-64) - Content caching: Reuse cached layers when content unchanged (
render.go:83-86) - Z-index sorting: Stack windows by priority (
render.go:115-118)
Style Cache
Location:internal/app/stylecache.go
The style cache provides 40-60% allocation reduction by caching Lipgloss styles:
stylecache.go:120-153):
- Hash cell attributes: Combine foreground, background, bold, italic, etc.
- Cache lookup: Check if style with identical attributes exists
- Reuse or create: Return cached style on hit, create and cache on miss
- Automatic eviction: When full, remove half the entries (LRU approximation)
Input System
Input Handler
Location:internal/input/handler.go:19-83
The input handler routes events based on current mode:
Keyboard Handling
Location:internal/input/keyboard.go
Mode-based routing:
Ctrl+B, w: Workspace commandsCtrl+B, m: Minimize/restoreCtrl+B, t: Tiling commandsCtrl+B, [: Copy mode
internal/config/registry.go for full keybind registry.
Mouse Handling
Location:internal/input/mouse.go
Mouse events:
- Drag: Click and hold title bar, move mouse
- Resize: Click and hold corner, drag to new size
- Snap: Drag to screen edge for auto-snap
Configuration System
Config Loading
Location:internal/config/userconfig.go
TUIOS loads configuration from TOML files:
- System config:
/etc/tuios/config.toml - User config:
~/.config/tuios/config.toml - CLI flags: Override config values
Keybind Registry
Location:internal/config/registry.go
The keybind registry maps key sequences to actions:
/keybindings documentation for full list of actions.
Layout System
BSP Tiling
Location:internal/layout/bsp.go:90-100
Binary Space Partitioning (BSP) provides flexible window tiling:
- Spiral: Alternating vertical/horizontal splits (bspwm-style)
- Longest Side: Split along longest dimension
- Alternate: Strict vertical/horizontal alternation
- Insert window:
tree.InsertWindow(id, scheme) - Remove window:
tree.RemoveWindow(id) - Apply layout:
tree.ApplyLayout(rect) - Rotate splits:
tree.Rotate(direction)
/features/tiling for user guide.
Related Documentation
- Architecture - Overall architecture
- Performance - Optimization details
- Configuration - Config options