2020-09-02 09:55:56 +02:00
|
|
|
#ifndef __LIB__TERM_H__
|
|
|
|
#define __LIB__TERM_H__
|
|
|
|
|
|
|
|
#include <stddef.h>
|
2021-08-16 18:02:28 +02:00
|
|
|
#include <stdint.h>
|
2022-02-07 02:10:57 +01:00
|
|
|
#include <lib/print.h>
|
2022-10-04 00:58:00 +02:00
|
|
|
#include <term/term.h>
|
2021-08-16 18:02:28 +02:00
|
|
|
|
|
|
|
enum {
|
2022-09-17 10:40:14 +02:00
|
|
|
_NOT_READY,
|
2022-10-04 01:37:19 +02:00
|
|
|
GTERM,
|
2021-12-14 06:47:28 +01:00
|
|
|
TEXTMODE,
|
|
|
|
FALLBACK
|
2021-08-16 18:02:28 +02:00
|
|
|
};
|
|
|
|
|
2022-11-18 23:59:31 +01:00
|
|
|
#if defined (BIOS)
|
2021-08-16 18:02:28 +02:00
|
|
|
extern int current_video_mode;
|
2022-11-18 23:59:31 +01:00
|
|
|
#endif
|
2020-09-02 09:55:56 +02:00
|
|
|
|
2022-11-18 23:59:31 +01:00
|
|
|
extern struct term_context **terms;
|
|
|
|
extern size_t terms_i;
|
|
|
|
|
|
|
|
extern int term_backend;
|
2021-04-04 18:05:18 +02:00
|
|
|
|
2021-08-16 18:02:28 +02: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 20:56:39 +02:00
|
|
|
#define TERM_FULL_REFRESH ((uint64_t)(-4))
|
2020-10-27 08:09:27 +01:00
|
|
|
|
2022-11-18 23:59:31 +01:00
|
|
|
#define FOR_TERM(...) do { \
|
|
|
|
for (size_t FOR_TERM_i = 0; FOR_TERM_i < terms_i; FOR_TERM_i++) { \
|
|
|
|
struct term_context *TERM = terms[FOR_TERM_i]; \
|
|
|
|
__VA_ARGS__ \
|
|
|
|
; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2021-10-09 13:32:57 +02:00
|
|
|
inline void reset_term(void) {
|
2022-11-18 23:59:31 +01:00
|
|
|
for (size_t i = 0; i < terms_i; i++) {
|
|
|
|
struct term_context *term = terms[i];
|
|
|
|
|
|
|
|
print("\e[2J\e[H");
|
|
|
|
term_context_reinit(term);
|
|
|
|
term->in_bootloader = true;
|
2022-12-30 07:58:46 +01:00
|
|
|
term->cursor_enabled = true;
|
2022-11-18 23:59:31 +01:00
|
|
|
term->double_buffer_flush(term);
|
|
|
|
}
|
2021-10-09 13:32:57 +02:00
|
|
|
}
|
|
|
|
|
2022-02-07 02:10:57 +01:00
|
|
|
inline void set_cursor_pos_helper(size_t x, size_t y) {
|
|
|
|
print("\e[%u;%uH", (int)y + 1, (int)x + 1);
|
|
|
|
}
|
|
|
|
|
2022-11-18 23:59:31 +01:00
|
|
|
void term_notready(void);
|
2022-10-04 00:58:00 +02:00
|
|
|
void term_fallback(void);
|
2022-11-18 23:59:31 +01:00
|
|
|
void _term_write(struct term_context *term, uint64_t buf, uint64_t count);
|
2022-10-04 00:58:00 +02:00
|
|
|
|
2020-09-02 09:55:56 +02:00
|
|
|
#endif
|