mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-27 20:57:01 +08:00
feat(textarea): add lv_textarea_get_current_char(obj) (#3536)
* Update lv_textarea.h add uint32_t lv_textarea_get_right_char(lv_obj_t * obj); //Get a the right character from the current cursor position * Update lv_textarea.c Add uint32_t lv_textarea_get_right_char(lv_obj_t * obj); Get a the right character from the current cursor position * Add uint32_t lv_textarea_get_right_char(lv_obj_t * obj); /* Get a the right character from the current cursor position */Y * Rename name to 'lv_textarea_get_current_char(..)' and modify 'int' to 'uint32_t' Co-authored-by: root <root@localhost.localdomain>
This commit is contained in:
@@ -704,6 +704,19 @@ uint16_t lv_textarea_get_password_show_time(lv_obj_t * obj)
|
||||
return ta->pwd_show_time;
|
||||
}
|
||||
|
||||
uint32_t lv_textarea_get_current_char(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
const char * txt = lv_textarea_get_text(obj);
|
||||
lv_textarea_t * ta = (lv_textarea_t *)obj;
|
||||
uint32_t pos = ta->cursor.pos;
|
||||
if(_lv_txt_get_encoded_length(txt) >= pos && pos > 0)
|
||||
return _lv_txt_encoded_prev(txt, &pos);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Other functions
|
||||
*====================*/
|
||||
|
||||
@@ -308,6 +308,13 @@ bool lv_textarea_get_text_selection(lv_obj_t * obj);
|
||||
*/
|
||||
uint16_t lv_textarea_get_password_show_time(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get a the character from the current cursor position
|
||||
* @param obj pointer to a text area object
|
||||
* @return a the character or 0
|
||||
*/
|
||||
uint32_t lv_textarea_get_current_char(lv_obj_t * obj);
|
||||
|
||||
/*=====================
|
||||
* Other functions
|
||||
*====================*/
|
||||
|
||||
Reference in New Issue
Block a user