libt3window
Data Structures | Macros | Typedefs | Enumerations | Enumerator | Functions | Variables
Contants, data types and miscellaneous functions.

Data Structures

struct  t3_term_caps_t
 Data structure to store information about the capabilities of the terminal. More...
 

Macros

#define T3_CHILD(_x)
 Define a child anchor point a relation (see t3_win_anchor_t).
 
#define T3_GETCHILD(_x)
 Get a child anchor point from a relation (see t3_win_anchor_t).
 
#define T3_GETPARENT(_x)
 Get a parent anchor point from a relation (see t3_win_anchor_t).
 
#define T3_PARENT(_x)
 Define a parent anchor point for a relation (see t3_win_anchor_t).
 
#define T3_UTF8_CONTROL_MASK
 Category mask for libunistring's uc_is_general_category_withtable for finding control characters.
 

Typedefs

typedef char t3_bool
 A boolean type that does not clash with C++ or C99 bool.
 

Enumerations

enum  { t3_false , t3_true }
 Values for t3_bool, a boolean type that does not clash with C++ or C99 bool. More...
 
enum  t3_win_anchor_t
 Anchor points for defining relations between the positions of two windows. More...
 

Functions

t3_bool t3_term_acs_available (int idx)
 Check if a character is available in the alternate character set (internal use mostly). More...
 
t3_bool t3_term_can_draw (const char *str, size_t str_len)
 These are implemented in convert_output.c. More...
 
t3_attr_t t3_term_combine_attrs (t3_attr_t a, t3_attr_t b)
 Combine attributes, with priority. More...
 
void t3_term_deinit (void)
 Free all memory allocated by libt3window. More...
 
void t3_term_disable_ansi_optimization (void)
 Disable the ANSI terminal control sequence optimization. More...
 
void t3_term_get_caps_internal (t3_term_caps_t *caps, int version)
 Get the terminal capabilities. More...
 
const char * t3_term_get_codeset (void)
 Get the string describing the current character set used by the library. More...
 
int t3_term_get_keychar (int msec)
 Get a key char from stdin with timeout. More...
 
int t3_term_get_modifiers_hack (void)
 Retrieve the state of the modifiers using terminal specific hacks. More...
 
t3_attr_t t3_term_get_ncv (void)
 Get the set of non-color video attributes. More...
 
void t3_term_get_size (int *height, int *width)
 Retrieve the terminal size. More...
 
void t3_term_hide_cursor (void)
 Hide the cursor. More...
 
int t3_term_init (int fd, const char *term)
 Initialize the terminal. More...
 
t3_bool t3_term_putc (char c)
 Add a charater to the output buffer. More...
 
t3_bool t3_term_putn (const char *s, size_t n)
 Add a string to the output buffer. More...
 
void t3_term_putp (const char *str)
 Send a terminal control string to the terminal, with correct padding. More...
 
t3_bool t3_term_puts (const char *s)
 Add a string to the output buffer. More...
 
void t3_term_redraw (void)
 Redraw the entire terminal from scratch.
 
t3_bool t3_term_resize (void)
 Handle resizing of the terminal. More...
 
void t3_term_restore (void)
 Restore terminal state (de-initialize).
 
void t3_term_set_attrs (t3_attr_t new_attrs)
 Set terminal drawing attributes. More...
 
void t3_term_set_cursor (int y, int x)
 Move cursor. More...
 
void t3_term_set_replacement_char (int c)
 Set the replacement character used for undrawable characters. More...
 
void t3_term_set_user_callback (t3_attr_user_callback_t callback)
 Set callback for drawing characters with T3_ATTR_USER attribute. More...
 
void t3_term_show_cursor (void)
 Show the cursor. More...
 
size_t t3_term_strcwidth (const char *str)
 Calculate the cell width of a string. More...
 
size_t t3_term_strncwidth (const char *str, size_t n)
 Calculate the cell width of a string. More...
 
int t3_term_strnwidth (const char *str, size_t n)
 Calculate the cell width of a string. More...
 
