summaryrefslogtreecommitdiff
path: root/terminal/terminal.h
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2015-05-22 03:28:49 +0200
committerMichal Idziorek <m.i@gmx.at>2015-05-22 03:28:49 +0200
commitfceb15b1d325a7bb0bcab8993a1057cb991172e8 (patch)
treeca95bf9b600d8687f2f6307628db4066e485119a /terminal/terminal.h
parenta6184be79e3918764d5e683796afbd8e8ccba018 (diff)
support for fg and bg color escape sequences
Diffstat (limited to 'terminal/terminal.h')
-rw-r--r--terminal/terminal.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/terminal/terminal.h b/terminal/terminal.h
new file mode 100644
index 0000000..e97a413
--- /dev/null
+++ b/terminal/terminal.h
@@ -0,0 +1,72 @@
+#ifndef TERMINAL_H
+#define TERMINAL_H
+
+#include <stdint.h>
+#include <stdbool.h>
+
+
+//
+// Terminal emulator implementing (a subset) of console codes of the
+// linux console (see man 4 console_codes)
+//
+// 1. pass a term_out and term_in struct to terminal_init(..).
+// 2. use the terminal_kb function for terminal/user input (eg. keyboard).
+// 3. use the terminal_put function for input from the host/programms.
+//
+//
+//
+// _____________
+// terminal_put()----> | | ----> (term_out_struct)
+// | TERMINAL |
+// (term_in_struct)<---|___________| <---- terminal_kb()
+//
+//
+// OTHER REQUIREMENTS
+//
+// Your also need to provide some memory allocation
+//
+// * uint32_t kballoc(uint32_t bloks); // block wise in-kernel allocation
+//
+
+typedef struct term_out_struct
+{
+
+ void (*put_char)(uint8_t c,uint8_t color_fg, uint8_t color_bg, uint32_t x, uint32_t y);
+ void (*update_cursor)(uint32_t col,uint32_t row);
+
+}term_out;
+
+typedef struct term_in_struct
+{
+
+ void (*put_char)(uint8_t c);
+
+}term_in;
+
+typedef struct terminal_tty_struct
+{
+ uint8_t fg;
+ uint8_t bg;
+
+ uint32_t width;
+ uint32_t height;
+ uint32_t x;
+ uint32_t y;
+ uint32_t *data; // screen data
+ uint8_t *command; // command line / also holds npar for escape sequences somewhere
+ int32_t command_l; // command line length
+
+ uint8_t escaping; // escaping mode?
+ uint8_t npar; // npar pos
+
+ term_out *screen;
+ term_in *input;
+
+}terminal_tty;
+
+terminal_tty terminal_init(term_out *screen,term_in *input);
+bool terminal_put(terminal_tty *tty, uint8_t c);
+void terminal_kb(terminal_tty *tty, uint8_t c);
+
+
+#endif