mikroSDK Reference Manual
lv_txt.h
Go to the documentation of this file.
1
6#ifndef LV_TXT_H
7#define LV_TXT_H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13/*********************
14 * INCLUDES
15 *********************/
16#include "../lv_conf_internal.h"
17
18#include <stdbool.h>
19#include <stdarg.h>
20#include "lv_area.h"
21#include "../font/lv_font.h"
22#include "lv_printf.h"
23#include "lv_types.h"
24
25/*********************
26 * DEFINES
27 *********************/
28#ifndef LV_TXT_COLOR_CMD
29#define LV_TXT_COLOR_CMD "#"
30#endif
31
32#define LV_TXT_ENC_UTF8 1
33#define LV_TXT_ENC_ASCII 2
34
35/**********************
36 * TYPEDEFS
37 **********************/
38
42enum {
43 LV_TEXT_FLAG_NONE = 0x00,
47};
48typedef uint8_t lv_text_flag_t;
49
52enum {
56};
57typedef uint8_t lv_text_cmd_state_t;
58
60enum {
65};
66typedef uint8_t lv_text_align_t;
67
68/**********************
69 * GLOBAL PROTOTYPES
70 **********************/
71
83void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * font, lv_coord_t letter_space,
84 lv_coord_t line_space, lv_coord_t max_width, lv_text_flag_t flag);
85
99uint32_t _lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coord_t letter_space,
100 lv_coord_t max_width, lv_coord_t * used_width, lv_text_flag_t flag);
101
112lv_coord_t lv_txt_get_width(const char * txt, uint32_t length, const lv_font_t * font, lv_coord_t letter_space,
113 lv_text_flag_t flag);
114
123bool _lv_txt_is_cmd(lv_text_cmd_state_t * state, uint32_t c);
124
131void _lv_txt_ins(char * txt_buf, uint32_t pos, const char * ins_txt);
132
140void _lv_txt_cut(char * txt, uint32_t pos, uint32_t len);
141
147char * _lv_txt_set_text_vfmt(const char * fmt, va_list ap) LV_FORMAT_ATTRIBUTE(1, 0);
148
158void _lv_txt_encoded_letter_next_2(const char * txt, uint32_t * letter, uint32_t * letter_next, uint32_t * ofs);
159
165static inline bool _lv_txt_is_break_char(uint32_t letter)
166{
167 uint8_t i;
168 bool ret = false;
169
170 /* each chinese character can be break */
171 if(letter >= 0x4E00 && letter <= 0x9FA5) {
172 return true;
173 }
174
175 /*Compare the letter to TXT_BREAK_CHARS*/
176 for(i = 0; LV_TXT_BREAK_CHARS[i] != '\0'; i++) {
177 if(letter == (uint32_t)LV_TXT_BREAK_CHARS[i]) {
178 ret = true; /*If match then it is break char*/
179 break;
180 }
181 }
182
183 return ret;
184}
185
186/***************************************************************
187 * GLOBAL FUNCTION POINTERS FOR CHARACTER ENCODING INTERFACE
188 ***************************************************************/
189
195extern uint8_t (*_lv_txt_encoded_size)(const char *);
196
202extern uint32_t (*_lv_txt_unicode_to_encoded)(uint32_t);
203
209extern uint32_t (*_lv_txt_encoded_conv_wc)(uint32_t c);
210
219extern uint32_t (*_lv_txt_encoded_next)(const char *, uint32_t *);
220
228extern uint32_t (*_lv_txt_encoded_prev)(const char *, uint32_t *);
229
237extern uint32_t (*_lv_txt_encoded_get_byte_id)(const char *, uint32_t);
238
246extern uint32_t (*_lv_txt_encoded_get_char_id)(const char *, uint32_t);
247
254extern uint32_t (*_lv_txt_get_encoded_length)(const char *);
255
256/**********************
257 * MACROS
258 **********************/
259
260#ifdef __cplusplus
261} /*extern "C"*/
262#endif
263
264#endif /*LV_TXT_H*/
char void _lv_txt_encoded_letter_next_2(const char *txt, uint32_t *letter, uint32_t *letter_next, uint32_t *ofs)
uint32_t(* _lv_txt_encoded_conv_wc)(uint32_t c)
uint8_t(* _lv_txt_encoded_size)(const char *)
lv_coord_t lv_txt_get_width(const char *txt, uint32_t length, const lv_font_t *font, lv_coord_t letter_space, lv_text_flag_t flag)
uint32_t(* _lv_txt_encoded_get_byte_id)(const char *, uint32_t)
uint32_t(* _lv_txt_get_encoded_length)(const char *)
uint32_t(* _lv_txt_encoded_next)(const char *, uint32_t *)
bool _lv_txt_is_cmd(lv_text_cmd_state_t *state, uint32_t c)
@ LV_TEXT_FLAG_RECOLOR
Definition lv_txt.h:44
@ LV_TEXT_FLAG_EXPAND
Definition lv_txt.h:45
@ LV_TEXT_FLAG_FIT
Definition lv_txt.h:46
@ LV_TEXT_ALIGN_CENTER
Definition lv_txt.h:63
@ LV_TEXT_ALIGN_LEFT
Definition lv_txt.h:62
@ LV_TEXT_ALIGN_RIGHT
Definition lv_txt.h:64
@ LV_TEXT_ALIGN_AUTO
Definition lv_txt.h:61
uint32_t _lv_txt_get_next_line(const char *txt, const lv_font_t *font, lv_coord_t letter_space, lv_coord_t max_width, lv_coord_t *used_width, lv_text_flag_t flag)
void lv_txt_get_size(lv_point_t *size_res, const char *text, const lv_font_t *font, lv_coord_t letter_space, lv_coord_t line_space, lv_coord_t max_width, lv_text_flag_t flag)
void _lv_txt_ins(char *txt_buf, uint32_t pos, const char *ins_txt)
uint32_t(* _lv_txt_encoded_prev)(const char *, uint32_t *)
char * _lv_txt_set_text_vfmt(const char *fmt, va_list ap) LV_FORMAT_ATTRIBUTE(1
uint32_t(* _lv_txt_encoded_get_char_id)(const char *, uint32_t)
uint32_t(* _lv_txt_unicode_to_encoded)(uint32_t)
@ LV_TEXT_CMD_STATE_WAIT
Definition lv_txt.h:53
@ LV_TEXT_CMD_STATE_PAR
Definition lv_txt.h:54
@ LV_TEXT_CMD_STATE_IN
Definition lv_txt.h:55
void _lv_txt_cut(char *txt, uint32_t pos, uint32_t len)
Definition lv_font.h:64
Definition lv_area.h:37