lv_text_private.h

Functions

uint32_t lv_text_get_next_line(const char *txt, uint32_t len, const lv_font_t *font, int32_t letter_space, int32_t max_width, int32_t *used_width, lv_text_flag_t flag)

Get the next line of text. Check line length and break chars too.

Parameters:
  • txt – a '\0' terminated string

  • len – length of 'txt' in bytes

  • font – pointer to a font

  • letter_space – letter space

  • max_width – max width of the text (break the lines to fit this size). Set COORD_MAX to avoid line breaks

  • used_width – When used_width != NULL, save the width of this line if flag == LV_TEXT_FLAG_NONE, otherwise save -1.

  • flag – settings for the text from 'txt_flag_type' enum

Returns:

the index of the first char of the new line (in byte index not letter index. With UTF-8 they are different)

void lv_text_ins(char *txt_buf, uint32_t pos, const char *ins_txt)

Insert a string into another

Parameters:
  • txt_buf – the original text (must be big enough for the result text and NULL terminated)

  • pos – position to insert (0: before the original text, 1: after the first char etc.)

  • ins_txt – text to insert, must be '\0' terminated

void lv_text_cut(char *txt, uint32_t pos, uint32_t len)

Delete a part of a string

Parameters:
  • txt – string to modify, must be '\0' terminated and should point to a heap or stack frame, not read-only memory.

  • pos – position where to start the deleting (0: before the first char, 1: after the first char etc.)

  • len – number of characters to delete

char *lv_text_set_text_vfmt(const char *fmt, va_list ap)

return a new formatted text. Memory will be allocated to store the text.

Parameters:
  • fmtprintf-like format

  • ap – items to print

Returns:

pointer to the allocated text string.

void lv_text_encoded_letter_next_2(const char *txt, uint32_t *letter, uint32_t *letter_next, uint32_t *ofs)

Decode two encoded character from a string.

Parameters:
  • txt – pointer to '\0' terminated string

  • letter – the first decoded Unicode character or 0 on invalid data code

  • letter_next – the second decoded Unicode character or 0 on invalid data code

  • ofs – start index in 'txt' where to start. After the call it will point to the next encoded char in 'txt'. NULL to use txt[0] as index

static inline bool lv_text_is_break_char(uint32_t letter)

Test if char is break char or not (a text can broken here or not)

Parameters:

letter – a letter

Returns:

false: 'letter' is not break char

static inline bool lv_text_is_a_word(uint32_t letter)

Test if char is break char or not (a text can broken here or not)

Parameters:

letter – a letter

Returns:

false: 'letter' is not break char

static inline bool lv_text_is_marker(uint32_t letter)

Test if character can be treated as marker, and don't need to be rendered. Note, this is not a full list. Add your findings to the list.

Parameters:

letter – a letter

Returns:

true if so

Variables

uint8_t (*const lv_text_encoded_size)(const char *txt)

Give the size of an encoded character

Param txt:

pointer to a character in a string

Return:

length of the encoded character (1,2,3 ...). O in invalid

uint32_t (*const lv_text_unicode_to_encoded)(uint32_t letter_uni)

Convert a Unicode letter to encoded

Param letter_uni:

a Unicode letter

Return:

Encoded character in Little Endian to be compatible with C chars (e.g. 'Á', 'Ü')

uint32_t (*const lv_text_encoded_conv_wc)(uint32_t c)

Convert a wide character, e.g. 'Á' little endian to be compatible with the encoded format.

Param c:

a wide character

Return:

c in the encoded format

uint32_t (*const lv_text_encoded_next)(const char *txt, uint32_t *i_start)

Decode the next encoded character from a string.

Param txt:

pointer to '\0' terminated string

Param i_start:

start index in 'txt' where to start. After the call it will point to the next encoded char in 'txt'. NULL to use txt[0] as index

Return:

the decoded Unicode character or 0 on invalid data code

uint32_t (*const lv_text_encoded_prev)(const char *txt, uint32_t *i_start)

Get the previous encoded character form a string.

Param txt:

pointer to '\0' terminated string

Param i_start:

index in 'txt' where to start. After the call it will point to the previous encoded char in 'txt'.

Return:

the decoded Unicode character or 0 on invalid data

uint32_t (*const lv_text_encoded_get_byte_id)(const char *txt, uint32_t utf8_id)

Convert a letter index (in the encoded text) to byte index. E.g. in UTF-8 "AÁRT" index of 'R' is 2 but start at byte 3 because 'Á' is 2 bytes long

Param txt:

a '\0' terminated UTF-8 string

Param utf8_id:

character index

Return:

byte index of the 'enc_id'th letter

uint32_t (*const lv_text_encoded_get_char_id)(const char *txt, uint32_t byte_id)

Convert a byte index (in an encoded text) to character index. E.g. in UTF-8 "AÁRT" index of 'R' is 2 but start at byte 3 because 'Á' is 2 bytes long

Param txt:

a '\0' terminated UTF-8 string

Param byte_id:

byte index

Return:

character index of the letter at 'byte_id'th position

uint32_t (*const lv_text_get_encoded_length)(const char *txt)

Get the number of characters (and NOT bytes) in a string. E.g. in UTF-8 "ÁBC" is 3 characters (but 4 bytes)

Param txt:

a '\0' terminated char string

Return:

number of characters