feat(color): Use generic YAML parser to save/load Theme yaml files (#3346)

* Change ThemeFile class to use generic YAML parser instead of hard wired code.
Fix handling of empty input lines in YAML parser.
Increase size of YAML parser variables to handle theme 'info' property length.

* Update comment.

* Fix error.

* Proper fix for blank lines in YAML file.

* Fix YAML blank line handling (attempt 3).

* Ensure theme YAML file is backward compatible.

* Store selected theme in radio settings instead of selectedtheme.txt file.
On start, if radio settings theme is empty, try and load from selectedtheme.txt file.
In Companion, save/load the selected theme in the radio settings YAML file; but no UI to select theme.

* Update selected theme name in radio.yml if the theme name was edited.

* Only save 'selectedTheme' in Companion on color LCD radios.
This commit is contained in:
philmoz
2023-04-09 13:32:30 +10:00
committed by GitHub
parent f01b0f2772
commit 92651429a2
17 changed files with 236 additions and 277 deletions
+5 -5
View File
@@ -29,7 +29,7 @@
#define MIN(a,b) (a < b ? a : b)
static void copy_string(char* dst, uint8_t dst_len, const char* src,
static void copy_string(char* dst, uint16_t dst_len, const char* src,
uint8_t src_len)
{
if (src_len < dst_len) {
@@ -57,7 +57,7 @@ uint32_t yaml_parse_enum(const struct YamlIdStr* choices, const char* val, uint8
static void yaml_set_attr(void* user, uint8_t* ptr, uint32_t bit_ofs,
const YamlNode* node, const char* val,
uint8_t val_len)
uint16_t val_len)
{
uint32_t i = 0;
@@ -265,7 +265,7 @@ bool YamlTreeWalker::findNode(const char* tag, uint8_t tag_len)
setAttrValue((char*)tag, tag_len);
return true;
}
while(attr && attr->type != YDT_NONE) {
if ((tag_len == attr->tag_len)
@@ -442,7 +442,7 @@ void YamlTreeWalker::toNextAttr()
}
}
void YamlTreeWalker::setAttrValue(char* buf, uint8_t len)
void YamlTreeWalker::setAttrValue(char* buf, uint16_t len)
{
if (!buf || !len || isIdxInvalid())
return;
@@ -684,7 +684,7 @@ static bool find_node(void* ctx, char* buf, uint8_t len)
return ((YamlTreeWalker*)ctx)->findNode(buf,len);
}
static void set_attr(void* ctx, char* buf, uint8_t len)
static void set_attr(void* ctx, char* buf, uint16_t len)
{
((YamlTreeWalker*)ctx)->setAttrValue(buf,len);
}