2 #include "console_keys.h"
11 /* initialize a Console struct */
12 void console_init(struct Console
* self
) {
15 /* cleanup restores the original term behaviour and releases acquired resources. */
16 void console_cleanup(struct Console
* self
) {
19 int console_setcolor(struct Console
* self
, int is_fg
, rgb_t mycolor
) {
23 int console_getcolorcount(Console
*self
) { (void) self
; return 8; }
25 void console_initoutput(struct Console
* self
) { (void) self
; }
27 /* get width and height of the console display (in characters) */
28 void console_getbounds(struct Console
* self
, int* width
, int* height
) {
29 self
->dim
.x
= *width
= 80;
30 self
->dim
.y
= *height
= 25;
33 void console_goto(struct Console
* self
, int x
, int y
) {
38 /* prints a char and NOT advances cursor */
39 void console_addchar(struct Console
* self
, int c
, unsigned int attributes
) {
41 /* prints a char and advances cursor */
42 void console_printchar(struct Console
* self
, int c
, unsigned int attributes
) {
45 void console_putchar(Console
* self
, int ch
, int doupdate
) {
50 void console_printf (struct Console* con, const char* fmt, ...) {
53 void console_printfxy (struct Console* con, int x, int y, const char* fmt, ...) {
57 int console_getkey(struct Console
* self
) {
61 /* non blocking getkey. returns -1 if no data is available */
62 int console_getkey_nb(struct Console
* self
) {
65 #undef _POSIX_C_SOURCE
66 #define _POSIX_C_SOURCE 200809L
70 int msleep(long millisecs
) {
71 struct timespec req
, rem
;
72 req
.tv_sec
= millisecs
/ 1000;
73 req
.tv_nsec
= (millisecs
% 1000) * 1000 * 1000;
75 while((ret
= nanosleep(&req
, &rem
)) == -1 && errno
== EINTR
) req
= rem
;
79 void console_sleep(struct Console
* self
, int ms
) {
84 void console_refresh(struct Console
* self
) {
87 void console_clear(struct Console
* self
) {
90 void console_blink_cursor(struct Console
* self
) { (void) self
; }
91 void console_lock(void) {}
92 void console_unlock(void) {}
93 void console_toggle_fullscreen(struct Console
* self
) { (void) self
; }
95 void console_init_graphics(Console
* self
, point resolution
, font
* fnt
) {
98 void console_settitle(Console
*self
, const char *title
) {