floater=1 in text elements assumed as floater=true to avoid referencing instance no.1. Texts with @params will go thru translation using parent level param assignments in translate()

This commit is contained in:
stefan schippers 2025-11-12 17:44:55 +01:00
parent e97a75f65a
commit 98395824bc
2 changed files with 16 additions and 6 deletions

View File

@ -114,6 +114,7 @@ const char *get_text_floater(int i)
instname = get_tok_value(xctx->text[i].prop_ptr, "name", 0); instname = get_tok_value(xctx->text[i].prop_ptr, "name", 0);
if(!xctx->tok_size) { if(!xctx->tok_size) {
instname = get_tok_value(xctx->text[i].prop_ptr, "floater", 0); instname = get_tok_value(xctx->text[i].prop_ptr, "floater", 0);
if(xctx->tok_size && !strboolcmp(instname, "true")) instname = "true";
} }
} }
inst = get_instance(instname); inst = get_instance(instname);
@ -940,7 +941,10 @@ int set_text_flags(xText *t)
t->flags |= strboolcmp(str, "true") ? 0 : HIDE_TEXT; t->flags |= strboolcmp(str, "true") ? 0 : HIDE_TEXT;
} }
str = get_tok_value(t->prop_ptr, "name", 0); str = get_tok_value(t->prop_ptr, "name", 0);
if(!xctx->tok_size) str = get_tok_value(t->prop_ptr, "floater", 0); if(!xctx->tok_size) {
str = get_tok_value(t->prop_ptr, "floater", 0);
if(xctx->tok_size && !strboolcmp(str, "true")) str = "true";
}
t->flags |= xctx->tok_size ? TEXT_FLOATER : 0; t->flags |= xctx->tok_size ? TEXT_FLOATER : 0;
my_strdup2(_ALLOC_ID_, &t->floater_instname, str); my_strdup2(_ALLOC_ID_, &t->floater_instname, str);
} }
@ -2290,6 +2294,7 @@ void get_sch_from_sym(char *filename, xSymbol *sym, int inst, int fallback)
if(strcmp(tclresult(), "yes") ) fallback = 0; /* 'no' or 'cancel' */ if(strcmp(tclresult(), "yes") ) fallback = 0; /* 'no' or 'cancel' */
if(!strcmp(tclresult(), "") ) { /* 'cancel' */ if(!strcmp(tclresult(), "") ) { /* 'cancel' */
cancel = 1; cancel = 1;
my_strncpy(filename,"", PATH_MAX);
} }
} }
} }

View File

@ -5203,10 +5203,15 @@ const char *translate(int inst, const char* s)
/* if spiceprefix==0 and token == @spiceprefix then set empty value */ /* if spiceprefix==0 and token == @spiceprefix then set empty value */
} else if(!sp_prefix && !strcmp(token, "@spiceprefix")) { } else if(!sp_prefix && !strcmp(token, "@spiceprefix")) {
/* add nothing */ /* add nothing */
} else if(inst >= 0) { } else {
value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 0); if(inst >= 0) {
if(!xctx->tok_size && xctx->inst[inst].ptr >= 0) { value = get_tok_value(xctx->inst[inst].prop_ptr, token+1, 0);
value=get_tok_value(xctx->sym[xctx->inst[inst].ptr].templ, token+1, 0); if(!xctx->tok_size && xctx->inst[inst].ptr >= 0) {
value=get_tok_value(xctx->sym[xctx->inst[inst].ptr].templ, token+1, 0);
}
} else {
xctx->tok_size = 1;
value = token + 1;
} }
if(!xctx->tok_size) { /* above lines did not find a value for token */ if(!xctx->tok_size) { /* above lines did not find a value for token */
if(token[0] =='%') { if(token[0] =='%') {
@ -5285,7 +5290,7 @@ const char *translate(int inst, const char* s)
* can be calculated */ * can be calculated */
my_strdup2(_ALLOC_ID_, &result, spice_get_node(tcl_hook2(result))); my_strdup2(_ALLOC_ID_, &result, spice_get_node(tcl_hook2(result)));
if(is_expr(result)) { if(is_expr(result) && inst >= 0) {
dbg(1, "translate(): expr():%s\n", result); dbg(1, "translate(): expr():%s\n", result);
my_strdup2(_ALLOC_ID_, &result, eval_expr( my_strdup2(_ALLOC_ID_, &result, eval_expr(
translate3(result, 1, xctx->inst[inst].prop_ptr, xctx->sym[xctx->inst[inst].ptr].templ, translate3(result, 1, xctx->inst[inst].prop_ptr, xctx->sym[xctx->inst[inst].ptr].templ,