···
1
+
/* Copyright (C) 2022-2025 mintsuki and contributors.
3
+
* Redistribution and use in source and binary forms, with or without
4
+
* modification, are permitted provided that the following conditions are met:
6
+
* 1. Redistributions of source code must retain the above copyright notice,
7
+
* this list of conditions and the following disclaimer.
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.
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.
26
+
#ifndef FLANTERM_PRIVATE_H
27
+
#define FLANTERM_PRIVATE_H 1
29
+
#ifndef FLANTERM_IN_FLANTERM
30
+
#error "Do not use flanterm_private.h. Use interfaces defined in flanterm.h only."
35
+
#include <stdbool.h>
41
+
#define FLANTERM_MAX_ESC_VALUES 16
43
+
struct flanterm_context {
48
+
bool cursor_enabled;
49
+
bool scroll_enabled;
50
+
bool control_sequence;
61
+
uint64_t code_point;
62
+
size_t unicode_remaining;
64
+
uint8_t charsets[2];
65
+
size_t current_charset;
66
+
size_t escape_offset;
67
+
size_t esc_values_i;
68
+
size_t saved_cursor_x;
69
+
size_t saved_cursor_y;
70
+
size_t current_primary;
72
+
size_t scroll_top_margin;
73
+
size_t scroll_bottom_margin;
74
+
uint32_t esc_values[FLANTERM_MAX_ESC_VALUES];
75
+
uint64_t oob_output;
76
+
bool saved_state_bold;
77
+
bool saved_state_bg_bold;
78
+
bool saved_state_reverse_video;
79
+
size_t saved_state_current_charset;
80
+
size_t saved_state_current_primary;
81
+
size_t saved_state_current_bg;
83
+
/* to be set by backend */
87
+
void (*raw_putchar)(struct flanterm_context *, uint8_t c);
88
+
void (*clear)(struct flanterm_context *, bool move);
89
+
void (*set_cursor_pos)(struct flanterm_context *, size_t x, size_t y);
90
+
void (*get_cursor_pos)(struct flanterm_context *, size_t *x, size_t *y);
91
+
void (*set_text_fg)(struct flanterm_context *, size_t fg);
92
+
void (*set_text_bg)(struct flanterm_context *, size_t bg);
93
+
void (*set_text_fg_bright)(struct flanterm_context *, size_t fg);
94
+
void (*set_text_bg_bright)(struct flanterm_context *, size_t bg);
95
+
void (*set_text_fg_rgb)(struct flanterm_context *, uint32_t fg);
96
+
void (*set_text_bg_rgb)(struct flanterm_context *, uint32_t bg);
97
+
void (*set_text_fg_default)(struct flanterm_context *);
98
+
void (*set_text_bg_default)(struct flanterm_context *);
99
+
void (*set_text_fg_default_bright)(struct flanterm_context *);
100
+
void (*set_text_bg_default_bright)(struct flanterm_context *);
101
+
void (*move_character)(struct flanterm_context *, size_t new_x, size_t new_y, size_t old_x, size_t old_y);
102
+
void (*scroll)(struct flanterm_context *);
103
+
void (*revscroll)(struct flanterm_context *);
104
+
void (*swap_palette)(struct flanterm_context *);
105
+
void (*save_state)(struct flanterm_context *);
106
+
void (*restore_state)(struct flanterm_context *);
107
+
void (*double_buffer_flush)(struct flanterm_context *);
108
+
void (*full_refresh)(struct flanterm_context *);
109
+
void (*deinit)(struct flanterm_context *, void (*)(void *, size_t));
111
+
/* to be set by client */
113
+
void (*callback)(struct flanterm_context *, uint64_t, uint64_t, uint64_t, uint64_t);