fix(color): Limit label lengths, improve lbl display, prevent inv. char (#2287)

* (cpn) Add bullets & length warning

* (fw) Show labels with bullet separators

* (fw) Check all running twice. Remove from here

* (fw) Correct buffer overflow when labels too long

* (fw) Rem bullets in model label string

* (fw, cpn) Labels length

cpn,fw Limit label length
cpn Check correct model on rename length
cpn Focus issues
cpn Add rename,  move up/down.. still has an issue with selection. TODO...
cpn Switch to utf8 encoding
cpn Rename button ;)

* (cpn) Move up down working

re-Fix Checkbox, partially isn't what I thought (not greyed)

* (fw) Add CSV string funcs

Limit length of model edit shorter in portrait mode

* (cpn) Correct Label option showing on B&W

* (fw) Radio filename set but no file exists don't create

* (cpn) Simplify wording

* (fw) Correct debug values

* (fw) Reduce truncation length

* (both) Don't allow special chars in label name

(cpn) Prevent move when at top and bottom
(fw) Remove multiple label length defines
(fw) Shorten truncate length even more

* (fw) Close model_select on new model
This commit is contained in:
Cliff
2022-09-18 10:47:21 +10:00
committed by GitHub
parent c3660ab931
commit 333c2828ea
16 changed files with 405 additions and 248 deletions
+12 -8
View File
@@ -49,8 +49,8 @@ struct labelslist_iter
bool modeldatavalid; // Used to determine if reading yaml values is necessary
uint8_t level;
uint8_t section;
char current_attr[LABEL_LENGTH+1]; // set after find_node()
char current_label[LABEL_LENGTH+1]; // set after find_node()
char current_attr[LABELS_LENGTH+1]; // set after find_node()
char current_label[LABELS_LENGTH+1]; // set after find_node()
};
static labelslist_iter __labelslist_iter_inst;
@@ -130,9 +130,9 @@ static bool find_node(void* ctx, char* buf, uint8_t len)
bool found=false;
for(auto &filehash : modelslist.fileHashInfo) {
if(filehash.name == mi->current_attr) {
TRACE_LABELS_YAML(" Model %s has a real file, creating a modelcell", filehash.name);
TRACE_LABELS_YAML(" Model %s has a real file, creating a modelcell", mi->current_attr);
if(filehash.celladded) {
TRACE_LABELS_YAML(" Duplicate found labels.yml model cell %s already added", filehash.name);
TRACE_LABELS_YAML(" Duplicate found labels.yml model cell %s already added", mi->current_attr);
break;
}
ModelCell *model = new ModelCell(mi->current_attr);
@@ -158,8 +158,8 @@ static bool find_node(void* ctx, char* buf, uint8_t len)
if(mi->level == 1 && mi->section == labelslist_iter::SEC_Labels) {
TRACE_LABELS_YAML("Label Found -- %s", mi->current_attr);
modelslabels.addLabel(mi->current_attr);
strncpy(mi->current_label,mi->current_attr, LABEL_LENGTH);
mi->current_label[LABEL_LENGTH] = '\0';
strncpy(mi->current_label,mi->current_attr, LABELS_LENGTH);
mi->current_label[LABELS_LENGTH] = '\0';
}
return true;
@@ -167,7 +167,11 @@ static bool find_node(void* ctx, char* buf, uint8_t len)
static void set_attr(void* ctx, char* buf, uint8_t len)
{
char value[40];
char value[LABELS_LENGTH + 1];
if(len > LABELS_LENGTH) {
TRACE("ERROR: YAML too long for buffer");
return;
}
memcpy(value, buf, len);
value[len] = '\0';
@@ -256,7 +260,7 @@ static void set_attr(void* ctx, char* buf, uint8_t len)
// Sort Order
} else if (mi->level == 0 && mi->section == labelslist_iter::SEC_Sort) {
TRACE_LABELS_YAML(" Sort Order Found -- %s", mi->current_attr);
TRACE_LABELS_YAML(" Sort Order Found -- %s", value);
modelslabels.setSortOrder((ModelsSortBy)strtol(value,NULL,10));
}
}