int t3_term_strwidth (const char *str)
 Calculate the cell width of a string. More...
 
int t3_term_unget_keychar (int c)
 Push a char back for later retrieval with t3_term_get_keychar. More...
 
void t3_term_update (void)
 Update the terminal, drawing all changes since last refresh. More...
 
void t3_term_update_cursor (void)
 Update the cursor, not drawing anything.
 
uint32_t t3_utf8_get (const char *src, size_t *size)
 Get the first codepoint represented by a UTF-8 string. More...
 
size_t t3_utf8_put (uint32_t c, char *dst)
 Convert a codepoint to a UTF-8 string. More...
 
int t3_utf8_wcwidth (uint32_t c)
 Get the width of a Unicode codepoint. More...
 
int t3_utf8_wcwidth_ext (uint32_t c, int *state)
 Get the width of a Unicode codepoint, taking previous state into account. More...
 

Variables

int t3_term_caps_t::cap_flags
 A bitmask of T3_TERM_CAP_* flags indicating capabilities of the terminal.
 
int t3_term_caps_t::colors
 The maximum number of supported colors, or 0 if color is not supported.
 
t3_attr_t t3_term_caps_t::highlights
 The supported attributes other then color attributes. More...
 
int t3_term_caps_t::pairs
 The maximum number of color pairs that are supported by this terminal, or 0 if color is not supported.
 

Attributes

enum  {
  T3_ACS_TTEE , T3_ACS_RTEE , T3_ACS_LTEE , T3_ACS_BTEE ,
  T3_ACS_ULCORNER , T3_ACS_URCORNER , T3_ACS_LLCORNER , T3_ACS_LRCORNER ,
  T3_ACS_HLINE , T3_ACS_VLINE , T3_ACS_UARROW , T3_ACS_DARROW ,
  T3_ACS_LARROW , T3_ACS_RARROW , T3_ACS_BOARD , T3_ACS_CKBOARD ,
  T3_ACS_BULLET , T3_ACS_DIAMOND , T3_ACS_BLOCK
}
 Alternate character set symbolic constants. More...
 
#define T3_ATTR_USER
 Use callback for drawing the characters. More...
 
#define T3_ATTR_UNDERLINE
 Draw characters with underlining.
 
#define T3_ATTR_BOLD
 Draw characters with bold face/bright appearance.
 
#define T3_ATTR_REVERSE
 Draw characters with reverse video.
 
#define T3_ATTR_BLINK
 Draw characters blinking.
 
#define T3_ATTR_DIM
 Draw characters with dim appearance.
 
#define T3_ATTR_ACS
 Draw characters with alternate character set (for line drawing etc).
 
#define T3_ATTR_FALLBACK_ACS
 Draw characters with fallback alternate character set (for line drawing etc). More...
 
#define T3_ATTR_COLOR_SHIFT
 Bit number of the least significant color attribute bit.
 
#define T3_ATTR_FG(x)
 Convert a color number to a foreground color attribute.
 
#define T3_ATTR_BG(x)
 Convert a color number to a background color attribute.
 
#define T3_ATTR_FG_MASK
 Bitmask to leave only the foreground color in a t3_attr_t value.
 
#define T3_ATTR_BG_MASK
 Bitmask to leave only the background color in a t3_attr_t value.
 
#define T3_ATTR_FG_UNSPEC
 Foreground color unspecified.
 
#define T3_ATTR_FG_DEFAULT
 Foreground color default.
 
#define T3_ATTR_FG_BLACK
 Foreground color black.
 
#define T3_ATTR_FG_RED
 Foreground color red.
 
#define T3_ATTR_FG_GREEN
 Foreground color green.
 
#define T3_ATTR_FG_YELLOW
 Foreground color yellow.
 
#define T3_ATTR_FG_BLUE
 Foreground color blue.
 
#define T3_ATTR_FG_MAGENTA
 Foreground color magenta.
 
#define T3_ATTR_FG_CYAN
 Foreground color cyan.
 
#define T3_ATTR_FG_WHITE
 Foreground color white.
 
