grux
A library for drawing grid-based user interfaces using ASCII characters.
// Provides a uniform interface for drawing to a 2D grid.
use GridWriter;
// Create a 3x3 2D array.
// Alternatives provided by `grux`: `Vec<Vec<T>>` and `String`.
let mut grid = ;
// Draw some random stuff. In practice, you'd probably use a loop :P.
grid.draw;
grid.draw;
grid.draw;
grid.draw;
grid.draw;
grid.draw;
grid.draw;
grid.draw;
// Provides a uniform interface for displaying a 2D grid.
use DisplayGrid;
// ╔═╗
// ║ ║
// ╚═╝
println!;
Why Grux?
There are plenty of existing libraries for terminal-based user interfaces, but none of them are quite what I wanted. I wanted a library that would let me draw a grid of cells, each of which could contain a single character.
Importantly, Grux isn't a UI framework.
It doesn't handle input or even output. It just lets you draw to a grid-like structure, which could be:
- A
Vec<Vec<T>> - A
String - A fixed-size 2D array (i.e.
[[T; 10]; 10]) - Your custom data structure (just implement
GridWriterand/orDisplayGrid)
tl;dr: Draw to whatever you want, and build on top of it (or replace it).