Zigline is a feature-rich terminal emulator written entirely in Zig, designed to showcase modern systems programming techniques while providing a functional and extensible terminal experience. The project demonstrates clean architecture, efficient memory management, and cross-platform GUI development.
- Educational: Demonstrate Zig's capabilities for systems programming
- Modular: Clean, maintainable codebase with clear separation of concerns
- Performance: Efficient rendering and memory usage
- Features: Modern terminal functionality with session management
- Quality: Comprehensive testing and documentation
- ✅ PTY Integration - Full pseudo-terminal support with shell spawning
- ✅ ANSI Processing - Complete escape sequence parsing and color support
- ✅ Buffer Management - Efficient screen buffer with cursor tracking
- ✅ Input Handling - Real-time keyboard input with special key support
- ✅ Raylib Rendering - Hardware-accelerated graphics with OpenGL
- ✅ Dynamic Resizing - Window resizing with automatic terminal adjustment
- ✅ Mouse Support - Full mouse interaction for UI elements
- ✅ Font System - FiraCode integration with fallback support
- ✅ Visual Effects - Tab hover effects and smooth transitions
- ✅ Multi-Tab Support - Multiple terminal sessions in one window
- ✅ Session Persistence - Save and restore sessions across restarts
- ✅ Dynamic Management - Create, close, and switch between sessions
- ✅ Auto-Save - Configurable automatic session saving
- ✅ JSON Configuration - Flexible, human-readable settings
- ✅ Hot Reload - Runtime configuration updates
- ✅ Theme Support - Customizable colors and appearance
- ✅ Keybinding Customization - User-defined keyboard shortcuts
- ✅ Unit Tests - Comprehensive test suite for core components
- ✅ Integration Tests - End-to-end functionality verification
- ✅ Documentation - Complete inline documentation and guides
- ✅ Build System - Modern Zig build configuration with test runners
┌─────────────────────────────────────────────────────────┐
│ Zigline Architecture │
├─────────────────────────────────────────────────────────┤
│ UI Layer │ Raylib GUI | Session Manager │
├─────────────────────────────────────────────────────────┤
│ Input Layer │ Keyboard | Input Processor │
├─────────────────────────────────────────────────────────┤
│ Terminal Layer │ ANSI Parser| Buffer Manager │
├─────────────────────────────────────────────────────────┤
│ Core Layer │ PTY | Logger | Config │
├─────────────────────────────────────────────────────────┤
│ Persistence Layer │ Session State | Configuration │
└─────────────────────────────────────────────────────────┘
zigline/
├── 🏗️ build.zig # Zig build system configuration
├── 📦 build.zig.zon # Dependency management
├── 📋 CHANGELOG.md # Version history
├── 📄 RELEASE_NOTES.md # Release documentation
├── ⚙️ zigline_config.json # User configuration
├── 💾 zigline_sessions.json # Session persistence
│
├── 📂 src/ # Source code
│ ├── 🎯 main.zig # Application entry point
│ ├── 🔧 config/
│ │ └── config.zig # Configuration management
│ ├── ⚡ core/
│ │ ├── logger.zig # Logging system
│ │ ├── pty.zig # Pseudo-terminal interface
│ │ └── terminal.zig # Terminal state management
│ ├── ⌨️ input/
│ │ ├── keyboard.zig # Keyboard input handling
│ │ └── processor.zig # Input event processing
│ ├── 💾 persistence/
│ │ └── session_persistence.zig # Session save/restore
│ ├── 🖥️ terminal/
│ │ ├── ansi.zig # ANSI escape sequence parser
│ │ └── buffer.zig # Screen buffer management
│ └── 🎨 ui/
│ ├── raylib_gui.zig # Main GUI implementation
│ └── session_manager.zig # Session management
│
├── 📂 tests/ # Test suite
│ ├── test_all_phases.zig # Integration tests
│ ├── test_ansi_parser.zig # ANSI parser unit tests
│ ├── test_buffer_behavior.zig # Buffer management tests
│ ├── test_history_navigation.zig # History navigation tests
│ └── test_key_normalization.zig # Input processing tests
│
└── 📂 assets/ # Resources
└── fonts/ # Font assets
└── ttf/
└── FiraCode-*.ttf # Programming fonts
- Zig 0.14.0+ - Download from ziglang.org
- Linux with X11 - Currently supports X11-based systems
- Development Libraries - OpenGL and X11 development packages
# Install dependencies
sudo apt update
sudo apt install libgl1-mesa-dev libglu1-mesa-dev libxcursor-dev libxext-dev \
libxfixes-dev libxi-dev libxinerama-dev libxrandr-dev \
libxrender-dev libx11-dev
# Clone and build
git clone git@github.com:fulgidus/zigline.git
cd zigline
zig build
# Run
./zig-out/bin/zigline# Install dependencies
sudo dnf install mesa-libGL-devel mesa-libGLU-devel libXcursor-devel \
libXext-devel libXfixes-devel libXi-devel libXinerama-devel \
libXrandr-devel libXrender-devel libX11-devel
# Clone and build
git clone git@github.com:fulgidus/zigline.git
cd zigline
zig build
# Run
./zig-out/bin/zigline# Run all tests
zig build test
# Run specific test suites
zig build test-ansi # ANSI parser tests
zig build test-buffer # Buffer behavior tests
zig build test-keys # Key normalization tests
zig build test-history # History navigation tests| Action | Shortcut | Description |
|---|---|---|
| New Tab | Ctrl+T |
Create new terminal session |
| Close Tab | Ctrl+W |
Close current session |
| Next Tab | Ctrl+Tab |
Switch to next session |
| Previous Tab | Shift+Ctrl+Tab |
Switch to previous session |
| Navigation | Ctrl+PageUp/PageDown |
Alternative tab navigation |
- Tab Switching - Click on any tab to switch to it
- Tab Closing - Click the
×button to close a tab - Tab Scrolling - Use mouse wheel over tab bar to scroll
- Window Resizing - Drag window edges to resize (terminal auto-adjusts)
Zigline uses zigline_config.json for configuration:
{
"theme": "dark",
"font_path": "assets/fonts/ttf/FiraCode-Regular.ttf",
"font_size": 26,
"window_width": 1200,
"window_height": 800,
"auto_save_sessions": true,
"auto_save_interval": 30,
"keybindings": {
"new_session": "Ctrl+T",
"close_session": "Ctrl+W",
"next_session": "Ctrl+Tab",
"prev_session": "Shift+Ctrl+Tab"
},
"colors": {
"background": { "r": 40, "g": 42, "b": 54, "a": 255 },
"foreground": { "r": 248, "g": 248, "b": 242, "a": 255 },
"cursor": { "r": 139, "g": 233, "b": 139, "a": 255 }
}
}| Option | Type | Description |
|---|---|---|
theme |
String | UI theme ("dark", "light") |
font_path |
String | Path to font file |
font_size |
Number | Font size in pixels |
window_width |
Number | Initial window width |
window_height |
Number | Initial window height |
auto_save_sessions |
Boolean | Enable automatic session saving |
auto_save_interval |
Number | Auto-save interval in seconds |
keybindings |
Object | Custom keyboard shortcuts |
colors |
Object | Color theme configuration |
Sessions are automatically saved to zigline_sessions.json:
- Terminal State - Cursor position, buffer content, working directory
- Session Metadata - Session names, active session index
- Window State - Terminal dimensions and display settings
- Auto-Save - Configurable interval (default: 30 seconds)
Unit Testing Infrastructure
- ✅ Comprehensive ANSI parser test suite (366 lines)
- ✅ Buffer behavior tests with edge case coverage (399 lines)
- ✅ Key normalization and input processing tests (477 lines)
- ✅ Integration tests for all development phases
- ✅ Individual test runners for each component
Documentation System
- ✅ Complete README with usage guides and examples
- ✅ Inline Zig documentation comments throughout codebase
- ✅ Build system documentation and configuration guides
- ✅ Architecture overview and project structure documentation
Quality Assurance
- ✅ Manual testing protocols for interactive features
- ✅ Build system integration with proper test dependencies
- ✅ Error handling verification and edge case testing
- ✅ Memory management and resource cleanup validation
| Phase | Status | Description |
|---|---|---|
| Phase 1 | ✅ Complete | Project setup and basic structure |
| Phase 2 | ✅ Complete | PTY integration and shell process management |
| Phase 3 | ✅ Complete | ANSI parsing and screen buffer management |
| Phase 4 | ✅ Complete | Input handling and keyboard processing |
| Phase 5 | ✅ Complete | Raylib GUI integration and rendering |
| Phase 6 | ✅ Complete | Advanced features and session management |
| Phase 7 | ✅ Complete | Testing infrastructure and documentation |
- 📋 Copy/Paste - Text selection and clipboard integration
- 📜 Scrollback - Terminal history with search functionality
- 🔌 Plugin System - Extensible architecture for custom features
- 🌐 Cross-Platform - Windows and macOS support
- 🎨 Themes - Additional color schemes and customization options
We welcome contributions! This project has evolved from a personal learning exercise into a functional terminal emulator.
- Terminal Features - Copy/paste, scrollback history, search
- Platform Support - Windows and macOS compatibility
- Performance - Rendering optimizations and memory improvements
- Testing - Additional unit tests and integration scenarios
- Documentation - Usage examples and developer guides
- Follow Zig Style - Use
zig fmtfor consistent formatting - Add Tests - Include unit tests for new functionality
- Document Code - Use Zig doc comments for public APIs
- Test Builds - Verify both debug and release builds
- Update Docs - Keep README and CHANGELOG current
# Set up development environment
git clone <repository-url>
cd zigline
# Make changes and test
zig build test
zig build
# Format code
zig fmt src/ tests/
# Run integration tests
./zig-out/bin/zigline- Zig Build - Modern build system with dependency management
- Raylib Integration - Automated dependency fetching and linking
- Test Runners - Individual and collective test execution
- Cross-Compilation - Support for multiple target platforms
- Arena Allocators - Efficient memory pooling for temporary data
- RAII Pattern - Automatic resource cleanup with
defer - Leak Detection - Debug builds include memory leak tracking
- Buffer Pooling - Reusable buffers for performance optimization
- Startup Time - < 100ms cold start on typical hardware
- Memory Usage - ~15MB base memory footprint
- Rendering - 60 FPS with hardware acceleration
- Input Latency - < 5ms input-to-display latency
- Zig Language Reference
- Raylib Programming Guide
- Terminal Emulator Implementation
- ANSI Escape Sequences
- Zig Programming Language - Systems programming language
- Raylib Graphics Library - Simple graphics and GUI
- FiraCode Font - Programming font with ligatures
- CHANGELOG.md - Detailed version history
- RELEASE_NOTES.md - Release information
- LICENSE - GPL-3.0 license terms
- Current Version: v0.7.0
- Zig Version: 0.14.0+
- Platform: Linux (X11)
- Build Date: June 2025
- Phase Status: Phase 7 Complete
Built with ❤️ and Zig
Zigline Terminal Emulator - Modern systems programming in action