https://github.com/meh/rust-terminfo
Terminal information for Rust.
https://github.com/meh/rust-terminfo
ncurses rust terminfo
Last synced: 6 months ago
JSON representation
Terminal information for Rust.
- Host: GitHub
- URL: https://github.com/meh/rust-terminfo
- Owner: meh
- License: other
- Created: 2016-12-25T14:06:11.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-05-08T13:44:38.000Z (over 1 year ago)
- Last Synced: 2025-03-28T20:06:32.795Z (6 months ago)
- Topics: ncurses, rust, terminfo
- Language: Rust
- Size: 161 KB
- Stars: 72
- Watchers: 9
- Forks: 18
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
terminfo
========
[](https://crates.io/crates/terminfo) [](https://crates.io/crates/terminfo)  [](https://github.com/meh/rust-terminfo/actions/workflows/rust.yml)Terminal capabilities with type-safe getters.
[Documentation](https://docs.rs/terminfo/latest/terminfo/)
Example
-------```rust
use std::io;
use terminfo::{capability as cap, Database};fn main() {
let info = Database::from_env().unwrap();if let Some(cap::MaxColors(n)) = info.get::() {
println!("The terminal supports {} colors.", n);
} else {
println!("The terminal does not support colors, what year is this?");
}if let Some(flash) = info.get::() {
flash.expand().to(io::stdout()).unwrap();
} else {
println!("FLASH GORDON!");
}info.get::().unwrap().expand().color(2).to(io::stdout()).unwrap();
info.get::().unwrap().expand().color(4).to(io::stdout()).unwrap();
println!("SUP");
info.get::().unwrap().expand().to(io::stdout()).unwrap();
}
```Packaging and Distributing
--------------------------
For all terminals but windows consoles, this library depends on a non-hashed
(for now) terminfo database being present. For example, on Debian derivitives,
you should depend on ncurses-term; on Arch Linux, you depend on ncurses; and on
MinGW, you should depend on mingw32-terminfo.Unfortunately, if you're using a non-windows console on Windows (e.g. MinGW,
Cygwin, Git Bash), you'll need to set the TERMINFO environment variable to
point to the directory containing the terminfo database.