Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bidi): support set neutral string #6146

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/misc/lv_bidi.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ static uint32_t get_txt_len(const char * txt, uint32_t max_len);
**********************/
static const uint8_t bracket_left[] = {"<({["};
static const uint8_t bracket_right[] = {">)}]"};
static const char * custom_neutrals = NULL;

/**********************
* MACROS
Expand Down Expand Up @@ -281,6 +282,11 @@ void lv_bidi_calculate_align(lv_text_align_t * align, lv_base_dir_t * base_dir,
}
}

void lv_bidi_set_custom_neutrals_static(const char * neutrals)
{
custom_neutrals = neutrals;
}

/**********************
* STATIC FUNCTIONS
**********************/
Expand Down Expand Up @@ -364,7 +370,11 @@ static bool lv_bidi_letter_is_rtl(uint32_t letter)
static bool lv_bidi_letter_is_neutral(uint32_t letter)
{
uint16_t i;
static const char neutrals[] = " \t\n\r.,:;'\"`!?%/\\-=()[]{}<>@#&$|";
const char * neutrals = " \t\n\r.,:;'\"`!?%/\\-=()[]{}<>@#&$|";
if(custom_neutrals) {
neutrals = custom_neutrals;
}

kisvegabor marked this conversation as resolved.
Show resolved Hide resolved
for(i = 0; neutrals[i] != '\0'; i++) {
if(letter == (uint32_t)neutrals[i]) return true;
}
Expand Down
6 changes: 6 additions & 0 deletions src/misc/lv_bidi.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t le
*/
void lv_bidi_calculate_align(lv_text_align_t * align, lv_base_dir_t * base_dir, const char * txt);

/**
* Set custom neutrals string
* @param neutrals default " \t\n\r.,:;'\"`!?%/\\-=()[]{}<>@#&$|"
*/
void lv_bidi_set_custom_neutrals_static(const char * neutrals);

/**********************
* MACROS
**********************/
Expand Down