Skip to main content

get_terminal_width_bounded

Function get_terminal_width_bounded 

Source
pub fn get_terminal_width_bounded(
    min_width: u16,
    max_width: u16,
    default_width: u16,
) -> u16
Expand description

Get the terminal width with a minimum and maximum bound.

Ensures the width is within reasonable bounds for formatting. Returns at least min_width and at most max_width. If terminal width cannot be determined, returns default_width.

ยงExamples

let width = get_terminal_width_bounded(60, 120, 80);
assert!(width >= 60 && width <= 120);