19 lines
492 B
C++
19 lines
492 B
C++
#pragma once
|
|
#include <sys/ioctl.h>
|
|
#include <iomanip>
|
|
|
|
inline auto terminal_size()
|
|
{
|
|
struct winsize result{};
|
|
ioctl(STDOUT_FILENO, TIOCGWINSZ, &result);
|
|
return std::make_tuple(result.ws_col, result.ws_row);
|
|
}
|
|
|
|
template<class CharT, class Traits>
|
|
std::basic_ostream<CharT,Traits>& hr(std::basic_ostream<CharT, Traits>& os)
|
|
{
|
|
auto [width, height] = terminal_size();
|
|
os << std::setfill('-') << std::setw(width) << "\n" << std::setfill(' ') << std::setw(0);
|
|
return os;
|
|
}
|