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_H
27#define FLANTERM_H 1
28
29#include <stddef.h>
30#include <stdint.h>
31#include <stdbool.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37#define FLANTERM_CB_DEC 10
38#define FLANTERM_CB_BELL 20
39#define FLANTERM_CB_PRIVATE_ID 30
40#define FLANTERM_CB_STATUS_REPORT 40
41#define FLANTERM_CB_POS_REPORT 50
42#define FLANTERM_CB_KBD_LEDS 60
43#define FLANTERM_CB_MODE 70
44#define FLANTERM_CB_LINUX 80
45
46#define FLANTERM_OOB_OUTPUT_OCRNL (1 << 0)
47#define FLANTERM_OOB_OUTPUT_OFDEL (1 << 1)
48#define FLANTERM_OOB_OUTPUT_OFILL (1 << 2)
49#define FLANTERM_OOB_OUTPUT_OLCUC (1 << 3)
50#define FLANTERM_OOB_OUTPUT_ONLCR (1 << 4)
51#define FLANTERM_OOB_OUTPUT_ONLRET (1 << 5)
52#define FLANTERM_OOB_OUTPUT_ONOCR (1 << 6)
53#define FLANTERM_OOB_OUTPUT_OPOST (1 << 7)
54
55#ifdef FLANTERM_IN_FLANTERM
56
57#include "flanterm_private.h"
58
59#else
60
61struct flanterm_context;
62
63#endif
64
65void flanterm_write(struct flanterm_context *ctx, const char *buf, size_t count);
66void flanterm_flush(struct flanterm_context *ctx);
67void flanterm_full_refresh(struct flanterm_context *ctx);
68void flanterm_deinit(struct flanterm_context *ctx, void (*_free)(void *ptr, size_t size));
69
70void flanterm_get_dimensions(struct flanterm_context *ctx, size_t *rows, size_t *cols);
71void flanterm_set_autoflush(struct flanterm_context *ctx, bool state);
72void flanterm_set_callback(struct flanterm_context *ctx, void (*callback)(struct flanterm_context *, uint64_t, uint64_t, uint64_t, uint64_t));
73uint64_t flanterm_get_oob_output(struct flanterm_context *ctx);
74void flanterm_set_oob_output(struct flanterm_context *ctx, uint64_t oob_output);
75
76#ifdef __cplusplus
77}
78#endif
79
80#endif