Fast and reasonably complete (framebuffer) terminal emulator (Zig fork)

Add support for out-of-band output control and implement ONLCR

mintsuki 4f44263c cdd2a948

Changed files
+13 -2
+3 -2
term.c
···
ctx->current_bg = (size_t)-1;
ctx->scroll_top_margin = 0;
ctx->scroll_bottom_margin = ctx->rows;
+
ctx->oob_output = TERM_OOB_OUTPUT_ONLCR;
}
static void term_putchar(struct term_context *ctx, uint8_t c);
···
case '\n':
if (y == ctx->scroll_bottom_margin - 1) {
ctx->scroll(ctx);
-
ctx->set_cursor_pos(ctx, 0, y);
+
ctx->set_cursor_pos(ctx, (ctx->oob_output & TERM_OOB_OUTPUT_ONLCR) ? 0 : x, y);
} else {
-
ctx->set_cursor_pos(ctx, 0, y + 1);
+
ctx->set_cursor_pos(ctx, (ctx->oob_output & TERM_OOB_OUTPUT_ONLCR) ? 0 : x, y + 1);
return;
case '\b':
+10
term.h
···
#define TERM_CB_MODE 70
#define TERM_CB_LINUX 80
+
#define TERM_OOB_OUTPUT_OCRNL (1 << 0)
+
#define TERM_OOB_OUTPUT_OFDEL (1 << 1)
+
#define TERM_OOB_OUTPUT_OFILL (1 << 2)
+
#define TERM_OOB_OUTPUT_OLCUC (1 << 3)
+
#define TERM_OOB_OUTPUT_ONLCR (1 << 4)
+
#define TERM_OOB_OUTPUT_ONLRET (1 << 5)
+
#define TERM_OOB_OUTPUT_ONOCR (1 << 6)
+
#define TERM_OOB_OUTPUT_OPOST (1 << 7)
+
struct term_context {
/* internal use */
···
size_t scroll_top_margin;
size_t scroll_bottom_margin;
uint32_t esc_values[TERM_MAX_ESC_VALUES];
+
uint64_t oob_output;
bool saved_state_bold;
bool saved_state_bg_bold;
bool saved_state_reverse_video;