2020-09-02 10:55:56 +03:00
|
|
|
#ifndef __LIB__TERM_H__
|
|
|
|
#define __LIB__TERM_H__
|
|
|
|
|
|
|
|
#include <stddef.h>
|
2021-08-16 19:02:28 +03:00
|
|
|
#include <stdint.h>
|
2020-09-02 10:55:56 +03:00
|
|
|
#include <stdbool.h>
|
2020-09-22 01:18:13 +03:00
|
|
|
#include <lib/image.h>
|
2020-09-02 10:55:56 +03:00
|
|
|
|
2021-08-16 19:02:28 +03:00
|
|
|
#define TERM_TABSIZE (8)
|
|
|
|
#define MAX_ESC_VALUES (16)
|
|
|
|
|
|
|
|
extern struct term_context {
|
|
|
|
bool control_sequence;
|
|
|
|
bool csi;
|
|
|
|
bool escape;
|
|
|
|
bool rrr;
|
|
|
|
bool discard_next;
|
|
|
|
bool bold;
|
|
|
|
bool reverse_video;
|
|
|
|
bool dec_private;
|
|
|
|
bool insert_mode;
|
|
|
|
uint8_t g_select;
|
|
|
|
uint8_t charsets[2];
|
|
|
|
size_t current_charset;
|
|
|
|
size_t escape_offset;
|
|
|
|
size_t esc_values_i;
|
|
|
|
size_t saved_cursor_x;
|
|
|
|
size_t saved_cursor_y;
|
|
|
|
size_t current_primary;
|
|
|
|
size_t scroll_top_margin;
|
|
|
|
size_t scroll_bottom_margin;
|
|
|
|
uint32_t esc_values[MAX_ESC_VALUES];
|
|
|
|
} term_context;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
NOT_READY,
|
|
|
|
VBE,
|
|
|
|
TEXTMODE
|
|
|
|
};
|
|
|
|
|
|
|
|
extern int current_video_mode;
|
|
|
|
extern int term_backend;
|
|
|
|
extern size_t term_rows, term_cols;
|
|
|
|
extern bool term_runtime;
|
|
|
|
extern bool early_term;
|
|
|
|
|
|
|
|
void term_reinit(void);
|
|
|
|
void term_deinit(void);
|
|
|
|
void term_vbe(size_t width, size_t height);
|
|
|
|
void term_textmode(void);
|
2021-11-20 23:47:51 +03:00
|
|
|
void term_notready(void);
|
2021-08-16 19:02:28 +03:00
|
|
|
void term_putchar(uint8_t c);
|
|
|
|
void term_write(uint64_t buf, uint64_t count);
|
|
|
|
|
2020-12-07 19:14:14 +03:00
|
|
|
extern void (*raw_putchar)(uint8_t c);
|
2020-09-02 10:55:56 +03:00
|
|
|
extern void (*clear)(bool move);
|
|
|
|
extern void (*enable_cursor)(void);
|
2021-06-08 01:06:33 +03:00
|
|
|
extern bool (*disable_cursor)(void);
|
2021-08-16 19:02:28 +03:00
|
|
|
extern void (*set_cursor_pos)(size_t x, size_t y);
|
|
|
|
extern void (*get_cursor_pos)(size_t *x, size_t *y);
|
|
|
|
extern void (*set_text_fg)(size_t fg);
|
|
|
|
extern void (*set_text_bg)(size_t bg);
|
|
|
|
extern void (*set_text_fg_bright)(size_t fg);
|
|
|
|
extern void (*set_text_bg_bright)(size_t bg);
|
2021-08-01 00:51:48 +03:00
|
|
|
extern void (*set_text_fg_default)(void);
|
|
|
|
extern void (*set_text_bg_default)(void);
|
2021-07-08 17:33:24 +03:00
|
|
|
extern bool (*scroll_disable)(void);
|
|
|
|
extern void (*scroll_enable)(void);
|
2021-08-16 19:02:28 +03:00
|
|
|
extern void (*term_move_character)(size_t new_x, size_t new_y, size_t old_x, size_t old_y);
|
|
|
|
extern void (*term_scroll)(void);
|
|
|
|
extern void (*term_swap_palette)(void);
|
2020-09-02 10:55:56 +03:00
|
|
|
|
2020-11-20 21:55:18 +03:00
|
|
|
extern void (*term_double_buffer_flush)(void);
|
|
|
|
|
2021-08-16 19:02:28 +03:00
|
|
|
extern uint64_t (*term_context_size)(void);
|
|
|
|
extern void (*term_context_save)(uint64_t ptr);
|
|
|
|
extern void (*term_context_restore)(uint64_t ptr);
|
2021-08-16 21:56:39 +03:00
|
|
|
extern void (*term_full_refresh)(void);
|
2020-09-02 10:55:56 +03:00
|
|
|
|
2021-08-16 19:02:28 +03:00
|
|
|
#define TERM_CB_DEC 10
|
|
|
|
#define TERM_CB_BELL 20
|
|
|
|
#define TERM_CB_PRIVATE_ID 30
|
2021-08-16 20:32:09 +03:00
|
|
|
#define TERM_CB_STATUS_REPORT 40
|
2021-08-16 23:47:40 +03:00
|
|
|
#define TERM_CB_POS_REPORT 50
|
|
|
|
#define TERM_CB_KBD_LEDS 60
|
|
|
|
#define TERM_CB_MODE 70
|
|
|
|
#define TERM_CB_LINUX 80
|
2021-04-04 19:05:18 +03:00
|
|
|
|
2021-08-16 19:02:28 +03:00
|
|
|
#define TERM_CTX_SIZE ((uint64_t)(-1))
|
|
|
|
#define TERM_CTX_SAVE ((uint64_t)(-2))
|
|
|
|
#define TERM_CTX_RESTORE ((uint64_t)(-3))
|
2021-08-16 21:56:39 +03:00
|
|
|
#define TERM_FULL_REFRESH ((uint64_t)(-4))
|
2020-10-27 10:09:27 +03:00
|
|
|
|
2021-08-16 21:00:37 +03:00
|
|
|
extern void (*term_callback)(uint64_t, uint64_t, uint64_t, uint64_t);
|
2021-04-11 03:30:48 +03:00
|
|
|
|
2021-10-09 14:32:57 +03:00
|
|
|
extern bool term_autoflush;
|
|
|
|
|
|
|
|
inline void reset_term(void) {
|
2021-11-20 23:47:51 +03:00
|
|
|
term_autoflush = true;
|
|
|
|
enable_cursor();
|
|
|
|
clear(true);
|
|
|
|
term_double_buffer_flush();
|
2021-10-09 14:32:57 +03:00
|
|
|
}
|
|
|
|
|
2020-09-02 10:55:56 +03:00
|
|
|
#endif
|