.load.l.paneright.list better positioning (remember last selection), print_spice_subckt_nodes(): use my_mstrcat() instead of fprintf, for future enhancements

This commit is contained in:
stefan schippers 2024-01-06 12:14:36 +01:00
parent dcef3d4b9d
commit f0e739cf02
3 changed files with 27 additions and 9 deletions

View File

@ -1824,6 +1824,7 @@ void print_spice_subckt_nodes(FILE *fd, int symbol)
size_t token_pos=0; size_t token_pos=0;
int escape=0; int escape=0;
int no_of_pins=0; int no_of_pins=0;
char *result = NULL;
const char *tclres, *fmt_attr = NULL; const char *tclres, *fmt_attr = NULL;
fmt_attr = xctx->format ? xctx->format : "format"; fmt_attr = xctx->format ? xctx->format : "format";
@ -1901,7 +1902,8 @@ void print_spice_subckt_nodes(FILE *fd, int symbol)
const char *name = get_tok_value(xctx->sym[symbol].rect[PINLAYER][i].prop_ptr,"name",0); const char *name = get_tok_value(xctx->sym[symbol].rect[PINLAYER][i].prop_ptr,"name",0);
if(!int_hash_lookup(&table, name, 1, XINSERT_NOREPLACE)) { if(!int_hash_lookup(&table, name, 1, XINSERT_NOREPLACE)) {
str_ptr= expandlabel(name, &multip); str_ptr= expandlabel(name, &multip);
fprintf(fd, "%s ", str_ptr); /* fprintf(fd, "%s ", str_ptr); */
my_mstrcat(_ALLOC_ID_, &result, str_ptr, " ", NULL);
} }
} }
} }
@ -1914,7 +1916,8 @@ void print_spice_subckt_nodes(FILE *fd, int symbol)
if(!strcmp(get_tok_value(prop, "name",0), token + 2)) break; if(!strcmp(get_tok_value(prop, "name",0), token + 2)) break;
} }
if(i<no_of_pins && strboolcmp(get_tok_value(prop,"spice_ignore",0), "true")) { if(i<no_of_pins && strboolcmp(get_tok_value(prop,"spice_ignore",0), "true")) {
fprintf(fd, "%s ", expandlabel(token+2, &multip)); /* fprintf(fd, "%s ", expandlabel(token+2, &multip)); */
my_mstrcat(_ALLOC_ID_, &result, expandlabel(token+2, &multip), " ", NULL);
} }
} }
/* reference by pin number instead of pin name, allows faster lookup of the attached net name 20180911 */ /* reference by pin number instead of pin name, allows faster lookup of the attached net name 20180911 */
@ -1926,7 +1929,8 @@ void print_spice_subckt_nodes(FILE *fd, int symbol)
if(pin_number >= 0 && pin_number < no_of_pins) { if(pin_number >= 0 && pin_number < no_of_pins) {
if(strboolcmp(get_tok_value(xctx->sym[symbol].rect[PINLAYER][pin_number].prop_ptr,"spice_ignore",0), "true")) { if(strboolcmp(get_tok_value(xctx->sym[symbol].rect[PINLAYER][pin_number].prop_ptr,"spice_ignore",0), "true")) {
str_ptr = get_tok_value(xctx->sym[symbol].rect[PINLAYER][pin_number].prop_ptr,"name",0); str_ptr = get_tok_value(xctx->sym[symbol].rect[PINLAYER][pin_number].prop_ptr,"name",0);
fprintf(fd, "%s ", expandlabel(str_ptr, &multip)); /* fprintf(fd, "%s ", expandlabel(str_ptr, &multip)); */
my_mstrcat(_ALLOC_ID_, &result, expandlabel(str_ptr, &multip), " ", NULL);
} }
} }
my_free(_ALLOC_ID_, &pin_attr); my_free(_ALLOC_ID_, &pin_attr);
@ -1939,7 +1943,8 @@ void print_spice_subckt_nodes(FILE *fd, int symbol)
else if(token[0] == '@') { /* given previous if() conditions not followed by @ or # */ else if(token[0] == '@') { /* given previous if() conditions not followed by @ or # */
/* if token not followed by white space it is not an extra node */ /* if token not followed by white space it is not an extra node */
if( ( (space || c == '%' || c == '@') && !escape ) ) { if( ( (space || c == '%' || c == '@') && !escape ) ) {
fprintf(fd, "%s ", token + 1); /* fprintf(fd, "%s ", token + 1); */
my_mstrcat(_ALLOC_ID_, &result, token + 1, " ", NULL);
} }
} }
/* if(c!='%' && c!='@' && c!='\0' ) fputc(c,fd); */ /* if(c!='%' && c!='@' && c!='\0' ) fputc(c,fd); */
@ -1952,9 +1957,14 @@ void print_spice_subckt_nodes(FILE *fd, int symbol)
} }
if(c=='\0') if(c=='\0')
{ {
my_mstrcat(_ALLOC_ID_, &result, "\n", NULL);
break ; break ;
} }
} }
if(result) {
fprintf(fd, "%s", result);
my_free(_ALLOC_ID_, &result);
}
my_free(_ALLOC_ID_, &format1); my_free(_ALLOC_ID_, &format1);
my_free(_ALLOC_ID_, &format); my_free(_ALLOC_ID_, &format);
my_free(_ALLOC_ID_, &token); my_free(_ALLOC_ID_, &token);

