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

This file contains implementations of tty info getters. More...

#include "sham/term/tty.hpp"
#include <cstdio>
#include <utility>
Include dependency graph for tty.cpp:

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.
void sham::term::set_tty_columns (int columns)
 Set the forced width of the terminal.
std::pair< int, int > sham::term::get_tty_dim ()
 Get the number of columns and lines of the current terminal.
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.

Variables

int sham::term::tty_forced_width = 0

Detailed Description

This file contains implementations of 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.cpp.

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_dim()

std::pair< int, int > sham::term::get_tty_dim ( )

Get the number of columns and lines 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 {10, 100}.

Returns
Number of columns and lines if the current terminal

Definition at line 53 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.

◆ 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.

Variable Documentation

◆ tty_forced_width

int sham::term::tty_forced_width = 0

Forced width of the terminal, if set by set_tty_columns. If set to 0, get_tty_dim returns the actual width of the terminal.

Definition at line 41 of file tty.cpp.