diff options
| author | Miguel <m.i@gmx.at> | 2018-08-31 12:01:29 +0200 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2018-08-31 12:01:29 +0200 |
| commit | 331ed2b6273c79e0eaa236c4615205823608dc6b (patch) | |
| tree | 2106c5b5ed9691f6eae445156910f3a93f36f322 /driver/terminal.h | |
| parent | 47d7e8e4527c663dd1a0c04a4ea5624589464895 (diff) | |
moved terminal.c and terminal.h
Diffstat (limited to 'driver/terminal.h')
| -rw-r--r-- | driver/terminal.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/driver/terminal.h b/driver/terminal.h new file mode 100644 index 0000000..be711f5 --- /dev/null +++ b/driver/terminal.h @@ -0,0 +1,77 @@ +#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; + + bool set_buff; + bool set_lfnl; + bool set_echo; + + 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; + + bool reverse_video; + +}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 |