#define T3_ATTR_BG_UNSPEC
 Background color unspecified.
 
#define T3_ATTR_BG_DEFAULT
 Background color default.
 
#define T3_ATTR_BG_BLACK
 Background color black.
 
#define T3_ATTR_BG_RED
 Background color red.
 
#define T3_ATTR_BG_GREEN
 Background color green.
 
#define T3_ATTR_BG_YELLOW
 Background color yellow.
 
#define T3_ATTR_BG_BLUE
 Background color blue.
 
#define T3_ATTR_BG_MAGENTA
 Background color magenta.
 
#define T3_ATTR_BG_CYAN
 Background color cyan.
 
#define T3_ATTR_BG_WHITE
 Background color white.
 
#define T3_ATTR_UNDERLINE_SET
 Draw characters with underlining.
 
#define T3_ATTR_BOLD_SET
 Draw characters with bold face/bright appearance.
 
#define T3_ATTR_REVERSE_SET
 Draw characters with reverse video.
 
#define T3_ATTR_BLINK_SET
 Draw characters blinking.
 
#define T3_ATTR_DIM_SET
 Draw characters with dim appearance.
 
#define T3_ATTR_SET_MASK
 
#define T3_TERM_KEY_CTRL
 
#define T3_TERM_KEY_META
 
#define T3_TERM_KEY_SHIFT
 

Version information

typedef long t3_attr_t
 Type to hold attributes used for terminal display. More...
 
typedef void(* t3_attr_user_callback_t) (const char *str, int length, int width, t3_attr_t attr)
 User callback type. More...
 
long t3_window_get_version (void)
 Get the value of T3_WINDOW_VERSION corresponding to the actually used library. More...
 
#define T3_WINDOW_VERSION
 The version of libt3window encoded as a single integer. More...
 
#define T3_TERM_CAP_FG
 Terminal capability flag: terminal can set foreground.
 
#define T3_TERM_CAP_BG
 Terminal capability flag: terminal can set foreground.
 
#define T3_TERM_CAP_CP
 Terminal capability flag: terminal uses color pairs for setting color.
 

Error codes (libt3window specific)

const char * t3_window_strerror (int error)
 Get a string description for an error code. More...
 
#define T3_ERR_NOT_A_TTY
 Error code: the file descriptor is not a terminal.
 
#define T3_ERR_TIMEOUT
 Error code: a timeout occured.
 
#define T3_ERR_NO_SIZE_INFO
 Error code: could not retrieve information about the size of the terminal window.
 
#define T3_ERR_NONPRINT
 Error code: input contains non-printable characters.
 
#define T3_ERR_CHARSET_ERROR
 Error code: could not open character-set conversion.
 
#define T3_WARN_UPDATE_TERMINAL
 Error code: terminal feature detection has finished and the terminal should be updated.
 

Error codes (T3 generic)

#define T3_ERR_SUCCESS
 Error code: success.
 
#define T3_ERR_ERRNO
 Error code: see errno.
 
#define T3_ERR_EOF
 Error code: end of file reached.
 
#define T3_ERR_UNKNOWN
 Error code: unkown error.
 
#define T3_ERR_BAD_ARG
 Error code: bad argument.
 
#define T3_ERR_OUT_OF_MEMORY
 Error code: out of memory.
 
#define T3_ERR_TERMINFODB_NOT_FOUND
 Error code: no information found for the terminal in the terminfo database.
 
#define T3_ERR_HARDCOPY_TERMINAL
 Error code: the file descriptor is a hard-copy terminal.
 
#define T3_ERR_TERMINAL_TOO_LIMITED
 Error code: terminal provides too limited possibilities for the library to function.
 
#define T3_ERR_NO_TERM
 Error code: no terminal given and TERM environment variable not set.
 
#define T3_ERR_INTERNAL
 Error code: internal error in the library.
 
#define T3_WARN_MIN
 Warning code: the smallest value returned as warning.
 

Detailed Description

Macro Definition Documentation

◆ T3_ATTR_FALLBACK_ACS

