Rótulo do bloco declarado pela library (tb_type_block_set_label)
A library diz como o bloco aparece no editor ("liste as ferramentas de
%1", valores iniciais "a|b"); o editor usa a tabela dele quando conhece
o tipo e o rótulo da library quando não conhece. Assim uma library
carregada de fora não aparece só com o nome técnico.
Acessibilidade: aviso comum não repete "aviso" na descrição.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8f046833e7
commit
2d580005b1
4 files changed
+33
-112
No files matched your search
@@ -163,6 +163,19 @@ static const BlockSpec* spec_of(const char* tn) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Rotulo do tipo: o da tabela do editor ou o que a library declarou
|
||||
* (tb_type_block_set_label); NULL = so o nome e os campos */
|
||||
static const BlockSpec* spec_of_type(const TinyBlocks_TypeBlock* t) {
|
||||
static BlockSpec own;
|
||||
if (!t) return NULL;
|
||||
const BlockSpec* sp = spec_of(t->type_name);
|
||||
if (sp || !t->label) return sp;
|
||||
own.type = t->type_name;
|
||||
own.label = t->label;
|
||||
own.defs = t->label_defaults;
|
||||
return &own;
|
||||
}
|
||||
|
||||
static int input_count(const TinyBlocks_TypeBlock* t) {
|
||||
if (!t) return 0;
|
||||
return t->input_desc_count < MAX_INPUTS ? (int)t->input_desc_count : MAX_INPUTS;
|
||||
@@ -305,7 +318,7 @@ static void blk_defaults(EdBlock* b) {
|
||||
}
|
||||
}
|
||||
}
|
||||
const BlockSpec* sp = t ? spec_of(t->type_name) : NULL;
|
||||
const BlockSpec* sp = spec_of_type(t);
|
||||
const char* p = sp ? sp->defs : NULL;
|
||||
for (int i = 0; i < n && p; i++) {
|
||||
const char* e = strchr(p, '|');
|
||||
@@ -565,7 +578,7 @@ static void build_parts(EdBlock* b) {
|
||||
if (!t) { add_part(b, -1, b->type_name, (int)strlen(b->type_name)); return; }
|
||||
int n = input_count(t);
|
||||
bool used[MAX_INPUTS] = {0};
|
||||
const BlockSpec* sp = spec_of(t->type_name);
|
||||
const BlockSpec* sp = spec_of_type(t);
|
||||
if (t->type_name && strcmp(t->type_name, "Port.Define") == 0) {
|
||||
/* "defina [prototipo]": o nome (campo 0) nao e editavel aqui */
|
||||
add_part(b, -1, "defina", 6);
|
||||
@@ -3927,7 +3940,7 @@ static void render_toasts(Ed* ed, TinyBlocks_RenderableBlock* rb) {
|
||||
rb_line(rb, cx + 4, cy - 4, cx - 4, cy + 4, 1.6f, xh ? txt : dim);
|
||||
/* temporizador: barra que encolhe (para com o mouse em cima) */
|
||||
int an = ax_push(ed, TB_A11Y_STATUS, t->text, t->x, t->y, w, h);
|
||||
tb_a11y_set_description(ax(ed), an, t->ok ? "aviso" : "erro");
|
||||
if (!t->ok) tb_a11y_set_description(ax(ed), an, "erro"); /* o papel ja diz "aviso" */
|
||||
if (t->count > 1) {
|
||||
char cnt[32];
|
||||
snprintf(cnt, sizeof(cnt), "%d vezes", t->count);
|
||||
|
||||
Reference in new issue
Block a user