43 releases (2 stable)

1.0.1 Dec 14, 2024
1.0.0 Jul 21, 2024
0.7.0 Jan 12, 2021
0.6.1 Aug 5, 2019
0.1.1 Dec 29, 2014

#267 in Command-line interface

Download history 344418/week @ 2024-10-29 323694/week @ 2024-11-05 393392/week @ 2024-11-12 385692/week @ 2024-11-19 314740/week @ 2024-11-26 405251/week @ 2024-12-03 400067/week @ 2024-12-10 329406/week @ 2024-12-17 142656/week @ 2024-12-24 205313/week @ 2024-12-31 388263/week @ 2025-01-07 388467/week @ 2025-01-14 369589/week @ 2025-01-21 385146/week @ 2025-01-28 470987/week @ 2025-02-04 415786/week @ 2025-02-11

1,695,435 downloads per month
Used in fewer than 185 crates

MIT/Apache

110KB
2K SLoC

term

A Rust library for terminfo parsing and terminal colors.

CI

Documentation

MSRV

1.63

Usage

Add this to your Cargo.toml:

[dependencies]

term = "*"

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.


lib.rs:

Terminal formatting library.

This crate provides the Terminal trait, which abstracts over an ANSI Terminal to provide color printing, among other things. There are two implementations, the TerminfoTerminal, which uses control characters from a terminfo database, and WinConsole, which uses the Win32 Console API.

Usage

This crate is on crates.io and can be used by adding term to the dependencies in your project's Cargo.toml.

[dependencies]

term = "*"

Examples

use std::io::prelude::*;

let mut t = term::stdout().unwrap();

t.fg(term::color::GREEN).unwrap();
write!(t, "hello, ").unwrap();

t.fg(term::color::RED).unwrap();
writeln!(t, "world!").unwrap();

t.reset().unwrap();

Dependencies

~0–8MB
~62K SLoC

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy