add lv_ta_set_text_align()

This commit is contained in:
Gabor Kiss-Vamosi
2018-09-25 16:21:31 +02:00
parent 0a7d5b8e32
commit e18e14f779
7 changed files with 104 additions and 62 deletions

View File

@@ -57,7 +57,7 @@ uint32_t (*lv_txt_unicode_to_encoded)(uint32_t) = lv_txt_unicode_to_utf8;
uint32_t (*lv_txt_encoded_conv_wc)(uint32_t) = lv_txt_utf8_conv_wc;
uint32_t (*lv_txt_encoded_next)(const char * , uint32_t *) = lv_txt_utf8_next;
uint32_t (*lv_txt_encoded_prev)(const char * , uint32_t * ) = lv_txt_utf8_prev;
uint32_t (*txt_encoded_get_byte_id)(const char * , uint32_t) = lv_txt_utf8_get_byte_id;
uint32_t (*lv_txt_encoded_get_byte_id)(const char * , uint32_t) = lv_txt_utf8_get_byte_id;
uint32_t (*lv_encoded_get_char_id)(const char * , uint32_t) = lv_txt_utf8_get_char_id;
uint32_t (*lv_txt_get_encoded_length)(const char * ) = lv_txt_utf8_get_length;
#else
@@ -66,7 +66,7 @@ uint32_t (*lv_txt_unicode_to_encoded)(uint32_t) = lv_txt_unicode_to_ascii;
uint32_t (*lv_txt_encoded_conv_wc)(uint32_t) = lv_txt_ascii_conv_wc;
uint32_t (*lv_txt_encoded_next)(const char * , uint32_t *) = lv_txt_ascii_next;
uint32_t (*lv_txt_encoded_prev)(const char * , uint32_t * ) = lv_txt_ascii_prev;
uint32_t (*txt_encoded_get_byte_id)(const char * , uint32_t) = lv_txt_ascii_get_byte_id;
uint32_t (*lv_txt_encoded_get_byte_id)(const char * , uint32_t) = lv_txt_ascii_get_byte_id;
uint32_t (*lv_encoded_get_char_id)(const char * , uint32_t) = lv_txt_ascii_get_char_id;
uint32_t (*lv_txt_get_encoded_length)(const char * ) = lv_txt_ascii_get_length;
#endif
@@ -296,7 +296,7 @@ void lv_txt_ins(char * txt_buf, uint32_t pos, const char * ins_txt)
uint32_t ins_len = strlen(ins_txt);
uint32_t new_len = ins_len + old_len;
#if LV_TXT_UTF8 != 0
pos = txt_encoded_get_byte_id(txt_buf, pos); /*Convert to byte index instead of letter index*/
pos = lv_txt_encoded_get_byte_id(txt_buf, pos); /*Convert to byte index instead of letter index*/
#endif
/*Copy the second part into the end to make place to text to insert*/
uint32_t i;
@@ -319,8 +319,8 @@ void lv_txt_cut(char * txt, uint32_t pos, uint32_t len)
uint32_t old_len = strlen(txt);
#if LV_TXT_UTF8 != 0
pos = txt_encoded_get_byte_id(txt, pos); /*Convert to byte index instead of letter index*/
len = txt_encoded_get_byte_id(&txt[pos], len);
pos = lv_txt_encoded_get_byte_id(txt, pos); /*Convert to byte index instead of letter index*/
len = lv_txt_encoded_get_byte_id(&txt[pos], len);
#endif
/*Copy the second part into the end to make place to text to insert*/

View File

@@ -36,7 +36,7 @@ enum
{
LV_TXT_FLAG_NONE = 0x00,
LV_TXT_FLAG_RECOLOR = 0x01, /*Enable parsing of recolor command*/
LV_TXT_FLAG_EXPAND = 0x02, /*Ignore width (Used by the library)*/
LV_TXT_FLAG_EXPAND = 0x02, /*Ignore width to avoid automatic word wrapping*/
LV_TXT_FLAG_CENTER = 0x04, /*Align the text to the middle*/
LV_TXT_FLAG_RIGHT = 0x08, /*Align the text to the right*/
};
@@ -168,7 +168,7 @@ extern uint32_t (*lv_txt_encoded_prev)(const char *, uint32_t *);
* @param enc_id letter index
* @return byte index of the 'enc_id'th letter
*/
extern uint32_t (*txt_encoded_get_byte_id)(const char *, uint32_t);
extern uint32_t (*lv_txt_encoded_get_byte_id)(const char *, uint32_t);
/**
* Convert a byte index (in an encoded text) to character index.