video-terminal-revival/video-terminal/tintty.h
2021-03-14 00:08:55 +01:00

46 lines
1.2 KiB
C

#include "Arduino.h"
extern bool tintty_cursor_key_mode_application;
/**
* Renderer callbacks.
*/
struct tintty_display {
int16_t screen_width, screen_height;
int16_t screen_col_count, screen_row_count; // width and height divided by char size
void (*fill_rect)(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
void (*draw_pixels)(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t *pixels);
void (*print_character)(int16_t col, int16_t row, uint16_t fg_color, uint16_t bg_color, char character);
void (*print_cursor)(int16_t col, int16_t row, uint16_t color);
void (*set_vscroll)(int16_t offset); // scroll offset for entire screen
};
/**
* Keyboard callbacks.
*/
struct tintty_keyboard {
void (*bell)();
};
/**
* Main entry point.
* Peek/read callbacks are expected to block until input is available;
* while sketch is waiting for input, it should call the tintty_idle() hook
* to allow animating cursor, etc.
*/
void tintty_run(
char (*peek_char)(),
char (*read_char)(),
void (*send_char)(char str),
tintty_display *display,
tintty_keyboard *keyboard
);
/**
* Hook to call while e.g. sketch is waiting for input
*/
void tintty_idle(
tintty_display *display
);