repr
0.1
Reconstructable string representations and more
Loading...
Searching...
No Matches
terminal.h
Go to the documentation of this file.
1
#pragma once
2
#include <
cstddef
>
3
4
#if defined(_WIN32)
5
#define WIN32_LEAN_AND_MEAN
6
#define NOMINMAX
7
#include <Windows.h>
8
#else
9
#include <sys/ioctl.h>
10
#include <unistd.h>
11
#endif
12
13
namespace
librepr
{
14
[[
nodiscard
]]
inline
std::size_t
get_terminal_width
() {
15
#if defined(_WIN32)
16
auto
terminal_size
=
CONSOLE_SCREEN_BUFFER_INFO
{};
17
GetConsoleScreenBufferInfo
(
GetStdHandle
(
STD_OUTPUT_HANDLE
), &
terminal_size
);
18
return
unsigned
(
terminal_size
.srWindow.Right -
terminal_size
.srWindow.Left) + 1U;
19
#else
20
auto
terminal_size
=
::winsize
{};
21
ioctl
(
STDOUT_FILENO
,
TIOCGWINSZ
, &
terminal_size
);
22
return
terminal_size
.ws_col;
23
#endif
24
}
25
}
// namespace librepr
cstddef
librepr
Definition
ctvi/ctvi.h:9
librepr::code_for
std::string code_for()
Definition
repr:39
librepr::get_terminal_width
std::size_t get_terminal_width()
Definition
terminal.h:14
std::size_t
include
librepr
terminal.h
Generated by
1.9.8, using the excellent
Doxygen Awesome
Theme