Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A rust console and terminal abstraction

License

NotificationsYou must be signed in to change notification settings

console-rs/console

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Statuscrates.ioLicenseDocumentation

console is a library for Rust that provides access to various terminalfeatures so you can build nicer looking command line interfaces. Itcomes with various tools and utilities for working with Terminals andformatting text.

Best paired with other libraries in the family:

Terminal Access

The terminal is abstracted through theconsole::Term type. It caneither directly provide access to the connected terminal or by bufferingup commands. A buffered terminal will however not be completely bufferedon windows where cursor movements are currently directly passed through.

Example usage:

use std::thread;use std::time::Duration;use console::Term;let term =Term::stdout();term.write_line("Hello World!")?;thread::sleep(Duration::from_millis(2000));term.clear_line()?;

Colors and Styles

console automatically detects when to use colors based on the tty flag, following theclicolors standard for color enabling/disabling. It alsoprovides higher level wrappers for styling text and other things that can bedisplayed with thestyle function and utility types.

Example usage:

use console::style;println!("This is {} neat", style("quite").cyan());

You can also store styles and apply them to text later:

use console::Style;let cyan =Style::new().cyan();println!("This is {} neat", cyan.apply_to("quite"));

Working with ANSI Codes

The crate provides the functionstrip_ansi_codes to remove ANSI codesfrom a string as well asmeasure_text_width to calculate the width of astring as it would be displayed by the terminal. Both of those togetherare useful for more complex formatting.

Unicode Width Support

By default this crate depends on theunicode-width crate to calculatethe width of terminal characters. If you do not need this you can disabletheunicode-width feature which will cut down on dependencies.

License: MIT

About

A rust console and terminal abstraction

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp