X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=visor;a=blobdiff_plain;f=visor%2Fsrc%2Fterm.c;h=4746836bb0a027e643af98047d14a27a5a1a4772;hp=ee93e031f5733ede6287e509a31b548305a2010a;hb=c17213b9500cfb26ba0d85b1a63c9aeb56981748;hpb=519bb5db64dd400724d8beedd10bf54d8cf2b7af diff --git a/visor/src/term.c b/visor/src/term.c index ee93e03..4746836 100644 --- a/visor/src/term.c +++ b/visor/src/term.c @@ -56,11 +56,20 @@ int term_init(const char *ttypath) void term_cleanup(void) { + term_clear(); + term_setcursor(0, 0); + term_flush(); tcsetattr(ttyfd, TCSAFLUSH, &saved_term); close(ttyfd); ttyfd = -1; } +void term_reset(void) +{ + term_puts("\033c"); + term_flush(); +} + void term_getsize(int *width, int *height) { *width = term_width; @@ -91,6 +100,11 @@ void term_send(const char *s, int size) } } +void term_putchar(char c) +{ + term_send(&c, 1); +} + void term_puts(const char *s) { term_send(s, strlen(s)); @@ -141,6 +155,16 @@ void term_clear(void) term_puts("\033[2J"); } +void term_cursor(int show) +{ + term_printf("\033[?25%c", show ? 'h' : 'l'); +} + +void term_setcursor(int row, int col) +{ + term_printf("\033[%d;%dH", row + 1, col + 1); +} + int term_getchar(void) { int res;