1 /**
2  * @file lv_bidi.h
3  *
4  */
5 
6 #ifndef LV_BIDI_H
7 #define LV_BIDI_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /*********************
14  *      INCLUDES
15  *********************/
16 #include "../lv_conf_internal.h"
17 #include "lv_types.h"
18 #include "lv_text.h"
19 
20 /*********************
21  *      DEFINES
22  *********************/
23 /** Special non printable strong characters.
24  * They can be inserted to texts to affect the run's direction */
25 #define LV_BIDI_LRO  "\xE2\x80\xAD" /*U+202D*/
26 #define LV_BIDI_RLO  "\xE2\x80\xAE" /*U+202E*/
27 
28 /**********************
29  *      TYPEDEFS
30  **********************/
31 typedef enum {
32     LV_BASE_DIR_LTR      = 0x00,
33     LV_BASE_DIR_RTL      = 0x01,
34     LV_BASE_DIR_AUTO     = 0x02,
35 
36     LV_BASE_DIR_NEUTRAL  = 0x20,
37     LV_BASE_DIR_WEAK     = 0x21,
38 } lv_base_dir_t;
39 
40 /**********************
41  * GLOBAL PROTOTYPES
42  **********************/
43 #if LV_USE_BIDI
44 
45 /**
46  * Get the real text alignment from the a text alignment, base direction and a text.
47  * @param align     LV_TEXT_ALIGN_..., write back the calculated align here (LV_TEXT_ALIGN_LEFT/RIGHT/CENTER)
48  * @param base_dir  LV_BASE_DIR_..., write the calculated base dir here (LV_BASE_DIR_LTR/RTL)
49  * @param txt       a text, used with LV_BASE_DIR_AUTO to determine the base direction
50  */
51 void lv_bidi_calculate_align(lv_text_align_t * align, lv_base_dir_t * base_dir, const char * txt);
52 
53 /**
54  * Set custom neutrals string
55  * @param neutrals  default " \t\n\r.,:;'\"`!?%/\\-=()[]{}<>@#&$|"
56  */
57 void lv_bidi_set_custom_neutrals_static(const char * neutrals);
58 
59 /**********************
60  *      MACROS
61  **********************/
62 
63 #else /*LV_USE_BIDI*/
64 /**
65  * For compatibility if LV_USE_BIDI = 0
66  * Get the real text alignment from the a text alignment, base direction and a text.
67  * @param align     For LV_TEXT_ALIGN_AUTO give LV_TEXT_ALIGN_LEFT else leave unchanged, write back the calculated align here
68  * @param base_dir  Unused
69  * @param txt       Unused
70  */
lv_bidi_calculate_align(lv_text_align_t * align,lv_base_dir_t * base_dir,const char * txt)71 static inline void lv_bidi_calculate_align(lv_text_align_t * align, lv_base_dir_t * base_dir, const char * txt)
72 {
73     LV_UNUSED(txt);
74     LV_UNUSED(base_dir);
75     if(*align == LV_TEXT_ALIGN_AUTO) * align = LV_TEXT_ALIGN_LEFT;
76 }
77 #endif /*LV_USE_BIDI*/
78 
79 #ifdef __cplusplus
80 } /*extern "C"*/
81 #endif
82 
83 #endif /*LV_BIDI_H*/
84