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

Start encapsulation of flanterm internals

mintsuki 283de1f1 201100c9

Changed files
+28
backends
+2
backends/fb.c
···
#include <stddef.h>
#include <stdbool.h>
#include "../flanterm.h"
#include "fb.h"
···
#include <stddef.h>
#include <stdbool.h>
+
#define FLANTERM_IN_FLANTERM
+
#include "../flanterm.h"
#include "fb.h"
+4
backends/fb.h
···
#include "../flanterm.h"
#define FLANTERM_FB_FONT_GLYPHS 256
struct flanterm_fb_char {
···
size_t old_cursor_x;
size_t old_cursor_y;
};
struct flanterm_context *flanterm_fb_init(
/* If _malloc and _free are nulled, use the bump allocated instance (1 use only). */
···
#include "../flanterm.h"
+
#ifdef FLANTERM_IN_FLANTERM
+
#define FLANTERM_FB_FONT_GLYPHS 256
struct flanterm_fb_char {
···
size_t old_cursor_x;
size_t old_cursor_y;
};
+
+
#endif
struct flanterm_context *flanterm_fb_init(
/* If _malloc and _free are nulled, use the bump allocated instance (1 use only). */
+10
flanterm.c
···
#include <stddef.h>
#include <stdbool.h>
#include "flanterm.h"
// Tries to implement this standard for terminfo
···
ctx->raw_putchar(ctx, 0xfe);
}
}
···
#include <stddef.h>
#include <stdbool.h>
+
#define FLANTERM_IN_FLANTERM
+
#include "flanterm.h"
// Tries to implement this standard for terminfo
···
ctx->raw_putchar(ctx, 0xfe);
}
}
+
+
void flanterm_deinit(struct flanterm_context *ctx, void (*_free)(void *, size_t)) {
+
ctx->deinit(ctx, _free);
+
}
+
+
void flanterm_set_callback(struct flanterm_context *ctx, void (*callback)(struct flanterm_context *, uint64_t, uint64_t, uint64_t, uint64_t)) {
+
ctx->callback = callback;
+
}
+12
flanterm.h
···
/* Copyright (C) 2022-2025 mintsuki and contributors.
*
* Redistribution and use in source and binary forms, with or without
···
#define FLANTERM_OOB_OUTPUT_ONLRET (1 << 5)
#define FLANTERM_OOB_OUTPUT_ONOCR (1 << 6)
#define FLANTERM_OOB_OUTPUT_OPOST (1 << 7)
struct flanterm_context {
/* internal use */
···
void (*callback)(struct flanterm_context *, uint64_t, uint64_t, uint64_t, uint64_t);
};
void flanterm_context_reinit(struct flanterm_context *ctx);
void flanterm_write(struct flanterm_context *ctx, const char *buf, size_t count);
#ifdef __cplusplus
}
···
+
/* Copyright (C) 2022-2025 mintsuki and contributors.
*
* Redistribution and use in source and binary forms, with or without
···
#define FLANTERM_OOB_OUTPUT_ONLRET (1 << 5)
#define FLANTERM_OOB_OUTPUT_ONOCR (1 << 6)
#define FLANTERM_OOB_OUTPUT_OPOST (1 << 7)
+
+
#ifdef FLANTERM_IN_FLANTERM
struct flanterm_context {
/* internal use */
···
void (*callback)(struct flanterm_context *, uint64_t, uint64_t, uint64_t, uint64_t);
};
+
#else
+
+
struct flanterm_context;
+
+
#endif
+
void flanterm_context_reinit(struct flanterm_context *ctx);
void flanterm_write(struct flanterm_context *ctx, const char *buf, size_t count);
+
+
void flanterm_deinit(struct flanterm_context *ctx, void (*_free)(void *, size_t));
+
void flanterm_set_callback(struct flanterm_context *ctx, void (*callback)(struct flanterm_context *, uint64_t, uint64_t, uint64_t, uint64_t));
#ifdef __cplusplus
}