From bcdd680a2f54364a072ee55507e4db5cd8b03c2a Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 16 Oct 2019 05:08:21 +0200 Subject: [PATCH] table: apply bidi on cell values --- src/lv_objx/lv_table.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lv_objx/lv_table.c b/src/lv_objx/lv_table.c index 52f8604ce..e1ca6a2d0 100644 --- a/src/lv_objx/lv_table.c +++ b/src/lv_objx/lv_table.c @@ -145,13 +145,14 @@ void lv_table_set_cell_value(lv_obj_t * table, uint16_t row, uint16_t col, const uint32_t cell = row * ext->col_cnt + col; lv_table_cell_format_t format; + lv_bidi_dir_t base_dir = lv_obj_get_base_dir(table); + /*Save the format byte*/ if(ext->cell_data[cell]) { format.format_byte = ext->cell_data[cell][0]; } /*Initialize the format byte*/ else { - lv_bidi_dir_t base_dir = lv_obj_get_base_dir(table); if(base_dir == LV_BIDI_DIR_LTR) format.s.align = LV_LABEL_ALIGN_LEFT; else if(base_dir == LV_BIDI_DIR_RTL) format.s.align = LV_LABEL_ALIGN_RIGHT; else if(base_dir == LV_BIDI_DIR_AUTO) format.s.align = lv_bidi_detect_base_dir(txt); @@ -162,7 +163,13 @@ void lv_table_set_cell_value(lv_obj_t * table, uint16_t row, uint16_t col, const } ext->cell_data[cell] = lv_mem_realloc(ext->cell_data[cell], strlen(txt) + 2); /*+1: trailing '\0; +1: format byte*/ - strcpy(ext->cell_data[cell] + 1, txt); /*Leave the format byte*/ + +#if LV_USE_BIDI == 0 + strcpy(ext->cell_data[cell] + 1, txt); /*+1 to skip the format byte*/ +#else + lv_bidi_process(txt, ext->cell_data[cell] + 1, base_dir); +#endif + ext->cell_data[cell][0] = format.format_byte; refr_size(table); }