#define T3_ATTR_FALLBACK_ACS

Draw characters with fallback alternate character set (for line drawing etc).

This attribute will result if the terminal can not combine color video with drawing characters with the alternate character set. This attribute should not be used directly.

◆ T3_ATTR_USER

#define T3_ATTR_USER

Use callback for drawing the characters.

When T3_ATTR_USER is set all other attribute bits are ignored. These can be used by the callback to determine the drawing style. The callback is set with t3_term_set_user_callback. Note that the callback is responsible for outputing the characters as well (using t3_term_putc).

◆ T3_WINDOW_VERSION

#define T3_WINDOW_VERSION

The version of libt3window encoded as a single integer.

The least significant 8 bits represent the patch level. The second 8 bits represent the minor version. The third 8 bits represent the major version.

At runtime, the value of T3_WINDOW_VERSION can be retrieved by calling
::t3_window_get_version.

Typedef Documentation

◆ t3_attr_t

Type to hold attributes used for terminal display.

The value of a t3_attr_t should be a bitwise or of T3_ATTR_* attribute values. When the terminal only supports setting colors by color pair, the T3_ATTR_FG macro can be used to specify the color pair to activate.

◆ t3_attr_user_callback_t

typedef void(* t3_attr_user_callback_t) (const char *str, int length, int width, t3_attr_t attr)

User callback type.

The user callback is passed a pointer to the characters that are is marked with T3_ATTR_USER, the length of the string, the width of the string in display cells and the attributes they are drawn with.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Alternate character set symbolic constants.

Enumerator
T3_ACS_TTEE 

Tee pointing down.

T3_ACS_RTEE 

Tee pointing left.

T3_ACS_LTEE 

Tee pointing right.

T3_ACS_BTEE 

Tee pointing up.

T3_ACS_ULCORNER 

Upper left corner.

T3_ACS_URCORNER 

Upper right corner.

T3_ACS_LLCORNER 

Lower left corner.

T3_ACS_LRCORNER 

Lower right corner.

T3_ACS_HLINE 

Horizontal line.

T3_ACS_VLINE 

Vertical line.

T3_ACS_UARROW 

Arrow pointing up.

T3_ACS_DARROW 

Arrow pointing down.

T3_ACS_LARROW 

Arrow pointing left.

T3_ACS_RARROW 

Arrow pointing right.

T3_ACS_BOARD 

Board of squares.

T3_ACS_CKBOARD 

Checker board pattern (stipple).

T3_ACS_BULLET 

Bullet.

T3_ACS_DIAMOND 

Diamond.

T3_ACS_BLOCK 

Solid block.

◆ anonymous enum

anonymous enum

Values for t3_bool, a boolean type that does not clash with C++ or C99 bool.

Enumerator
t3_false 

False.

t3_true 

True.

◆ t3_win_anchor_t

Anchor points for defining relations between the positions of two windows.

The anchor points can be used to define the relative positioning of two windows. For example, using T3_PARENT(T3_ANCHOR_TOPRIGHT) | T3_CHILD(T3_ANCHOR_TOPLEFT) allows positioning of one window left of another.

Function Documentation

◆ t3_term_acs_available()

t3_bool t3_term_acs_available ( int  idx)

Check if a character is available in the alternate character set (internal use mostly).

Parameters
idxThe character to check.
Returns
t3_true if the character is available in the alternate character set.

Characters for which an alternate character is generally available are documented in terminfo(5), but most are encoded in T3_ACS_* constants.

◆ t3_term_can_draw()

t3_bool t3_term_can_draw ( const char *  str,
size_t  str_len 
)

These are implemented in convert_output.c.

These are implemented in convert_output.c.

Parameters
strThe UTF-8 string representing the character to be displayed.
str_lenThe length of str.
Returns
A boolean indicating to whether the terminal is able to correctly draw the character.

Note that str may contain combining characters, which will only be drawn correctly if a precomposed character is available or the terminal supports them. And even if the terminal supports combining characters they may not be correctly rendered, depending on the combination of combining marks.

