uvw 3.1.0
Loading...
Searching...
No Matches
tty.h
1#ifndef UVW_TTY_INCLUDE_H
2#define UVW_TTY_INCLUDE_H
3
4#include <memory>
5#include <type_traits>
6#include <uv.h>
7#include "config.h"
8#include "stream.h"
9#include "util.h"
10
11namespace uvw {
12
13namespace details {
14
15struct reset_mode_memo {
16 ~reset_mode_memo();
17};
18
19enum class uvw_tty_mode_t : std::underlying_type_t<uv_tty_mode_t> {
20 NORMAL = UV_TTY_MODE_NORMAL,
21 RAW = UV_TTY_MODE_RAW,
22 IO = UV_TTY_MODE_IO
23};
24
25enum class uvw_tty_vtermstate_t : std::underlying_type_t<uv_tty_vtermstate_t> {
26 SUPPORTED = UV_TTY_SUPPORTED,
27 UNSUPPORTED = UV_TTY_UNSUPPORTED
28};
29
30} // namespace details
31
50class tty_handle final: public stream_handle<tty_handle, uv_tty_t> {
51 static std::shared_ptr<details::reset_mode_memo> mode_memo_handler();
52
53public:
54 using tty_mode = details::uvw_tty_mode_t;
55 using tty_vtermstate = details::uvw_tty_vtermstate_t;
56
57 explicit tty_handle(loop::token token, std::shared_ptr<loop> ref, file_handle desc, bool readable);
58
63 int init() final;
64
81 bool mode(tty_mode m);
82
87 bool reset_mode() noexcept;
88
94
113 void vterm_state(tty_vtermstate s) const noexcept;
114
132 tty_vtermstate vterm_state() const noexcept;
133
134private:
135 std::shared_ptr<details::reset_mode_memo> memo;
136 file_handle fd;
137 int rw;
138};
139
140} // namespace uvw
141
142#ifndef UVW_AS_LIB
143# include "tty.cpp"
144#endif
145
146#endif // UVW_TTY_INCLUDE_H
The stream handle.
Definition: stream.h:108
bool readable() const noexcept
Checks if the stream is readable.
Definition: stream.h:424
The tty handle.
Definition: tty.h:50
tty_vtermstate vterm_state() const noexcept
Gets the current state of whether console virtual terminal sequences are handled by the library or th...
bool mode(tty_mode m)
Sets the TTY using the specified terminal mode.
win_size get_win_size()
Gets the current Window size.
int init() final
Initializes the handle.
bool reset_mode() noexcept
Resets TTY settings to default values.
uvw default namespace.
Definition: async.h:8
details::uv_type_wrapper< uv_file > file_handle
Definition: util.h:85
Windows size representation.
Definition: util.h:78