View File

@ -3481,7 +3481,13 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}}
set file_dialog_globfilter *[.load.buttons_bot.entry get]* set file_dialog_globfilter *[.load.buttons_bot.entry get]*
if { $file_dialog_globfilter eq {**} } { set file_dialog_globfilter * } if { $file_dialog_globfilter eq {**} } { set file_dialog_globfilter * }
setglob $file_dialog_dir1 setglob $file_dialog_dir1
.load.l.paneright.list yview moveto 1.0 if {[.load.buttons_bot.entry get] ne {}} {
.load.l.paneright.list yview moveto 1.0
} else {
if { [info exists file_dialog_yview]} {
.load.l.paneright.list yview moveto [lindex $file_dialog_yview 0]
}
}
} }
# set to something different to any file to force a new placement in file_dialog_place_symbol # set to something different to any file to force a new placement in file_dialog_place_symbol
set file_dialog_retval { } set file_dialog_retval { }

View File

@ -39,13 +39,14 @@ subdivx=1
node="out node="out
trig trig
\\"2/3 Vcc; ctrl\\" \\"2/3 Vcc; ctrl\\"
\\"1/3 Vcc; x1.18\\"" \\"1/3 Vcc; x1.18\\"
color="4 15 7 12" dis"
color="4 15 7 12 9"
dataset=-1 dataset=-1
unitx=1 unitx=1
logx=0 logx=0
logy=0 logy=0
} hilight_wave=-1}
T {NE555 TIMER IC EXAMPLE} 360 -490 0 0 0.4 0.4 {} T {NE555 TIMER IC EXAMPLE} 360 -490 0 0 0.4 0.4 {}
N 130 -150 200 -150 {lab=TRIG} N 130 -150 200 -150 {lab=TRIG}
N 570 -130 570 -100 { N 570 -130 570 -100 {
@ -69,7 +70,8 @@ vvss vss 0 dc 0
write test_ne555.raw write test_ne555.raw
.endc .endc
"} "}
C {ne555.sym} 490 -220 0 0 {name=x1} C {ne555.sym} 490 -220 0 0 {name=x1
tclcommand="textwindow $netlist_dir/model_test_ne555.txt"}
C {res.sym} 130 -180 0 0 {name=r3 m=1 value=2k} C {res.sym} 130 -180 0 0 {name=r3 m=1 value=2k}
C {capa.sym} 130 -120 0 0 {name=c6 m=1 value=2n} C {capa.sym} 130 -120 0 0 {name=c6 m=1 value=2n}
C {vsource.sym} 130 -360 0 1 {name=v1 value=5} C {vsource.sym} 130 -360 0 1 {name=v1 value=5}