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.

Examples

Create a Wrapper for the current terminal with a two column margin:

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

let width = termwidth() - 4; // Two columns on each side.
let wrapper = Wrapper::with_splitter(width, NoHyphenation)
    .initial_indent("  ")
    .subsequent_indent("  ");