Moreover, the font the terminal is using may not have a glyph available for the requested character. Therefore, if this function determines that the character can be drawn, it may still not be correctly represented on screen.

◆ t3_term_combine_attrs()

t3_attr_t t3_term_combine_attrs ( t3_attr_t  a,
t3_attr_t  b 
)

Combine attributes, with priority.

Parameters
aThe first set of attributes to combine (priority).
bThe second set of attributes to combine (no priority).
Returns
The combined attributes.

This function combines a and b, with the color attributes from a overriding the color attributes from b if both specify colors. Note that if b has an attribute that was explicitly set (indicated by the corresponding _SET value), and a does not have the corresponding _SET bit, the value of b will be taken. The background is that this allows distinction between "the default should be used" (without the _SET bit) and "this bit is explicitly cleared" (with the _SET bit).

◆ t3_term_deinit()

void t3_term_deinit ( void  )

Free all memory allocated by libt3window.

This function releases all memory allocated by libt3window, and allows libt3window to be initialized for a new terminal.

◆ t3_term_disable_ansi_optimization()

void t3_term_disable_ansi_optimization ( void  )

Disable the ANSI terminal control sequence optimization.

Deprecated:
This function does nothing anymore. To disable the ANSI optimization, set the environment variable T3WINDOW_OPTS=ansi=off.

◆ t3_term_get_caps_internal()

void t3_term_get_caps_internal ( t3_term_caps_t caps,
int  version 
)

Get the terminal capabilities.

Parameters
capsThe location to store the capabilities.
versionThe version of the library used when compiling (should be T3_WINDOW_VERSION).
Note
Do not call this function directly, but use t3_term_get_caps which automatically uses T3_WINDOW_VERSION as the second argument.

This function can be used to obtain the supported video attributes and other information about the capabilities of the terminal. To allow different ABI versions to live together, the version number of the library used when compiling the call to this function must be passed.

◆ t3_term_get_codeset()

const char* t3_term_get_codeset ( void  )

Get the string describing the current character set used by the library.

The reason this function is provided, is that although the library initially will use the result of transcript_get_codeset, the terminal-capabilities detection may result in a different character set being used. After receiving T3_WARN_UPDATE_TERMINAL from t3_term_get_keychar, this routine may return a different value.

◆ t3_term_get_keychar()

int t3_term_get_keychar ( int  msec)

Get a key char from stdin with timeout.

Parameters
msecThe timeout in miliseconds, or a value <= 0 for indefinite wait.
Return values
>=0A char read from stdin.
T3_ERR_ERRNOon error, with errno set to the error.
T3_ERR_EOFon end of file.
T3_ERR_TIMEOUTif there was no character to read within the specified timeout.
T3_WARN_UPDATE_TERMINALif the terminal-feature detection has finished and requires that the terminal is updated. Note: this is not an error, but a signal to update the terminal. To check for errors, use:
#define T3_WARN_MIN
Warning code: the smallest value returned as warning.
Definition: window_errors.h:51
int t3_term_get_keychar(int msec)
Get a key char from stdin with timeout.
Definition: input.c:253

◆ t3_term_get_modifiers_hack()

int t3_term_get_modifiers_hack ( void  )

Retrieve the state of the modifiers using terminal specific hacks.

This function can be used to retrieve the modifier state from the terminal, if the terminal provides a method for querying the corrent modifier state. One example of such a terminal is the linux console. Using this function is basically a hack to get at state that is not encoded in the key sequence, and is not the prefered way of accessing this data. For some terminals this is however the only way to get at this data.

◆ t3_term_get_ncv()

t3_attr_t t3_term_get_ncv ( void  )

Get the set of non-color video attributes.

Returns
Attributes bits from the T3_ATTR_* set indicating which attributes can not be combined with video attributes.

Non-color video attributes are attributes that can not be combined with the color attributes. It is unspecified what will happen when the are combined.

◆ t3_term_get_size()

void t3_term_get_size ( int *  height,
int *  width 
)

Retrieve the terminal size.

