This commit is contained in:
mintsuki 2022-10-04 03:31:39 +02:00
parent dd016334c5
commit 25dc8a177f
3 changed files with 34 additions and 14 deletions

View File

@ -7,6 +7,22 @@
void *memset(void *, int, size_t);
void *memcpy(void *, const void *, size_t);
static void fbterm_save_state(struct term_context *_ctx) {
struct fbterm_context *ctx = (void *)_ctx;
ctx->saved_state_text_fg = ctx->text_fg;
ctx->saved_state_text_bg = ctx->text_bg;
ctx->saved_state_cursor_x = ctx->cursor_x;
ctx->saved_state_cursor_y = ctx->cursor_y;
}
static void fbterm_restore_state(struct term_context *_ctx) {
struct fbterm_context *ctx = (void *)_ctx;
ctx->text_fg = ctx->saved_state_text_fg;
ctx->text_bg = ctx->saved_state_text_bg;
ctx->cursor_x = ctx->saved_state_cursor_x;
ctx->cursor_y = ctx->saved_state_cursor_y;
}
static void fbterm_swap_palette(struct term_context *_ctx) {
struct fbterm_context *ctx = (void *)_ctx;
uint32_t tmp = ctx->text_bg;
@ -554,6 +570,8 @@ struct term_context *fbterm_init(
_ctx->scroll = fbterm_scroll;
_ctx->revscroll = fbterm_revscroll;
_ctx->swap_palette = fbterm_swap_palette;
_ctx->save_state = fbterm_save_state;
_ctx->restore_state = fbterm_restore_state;
_ctx->double_buffer_flush = fbterm_double_buffer_flush;
_ctx->full_refresh = fbterm_full_refresh;
_ctx->deinit = fbterm_deinit;

16
term.c
View File

@ -44,9 +44,9 @@ static const uint32_t col256[] = {
#define CHARSET_DEC_SPECIAL 1
void term_context_reinit(struct term_context *ctx) {
ctx->scroll_enabled = true;
ctx->tab_size = 8;
ctx->escape_offset = 0;
ctx->autoflush = true;
ctx->scroll_enabled = true;
ctx->control_sequence = false;
ctx->csi = false;
ctx->escape = false;
@ -55,18 +55,18 @@ void term_context_reinit(struct term_context *ctx) {
ctx->bold = false;
ctx->reverse_video = false;
ctx->dec_private = false;
ctx->insert_mode = false;
ctx->g_select = 0;
ctx->charsets[0] = CHARSET_DEFAULT;
ctx->charsets[1] = CHARSET_DEC_SPECIAL;
ctx->current_charset = 0;
ctx->escape_offset = 0;
ctx->esc_values_i = 0;
ctx->saved_cursor_x = 0;
ctx->saved_cursor_y = 0;
ctx->current_primary = (size_t)-1;
ctx->insert_mode = false;
ctx->scroll_top_margin = 0;
ctx->scroll_bottom_margin = ctx->rows;
ctx->current_charset = 0;
ctx->g_select = 0;
ctx->charsets[0] = CHARSET_DEFAULT;
ctx->charsets[1] = CHARSET_DEC_SPECIAL;
ctx->autoflush = true;
}
static void term_putchar(struct term_context *ctx, uint8_t c);

14
term.h
View File

@ -17,14 +17,10 @@
#define TERM_CB_LINUX 80
struct term_context {
size_t rows, cols;
/* internal use */
size_t tab_size;
bool autoflush;
bool in_bootloader;
bool scroll_enabled;
bool control_sequence;
bool csi;
@ -46,12 +42,16 @@ struct term_context {
size_t scroll_top_margin;
size_t scroll_bottom_margin;
uint32_t esc_values[TERM_MAX_ESC_VALUES];
bool saved_state_bold;
bool saved_state_reverse_video;
size_t saved_state_current_charset;
size_t saved_state_current_primary;
/* to be set by backend */
size_t rows, cols;
bool in_bootloader;
void (*raw_putchar)(struct term_context *, uint8_t c);
void (*clear)(struct term_context *, bool move);
void (*enable_cursor)(struct term_context *);
@ -76,6 +76,8 @@ struct term_context {
void (*full_refresh)(struct term_context *);
void (*deinit)(struct term_context *, void (*)(void *, size_t));
/* to be set by client */
void (*callback)(struct term_context *, uint64_t, uint64_t, uint64_t, uint64_t);
};