txt_recolor: text recolor option added, text size function are exteded with a falg paramter

This commit is contained in:
Gabor
2017-02-01 11:39:48 +01:00
parent 2de1f4363c
commit 014d0a3842
10 changed files with 259 additions and 47 deletions

View File

@@ -18,10 +18,23 @@
/*********************
* DEFINES
*********************/
#define TXT_RECOLOR_CMD '#'
/**********************
* TYPEDEFS
**********************/
typedef enum
{
TXT_FLAG_NONE = 0x00,
TXT_FLAG_RECOLOR = 0x01,
}txt_flag_t;
typedef enum
{
TXT_CMD_STATE_WAIT,
TXT_CMD_STATE_PAR,
TXT_CMD_STATE_IN,
}txt_cmd_state_t;
/**********************
* GLOBAL PROTOTYPES
@@ -34,10 +47,11 @@
* @param font pinter to font of the text
* @param letter_space letter space of the text
* @param line_space line space of the text
* @param flags settings for the text from 'txt_flag_t' enum
* @param max_width max with of the text (break the lines to fit this size) Set LV_CORD_MAX to avoid line breaks
*/
void txt_get_size(point_t * size_res, const char * text, const font_t * font,
uint16_t letter_space, uint16_t line_space, cord_t max_width);
uint16_t letter_space, uint16_t line_space, cord_t max_width, txt_flag_t flag);
/**
* Get the next line of text. Check line length and break chars too.
@@ -45,21 +59,32 @@ void txt_get_size(point_t * size_res, const char * text, const font_t * font,
* @param font_p pointer to a font
* @param letter_space letter space
* @param max_l max line length
* @param flags settings for the text from 'txt_flag_t' enum
* @return the index of the first char of the new line
*/
uint16_t txt_get_next_line(const char * txt, const font_t * font_p,
uint16_t letter_space, cord_t max_l);
uint16_t letter_space, cord_t max_l, txt_flag_t flag);
/**
* Give the length of a text with a given font
* @param txt a '\0' terminate string
* @param char_num number of characters in 'txt'
* @param font_p pointer to a font
* @param letter_space letter sapce
* @param letter_space letter space
* @param flags settings for the text from 'txt_flag_t' enum
* @return length of a char_num long text
*/
cord_t txt_get_width(const char * txt, uint16_t char_num,
const font_t * font_p, uint16_t letter_space);
const font_t * font_p, uint16_t letter_space, txt_flag_t flag);
/**
* Check next character in a string and decide if te character is part of the command or not
* @param state pointer to a txt_cmd_state_t variable which stores the current state of command processing
* @param c the current character
* @return true: the character is part of a command and should not be written,
* false: the character should be written
*/
bool txt_is_cmd(txt_cmd_state_t * state, char c);
/**********************
* MACROS