better check_unique_names() and hash_all_names() implementation (do not skip label instances or instances with no format attr). Button click focuses main drawing window even if autofocus_mainwindow is set to 0, to avoid losing keyboard focus forever if TAB is pressed.

This commit is contained in:
Stefan Frederik 2022-10-12 11:56:02 +02:00
parent 7d016eab28
commit 7a1fbb4809
9 changed files with 33 additions and 50 deletions

View File

@ -1556,7 +1556,7 @@ void calc_drawing_bbox(xRect *boundbox, int selected)
entry=bus_hilight_hash_lookup(xctx->inst[i].lab, 0, XLOOKUP );
if(entry) found = 1;
}
else if( xctx->inst[i].color != -10000 ) {
if(!found && xctx->inst[i].color != -10000 ) {
found = 1;
}
if(!found) continue;

View File

@ -458,8 +458,8 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot,
( /* ... and inst is hilighted ... */
IS_LABEL_SH_OR_PIN(type) && xctx->inst[n].node && xctx->inst[n].node[0] &&
bus_hilight_hash_lookup(xctx->inst[n].node[0], 0, XLOOKUP )
) || ( !IS_LABEL_SH_OR_PIN(type) && (xctx->inst[n].color != -10000)) )) {
xctx->inst[n].flags|=1; /* ... then SKIP instance now and for following layers */
) || (/* !IS_LABEL_SH_OR_PIN(type) && */ (xctx->inst[n].color != -10000)) )) {
xctx->inst[n].flags|=1; /* ... then SKIP instance now and for following layers */
return;
}
else if(!xctx->only_probes && (xctx->inst[n].x2 - xctx->inst[n].x1) * xctx->mooz < 3 &&

View File

@ -133,6 +133,7 @@ Hilight_hashentry *inst_hilight_hash_lookup(const char *token, int value, int wh
char *inst_tok = NULL;
size_t len = strlen(token) + 2; /* token plus one more character and \0 */
Hilight_hashentry *entry;
dbg(1, "inst_hilight_hash_lookup: token=%s value=%s what=%d\n", token, value, what);
inst_tok = my_malloc(1568, len);
/* instance name uglyfication: add a space at beginning so it will never match a valid net name */
my_snprintf(inst_tok, len, " %s", token);

View File

@ -126,19 +126,15 @@ static void inst_hash_free(void) /* remove the whole hash table */
void hash_all_names(int n)
{
int i, has_fmt_attr;
int i;
char *upinst = NULL, *type = NULL;
const char *fmt_attr = NULL;
inst_hash_free();
fmt_attr = xctx->format ? xctx->format : "format";
for(i=0; i<xctx->instances; i++) {
has_fmt_attr = get_tok_value((xctx->inst[i].ptr + xctx->sym)->prop_ptr, fmt_attr, 2)[0] ? 1 : 0;
if(xctx->inst[i].instname && xctx->inst[i].instname[0]) {
my_strdup(1526, &type,(xctx->inst[i].ptr+ xctx->sym)->type);
if(!type || !has_fmt_attr || IS_LABEL_SH_OR_PIN(type) ) continue;
if(!type) continue;
my_strdup(1254, &upinst, xctx->inst[i].instname);
strtoupper(upinst);
/* if(i == n) continue; */
inst_hash_lookup(upinst, i, XINSERT);
}
}
@ -177,21 +173,18 @@ void clear_instance_hash()
*/
void check_unique_names(int rename)
{
int i, first = 1, has_fmt_attr;
int i, first = 1;
int newpropcnt = 0;
char *tmp = NULL;
Inst_hashentry *entry;
int big = xctx->wires> 2000 || xctx->instances > 2000;
char *upinst = NULL, *type = NULL;
const char *fmt_attr = NULL;
/* int save_draw; */
if(xctx->hilight_nets) {
xRect boundbox;
if(!big) calc_drawing_bbox(&boundbox, 2);
xctx->enable_drill=0;
clear_all_hilights();
/* undraw_hilight_net(1); */
if(!big) {
bbox(START, 0.0 , 0.0 , 0.0 , 0.0);
bbox(ADD, boundbox.x1, boundbox.y1, boundbox.x2, boundbox.y2);
@ -202,17 +195,15 @@ void check_unique_names(int rename)
}
inst_hash_free();
first = 1;
fmt_attr = xctx->format ? xctx->format : "format";
for(i=0;i<xctx->instances;i++) {
if(xctx->inst[i].instname && xctx->inst[i].instname[0]) {
has_fmt_attr = get_tok_value((xctx->inst[i].ptr + xctx->sym)->prop_ptr, fmt_attr, 2)[0] ? 1 : 0;
my_strdup(1261, &type,(xctx->inst[i].ptr+ xctx->sym)->type);
if(!type || !has_fmt_attr || IS_LABEL_SH_OR_PIN(type) ) continue;
if(!type) continue;
my_strdup(1246, &upinst, xctx->inst[i].instname);
strtoupper(upinst);
if( (entry = inst_hash_lookup(upinst, i, XINSERT_NOREPLACE) ) && entry->value != i) {
xctx->inst[i].color = -PINLAYER;
xctx->hilight_nets=1;
inst_hilight_hash_lookup(xctx->inst[i].instname, -PINLAYER, XINSERT_NOREPLACE);
if(rename == 1) {
if(first) {
bbox(START,0.0,0.0,0.0,0.0);
@ -244,9 +235,7 @@ void check_unique_names(int rename)
draw();
bbox(END,0.0,0.0,0.0,0.0);
}
/* draw_hilight_net(1); */
redraw_hilights(0);
/* xctx->draw_window = save_draw; */
}

View File

@ -1412,7 +1412,7 @@ static void create_new_tab(int *window_count, const char *fname)
/* tcl code to create the tab button */
my_snprintf(nn, S(nn), "%d", n);
tclvareval(
"button ", ".tabs.x", nn, " -padx 2 -pady 0 -anchor nw -text Tab2 "
"button ", ".tabs.x", nn, " -padx 2 -pady 0 -takefocus 0 -anchor nw -text Tab2 "
"-command \"xschem new_schematic switch_tab .x", nn, ".drw\"", NULL);
tclvareval("bind .tabs.x",nn," <ButtonPress> {swap_tabs %X %Y press}", NULL);
tclvareval("bind .tabs.x",nn," <ButtonRelease> {swap_tabs %X %Y release}", NULL);

View File

@ -4778,10 +4778,11 @@ proc setup_tabbed_interface {} {
if { $tabbed_interface } {
if { ![winfo exists .tabs] } {
frame .tabs
button .tabs.x0 -padx 2 -pady 0 -anchor nw -text Main -command "xschem new_schematic switch_tab .drw"
button .tabs.x0 -padx 2 -pady 0 -anchor nw -takefocus 0 \
-text Main -command "xschem new_schematic switch_tab .drw"
bind .tabs.x0 <ButtonPress> {swap_tabs %X %Y press}
bind .tabs.x0 <ButtonRelease> {swap_tabs %X %Y release}
button .tabs.add -padx 0 -pady 0 -text { + } -command "xschem new_schematic create"
button .tabs.add -padx 0 -pady 0 -takefocus 0 -text { + } -command "xschem new_schematic create"
pack .tabs.x0 .tabs.add -side left
pack_tabs
}
@ -5159,7 +5160,7 @@ global env has_x OS autofocus_mainwindow
bind $topwin <Double-Button-2> "xschem callback %W -3 %x %y 0 %b 0 %s"
bind $topwin <Double-Button-3> "xschem callback %W -3 %x %y 0 %b 0 %s"
bind $topwin <Configure> "xschem callback %W %T %x %y 0 %w %h 0"
bind $topwin <ButtonPress> "xschem callback %W %T %x %y 0 %b 0 %s"
bind $topwin <ButtonPress> "focus $topwin; xschem callback %W %T %x %y 0 %b 0 %s"
bind $topwin <ButtonRelease> "xschem callback %W %T %x %y 0 %b 0 %s"
bind $topwin <KeyPress> "xschem callback %W %T %x %y %N 0 0 %s"
bind $topwin <KeyRelease> "xschem callback %W %T %x %y %N 0 0 %s"

View File

@ -198,7 +198,7 @@ proc netlist_test {} {
hierarchical_tedax.sch tedax 998070173
LCC_instances.sch spice 2610855064
pcb_test1.sch tedax 1925087189
test_doublepin.sch spice 556408606
test_doublepin.sch spice 64707104
simulate_ff.sch spice 1321596936
} {
xschem set netlist_type $t

View File

@ -5,40 +5,30 @@ K {}
V {}
S {}
E {}
N 210 -300 250 -300 {
N 360 -240 400 -240 {
lab=CK}
N 250 -300 250 -220 {
lab=CK}
N 250 -220 340 -220 {
lab=CK}
N 210 -260 210 -240 {
lab=RST}
N 210 -240 340 -240 {
lab=RST}
N 210 -190 280 -190 {
N 210 -190 400 -190 {
lab=B}
N 280 -260 280 -190 {
lab=B}
N 280 -260 340 -260 {
lab=B}
N 210 -220 230 -220 {
lab=A[3:0]}
N 230 -280 230 -220 {
lab=A[3:0]}
N 230 -280 340 -280 {
N 210 -280 400 -280 {
lab=A[3:0]}
N 540 -280 580 -280 {
lab=Z,NC1,NC2,NC3}
N 330 -150 470 -150 {
lab=RST}
N 470 -210 470 -150 {
lab=RST}
C {title.sym} 160 -30 0 0 {name=l1 author="Stefan Schippers"}
C {ipin.sym} 210 -220 0 0 {name=p1 lab=A[3:0]}
C {ipin.sym} 210 -280 0 0 {name=p1 lab=A[3:0]}
C {ipin.sym} 210 -190 0 0 {name=p3 lab=B}
C {opin.sym} 690 -250 0 0 {name=p4 lab=Z}
C {ipin.sym} 210 -260 0 0 {name=p5 lab=RST}
C {ipin.sym} 210 -300 0 0 {name=p7 lab=CK}
C {noconn.sym} 690 -250 2 1 {name=l6}
C {opin.sym} 810 -250 0 0 {name=p4 lab=Z}
C {ipin.sym} 330 -150 0 0 {name=p5 lab=RST}
C {ipin.sym} 360 -240 0 0 {name=p7 lab=CK}
C {noconn.sym} 810 -250 2 1 {name=l6}
C {use.sym} 380 -480 0 0 {------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;}
C {sync_reg.sym} 440 -250 0 0 {name=x1 width=4 del=400 delay="400 ps"}
C {lab_pin.sym} 580 -280 0 1 {name=l1 sig_type=std_logic lab=Z,NC1,NC2,NC3}
C {lab_pin.sym} 580 -280 0 1 {name=l2 sig_type=std_logic lab=Z,NC1,NC2,NC3}
C {latch.sym} 470 -260 0 0 {name=x2[3:0] delay="200 ps" del=200}
C {lab_pin.sym} 540 -240 0 1 {name=l3 sig_type=std_logic lab=NC4,NC5,NC6,NC7}
C {noconn.sym} 400 -190 2 0 {name=l4}

View File

@ -19,4 +19,6 @@ C {res.sym} 150 -50 0 0 {name=R1
value=1k
footprint=1206
device=resistor
verilog_ignore=true
vhdl_ignore=true
m=1}