|
160
|
1
|
|
|
2 .. _tty:
|
|
|
3
|
|
|
4 :c:type:`uv_tty_t` --- TTY handle
|
|
|
5 =================================
|
|
|
6
|
|
|
7 TTY handles represent a stream for the console.
|
|
|
8
|
|
|
9 :c:type:`uv_tty_t` is a 'subclass' of :c:type:`uv_stream_t`.
|
|
|
10
|
|
|
11
|
|
|
12 Data types
|
|
|
13 ----------
|
|
|
14
|
|
|
15 .. c:type:: uv_tty_t
|
|
|
16
|
|
|
17 TTY handle type.
|
|
|
18
|
|
|
19 .. c:enum:: uv_tty_mode_t
|
|
|
20
|
|
|
21 .. versionadded:: 1.2.0
|
|
|
22
|
|
|
23 TTY mode type:
|
|
|
24
|
|
|
25 ::
|
|
|
26
|
|
|
27 typedef enum {
|
|
|
28 /* Initial/normal terminal mode */
|
|
|
29 UV_TTY_MODE_NORMAL,
|
|
|
30 /*
|
|
|
31 * Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled).
|
|
|
32 * May become equivalent to UV_TTY_MODE_RAW_VT in future libuv versions.
|
|
|
33 */
|
|
|
34 UV_TTY_MODE_RAW,
|
|
|
35 /* Binary-safe I/O mode for IPC (Unix-only) */
|
|
|
36 UV_TTY_MODE_IO,
|
|
|
37 /* Raw input mode. On Windows ENABLE_VIRTUAL_TERMINAL_INPUT is also set. */
|
|
|
38 UV_TTY_MODE_RAW_VT
|
|
|
39 } uv_tty_mode_t;
|
|
|
40
|
|
|
41 .. c:enum:: uv_tty_vtermstate_t
|
|
|
42
|
|
|
43 Console virtual terminal mode type:
|
|
|
44
|
|
|
45 ::
|
|
|
46
|
|
|
47 typedef enum {
|
|
|
48 /*
|
|
|
49 * The console supports handling of virtual terminal sequences
|
|
|
50 * (Windows10 new console, ConEmu)
|
|
|
51 */
|
|
|
52 UV_TTY_SUPPORTED,
|
|
|
53 /* The console cannot process virtual terminal sequences. (Legacy
|
|
|
54 * console)
|
|
|
55 */
|
|
|
56 UV_TTY_UNSUPPORTED
|
|
|
57 } uv_tty_vtermstate_t
|
|
|
58
|
|
|
59
|
|
|
60
|
|
|
61 Public members
|
|
|
62 ^^^^^^^^^^^^^^
|
|
|
63
|
|
|
64 N/A
|
|
|
65
|
|
|
66 .. seealso:: The :c:type:`uv_stream_t` members also apply.
|
|
|
67
|
|
|
68
|
|
|
69 API
|
|
|
70 ---
|
|
|
71
|
|
|
72 .. c:function:: int uv_tty_init(uv_loop_t* loop, uv_tty_t* handle, uv_file fd, int unused)
|
|
|
73
|
|
|
74 Initialize a new TTY stream with the given file descriptor. Usually the
|
|
|
75 file descriptor will be:
|
|
|
76
|
|
|
77 * 0 = stdin
|
|
|
78 * 1 = stdout
|
|
|
79 * 2 = stderr
|
|
|
80
|
|
|
81 On Unix this function will determine the path of the fd of the terminal
|
|
|
82 using :man:`ttyname_r(3)`, open it, and use it if the passed file descriptor
|
|
|
83 refers to a TTY. This lets libuv put the tty in non-blocking mode without
|
|
|
84 affecting other processes that share the tty.
|
|
|
85
|
|
|
86 This function is not thread safe on systems that don't support
|
|
|
87 ioctl TIOCGPTN or TIOCPTYGNAME, for instance OpenBSD and Solaris.
|
|
|
88
|
|
|
89 .. note::
|
|
|
90 If reopening the TTY fails, libuv falls back to blocking writes.
|
|
|
91
|
|
|
92 .. versionchanged:: 1.23.1: the `readable` parameter is now unused and ignored.
|
|
|
93 The correct value will now be auto-detected from the kernel.
|
|
|
94
|
|
|
95 .. versionchanged:: 1.9.0: the path of the TTY is determined by
|
|
|
96 :man:`ttyname_r(3)`. In earlier versions libuv opened
|
|
|
97 `/dev/tty` instead.
|
|
|
98
|
|
|
99 .. versionchanged:: 1.5.0: trying to initialize a TTY stream with a file
|
|
|
100 descriptor that refers to a file returns `UV_EINVAL`
|
|
|
101 on UNIX.
|
|
|
102
|
|
|
103 .. c:function:: int uv_tty_set_mode(uv_tty_t* handle, uv_tty_mode_t mode)
|
|
|
104
|
|
|
105 .. versionchanged:: 1.2.0: the mode is specified as a
|
|
|
106 :c:enum:`uv_tty_mode_t` value.
|
|
|
107
|
|
|
108 Set the TTY using the specified terminal mode.
|
|
|
109
|
|
|
110 .. c:function:: int uv_tty_reset_mode(void)
|
|
|
111
|
|
|
112 To be called when the program exits. Resets TTY settings to default
|
|
|
113 values for the next process to take over.
|
|
|
114
|
|
|
115 This function is async signal-safe on Unix platforms but can fail with error
|
|
|
116 code ``UV_EBUSY`` if you call it when execution is inside
|
|
|
117 :c:func:`uv_tty_set_mode`.
|
|
|
118
|
|
|
119 .. c:function:: int uv_tty_get_winsize(uv_tty_t* handle, int* width, int* height)
|
|
|
120
|
|
|
121 Gets the current Window size. On success it returns 0.
|
|
|
122
|
|
|
123 .. seealso:: The :c:type:`uv_stream_t` API functions also apply.
|
|
|
124
|
|
|
125 .. c:function:: void uv_tty_set_vterm_state(uv_tty_vtermstate_t state)
|
|
|
126
|
|
|
127 Controls whether console virtual terminal sequences are processed by libuv
|
|
|
128 or console.
|
|
|
129 Useful in particular for enabling ConEmu support of ANSI X3.64 and Xterm
|
|
|
130 256 colors. Otherwise Windows10 consoles are usually detected automatically.
|
|
|
131
|
|
|
132 This function is only meaningful on Windows systems. On Unix it is silently
|
|
|
133 ignored.
|
|
|
134
|
|
|
135 .. versionadded:: 1.33.0
|
|
|
136
|
|
|
137 .. c:function:: int uv_tty_get_vterm_state(uv_tty_vtermstate_t* state)
|
|
|
138
|
|
|
139 Get the current state of whether console virtual terminal sequences are
|
|
|
140 handled by libuv or the console.
|
|
|
141
|
|
|
142 This function is not implemented on Unix, where it returns ``UV_ENOTSUP``.
|
|
|
143
|
|
|
144 .. versionadded:: 1.33.0
|
|
|
145
|