term_size

All functions return Error(Nil) if the terminal’s size could not be determined for any reason.

Functions

pub fn columns() -> Result(Int, Nil)

Get the character width of the terminal.

pub fn get() -> Result(#(Int, Int), Nil)

Get the current terminal’s size. The return tuple is of the form #(rows, columns).

import term_size

pub fn main() {
  case term_size.get() {
    Ok(#(rows, columns)) -> // ...
    Error(Nil) -> // ...
  }
}
pub fn rows() -> Result(Int, Nil)

Get the number of rows (lines) visible in the terminal.

Search Document