From 2ac1fbf0fa5a35f481d0f00e6ca54b016c63bcc6 Mon Sep 17 00:00:00 2001 From: C47D Date: Sat, 19 Oct 2024 00:10:53 -0600 Subject: [PATCH] fix(draw_label) Move back the recolor handling --- src/draw/lv_draw_label.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/draw/lv_draw_label.c b/src/draw/lv_draw_label.c index 02cae2c46080..59ef6d3e742f 100644 --- a/src/draw/lv_draw_label.c +++ b/src/draw/lv_draw_label.c @@ -294,6 +294,17 @@ void lv_draw_label_iterate_characters(lv_draw_unit_t * draw_unit, const lv_draw_ while(i < line_end - line_start) { uint32_t logical_char_pos = 0; + /* Check if the text selection is enabled */ + if(sel_start != 0xFFFF && sel_end != 0xFFFF) { +#if LV_USE_BIDI + logical_char_pos = lv_text_encoded_get_char_id(dsc->text, line_start); + uint32_t t = lv_text_encoded_get_char_id(bidi_txt, i); + logical_char_pos += lv_bidi_get_logical_pos(bidi_txt, NULL, line_end - line_start, base_dir, t, NULL); +#else + logical_char_pos = lv_text_encoded_get_char_id(dsc->text, line_start + i); +#endif + } + uint32_t letter; uint32_t letter_next; lv_text_encoded_letter_next_2(bidi_txt, &letter, &letter_next, &i); @@ -361,17 +372,6 @@ void lv_draw_label_iterate_characters(lv_draw_unit_t * draw_unit, const lv_draw_ } } - /* Check if the text selection is enabled */ - if(sel_start != 0xFFFF && sel_end != 0xFFFF) { -#if LV_USE_BIDI - logical_char_pos = lv_text_encoded_get_char_id(dsc->text, line_start); - uint32_t t = lv_text_encoded_get_char_id(bidi_txt, i); - logical_char_pos += lv_bidi_get_logical_pos(bidi_txt, NULL, line_end - line_start, base_dir, t, NULL); -#else - logical_char_pos = lv_text_encoded_get_char_id(dsc->text, line_start + i); -#endif - } - /* If we're in the CMD_STATE_IN state then we need to subtract the recolor command length */ if(((dsc->flag & LV_TEXT_FLAG_RECOLOR) != 0) && (cmd_state == CMD_STATE_IN)) { logical_char_pos -= (LABEL_RECOLOR_PAR_LENGTH + 1);