Logging for text that should stay in the same place in a console

13 releases (7 breaking)

new 0.8.0 Mar 14, 2023
0.7.0 Jan 3, 2023
0.5.0 Dec 17, 2022

#457 in Text processing

Download history 901/week @ 2022-12-10 1442/week @ 2022-12-17 724/week @ 2022-12-24 1001/week @ 2022-12-31 1202/week @ 2023-01-07 970/week @ 2023-01-14 819/week @ 2023-01-21 727/week @ 2023-01-28 810/week @ 2023-02-04 1402/week @ 2023-02-11 1217/week @ 2023-02-18 873/week @ 2023-02-25 1126/week @ 2023-03-04 1128/week @ 2023-03-11

4,647 downloads per month
Used in 12 crates (7 directly)

MIT license

774 lines


Crate for logging text that should stay in the same place in a console. This measures words to handle wrapping and has some console resizing support. Example use might be for displaying progress bars or rendering selections.

Example use with the console crate:

use console_static_text::ConsoleSize;
use console_static_text::ConsoleStaticText;

let mut static_text = ConsoleStaticText::new(|| {
  let size = console::Term::stderr().size();
  ConsoleSize {
    rows: Some(size.0),
    cols: Some(size.1),


// will clear the previous text and put this new text
static_text.eprint("new text");

// or get and output the text manually
if let Some(text) = static_text.render("new text") {
  eprint!("{}", text);

// clear out the previous text

Hanging indentation

To get hanging indentation, you can use the lower level "items" api.

  TextItem::Text(Cow::Borrowed("Some non-hanging text.")),
  TextItem::HangingText {
    text: Cow::Borrowed("some long text that will wrap at a certain width"),
    indent: 4,

This is useful when implementing something like a selection UI where you want text to wrap with hanging indentation.

"sized" feature

By default, this crate encourages you to use your own functionality for getting the console size since you'll likely already have a dependency that does that, but if not, then you can use the sized Cargo.toml feature.

console_static_text = { version = "...", features = ["sized"] }

Then you can use the new_sized function, which will get the console size automatically:

let mut static_text = ConsoleStaticText::new_sized();


static_text.eprint("next text");


~146K SLoC