Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
tty.hpp File Reference

This file contains tty info getters. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  sham
 namespace for backends this one is named only sham since shambackends is too long to write

Functions

bool sham::term::is_a_tty ()
 Test if current terminal is a tty.
int sham::term::get_tty_columns ()
 Get the number of columns of the current terminal.
int sham::term::get_tty_lines ()
 Get the number of lines of the current terminal.
void sham::term::set_tty_columns (int columns)
 Set the forced width of the terminal.
void sham::term::reset_tty_columns ()
 Reset the forced width of the terminal.

Detailed Description

This file contains tty info getters.

Author
Timothée David–Cléris (tim.s.nosp@m.hamr.nosp@m.ock@p.nosp@m.roto.nosp@m.n.me)

Definition in file tty.hpp.

Function Documentation

◆ get_tty_columns()

int sham::term::get_tty_columns ( )

Get the number of columns of the current terminal.

If forced width is set (by set_tty_columns), this function returns the forced width. If the current terminal is not a tty, the function returns 100.

Returns
Number of columns if the current terminal

Definition at line 81 of file tty.cpp.

◆ get_tty_lines()

int sham::term::get_tty_lines ( )

Get the number of lines of the current terminal.

If the current terminal is not a tty, the function returns 10.

Returns
Number of lines if the current terminal

Definition at line 82 of file tty.cpp.

◆ is_a_tty()

bool sham::term::is_a_tty ( )

Test if current terminal is a tty.

Returns
true is a tty
false is not a tty

Definition at line 31 of file tty.cpp.

◆ reset_tty_columns()

void sham::term::reset_tty_columns ( )
inline

Reset the forced width of the terminal.

Calls set_tty_columns(0) to restore the default behavior of get_tty_columns().

Definition at line 65 of file tty.hpp.

◆ set_tty_columns()

void sham::term::set_tty_columns ( int columns)

Set the forced width of the terminal.

By default, the function get_tty_columns() returns the number of columns of the current terminal. If this function is called with a non-zero value, get_tty_columns() will always return this value until set_tty_columns() is called again with a different value.

Parameters
columnsThe width of the terminal. If zero, the default behavior of get_tty_columns() is restored.

Definition at line 43 of file tty.cpp.