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

Minor style adjustments

mintsuki 9596ebd9 80a06672

Changed files
+9 -9
backends
+6 -6
backends/fb.c
···
if (x >= _ctx->cols || y >= _ctx->rows) {
return;
}
-
+
#ifdef FLANTERM_FB_DISABLE_CANVAS
uint32_t default_bg = ctx->default_bg;
#endif
···
for (size_t gy = 0; gy < ctx->glyph_height; gy++) {
uint8_t fy = gy / ctx->font_scale_y;
volatile uint32_t *fb_line = ctx->framebuffer + x + (y + gy) * (ctx->pitch / 4);
-
+
#ifndef FLANTERM_FB_DISABLE_CANVAS
uint32_t *canvas_line = ctx->canvas + x + (y + gy) * ctx->width;
#endif
-
+
for (size_t fx = 0; fx < ctx->font_width; fx++) {
bool draw = glyph[fy * ctx->font_width + fx];
for (size_t i = 0; i < ctx->font_scale_x; i++) {
···
static void flanterm_fb_full_refresh(struct flanterm_context *_ctx) {
struct flanterm_fb_context *ctx = (void *)_ctx;
-
+
#ifdef FLANTERM_FB_DISABLE_CANVAS
uint32_t default_bg = ctx->default_bg;
#endif
···
_free(ctx->grid, ctx->grid_size);
_free(ctx->queue, ctx->queue_size);
_free(ctx->map, ctx->map_size);
-
+
#ifndef FLANTERM_FB_DISABLE_CANVAS
_free(ctx->canvas, ctx->canvas_size);
#endif
-
+
_free(ctx, sizeof(struct flanterm_fb_context));
}
+3 -3
flanterm.c
···
#include "flanterm.h"
+
// Tries to implement this standard for terminfo
+
// https://man7.org/linux/man-pages/man4/console_codes.4.html
+
static const uint32_t col256[] = {
0x000000, 0x00005f, 0x000087, 0x0000af, 0x0000d7, 0x0000ff, 0x005f00, 0x005f5f,
0x005f87, 0x005faf, 0x005fd7, 0x005fff, 0x008700, 0x00875f, 0x008787, 0x0087af,
···
0x585858, 0x626262, 0x6c6c6c, 0x767676, 0x808080, 0x8a8a8a, 0x949494, 0x9e9e9e,
0xa8a8a8, 0xb2b2b2, 0xbcbcbc, 0xc6c6c6, 0xd0d0d0, 0xdadada, 0xe4e4e4, 0xeeeeee
};
-
-
// Tries to implement this standard for terminfo
-
// https://man7.org/linux/man-pages/man4/console_codes.4.html
#define CHARSET_DEFAULT 0
#define CHARSET_DEC_SPECIAL 1