1*0e552da7Schristos #include <stdio.h>
2*0e552da7Schristos #include <string.h>
3*0e552da7Schristos #include <unistd.h>
4*0e552da7Schristos #include <uv.h>
5*0e552da7Schristos
6*0e552da7Schristos uv_loop_t *loop;
7*0e552da7Schristos uv_tty_t tty;
main()8*0e552da7Schristos int main() {
9*0e552da7Schristos loop = uv_default_loop();
10*0e552da7Schristos
11*0e552da7Schristos uv_tty_init(loop, &tty, STDOUT_FILENO, 0);
12*0e552da7Schristos uv_tty_set_mode(&tty, UV_TTY_MODE_NORMAL);
13*0e552da7Schristos
14*0e552da7Schristos if (uv_guess_handle(1) == UV_TTY) {
15*0e552da7Schristos uv_write_t req;
16*0e552da7Schristos uv_buf_t buf;
17*0e552da7Schristos buf.base = "\033[41;37m";
18*0e552da7Schristos buf.len = strlen(buf.base);
19*0e552da7Schristos uv_write(&req, (uv_stream_t*) &tty, &buf, 1, NULL);
20*0e552da7Schristos }
21*0e552da7Schristos
22*0e552da7Schristos uv_write_t req;
23*0e552da7Schristos uv_buf_t buf;
24*0e552da7Schristos buf.base = "Hello TTY\n";
25*0e552da7Schristos buf.len = strlen(buf.base);
26*0e552da7Schristos uv_write(&req, (uv_stream_t*) &tty, &buf, 1, NULL);
27*0e552da7Schristos uv_tty_reset_mode();
28*0e552da7Schristos return uv_run(loop, UV_RUN_DEFAULT);
29*0e552da7Schristos }
30