/** * @file lv_ta.h * */ #ifndef LV_TA_H #define LV_TA_H /********************* * INCLUDES *********************/ #include "lv_conf.h" #if USE_LV_TA != 0 /*Testing of dependencies*/ #if USE_LV_PAGE == 0 #error "lv_ta: lv_page is required. Enable it in lv_conf.h (USE_LV_PAGE 1) " #endif #if USE_LV_LABEL == 0 #error "lv_ta: lv_label is required. Enable it in lv_conf.h (USE_LV_LABEL 1) " #endif #include "../lv_obj/lv_obj.h" #include "lv_page.h" #include "lv_label.h" /********************* * DEFINES *********************/ #define LV_TA_CUR_LAST (0x7FFF) /*Put the cursor after the last character*/ /********************** * TYPEDEFS **********************/ /*Data of text area*/ typedef struct { lv_page_ext_t page; /*Ext. of ancestor*/ /*New data for this type */ lv_obj_t * label; /*Label of the text area*/ cord_t cursor_valid_x; /*Used when stepping up/down in text area. Handled by the library*/ uint16_t cursor_pos; /*The current cursor position (0: before 1. letter, 1: before 2. letter etc.)*/ uint8_t cur_hide :1; /*Indicates that the cursor is visible now or not*/ }lv_ta_ext_t; /*Style of text area*/ typedef struct { lv_pages_t page; /*Style of ancestor*/ /*New style element for this type */ lv_labels_t label; color_t cursor_color; cord_t cursor_width; uint8_t cursor_show :1; }lv_tas_t; /*Built-in styles of text area*/ typedef enum { LV_TAS_DEF, }lv_tas_builtin_t; /********************** * GLOBAL PROTOTYPES **********************/ /** * Create a text area objects * @param par pointer to an object, it will be the parent of the new text area * @param copy pointer to a text area object, if not NULL then the new object will be copied from it * @return pointer to the created text area */ lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy); /** * Signal function of the text area * @param ta pointer to a text area object * @param sign a signal type from lv_signal_t enum * @param param pointer to a signal specific variable * @return true: the object is still valid (not deleted), false: the object become invalid */ bool lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param); /** * Insert a character to the current cursor position * @param ta pointer to a text area object * @param c a character */ void lv_ta_add_char(lv_obj_t * ta, char c); /** * Insert a text to the current cursor position * @param ta pointer to a text area object * @param txt a '\0' terminated string to insert */ void lv_ta_add_text(lv_obj_t * ta, const char * txt); /** * Set the text of a text area * @param ta pointer to a text area * @param txt pointer to the text */ void lv_ta_set_text(lv_obj_t * ta, const char * txt); /** * Delete a the left character from the current cursor position * @param ta pointer to a text area object */ void lv_ta_del(lv_obj_t * ta); /** * Set the cursor position * @param obj pointer to a text area object * @param pos the new cursor position in character index * < 0 : index from the end of the text * LV_TA_CUR_LAST: go after the last character */ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos); /** * Move the cursor one character right * @param ta pointer to a text area object */ void lv_ta_cursor_right(lv_obj_t * ta); /** * Move the cursor one character left * @param ta pointer to a text area object */ void lv_ta_cursor_left(lv_obj_t * ta); /** * Move the cursor one line down * @param ta pointer to a text area object */ void lv_ta_cursor_down(lv_obj_t * ta); /** * Move the cursor one line up * @param ta pointer to a text area object */ void lv_ta_cursor_up(lv_obj_t * ta); /** * Get the text of the i the text area * @param ta obj pointer to a text area object * @return pointer to the text */ const char * lv_ta_get_txt(lv_obj_t * ta); /** * Get the current cursor position in character index * @param ta pointer to a text area object * @return the cursor position */ uint16_t lv_ta_get_cursor_pos(lv_obj_t * ta); /** * Return with a pointer to a built-in style and/or copy it to a variable * @param style a style name from lv_tas_builtin_t enum * @param copy copy the style to this variable. (NULL if unused) * @return pointer to an lv_tas_t style */ lv_tas_t * lv_tas_get(lv_tas_builtin_t style, lv_tas_t * copy); /********************** * MACROS **********************/ #endif #endif