8 #ifndef WPIUTIL_WPI_UV_TTY_H_
9 #define WPIUTIL_WPI_UV_TTY_H_
16 #include "wpi/uv/Stream.h"
29 struct private_init {};
32 explicit Tty(
const private_init&) {}
33 ~
Tty() noexcept
override =
default;
43 static std::shared_ptr<Tty>
Create(
Loop& loop, uv_file fd,
bool readable);
53 static std::shared_ptr<Tty>
Create(
const std::shared_ptr<Loop>& loop,
54 uv_file fd,
bool readable) {
55 return Create(*loop, fd, readable);
64 int err = uv_tty_set_mode(
GetRaw(), mode);
79 int width = 0, height = 0;
80 Invoke(&uv_tty_get_winsize,
GetRaw(), &width, &height);
81 return std::make_pair(width, height);
88 #endif // WPIUTIL_WPI_UV_TTY_H_
static std::shared_ptr< Tty > Create(const std::shared_ptr< Loop > &loop, uv_file fd, bool readable)
Create a TTY handle.
Definition: Tty.h:53
std::pair< int, int > GetWindowSize()
Gets the current window size.
Definition: Tty.h:78
WPILib C++ utilities (wpiutil) namespace.
Definition: SmallString.h:21
TTY handle.
Definition: Tty.h:28
static std::shared_ptr< Tty > Create(Loop &loop, uv_file fd, bool readable)
Create a TTY handle.
uv_tty_t * GetRaw() const noexcept
Get the underlying handle data structure.
Definition: Stream.h:240
void ReportError(int err)
Report an error.
Definition: Handle.h:213
void SetMode(uv_tty_mode_t mode)
Set the TTY using the specified terminal mode.
Definition: Tty.h:63
Event loop.
Definition: Loop.h:37
void ResetMode()
Reset TTY settings to default values for the next process to take over.
Definition: Tty.h:72