mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
Changed all text related indices from 16 bit to 32 bit integers.
This commit is contained in:
parent
a0583f6feb
commit
3561d9e063
@ -206,10 +206,10 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
||||
|
||||
lv_opa_t opa = dsc->opa;
|
||||
|
||||
uint16_t sel_start = dsc->sel_start;
|
||||
uint16_t sel_end = dsc->sel_end;
|
||||
uint32_t sel_start = dsc->sel_start;
|
||||
uint32_t sel_end = dsc->sel_end;
|
||||
if(sel_start > sel_end) {
|
||||
uint16_t tmp = sel_start;
|
||||
uint32_t tmp = sel_start;
|
||||
sel_start = sel_end;
|
||||
sel_end = tmp;
|
||||
}
|
||||
@ -225,7 +225,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
||||
|
||||
cmd_state_t cmd_state = CMD_STATE_WAIT;
|
||||
uint32_t i;
|
||||
uint16_t par_start = 0;
|
||||
uint32_t par_start = 0;
|
||||
lv_color_t recolor;
|
||||
int32_t letter_w;
|
||||
|
||||
@ -250,11 +250,11 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
||||
#endif
|
||||
|
||||
while(i < line_end - line_start) {
|
||||
uint16_t logical_char_pos = 0;
|
||||
uint32_t logical_char_pos = 0;
|
||||
if(sel_start != 0xFFFF && sel_end != 0xFFFF) {
|
||||
#if LV_USE_BIDI
|
||||
logical_char_pos = _lv_txt_encoded_get_char_id(txt, line_start);
|
||||
uint16_t t = _lv_txt_encoded_get_char_id(bidi_txt, i);
|
||||
uint32_t t = _lv_txt_encoded_get_char_id(bidi_txt, i);
|
||||
logical_char_pos += _lv_bidi_get_logical_pos(bidi_txt, NULL, line_end - line_start, dsc->bidi_dir, t, NULL);
|
||||
#else
|
||||
logical_char_pos = _lv_txt_encoded_get_char_id(txt, line_start + i);
|
||||
|
@ -33,8 +33,8 @@ typedef struct {
|
||||
lv_opa_t opa;
|
||||
lv_style_int_t line_space;
|
||||
lv_style_int_t letter_space;
|
||||
uint16_t sel_start;
|
||||
uint16_t sel_end;
|
||||
uint32_t sel_start;
|
||||
uint32_t sel_end;
|
||||
lv_coord_t ofs_x;
|
||||
lv_coord_t ofs_y;
|
||||
lv_bidi_dir_t bidi_dir;
|
||||
|
@ -169,7 +169,7 @@ void _lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t
|
||||
* @param force Force return the fraction of the word that can fit in the provided space.
|
||||
* @return the index of the first char of the next word (in byte index not letter index. With UTF-8 they are different)
|
||||
*/
|
||||
static uint16_t lv_txt_get_next_word(const char * txt, const lv_font_t * font,
|
||||
static uint32_t lv_txt_get_next_word(const char * txt, const lv_font_t * font,
|
||||
lv_coord_t letter_space, lv_coord_t max_width,
|
||||
lv_txt_flag_t flag, uint32_t * word_w_ptr, lv_txt_cmd_state_t * cmd_state, bool force)
|
||||
{
|
||||
@ -290,7 +290,7 @@ static uint16_t lv_txt_get_next_word(const char * txt, const lv_font_t * font,
|
||||
* @param flags settings for the text from 'txt_flag_type' enum
|
||||
* @return the index of the first char of the new line (in byte index not letter index. With UTF-8 they are different)
|
||||
*/
|
||||
uint16_t _lv_txt_get_next_line(const char * txt, const lv_font_t * font,
|
||||
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_txt_flag_t flag)
|
||||
{
|
||||
if(txt == NULL) return 0;
|
||||
@ -350,7 +350,7 @@ uint16_t _lv_txt_get_next_line(const char * txt, const lv_font_t * font,
|
||||
* @param flags settings for the text from 'txt_flag_t' enum
|
||||
* @return length of a char_num long text
|
||||
*/
|
||||
lv_coord_t _lv_txt_get_width(const char * txt, uint16_t length, const lv_font_t * font, lv_coord_t letter_space,
|
||||
lv_coord_t _lv_txt_get_width(const char * txt, uint32_t length, const lv_font_t * font, lv_coord_t letter_space,
|
||||
lv_txt_flag_t flag)
|
||||
{
|
||||
if(txt == NULL) return 0;
|
||||
|
@ -84,7 +84,7 @@ void _lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t
|
||||
* @return the index of the first char of the new line (in byte index not letter index. With UTF-8
|
||||
* they are different)
|
||||
*/
|
||||
uint16_t _lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coord_t letter_space, lv_coord_t max_width,
|
||||
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_txt_flag_t flag);
|
||||
|
||||
/**
|
||||
@ -97,7 +97,7 @@ uint16_t _lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coor
|
||||
* @param flags settings for the text from 'txt_flag_t' enum
|
||||
* @return length of a char_num long text
|
||||
*/
|
||||
lv_coord_t _lv_txt_get_width(const char * txt, uint16_t length, const lv_font_t * font, lv_coord_t letter_space,
|
||||
lv_coord_t _lv_txt_get_width(const char * txt, uint32_t length, const lv_font_t * font, lv_coord_t letter_space,
|
||||
lv_txt_flag_t flag);
|
||||
|
||||
/**
|
||||
|
@ -51,7 +51,7 @@ static void lv_label_revert_dots(lv_obj_t * label);
|
||||
static void lv_label_set_offset_y(lv_obj_t * label, lv_coord_t y);
|
||||
#endif
|
||||
|
||||
static bool lv_label_set_dot_tmp(lv_obj_t * label, char * data, uint16_t len);
|
||||
static bool lv_label_set_dot_tmp(lv_obj_t * label, char * data, uint32_t len);
|
||||
static char * lv_label_get_dot_tmp(lv_obj_t * label);
|
||||
static void lv_label_dot_tmp_free(lv_obj_t * label);
|
||||
static void get_txt_coords(const lv_obj_t * label, lv_area_t * area);
|
||||
@ -152,7 +152,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
}
|
||||
|
||||
if(copy_ext->dot_tmp_alloc && copy_ext->dot.tmp_ptr) {
|
||||
uint16_t len = (uint16_t)strlen(copy_ext->dot.tmp_ptr);
|
||||
uint32_t len = (uint32_t)strlen(copy_ext->dot.tmp_ptr);
|
||||
lv_label_set_dot_tmp(new_label, ext->dot.tmp_ptr, len);
|
||||
}
|
||||
else {
|
||||
@ -442,7 +442,7 @@ void lv_label_set_anim_speed(lv_obj_t * label, uint16_t anim_speed)
|
||||
#endif
|
||||
}
|
||||
|
||||
void lv_label_set_text_sel_start(lv_obj_t * label, uint16_t index)
|
||||
void lv_label_set_text_sel_start(lv_obj_t * label, uint32_t index)
|
||||
{
|
||||
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||
|
||||
@ -456,7 +456,7 @@ void lv_label_set_text_sel_start(lv_obj_t * label, uint16_t index)
|
||||
#endif
|
||||
}
|
||||
|
||||
void lv_label_set_text_sel_end(lv_obj_t * label, uint16_t index)
|
||||
void lv_label_set_text_sel_end(lv_obj_t * label, uint32_t index)
|
||||
{
|
||||
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||
|
||||
@ -567,7 +567,7 @@ uint16_t lv_label_get_anim_speed(const lv_obj_t * label)
|
||||
* index (different in UTF-8)
|
||||
* @param pos store the result here (E.g. index = 0 gives 0;0 coordinates)
|
||||
*/
|
||||
void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t char_id, lv_point_t * pos)
|
||||
void lv_label_get_letter_pos(const lv_obj_t * label, uint32_t char_id, lv_point_t * pos)
|
||||
{
|
||||
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||
LV_ASSERT_NULL(pos);
|
||||
@ -595,7 +595,7 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t char_id, lv_point_
|
||||
if(align == LV_LABEL_ALIGN_CENTER) flag |= LV_TXT_FLAG_CENTER;
|
||||
if(align == LV_LABEL_ALIGN_RIGHT) flag |= LV_TXT_FLAG_RIGHT;
|
||||
|
||||
uint16_t byte_id = _lv_txt_encoded_get_byte_id(txt, char_id);
|
||||
uint32_t byte_id = _lv_txt_encoded_get_byte_id(txt, char_id);
|
||||
|
||||
/*Search the line of the index letter */;
|
||||
while(txt[new_line_start] != '\0') {
|
||||
@ -616,7 +616,7 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t char_id, lv_point_
|
||||
}
|
||||
|
||||
const char * bidi_txt;
|
||||
uint16_t visual_byte_pos;
|
||||
uint32_t visual_byte_pos;
|
||||
#if LV_USE_BIDI
|
||||
char * mutable_bidi_txt = NULL;
|
||||
/*Handle Bidi*/
|
||||
@ -625,10 +625,10 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t char_id, lv_point_
|
||||
bidi_txt = &txt[line_start];
|
||||
}
|
||||
else {
|
||||
uint16_t line_char_id = _lv_txt_encoded_get_char_id(&txt[line_start], byte_id - line_start);
|
||||
uint32_t line_char_id = _lv_txt_encoded_get_char_id(&txt[line_start], byte_id - line_start);
|
||||
|
||||
bool is_rtl;
|
||||
uint16_t visual_char_pos = _lv_bidi_get_visual_pos(&txt[line_start], &mutable_bidi_txt, new_line_start - line_start,
|
||||
uint32_t visual_char_pos = _lv_bidi_get_visual_pos(&txt[line_start], &mutable_bidi_txt, new_line_start - line_start,
|
||||
lv_obj_get_base_dir(label), line_char_id, &is_rtl);
|
||||
bidi_txt = mutable_bidi_txt;
|
||||
if(is_rtl) visual_char_pos++;
|
||||
@ -672,7 +672,7 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t char_id, lv_point_
|
||||
* @return the index of the letter on the 'pos_p' point (E.g. on 0;0 is the 0. letter)
|
||||
* Expressed in character index and not byte index (different in UTF-8)
|
||||
*/
|
||||
uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
|
||||
uint32_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
|
||||
{
|
||||
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||
LV_ASSERT_NULL(pos);
|
||||
@ -690,7 +690,7 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
|
||||
lv_coord_t letter_height = lv_font_get_line_height(font);
|
||||
lv_coord_t y = 0;
|
||||
lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
|
||||
uint16_t logical_pos;
|
||||
uint32_t logical_pos;
|
||||
char * bidi_txt;
|
||||
|
||||
if(ext->recolor != 0) flag |= LV_TXT_FLAG_RECOLOR;
|
||||
@ -721,7 +721,7 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
|
||||
|
||||
#if LV_USE_BIDI
|
||||
bidi_txt = _lv_mem_buf_get(new_line_start - line_start + 1);
|
||||
uint16_t txt_len = new_line_start - line_start;
|
||||
uint32_t txt_len = new_line_start - line_start;
|
||||
if(new_line_start > 0 && txt[new_line_start - 1] == '\0' && txt_len > 0) txt_len--;
|
||||
_lv_bidi_process_paragraph(txt + line_start, bidi_txt, txt_len, lv_obj_get_base_dir(label), NULL, 0);
|
||||
#else
|
||||
@ -792,7 +792,7 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
|
||||
* @param label pointer to a label object.
|
||||
* @return selection start index. `LV_LABEL_TXT_SEL_OFF` if nothing is selected.
|
||||
*/
|
||||
uint16_t lv_label_get_text_sel_start(const lv_obj_t * label)
|
||||
uint32_t lv_label_get_text_sel_start(const lv_obj_t * label)
|
||||
{
|
||||
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||
|
||||
@ -811,7 +811,7 @@ uint16_t lv_label_get_text_sel_start(const lv_obj_t * label)
|
||||
* @param label pointer to a label object.
|
||||
* @return selection end index. `LV_LABEL_TXT_SEL_OFF` if nothing is selected.
|
||||
*/
|
||||
uint16_t lv_label_get_text_sel_end(const lv_obj_t * label)
|
||||
uint32_t lv_label_get_text_sel_end(const lv_obj_t * label)
|
||||
{
|
||||
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||
|
||||
@ -1449,7 +1449,7 @@ static void lv_label_set_offset_y(lv_obj_t * label, lv_coord_t y)
|
||||
* @param len Number of characters to store.
|
||||
* @return true on success.
|
||||
*/
|
||||
static bool lv_label_set_dot_tmp(lv_obj_t * label, char * data, uint16_t len)
|
||||
static bool lv_label_set_dot_tmp(lv_obj_t * label, char * data, uint32_t len)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
lv_label_dot_tmp_free(label); /* Deallocate any existing space */
|
||||
|
@ -72,7 +72,7 @@ typedef struct {
|
||||
char tmp[LV_LABEL_DOT_NUM + 1]; /* Directly store the characters if <=4 characters */
|
||||
} dot;
|
||||
|
||||
uint16_t dot_end; /*The text end position in dot mode (Handled by the library)*/
|
||||
uint32_t dot_end; /*The text end position in dot mode (Handled by the library)*/
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
uint16_t anim_speed; /*Speed of scroll and roll animation in px/sec unit*/
|
||||
@ -85,8 +85,8 @@ typedef struct {
|
||||
#endif
|
||||
|
||||
#if LV_LABEL_TEXT_SEL
|
||||
uint16_t sel_start;
|
||||
uint16_t sel_end;
|
||||
uint32_t sel_start;
|
||||
uint32_t sel_end;
|
||||
#endif
|
||||
|
||||
lv_label_long_mode_t long_mode : 3; /*Determinate what to do with the long texts*/
|
||||
@ -178,14 +178,14 @@ void lv_label_set_anim_speed(lv_obj_t * label, uint16_t anim_speed);
|
||||
* @param label pointer to a label object.
|
||||
* @param index index to set. `LV_LABEL_TXT_SEL_OFF` to select nothing.
|
||||
*/
|
||||
void lv_label_set_text_sel_start(lv_obj_t * label, uint16_t index);
|
||||
void lv_label_set_text_sel_start(lv_obj_t * label, uint32_t index);
|
||||
|
||||
/**
|
||||
* @brief Set the selection end index.
|
||||
* @param label pointer to a label object.
|
||||
* @param index index to set. `LV_LABEL_TXT_SEL_OFF` to select nothing.
|
||||
*/
|
||||
void lv_label_set_text_sel_end(lv_obj_t * label, uint16_t index);
|
||||
void lv_label_set_text_sel_end(lv_obj_t * label, uint32_t index);
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
@ -233,7 +233,7 @@ uint16_t lv_label_get_anim_speed(const lv_obj_t * label);
|
||||
* index (different in UTF-8)
|
||||
* @param pos store the result here (E.g. index = 0 gives 0;0 coordinates)
|
||||
*/
|
||||
void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t * pos);
|
||||
void lv_label_get_letter_pos(const lv_obj_t * label, uint32_t index, lv_point_t * pos);
|
||||
|
||||
/**
|
||||
* Get the index of letter on a relative point of a label
|
||||
@ -242,7 +242,7 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t
|
||||
* @return the index of the letter on the 'pos_p' point (E.g. on 0;0 is the 0. letter)
|
||||
* Expressed in character index and not byte index (different in UTF-8)
|
||||
*/
|
||||
uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos);
|
||||
uint32_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos);
|
||||
|
||||
/**
|
||||
* Check if a character is drawn under a point.
|
||||
@ -257,14 +257,14 @@ bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos);
|
||||
* @param label pointer to a label object.
|
||||
* @return selection start index. `LV_LABEL_TXT_SEL_OFF` if nothing is selected.
|
||||
*/
|
||||
uint16_t lv_label_get_text_sel_start(const lv_obj_t * label);
|
||||
uint32_t lv_label_get_text_sel_start(const lv_obj_t * label);
|
||||
|
||||
/**
|
||||
* @brief Get the selection end index.
|
||||
* @param label pointer to a label object.
|
||||
* @return selection end index. `LV_LABEL_TXT_SEL_OFF` if nothing is selected.
|
||||
*/
|
||||
uint16_t lv_label_get_text_sel_end(const lv_obj_t * label);
|
||||
uint32_t lv_label_get_text_sel_end(const lv_obj_t * label);
|
||||
|
||||
|
||||
lv_style_list_t * lv_label_get_style(lv_obj_t * label, uint8_t type);
|
||||
|
@ -156,7 +156,7 @@ void lv_roller_set_options(lv_obj_t * roller, const char * options, lv_roller_mo
|
||||
|
||||
/*Count the '\n'-s to determine the number of options*/
|
||||
ext->option_cnt = 0;
|
||||
uint16_t cnt;
|
||||
uint32_t cnt;
|
||||
for(cnt = 0; options[cnt] != '\0'; cnt++) {
|
||||
if(options[cnt] == '\n') ext->option_cnt++;
|
||||
}
|
||||
@ -316,7 +316,7 @@ void lv_roller_get_selected_str(const lv_obj_t * roller, char * buf, uint16_t bu
|
||||
|
||||
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
||||
lv_obj_t * label = get_label(roller);
|
||||
uint16_t i;
|
||||
uint32_t i;
|
||||
uint16_t line = 0;
|
||||
const char * opt_txt = lv_label_get_text(label);
|
||||
size_t txt_len = strlen(opt_txt);
|
||||
@ -325,7 +325,7 @@ void lv_roller_get_selected_str(const lv_obj_t * roller, char * buf, uint16_t bu
|
||||
if(opt_txt[i] == '\n') line++;
|
||||
}
|
||||
|
||||
uint16_t c;
|
||||
uint32_t c;
|
||||
for(c = 0; i < txt_len && opt_txt[i] != '\n'; c++, i++) {
|
||||
if(buf_size && c >= buf_size - 1) {
|
||||
LV_LOG_WARN("lv_dropdown_get_selected_str: the buffer was too small")
|
||||
@ -403,7 +403,7 @@ const char * lv_roller_get_options(const lv_obj_t * roller)
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
||||
* LV_DESIGN_DRAW_POST: drawing after all children are drawn
|
||||
* @param return an element of `lv_design_res_t`
|
||||
*/
|
||||
static lv_design_res_t lv_roller_design(lv_obj_t * roller, const lv_area_t * clip_area, lv_design_mode_t mode)
|
||||
@ -556,14 +556,14 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
|
||||
char c = *((char *)param);
|
||||
if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN) {
|
||||
if(ext->sel_opt_id + 1 < ext->option_cnt) {
|
||||
uint16_t ori_id = ext->sel_opt_id_ori; /*lv_roller_set_selceted will overwrite this*/
|
||||
uint16_t ori_id = ext->sel_opt_id_ori; /*lv_roller_set_selected will overwrite this*/
|
||||
lv_roller_set_selected(roller, ext->sel_opt_id + 1, true);
|
||||
ext->sel_opt_id_ori = ori_id;
|
||||
}
|
||||
}
|
||||
else if(c == LV_KEY_LEFT || c == LV_KEY_UP) {
|
||||
if(ext->sel_opt_id > 0) {
|
||||
uint16_t ori_id = ext->sel_opt_id_ori; /*lv_roller_set_selceted will overwrite this*/
|
||||
uint16_t ori_id = ext->sel_opt_id_ori; /*lv_roller_set_selected will overwrite this*/
|
||||
|
||||
lv_roller_set_selected(roller, ext->sel_opt_id - 1, true);
|
||||
ext->sel_opt_id_ori = ori_id;
|
||||
@ -645,7 +645,7 @@ static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign,
|
||||
|
||||
ext->sel_opt_id = id;
|
||||
ext->sel_opt_id_ori = id;
|
||||
res = lv_event_send(roller, LV_EVENT_VALUE_CHANGED, &id);
|
||||
res = lv_event_send(roller, LV_EVENT_VALUE_CHANGED, &id);
|
||||
if(res != LV_RES_OK) return res;
|
||||
}
|
||||
/*If picked an option by clicking then set it*/
|
||||
@ -815,7 +815,7 @@ static lv_res_t release_handler(lv_obj_t * roller)
|
||||
lv_indev_get_point(indev, &p);
|
||||
p.y -= label->coords.y1;
|
||||
p.x -= label->coords.x1;
|
||||
uint16_t letter_i;
|
||||
uint32_t letter_i;
|
||||
letter_i = lv_label_get_letter_on(label, &p);
|
||||
|
||||
const char * txt = lv_label_get_text(label);
|
||||
|
@ -176,7 +176,7 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
}
|
||||
|
||||
if(copy_ext->pwd_tmp) {
|
||||
uint16_t len = _lv_mem_get_size(copy_ext->pwd_tmp);
|
||||
uint32_t len = _lv_mem_get_size(copy_ext->pwd_tmp);
|
||||
ext->pwd_tmp = lv_mem_alloc(len);
|
||||
LV_ASSERT_MEM(ext->pwd_tmp);
|
||||
if(ext->pwd_tmp == NULL) return NULL;
|
||||
@ -407,7 +407,7 @@ void lv_textarea_del_char(lv_obj_t * ta)
|
||||
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||
|
||||
lv_textarea_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
uint16_t cur_pos = ext->cursor.pos;
|
||||
uint32_t cur_pos = ext->cursor.pos;
|
||||
|
||||
if(cur_pos == 0) return;
|
||||
|
||||
@ -469,7 +469,7 @@ void lv_textarea_del_char_forward(lv_obj_t * ta)
|
||||
{
|
||||
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||
|
||||
uint16_t cp = lv_textarea_get_cursor_pos(ta);
|
||||
uint32_t cp = lv_textarea_get_cursor_pos(ta);
|
||||
lv_textarea_set_cursor_pos(ta, cp + 1);
|
||||
if(cp != lv_textarea_get_cursor_pos(ta)) lv_textarea_del_char(ta);
|
||||
}
|
||||
@ -601,14 +601,14 @@ void lv_textarea_set_placeholder_text(lv_obj_t * ta, const char * txt)
|
||||
* < 0 : index from the end of the text
|
||||
* LV_TEXTAREA_CURSOR_LAST: go after the last character
|
||||
*/
|
||||
void lv_textarea_set_cursor_pos(lv_obj_t * ta, int16_t pos)
|
||||
void lv_textarea_set_cursor_pos(lv_obj_t * ta, int32_t pos)
|
||||
{
|
||||
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||
|
||||
lv_textarea_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
if(ext->cursor.pos == pos) return;
|
||||
|
||||
uint16_t len = _lv_txt_get_encoded_length(lv_label_get_text(ext->label));
|
||||
uint32_t len = _lv_txt_get_encoded_length(lv_label_get_text(ext->label));
|
||||
|
||||
if(pos < 0) pos = len + pos;
|
||||
|
||||
@ -838,7 +838,7 @@ void lv_textarea_set_accepted_chars(lv_obj_t * ta, const char * list)
|
||||
* @param ta pointer to Text Area
|
||||
* @param num the maximal number of characters can be added (`lv_textarea_set_text` ignores it)
|
||||
*/
|
||||
void lv_textarea_set_max_length(lv_obj_t * ta, uint16_t num)
|
||||
void lv_textarea_set_max_length(lv_obj_t * ta, uint32_t num)
|
||||
{
|
||||
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||
|
||||
@ -1001,7 +1001,7 @@ lv_obj_t * lv_textarea_get_label(const lv_obj_t * ta)
|
||||
* @param ta pointer to a text area object
|
||||
* @return the cursor position
|
||||
*/
|
||||
uint16_t lv_textarea_get_cursor_pos(const lv_obj_t * ta)
|
||||
uint32_t lv_textarea_get_cursor_pos(const lv_obj_t * ta)
|
||||
{
|
||||
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||
|
||||
@ -1080,7 +1080,7 @@ const char * lv_textarea_get_accepted_chars(lv_obj_t * ta)
|
||||
* @param ta pointer to Text Area
|
||||
* @return the maximal number of characters to be add
|
||||
*/
|
||||
uint16_t lv_textarea_get_max_length(lv_obj_t * ta)
|
||||
uint32_t lv_textarea_get_max_length(lv_obj_t * ta)
|
||||
{
|
||||
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||
|
||||
@ -1191,7 +1191,7 @@ void lv_textarea_cursor_right(lv_obj_t * ta)
|
||||
{
|
||||
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||
|
||||
uint16_t cp = lv_textarea_get_cursor_pos(ta);
|
||||
uint32_t cp = lv_textarea_get_cursor_pos(ta);
|
||||
cp++;
|
||||
lv_textarea_set_cursor_pos(ta, cp);
|
||||
}
|
||||
@ -1204,7 +1204,7 @@ void lv_textarea_cursor_left(lv_obj_t * ta)
|
||||
{
|
||||
LV_ASSERT_OBJ(ta, LV_OBJX_NAME);
|
||||
|
||||
uint16_t cp = lv_textarea_get_cursor_pos(ta);
|
||||
uint32_t cp = lv_textarea_get_cursor_pos(ta);
|
||||
if(cp > 0) {
|
||||
cp--;
|
||||
lv_textarea_set_cursor_pos(ta, cp);
|
||||
@ -1236,7 +1236,7 @@ void lv_textarea_cursor_down(lv_obj_t * ta)
|
||||
/*Do not go below the last line*/
|
||||
if(pos.y < lv_obj_get_height(ext->label)) {
|
||||
/*Get the letter index on the new cursor position and set it*/
|
||||
uint16_t new_cur_pos = lv_label_get_letter_on(ext->label, &pos);
|
||||
uint32_t new_cur_pos = lv_label_get_letter_on(ext->label, &pos);
|
||||
|
||||
lv_coord_t cur_valid_x_tmp = ext->cursor.valid_x; /*Cursor position set overwrites the valid positon */
|
||||
lv_textarea_set_cursor_pos(ta, new_cur_pos);
|
||||
@ -1266,7 +1266,7 @@ void lv_textarea_cursor_up(lv_obj_t * ta)
|
||||
pos.x = ext->cursor.valid_x;
|
||||
|
||||
/*Get the letter index on the new cursor position and set it*/
|
||||
uint16_t new_cur_pos = lv_label_get_letter_on(ext->label, &pos);
|
||||
uint32_t new_cur_pos = lv_label_get_letter_on(ext->label, &pos);
|
||||
lv_coord_t cur_valid_x_tmp = ext->cursor.valid_x; /*Cursor position set overwrites the valid position */
|
||||
lv_textarea_set_cursor_pos(ta, new_cur_pos);
|
||||
ext->cursor.valid_x = cur_valid_x_tmp;
|
||||
@ -1644,7 +1644,7 @@ static void pwd_char_hider(lv_obj_t * ta)
|
||||
lv_textarea_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
if(ext->pwd_mode != 0) {
|
||||
char * txt = lv_label_get_text(ext->label);
|
||||
int16_t enc_len = _lv_txt_get_encoded_length(txt);
|
||||
int32_t enc_len = _lv_txt_get_encoded_length(txt);
|
||||
if(enc_len == 0) return;
|
||||
|
||||
/*If the textarea's font has "bullet" character use it else fallback to "*"*/
|
||||
@ -1658,7 +1658,7 @@ static void pwd_char_hider(lv_obj_t * ta)
|
||||
|
||||
size_t bullet_len = strlen(bullet);
|
||||
char * txt_tmp = _lv_mem_buf_get(enc_len * bullet_len + 1);
|
||||
uint16_t i;
|
||||
uint32_t i;
|
||||
for(i = 0; i < enc_len; i++) {
|
||||
_lv_memcpy(&txt_tmp[i * bullet_len], bullet, bullet_len);
|
||||
}
|
||||
@ -1712,7 +1712,7 @@ static void refr_cursor_area(lv_obj_t * ta)
|
||||
const lv_font_t * font = lv_obj_get_style_text_font(ta, LV_TEXTAREA_PART_BG);
|
||||
lv_style_int_t line_space = lv_obj_get_style_text_line_space(ta, LV_TEXTAREA_PART_BG);
|
||||
|
||||
uint16_t cur_pos = lv_textarea_get_cursor_pos(ta);
|
||||
uint32_t cur_pos = lv_textarea_get_cursor_pos(ta);
|
||||
const char * txt = lv_label_get_text(ext->label);
|
||||
|
||||
uint32_t byte_pos;
|
||||
|
@ -50,24 +50,24 @@ typedef struct {
|
||||
lv_style_list_t style_placeholder;
|
||||
char * pwd_tmp; /*Used to store the original text in password mode*/
|
||||
const char * accapted_chars; /*Only these characters will be accepted. NULL: accept all*/
|
||||
uint16_t max_length; /*The max. number of characters. 0: no limit*/
|
||||
uint32_t max_length; /*The max. number of characters. 0: no limit*/
|
||||
uint16_t pwd_show_time; /*Time to show characters in password mode before change them to '*' */
|
||||
struct {
|
||||
lv_style_list_t style; /* Style of the cursor (NULL to use label's style)*/
|
||||
lv_coord_t valid_x; /* Used when stepping up/down to a shorter line.
|
||||
* (Used by the library)*/
|
||||
uint16_t pos; /* The current cursor position
|
||||
uint32_t pos; /* The current cursor position
|
||||
* (0: before 1st letter; 1: before 2nd letter ...)*/
|
||||
uint16_t blink_time; /*Blink period*/
|
||||
lv_area_t area; /* Cursor area relative to the Text Area*/
|
||||
uint16_t txt_byte_pos; /* Byte index of the letter after (on) the cursor*/
|
||||
uint32_t txt_byte_pos; /* Byte index of the letter after (on) the cursor*/
|
||||
uint8_t state : 1; /*Cursor is visible now or not (Handled by the library)*/
|
||||
uint8_t hidden : 1; /*Cursor is hidden by he user */
|
||||
uint8_t click_pos : 1; /*1: Enable positioning the cursor by clicking the text area*/
|
||||
} cursor;
|
||||
#if LV_LABEL_TEXT_SEL
|
||||
uint16_t sel_start; /*Temporary values for text selection*/
|
||||
uint16_t sel_end;
|
||||
uint32_t sel_start; /*Temporary values for text selection*/
|
||||
uint32_t sel_end;
|
||||
uint8_t text_sel_in_prog : 1; /*User is in process of selecting */
|
||||
uint8_t text_sel_en : 1; /*Text can be selected on this text area*/
|
||||
#endif
|
||||
@ -156,7 +156,7 @@ void lv_textarea_set_placeholder_text(lv_obj_t * ta, const char * txt);
|
||||
* < 0 : index from the end of the text
|
||||
* LV_TEXTAREA_CURSOR_LAST: go after the last character
|
||||
*/
|
||||
void lv_textarea_set_cursor_pos(lv_obj_t * ta, int16_t pos);
|
||||
void lv_textarea_set_cursor_pos(lv_obj_t * ta, int32_t pos);
|
||||
|
||||
/**
|
||||
* Hide/Unhide the cursor.
|
||||
@ -207,7 +207,7 @@ void lv_textarea_set_accepted_chars(lv_obj_t * ta, const char * list);
|
||||
* @param ta pointer to Text Area
|
||||
* @param num the maximal number of characters can be added (`lv_textarea_set_text` ignores it)
|
||||
*/
|
||||
void lv_textarea_set_max_length(lv_obj_t * ta, uint16_t num);
|
||||
void lv_textarea_set_max_length(lv_obj_t * ta, uint32_t num);
|
||||
|
||||
/**
|
||||
* In `LV_EVENT_INSERT` the text which planned to be inserted can be replaced by an other text.
|
||||
@ -301,7 +301,7 @@ lv_obj_t * lv_textarea_get_label(const lv_obj_t * ta);
|
||||
* @param ta pointer to a text area object
|
||||
* @return the cursor position
|
||||
*/
|
||||
uint16_t lv_textarea_get_cursor_pos(const lv_obj_t * ta);
|
||||
uint32_t lv_textarea_get_cursor_pos(const lv_obj_t * ta);
|
||||
|
||||
/**
|
||||
* Get whether the cursor is hidden or not
|
||||
@ -339,11 +339,11 @@ bool lv_textarea_get_one_line(const lv_obj_t * ta);
|
||||
const char * lv_textarea_get_accepted_chars(lv_obj_t * ta);
|
||||
|
||||
/**
|
||||
* Set max length of a Text Area.
|
||||
* Get max length of a Text Area.
|
||||
* @param ta pointer to Text Area
|
||||
* @return the maximal number of characters to be add
|
||||
*/
|
||||
uint16_t lv_textarea_get_max_length(lv_obj_t * ta);
|
||||
uint32_t lv_textarea_get_max_length(lv_obj_t * ta);
|
||||
|
||||
/**
|
||||
* Get the scroll bar mode of a text area
|
||||
|
Loading…
x
Reference in New Issue
Block a user