Function get_terminal_width

Source
pub fn get_terminal_width() -> usize
Expand description

Get the width of the terminal.

This function attempts to determine the terminal width using multiple approaches:

  1. Environment variables: Check COLUMNS and TERM_WIDTH
  2. Use ioctl system call to get terminal size directly
  3. Try tput command as fallback
  4. Fallback to 80 columns