Parameters
heightThe location to store the terminal height in lines.
widthThe location to store the terminal height in columns.

Neither height nor width may be NULL.

◆ t3_term_hide_cursor()

void t3_term_hide_cursor ( void  )

Hide the cursor.

Instructs the terminal to make the cursor invisible. If the terminal does not provide the required functionality, the cursor is moved to the bottom right.

◆ t3_term_init()

int t3_term_init ( int  fd,
const char *  term 
)

Initialize the terminal.

Parameters
fdThe file descriptor of the terminal or -1 for default.
termThe name of the terminal, or NULL to use the TERM environment variable.
Returns
One of: T3_ERR_SUCCESS, T3_ERR_NOT_A_TTY, T3_ERR_ERRNO, T3_ERR_HARDCOPY_TERMINAL, T3_ERR_TERMINFODB_NOT_FOUND, T3_ERR_UNKNOWN, T3_ERR_TERMINAL_TOO_LIMITED, T3_ERR_NO_SIZE_INFO.

This function depends on the correct setting of the LC_CTYPE property by the setlocale function. Therefore, the setlocale function should be called before this function.

If standard input/output should be used as the terminal, -1 should be passed. When calling t3_term_init multiple times (necessary when t3_term_restore was called), only the first successful call will inspect the fd and term parameters.

The terminal is initialized to raw mode such that echo is disabled (characters typed are not shown), control characters are passed to the program (i.e. ctrl-c will result in a character rather than a TERM signal) and generally all characters typed are passed to the program immediately and with a minimum of pre-processing.

◆ t3_term_putc()

t3_bool t3_term_putc ( char  c)

Add a charater to the output buffer.

Parameters
cThe character to add.

The character passed as c is a single char, not a unicode codepoint. This function should not be used outside the callback set with t3_term_set_user_callback.

◆ t3_term_putn()

t3_bool t3_term_putn ( const char *  s,
size_t  n 
)

Add a string to the output buffer.

Parameters
sThe string to add.
nThe length of s.

This function should not be used outside the callback set with t3_term_set_user_callback.

◆ t3_term_putp()

void t3_term_putp ( const char *  str)

Send a terminal control string to the terminal, with correct padding.

Note
This function should only be called in very special circumstances in a registered user callback (see t3_term_set_user_callback), when you want to do something which the library can not. Make sure that any state changes are undone before returning from the callback.

◆ t3_term_puts()

t3_bool t3_term_puts ( const char *  s)

Add a string to the output buffer.

Parameters
sThe string to add.

This function should not be used outside the callback set with t3_term_set_user_callback.

◆ t3_term_resize()

t3_bool t3_term_resize ( void  )

Handle resizing of the terminal.

Returns
A boolean indicating success of the resizing operation, which depends on memory allocation success.

Should be called after a SIGWINCH. Retrieves the size of the terminal and resizes the backing structures. After calling t3_term_resize, t3_term_get_size can be called to retrieve the new terminal size.

◆ t3_term_set_attrs()

void t3_term_set_attrs ( t3_attr_t  new_attrs)

Set terminal drawing attributes.

Parameters
new_attrsThe new attributes that should be used for subsequent character display.

◆ t3_term_set_cursor()

void t3_term_set_cursor ( int  y,
int  x 
)

Move cursor.

Parameters
yThe terminal line to move the cursor to.
xThe terminal column to move the cursor to.

If the cursor is invisible the new position is recorded, but not actually moved yet. Moving the cursor takes effect immediately.

◆ t3_term_set_replacement_char()

void t3_term_set_replacement_char ( int  c)

Set the replacement character used for undrawable characters.

Parameters
cThe character to draw when an undrawable characters is encountered.

The default character is the question mark ('?'). The character must be a Unicode character representable in the current character set. For terminals capable of Unicode output the Replacement Character is used (codepoint FFFD).

◆ t3_term_set_user_callback()

void t3_term_set_user_callback ( t3_attr_user_callback_t  callback)

Set callback for drawing characters with T3_ATTR_USER attribute.

