Building Modern TUI Applications in Go, Python and Rust
Preface
- About This Book
- Intended Audience
- Prerequisites
- How to Read This Book
- Conventions Used in This Book
- A Note on Versions
Chapter 1: The Terminal as a Device
- From Teletype to Terminal Emulator
- What Is an ANSI Escape Sequence Really
- Character Cells, Coordinates and Screen Buffers
- Standard Streams: stdin, stdout, stderr Explained
- Raw Mode vs Canonical Mode and Line Discipline
- Why This Matters for Your Application
Chapter 2: Input, Output and Events
- How Keyboard Input Travels from Key Press to Your Code
- Mouse Support in Terminals via Escape Sequences
- Unix Signals and Graceful Shutdown
- The Event Loop Pattern Explained
- Building a Minimal Event Loop from Scratch
- Common Pitfalls with Blocking I/O
Chapter 3: Rendering, Layouts and State
- Immediate Mode vs Retained Mode UI Paradigms
- Screen Buffers and Double Buffering
- Diff-Based Rendering for Performance
- Layout Strategies: Absolute Positioning, Flexbox-Like, Grids
- State Management in TUI Applications
- Focus Models and Navigation Patterns
Chapter 4: Text, Unicode and Colors
- Code Points vs Graphemes vs Display Width
- East Asian Width and Fullwidth Characters
- True Color, 256 Colors and Legacy Palettes
- Hyperlinks and Terminal Features Beyond Text
- Accessibility in Terminal Applications
- Common Unicode Bugs and How to Avoid Them
Chapter 5: Go TUI Development with Bubble Tea
- Why Go for TUIs and the Ecosystem Landscape
- The Elm Architecture in Bubble Tea Explained
- Models, Views and Messages Pattern
- Building Your First Bubble Tea Application
- Styling with Lip Gloss and Theming Strategies
- Composing Components with Bubbles Library
- Async Operations and Commands in Bubble Tea
- Reference Application: A Terminal Task Manager
Chapter 6: Python TUI Development with Textual and Rich
- Why Python for TUIs and When It Makes Sense
- Rich as a Foundation: Console Output Beyond Print
- Textual Framework Architecture and Philosophy
- Widgets, Styles and Layouts in Textual
- Event Handling and Reactive Programming Patterns
- Building Interactive Forms and Data Displays
- Reference Application: A Terminal Dashboard with Real-Time Updates
Chapter 7: Rust TUI Development with Ratatui and Crossterm
- Why Rust for TUIs: Performance, Safety and Distribution
- Crossterm: Terminal Control from the Ground Up
- Ratatui Architecture: Widgets, Layouts and Buffers
- Building Your First Ratatui Application
- Event Handling with Polling and Async Integration
- Custom Widgets and Advanced Rendering Techniques
- Reference Application: A Terminal System Monitor
Chapter 8: Architectural Patterns Across Languages
- Event Loop Implementations Compared
- State Management: Elm Architecture vs Alternatives
- Concurrency Models: Goroutines vs Async Await vs Threads
- Error Handling Patterns Across Languages
- Component Composition and Reusability
- Choosing a Language for Your TUI Project
Chapter 9: Building Reference Applications End-to-End
- Application Requirements and Architecture Planning
- Go Implementation: Task Manager with Persistence and Networking
- Python Implementation: Dashboard with WebSocket Streaming
- Rust Implementation: System Monitor with Real-Time Metrics
- Project Structure and Module Organization Compared
- Testing Strategies for Each Language
Chapter 10: Advanced Rendering and Performance
- Frame Timing and Smooth Animation in Terminals
- Diff-Based Rendering Optimization Techniques
- Virtualizing Large Lists and Tables
- Profiling TUI Applications for Performance Bottlenecks
- Reducing Escape Sequence Overhead
- Cross-Language Performance Comparison
Chapter 11: Advanced Input, Interaction and Integration
- Sophisticated Mouse Event Handling
- Dynamic Key Bindings and Help Systems
- Clipboard Integration Across Platforms
- Running Subprocesses and PTY Allocation
- Shell Integration and Terminal Features
- SSH-Hosted TUIs and Remote Applications
Chapter 12: Production Readiness
- Configuration Management and Environment Handling
- Structured Logging for Terminal Applications
- Robust Error Handling and User Feedback
- Testing TUIs: Unit, Integration and Snapshot Tests
- Packaging and Distribution Across Platforms
- CI/CD Pipelines and Release Automation
- Long-Term Maintenance and Versioning
Chapter 13: Troubleshooting and Anti-Patterns
- Terminal Compatibility Issues and Debugging Strategies
- Input Handling Bugs and Race Conditions
- Rendering Glitches and How to Fix Them
- Memory Leaks and Resource Exhaustion
- Anti-Patterns That Make TUIs Feel Bad
- Checklist for Polished Keyboard-First UX
Chapter 14: Framework Selection and Decision Guide
- Requirements Analysis Framework for TUI Projects
- Go vs Python vs Rust: When Each Is the Right Choice
- Library Comparison Matrix: Bubble Tea vs Textual vs Ratatui
- Architecture Decision Records for Common Scenarios
- Evolution Paths: Starting Simple and Growing Complexity
- Future of Terminal UI Development
- Final Thoughts