MiniDevil
As beautiful as a shell
Text utilities: truncates lines & handles UTF-8 display width. More...
#include "minishell_ui.h"
Include dependency graph for drawing_text.c:Text utilities: truncates lines & handles UTF-8 display width.
Definition in file drawing_text.c.
Functions | |
| static int | utf8_byte_len (unsigned char c) |
| Return the length in bytes of an UTF-8 character. More... | |
| char * | truncate_line (const char *line, int max_width) |
| Copy up to max_width visible characters into a static buffer. More... | |
| int | visual_strlen (const char *s) |
| Calculate the visual display width of a UTF-8 string in terminal cols. More... | |
|
static |
Return the length in bytes of an UTF-8 character.
| c | First byte of the UTF-8 sequence |
Definition at line 21 of file drawing_text.c.
Referenced by truncate_line(), and visual_strlen().
Here is the caller graph for this function:| char* truncate_line | ( | const char * | line, |
| int | max_width | ||
| ) |
Copy up to max_width visible characters into a static buffer.
Handles UTF-8 sequences
| line | Source string to truncate (could be NULL) |
| max_width | Maximum number to include |
Definition at line 42 of file drawing_text.c.
References BUF_SIZE, and utf8_byte_len().
Referenced by draw_line_content().
Here is the call graph for this function:
Here is the caller graph for this function:| int visual_strlen | ( | const char * | s | ) |
Calculate the visual display width of a UTF-8 string in terminal cols.
4 byte (emoji range) are counted as 2 columns, the others as 1
| s | UTF-8 string (NULL terminated) |
Definition at line 75 of file drawing_text.c.
References utf8_byte_len().
Referenced by draw_box_title().
Here is the call graph for this function:
Here is the caller graph for this function: