Function textwrap::termwidth[][src]

pub fn termwidth() -> usize

Return the current terminal width. If the terminal width cannot be determined (typically because the standard output is not connected to a terminal), a default width of 80 characters will be used.


Create an Options for wrapping at the current terminal width with a two column margin to the left and the right:

use textwrap::{termwidth, NoHyphenation, Options};

let width = termwidth() - 4; // Two columns on each side.
let options = Options::new(width)
    .initial_indent("  ")
    .subsequent_indent("  ");

Note: Only available when the terminal_size Cargo feature is enabled.