summaryrefslogtreecommitdiff
path: root/src/tty.h
diff options
context:
space:
mode:
authorJohn Hawthorn <john.hawthorn@gmail.com>2016-05-21 14:56:03 -0700
committerJohn Hawthorn <john.hawthorn@gmail.com>2016-05-21 14:56:25 -0700
commit2b3c3a85ec8aa8b4b94c0e594c32449dd70b4d26 (patch)
treeb72c2815f22fbae416cf10284c5acd273c75af7f /src/tty.h
parent45499644d85a9ba93dd9f1504d1ca7df15b60148 (diff)
Move sources into src directory
Diffstat (limited to 'src/tty.h')
-rw-r--r--src/tty.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/tty.h b/src/tty.h
new file mode 100644
index 0000000..b5a9343
--- /dev/null
+++ b/src/tty.h
@@ -0,0 +1,55 @@
+#ifndef TTY_H
+#define TTY_H TTY_H
+
+#include <termios.h>
+
+typedef struct {
+ int fdin;
+ FILE *fout;
+ struct termios original_termios;
+ int fgcolor;
+ size_t maxwidth;
+ size_t maxheight;
+} tty_t;
+
+void tty_reset(tty_t *tty);
+void tty_close(tty_t *tty);
+void tty_init(tty_t *tty, const char *tty_filename);
+void tty_getwinsz(tty_t *tty);
+char tty_getchar(tty_t *tty);
+
+void tty_setfg(tty_t *tty, int fg);
+void tty_setinvert(tty_t *tty);
+void tty_setnormal(tty_t *tty);
+
+#define TTY_COLOR_BLACK 0
+#define TTY_COLOR_RED 1
+#define TTY_COLOR_GREEN 2
+#define TTY_COLOR_YELLOW 3
+#define TTY_COLOR_BLUE 4
+#define TTY_COLOR_MAGENTA 5
+#define TTY_COLOR_CYAN 6
+#define TTY_COLOR_WHITE 7
+#define TTY_COLOR_NORMAL 9
+
+/* tty_newline
+ * Move cursor to the beginning of the next line, clearing to the end of the
+ * current line
+ */
+void tty_newline(tty_t *tty);
+
+/* tty_clearline
+ * Clear to the end of the current line without advancing the cursor.
+ */
+void tty_clearline(tty_t *tty);
+
+void tty_moveup(tty_t *tty, int i);
+void tty_setcol(tty_t *tty, int col);
+
+void tty_printf(tty_t *tty, const char *fmt, ...);
+void tty_flush(tty_t *tty);
+
+size_t tty_getwidth(tty_t *tty);
+size_t tty_getheight(tty_t *tty);
+
+#endif