Parameters
callbackThe function to call for drawing.

◆ t3_term_show_cursor()

void t3_term_show_cursor ( void  )

Show the cursor.

Instructs the terminal to make the cursor visible.

◆ t3_term_strcwidth()

size_t t3_term_strcwidth ( const char *  str)

Calculate the cell width of a string.

Parameters
strThe string to calculate the width of.
Returns
The width of the string in character cells.

Using strlen on a string will not give one the correct width of a UTF-8 string on the terminal screen. This function is provided to calculate that value.

◆ t3_term_strncwidth()

size_t t3_term_strncwidth ( const char *  str,
size_t  n 
)

Calculate the cell width of a string.

Parameters
strThe string to calculate the width of.
nThe length of str.
Returns
The width of the string in character cells.

Using strlen on a string will not give one the correct width of a UTF-8 string on the terminal screen. This function is provided to calculate that value.

◆ t3_term_strnwidth()

int t3_term_strnwidth ( const char *  str,
size_t  n 
)

Calculate the cell width of a string.

Deprecated:
Use t3_term_strncwidth instead.

◆ t3_term_strwidth()

int t3_term_strwidth ( const char *  str)

Calculate the cell width of a string.

Deprecated:
Use t3_term_strcwidth instead.

◆ t3_term_unget_keychar()

int t3_term_unget_keychar ( int  c)

Push a char back for later retrieval with t3_term_get_keychar.

Parameters
cThe char to push back.
Returns
The char pushed back or T3_ERR_BAD_ARG.

Only a char just read from stdin with t3_term_get_keychar can be pushed back.

◆ t3_term_update()

void t3_term_update ( void  )

Update the terminal, drawing all changes since last refresh.

After changing window contents, this function should be called to make those changes visible on the terminal. The refresh is not done automatically to allow programs to bunch many separate updates. Generally this is called right before t3_term_get_keychar.

◆ t3_utf8_get()

uint32_t t3_utf8_get ( const char *  src,
size_t *  size 
)

Get the first codepoint represented by a UTF-8 string.

Parameters
srcThe UTF-8 string to parse.
sizeThe location to store the number of bytes in the first codepoint, which should contain the number of bytes in src on entry (may be NULL).
Returns
The codepoint at the start of src or FFFD if an invalid codepoint is encountered.

◆ t3_utf8_put()

size_t t3_utf8_put ( uint32_t  c,
char *  dst 
)

Convert a codepoint to a UTF-8 string.

Parameters
cThe codepoint to convert.
dstThe location to store the result.
Returns
The number of bytes stored in dst.

If an invalid codepoint is passed in c, the replacement character (FFFD) is stored instead

◆ t3_utf8_wcwidth()

int t3_utf8_wcwidth ( uint32_t  c)

Get the width of a Unicode codepoint.

This function returns the width of a codepoint as a terminal would print it. This is mostly similar to the result of wcwidth, with the exception of some characters where terminals actually use a different value.

◆ t3_utf8_wcwidth_ext()

int t3_utf8_wcwidth_ext ( uint32_t  c,
int *  state 
)

Get the width of a Unicode codepoint, taking previous state into account.

Like t3_utf8_wcwidth, but with the added possibility to track the state of conjoining Jamo, which modifies the width of some characters.

state should be initialized with 0.

◆ t3_window_get_version()

long t3_window_get_version ( void  )

Get the value of T3_WINDOW_VERSION corresponding to the actually used library.

Returns
The value of T3_WINDOW_VERSION.

This function can be useful to determine at runtime what version of the library was linked to the program. Although currently there are no known uses for this information, future library additions may prompt library users to want to operate differently depending on the available features.

◆ t3_window_strerror()

const char* t3_window_strerror ( int  error)

Get a string description for an error code.

Parameters
errorThe error code returned by a function in libt3window.
Returns
An internationalized string description for the error code.

Variable Documentation

◆ highlights

t3_attr_t t3_term_caps_t::highlights

The supported attributes other then color attributes.

This is a bitmask of T3_ATTR_* flags.