Crate any_terminal_size[][src]

Expand description

A simple utility for getting the size of a console of any process or on windows.

If the process doesn’t have a terminal, all parent processes are searched for one.

The windows version has to make use of dll injection because there is no api which allows to query console infos of foreign processes. The unix version should be considered experimental.

This crate requires a minimum rust version of 1.31.0 (2018-12-06)

Example

use any_terminal_size::{Width, Height, any_terminal_size};

let size = any_terminal_size();
if let Some((Width(w), Height(h))) = size {
    println!("The terminal size of your process or [transitive] parent process is {} cols wide and {} lines tall", w, h);
} else {
    println!("Unable to get terminal size");
}

Structs

Functions

Returns the size of the terminal of the current process or one of its parents, if available. Iostreams are queried in stdout, stderr and stdin order.

Returns the size of the terminal of the given process id or one of its parents, if available. Iostreams are queried in stdout, stderr and stdin order.