Skip to content

Commit

Permalink
feat(lv_bidi): Add set custom neutrals api
Browse files Browse the repository at this point in the history
Signed-off-by: qinshijing <[email protected]>
  • Loading branch information
qinshijing committed Apr 29, 2024
1 parent 5a6f8b7 commit f69015f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
14 changes: 12 additions & 2 deletions 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 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;

Check failure on line 287 in src/misc/lv_bidi.c

View workflow job for this annotation

GitHub Actions / Build Windows GCC

assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

Check failure on line 287 in src/misc/lv_bidi.c

View workflow job for this annotation

GitHub Actions / Build OPTIONS_FULL_32BIT

assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]

Check failure on line 287 in src/misc/lv_bidi.c

View workflow job for this annotation

GitHub Actions / Build OPTIONS_VG_LITE

assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]

Check failure on line 287 in src/misc/lv_bidi.c

View workflow job for this annotation

GitHub Actions / aarch64 Executable Tests

assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]

Check failure on line 287 in src/misc/lv_bidi.c

View workflow job for this annotation

GitHub Actions / amd64 Executable Tests

assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
}

/**********************
* STATIC FUNCTIONS
**********************/
Expand Down Expand Up @@ -365,8 +371,12 @@ static bool lv_bidi_letter_is_neutral(uint32_t letter)
{
uint16_t i;
static const char neutrals[] = " \t\n\r.,:;'\"`!?%/\\-=()[]{}<>@#&$|";
for(i = 0; neutrals[i] != '\0'; i++) {
if(letter == (uint32_t)neutrals[i]) return true;
if(custom_neutrals == NULL) {
custom_neutrals = neutrals;

Check failure on line 375 in src/misc/lv_bidi.c

View workflow job for this annotation

GitHub Actions / Build Windows GCC

assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

Check failure on line 375 in src/misc/lv_bidi.c

View workflow job for this annotation

GitHub Actions / Build OPTIONS_FULL_32BIT

assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]

Check failure on line 375 in src/misc/lv_bidi.c

View workflow job for this annotation

GitHub Actions / Build OPTIONS_VG_LITE

assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]

Check failure on line 375 in src/misc/lv_bidi.c

View workflow job for this annotation

GitHub Actions / aarch64 Executable Tests

assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]

Check failure on line 375 in src/misc/lv_bidi.c

View workflow job for this annotation

GitHub Actions / amd64 Executable Tests

assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
}

for(i = 0; custom_neutrals[i] != '\0'; i++) {
if(letter == (uint32_t)custom_neutrals[i]) return true;
}

return false;
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 str default " \t\n\r.,:;'\"`!?%/\\-=()[]{}<>@#&$|"
*/
void lv_bidi_set_custom_neutrals_static(const char * str);

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

0 comments on commit f69015f

Please sign in to comment.