MinUI is a minimal terminal-based game and UI engine written in Rust. This project is a work in progress, currently in its very early stages!
MinUI was born from a desire to create terminal-based games in Rust, specifically a terminal Tetris clone in my case. While several terminal UI libraries exist for Rust, none quite offered the perfect balance of simplicity, performance, and game-focused features that I was looking for. MinUI aims to fill this gap by providing a fast, easy-to-use library that makes terminal game and UI development a joy.
- ๐ Fast: Built for performance with gaming in mind
- ๐ฎ Game-focused, TUI-ready: API designed around common game development needs
- ๐ฏ Minimalist: Clean, intuitive API with zero unnecessary complexity
- โจ๏ธ Input Handling: Robust keyboard event system
- ๐งฐ Safe: Proper error handling and automatic resource cleanup
MinUI is in early development, and I'm actively working on adding more features:
- Color support
- Simple and customizable widget system
- Container widget
- Label widget
- Text block widget
- Panel widget
- Table widget
- Input widget
- Predefined widget layouts
- Buffered drawing for smooth and efficient updates
- Built-in game loop utilities
- Simplified sprite and map management utilities
- Easy character movement support
- Cell management with collision detection options
- Support for various input methods (custom key binds, mouse support, etc.)
For now, you'll have to clone this repository and build your games/applications locally.
Once MinUI is formally released as a crate, you could add it to your Cargo.toml like so:
[dependencies]
minui = "0.1.0"
use minui::{Window, Event, TerminalWindow};
// This example shows the minimal workflow, how to:
// - Create a window
// - Write some text
// - Enter an input loop
// - Handle different types of input events
// - Clean up automatically when done
fn main() -> minui::Result<()> {
let mut window = TerminalWindow::new()?;
window.clear()?;
window.write_str(0, 0, "Press 'q' to quit")?;
loop {
match window.get_input()? {
Event::Character('q') => break,
Event::Character(c) => {
window.write_str(1, 0, &format!("You pressed: {}", c))?;
}
evt => {
window.write_str(1, 0, &format!("Event: {:?}", evt))?;
}
}
}
Ok(())
}
Run the program with the command: cargo run example --basic_usage
MinUI is designed to make terminal game development straightforward. Here's what makes it great for games:
- Minimal Dependencies: Built on crossterm with minimal additional dependencies
- Game First: Designed primarily for terminal-based game development, with great UI capabilities as well
- Easy to Learn: Clean, intuitive API that gets out of your way
- Performance Focused: Built with game performance requirements in mind
MinUI also has a focus on simplifying the task of building TUI applications. Here's some of what it has to offer:
- Simple Widget System: Easy-to-use widgets with all the features you need and nothing you don't
- Example Programs: Several examples to help you get started with the widgets
- Customizable: I'm trying to make every widget I add as configurable as possible, while not overwhelming you with options
- Coming Soon: Tet.rs
Built using: