27 #include <t3window/window_api.h>
46 #define T3_WINDOW_VERSION 0
62 #if INT_MAX < 2147483647L
80 #define T3_TERM_CAP_FG (1 << 0)
82 #define T3_TERM_CAP_BG (1 << 1)
84 #define T3_TERM_CAP_CP (1 << 2)
101 #define T3_ATTR_USER ((t3_attr_t) (1L << 0))
103 #define T3_ATTR_UNDERLINE ((t3_attr_t) (1L << 1))
105 #define T3_ATTR_BOLD ((t3_attr_t) (1L << 2))
107 #define T3_ATTR_REVERSE ((t3_attr_t) (1L << 3))
109 #define T3_ATTR_BLINK ((t3_attr_t) (1L << 4))
111 #define T3_ATTR_DIM ((t3_attr_t) (1L << 5))
113 #define T3_ATTR_ACS ((t3_attr_t) (1L << 6))
119 #define T3_ATTR_FALLBACK_ACS ((t3_attr_t) (1L << 7))
122 #define T3_ATTR_COLOR_SHIFT 8
124 #define T3_ATTR_FG(x) (((((t3_attr_t) (x)) & 0xff) + 1) << T3_ATTR_COLOR_SHIFT)
126 #define T3_ATTR_BG(x) (((((t3_attr_t) (x)) & 0xff) + 1) << (T3_ATTR_COLOR_SHIFT + 9))
128 #define T3_ATTR_FG_MASK (0x1ff << T3_ATTR_COLOR_SHIFT)
130 #define T3_ATTR_BG_MASK (0x1ff << (T3_ATTR_COLOR_SHIFT + 9))
133 #define T3_ATTR_FG_UNSPEC ((t3_attr_t) 0L)
135 #define T3_ATTR_FG_DEFAULT (((t3_attr_t) 257) << (T3_ATTR_COLOR_SHIFT))
137 #define T3_ATTR_FG_BLACK T3_ATTR_FG(0)
139 #define T3_ATTR_FG_RED T3_ATTR_FG(1)
141 #define T3_ATTR_FG_GREEN T3_ATTR_FG(2)
143 #define T3_ATTR_FG_YELLOW T3_ATTR_FG(3)
145 #define T3_ATTR_FG_BLUE T3_ATTR_FG(4)
147 #define T3_ATTR_FG_MAGENTA T3_ATTR_FG(5)
149 #define T3_ATTR_FG_CYAN T3_ATTR_FG(6)
151 #define T3_ATTR_FG_WHITE T3_ATTR_FG(7)
154 #define T3_ATTR_BG_UNSPEC ((t3_attr_t) 0L)
156 #define T3_ATTR_BG_DEFAULT (((t3_attr_t) 257) << (T3_ATTR_COLOR_SHIFT + 9))
158 #define T3_ATTR_BG_BLACK T3_ATTR_BG(0)
160 #define T3_ATTR_BG_RED T3_ATTR_BG(1)
162 #define T3_ATTR_BG_GREEN T3_ATTR_BG(2)
164 #define T3_ATTR_BG_YELLOW T3_ATTR_BG(3)
166 #define T3_ATTR_BG_BLUE T3_ATTR_BG(4)
168 #define T3_ATTR_BG_MAGENTA T3_ATTR_BG(5)
170 #define T3_ATTR_BG_CYAN T3_ATTR_BG(6)
172 #define T3_ATTR_BG_WHITE T3_ATTR_BG(7)
199 #define T3_TERM_KEY_CTRL (1<<0)
200 #define T3_TERM_KEY_META (1<<1)
201 #define T3_TERM_KEY_SHIFT (1<<2)
203 #include "window_errors.h"
208 #define T3_ERR_NOT_A_TTY (-64)
210 #define T3_ERR_TIMEOUT (-63)
212 #define T3_ERR_NO_SIZE_INFO (-62)
214 #define T3_ERR_NONPRINT (-61)
216 #define T3_ERR_CHARSET_ERROR (-60)
218 #define T3_WARN_UPDATE_TERMINAL (-1)
225 T3_WINDOW_API
int t3_term_init(
int fd,
const char *term);
226 T3_WINDOW_API
void t3_term_deinit(
void);
227 T3_WINDOW_API
void t3_term_restore(
void);
250 T3_WINDOW_API
void t3_term_disable_ansi_optimization(
void);
267 #define t3_term_get_caps(caps) t3_term_get_caps_internal((caps), T3_WINDOW_VERSION)
Vertical line.
Definition: terminal.h:186
long t3_window_get_version(void)
Get the value of T3_WINDOW_VERSION corresponding to the actually used library.
Definition: misc.c:35
Arrow pointing up.
Definition: terminal.h:187
int t3_term_get_keychar(int msec)
Get a key char from stdin with timeout.
Definition: input.c:230
void t3_term_putp(const char *str)
Send a terminal control string to the terminal, with correct padding.
Definition: terminal.c:808
Board of squares.
Definition: terminal.h:191
void t3_term_get_size(int *height, int *width)
Retrieve the terminal size.
Definition: terminal.c:287
Lower left corner.
Definition: terminal.h:183
Data structure to store information about the capabilities of the terminal.
Definition: terminal.h:72
Bullet.
Definition: terminal.h:193
Solid block.
Definition: terminal.h:195
Tee pointing left.
Definition: terminal.h:178
Checker board pattern (stipple).
Definition: terminal.h:192
Tee pointing right.
Definition: terminal.h:179
void t3_term_hide_cursor(void)
Hide the cursor.
Definition: terminal.c:269
Upper left corner.
Definition: terminal.h:181
Upper right corner.
Definition: terminal.h:182
Arrow pointing left.
Definition: terminal.h:189
t3_attr_t highlights
The supported attributes other then color attributes.
Definition: terminal.h:73
char t3_bool
A boolean type that does not clash with C++ or C99 bool.
Definition: window_api.h:47
void t3_term_show_cursor(void)
Show the cursor.
Definition: terminal.c:277
void t3_term_set_cursor(int y, int x)
Move cursor.
Definition: terminal.c:259
void t3_term_set_replacement_char(int c)
Set the replacement character used for undrawable characters.
Definition: convert_output.c:393
void t3_term_get_caps_internal(t3_term_caps_t *caps, int version)
Get the terminal capabilities.
Definition: terminal.c:892
t3_bool t3_term_resize(void)
Handle resizing of the terminal.
Definition: terminal.c:302
Arrow pointing down.
Definition: terminal.h:188
const char * t3_window_strerror(int error)
Get a string description for an error code.
Definition: misc.c:43
Diamond.
Definition: terminal.h:194
void t3_term_set_attrs(t3_attr_t new_attrs)
Set terminal drawing attributes.
Definition: terminal.c:540
int colors
The maximum number of supported colors, or 0 if color is not supported.
Definition: terminal.h:74
int t3_term_strwidth(const char *str)
Calculate the cell width of a string.
Definition: terminal.c:820
t3_attr_t t3_term_combine_attrs(t3_attr_t a, t3_attr_t b)
Combine attributes, with priority.
Definition: terminal.c:858
Tee pointing up.
Definition: terminal.h:180
int t3_term_unget_keychar(int c)
Push a char back for later retrieval with t3_term_get_keychar.
Definition: input.c:268
void(* t3_attr_user_callback_t)(const char *str, int length, int width, t3_attr_t attr)
User callback type.
Definition: terminal.h:91
int pairs
The maximum number of color pairs that are supported by this terminal, or 0 if color is not supported...
Definition: terminal.h:75
void t3_term_update(void)
Update the terminal, drawing all changes since last refresh.
Definition: terminal.c:581
t3_bool t3_term_acs_available(int idx)
Check if a character is available in the alternate character set (internal use mostly).
Definition: terminal.c:844
int t3_term_get_modifiers_hack(void)
Retrieve the state of the modifiers using terminal specific hacks.
Definition: terminal.c:942
int cap_flags
A bitmask of T3_TERM_CAP_* flags indicating capabilities of the terminal.
Definition: terminal.h:76
void t3_term_redraw(void)
Redraw the entire terminal from scratch.
Definition: terminal.c:789
Horizontal line.
Definition: terminal.h:185
Arrow pointing right.
Definition: terminal.h:190
t3_bool t3_term_puts(const char *s)
Add a string to the output buffer.
Definition: convert_output.c:134
Lower right corner.
Definition: terminal.h:184
void t3_term_update_cursor(void)
Update the cursor, not drawing anything.
Definition: terminal.c:552
t3_bool t3_term_putn(const char *s, size_t n)
Add a string to the output buffer.
Definition: convert_output.c:151
void t3_term_set_user_callback(t3_attr_user_callback_t callback)
Set callback for drawing characters with T3_ATTR_USER attribute.
Definition: terminal.c:547
Tee pointing down.
Definition: terminal.h:177
t3_attr_t t3_term_get_ncv(void)
Get the set of non-color video attributes.
Definition: terminal.c:877
t3_bool t3_term_putc(char c)
Add a charater to the output buffer.
Definition: convert_output.c:110
long t3_attr_t
Type to hold attributes used for terminal display.
Definition: terminal.h:63
t3_bool t3_term_can_draw(const char *str, size_t str_len)
These are implemented in convert_output.c.
Definition: convert_output.c:288
const char * t3_term_get_codeset(void)
Get the string describing the current character set used by the library.
Definition: terminal.c:248