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