From 0fe28fd69dd15006ccd684d563699420aadde61a Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Tue, 3 Oct 2006 01:37:17 +0000 Subject: first working version of uuterm! - at this point it is purely experimental. only ascii characters are visible (using builtin font) although all characters are processed. - there are known bugs, including crashes. - there are major missing features. - but it works. ^_^ --- main.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 main.c (limited to 'main.c') diff --git a/main.c b/main.c new file mode 100644 index 0000000..8a8fd31 --- /dev/null +++ b/main.c @@ -0,0 +1,96 @@ +/* uuterm, Copyright (C) 2006 Rich Felker; licensed under GNU GPL v2 only */ + +#include +#include +#include +#include +#include +#include /* for broken systems */ + +#include "uuterm.h" + +int main(int argc, char *argv[]) +{ + struct uuterm t = { }; + struct uudisp d = { }; + int tty, max; + int i, l; + unsigned char b[128]; + fd_set fds; + struct timeval tv; + void *buf; + + setlocale(LC_CTYPE, ""); + + d.cell_w = 8; + d.cell_h = 16; + + if (uudisp_open(&d) < 0) + return 1; + + for (i=1; i 1 ? argv : NULL, d.w, d.h)) < 0) + return 1; + + signal(SIGHUP, SIG_IGN); + + if (!(buf = uuterm_buf_alloc(d.w, d.h))) { + uudisp_close(&d); + return 1; + } + uuterm_replace_buffer(&t, d.w, d.h, buf); + uuterm_reset(&t); + + for (;;) { + /* Setup fd_set containing fd's used by display and our tty */ + FD_ZERO(&fds); + FD_SET(tty, &fds); + max = uudisp_fd_set(&d, tty, &fds); + tv.tv_sec = 0; + tv.tv_usec = 250000; + if (select(max, &fds, NULL, NULL, &tv) == 0) + d.blink++; + + /* Process input from the tty, up to buffer size */ + if (FD_ISSET(tty, &fds)) { + if ((l = read(tty, b, sizeof b)) <= 0) + break; + for (i=0; i