2021-02-10 16:32:59 -05:00
|
|
|
#pragma once
|
2021-02-10 23:25:56 -05:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <iomanip>
|
2021-02-10 16:32:59 -05:00
|
|
|
|
|
|
|
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>
|
2021-02-10 23:25:56 -05:00
|
|
|
std::basic_ostream<CharT,Traits>& hr(std::basic_ostream<CharT, Traits>& os)
|
2021-02-10 16:32:59 -05:00
|
|
|
{
|
|
|
|
auto [width, height] = terminal_size();
|
|
|
|
os << std::setfill('-') << std::setw(width) << "\n" << std::setfill(' ') << std::setw(0);
|
|
|
|
return os;
|
|
|
|
}
|