Fast and reasonably complete (framebuffer) terminal emulator (Zig fork)
1/* Copyright (C) 2022-2025 mintsuki and contributors. 2 * 3 * Redistribution and use in source and binary forms, with or without 4 * modification, are permitted provided that the following conditions are met: 5 * 6 * 1. Redistributions of source code must retain the above copyright notice, 7 * this list of conditions and the following disclaimer. 8 * 9 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * this list of conditions and the following disclaimer in the documentation 11 * and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 17 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 23 * POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#ifndef FLANTERM_FB_H 27#define FLANTERM_FB_H 1 28 29#include <stdint.h> 30#include <stddef.h> 31#include <stdbool.h> 32 33#ifdef __cplusplus 34extern "C" { 35#endif 36 37#include "../flanterm.h" 38 39#ifdef FLANTERM_IN_FLANTERM 40 41#include "fb_private.h" 42 43#endif 44 45struct flanterm_context *flanterm_fb_init( 46 /* If _malloc and _free are nulled, use the bump allocated instance (1 use only). */ 47 void *(*_malloc)(size_t), 48 void (*_free)(void *, size_t), 49 uint32_t *framebuffer, size_t width, size_t height, size_t pitch, 50 uint8_t red_mask_size, uint8_t red_mask_shift, 51 uint8_t green_mask_size, uint8_t green_mask_shift, 52 uint8_t blue_mask_size, uint8_t blue_mask_shift, 53 uint32_t *canvas, /* If nulled, no canvas. */ 54 uint32_t *ansi_colours, uint32_t *ansi_bright_colours, /* If nulled, default. */ 55 uint32_t *default_bg, uint32_t *default_fg, /* If nulled, default. */ 56 uint32_t *default_bg_bright, uint32_t *default_fg_bright, /* If nulled, default. */ 57 /* If font is null, use default font and font_width and font_height ignored. */ 58 void *font, size_t font_width, size_t font_height, size_t font_spacing, 59 /* If scale_x and scale_y are 0, automatically scale font based on resolution. */ 60 size_t font_scale_x, size_t font_scale_y, 61 size_t margin 62); 63 64#ifdef __cplusplus 65} 66#endif 67 68#endif