Fast and reasonably complete (framebuffer) terminal emulator (Zig fork)
1
2/* Copyright (C) 2022-2025 mintsuki and contributors.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 * POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#ifndef FLANTERM_H
28#define FLANTERM_H 1
29
30#include <stddef.h>
31#include <stdint.h>
32#include <stdbool.h>
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38#define FLANTERM_CB_DEC 10
39#define FLANTERM_CB_BELL 20
40#define FLANTERM_CB_PRIVATE_ID 30
41#define FLANTERM_CB_STATUS_REPORT 40
42#define FLANTERM_CB_POS_REPORT 50
43#define FLANTERM_CB_KBD_LEDS 60
44#define FLANTERM_CB_MODE 70
45#define FLANTERM_CB_LINUX 80
46
47#define FLANTERM_OOB_OUTPUT_OCRNL (1 << 0)
48#define FLANTERM_OOB_OUTPUT_OFDEL (1 << 1)
49#define FLANTERM_OOB_OUTPUT_OFILL (1 << 2)
50#define FLANTERM_OOB_OUTPUT_OLCUC (1 << 3)
51#define FLANTERM_OOB_OUTPUT_ONLCR (1 << 4)
52#define FLANTERM_OOB_OUTPUT_ONLRET (1 << 5)
53#define FLANTERM_OOB_OUTPUT_ONOCR (1 << 6)
54#define FLANTERM_OOB_OUTPUT_OPOST (1 << 7)
55
56#ifdef FLANTERM_IN_FLANTERM
57
58#include "flanterm_private.h"
59
60#else
61
62struct flanterm_context;
63
64#endif
65
66void flanterm_context_reinit(struct flanterm_context *ctx);
67void flanterm_write(struct flanterm_context *ctx, const char *buf, size_t count);
68
69void flanterm_full_refresh(struct flanterm_context *ctx);
70void flanterm_deinit(struct flanterm_context *ctx, void (*_free)(void *, size_t));
71
72void flanterm_get_dimensions(struct flanterm_context *ctx, size_t *rows, size_t *cols);
73void flanterm_set_autoflush(struct flanterm_context *ctx, bool state);
74void flanterm_set_callback(struct flanterm_context *ctx, void (*callback)(struct flanterm_context *, uint64_t, uint64_t, uint64_t, uint64_t));
75
76#ifdef __cplusplus
77}
78#endif
79
80#endif