Merge branch 'master' into SuperChayan

This commit is contained in:
stefan schippers 2025-03-15 23:31:54 +01:00
commit 38a8e4c042
1 changed files with 32 additions and 32 deletions

View File

@ -4835,16 +4835,9 @@ proc get_list_of_dirs_with_symbols {{paths {}} {levels -1} {ext {\.(sch|sym)$}}
##### new alternate insert_symbol browser
#######################################################################
#### Display preview of selected symbol
proc insert_symbol_focusin {{paths {}} {maxdepth -1}} {
global insert_symbol new_symbol_browser_ext
xschem abort_operation
set insert_symbol(ext) $new_symbol_browser_ext
insert_symbol_filelist $paths $maxdepth
}
proc insert_symbol_preview {{paths {}}} {
# puts insert_symbol_preview
#### Display preview of selected symbol and start sym placement
proc insert_symbol_preview {} {
puts "insert_symbol_preview"
global insert_symbol
xschem preview_window close .ins.center.right {}
.ins.center.right configure -bg white
@ -4855,22 +4848,25 @@ proc insert_symbol_preview {{paths {}}} {
set sel [.ins.center.left.l index active]
.ins.center.left.l selection set active
}
if {$sel ne {}} {
set f [lindex $insert_symbol(fullpathlist) $sel 0]
if {$sel ne {} && [info exists insert_symbol(fullpathlist)]} {
set insert_symbol(fileindex) $sel
# puts "set fileindex=$sel"
.ins.center.left.l see $sel
set f [lindex $insert_symbol(fullpathlist) $sel]
if {$f ne {}} {
set type [is_xschem_file $f]
if {$type ne {0}} {
set dir [rel_sym_path $f $paths]
set dir [rel_sym_path $f]
.ins.top.dir_e configure -state normal
.ins.top.dir_e delete 0 end
.ins.top.dir_e insert 0 $dir
.ins.top.dir_e configure -state readonly
.ins.top2.dir_e configure -state normal
.ins.top2.dir_e delete 0 end
.ins.top2.dir_e insert 0 $f
.ins.top2.dir_e configure -state readonly
.ins.center.right configure -bg {}
xschem preview_window create .ins.center.right {}
xschem preview_window draw .ins.center.right [list $f]
@ -4884,19 +4880,19 @@ proc insert_symbol_preview {{paths {}}} {
#### fill list of files matching pattern
proc insert_symbol_filelist {paths {maxdepth -1}} {
# puts "insert_symbol_filelist: paths=$paths"
global insert_symbol
global insert_symbol new_symbol_browser_ext
set paths [.ins.center.leftdir.l curselection]
if {$paths eq {}} { return}
if {$paths eq {}} {return}
set insert_symbol(dirindex) $paths
# puts "set dirindex=$paths"
set paths [lindex $insert_symbol(dirs) $paths]
puts "insert_symbol_filelist: paths=$paths"
.ins.top2.dir_e configure -state normal
.ins.top2.dir_e delete 0 end
.ins.top2.dir_e insert 0 $paths
.ins.top2.dir_e configure -state readonly
set insert_symbol(regex) [.ins.top.pat_e get]
#check if regex is valid
set err [catch {regexp $insert_symbol(regex) {12345}} res]
if {$err} {return}
@ -4905,11 +4901,15 @@ proc insert_symbol_filelist {paths {maxdepth -1}} {
set filelist {}
set insert_symbol(fullpathlist) {}
set sel [.ins.center.left.l curselection]
if {$sel ne {}} {
set insert_symbol(fileindex) $sel
# puts "set fileindex=$sel"
}
if {$sel eq {}} { set sel 0}
.ins.center.left.l activate $sel
foreach i $f {
set err [catch {regexp $insert_symbol(ext) $i} type]
set err [catch {regexp $new_symbol_browser_ext $i} type]
if {!$err && $type} {
set fname [rel_sym_path $i $paths]
lappend filelist $fname
@ -4937,7 +4937,7 @@ proc insert_symbol_filelist {paths {maxdepth -1}} {
}
proc insert_symbol_place {} {
# puts insert_symbol_place
puts insert_symbol_place
global insert_symbol
set sel [.ins.center.left.l curselection]
if {$sel eq {}} {
@ -4959,14 +4959,15 @@ proc insert_symbol_place {} {
#### paths: list of paths to use for listing symbols
#### maxdepth: how many levels to descend for each $paths directory (-1: no limit)
proc insert_symbol {{paths {}} {maxdepth -1} {ext {.*}}} {
global insert_symbol
global insert_symbol new_symbol_browser_ext
set paths [cleanup_paths $paths] ;# remove ~ and other strange path combinations
# xschem set semaphore [expr {[xschem get semaphore] +1}]
set insert_symbol(ext) $ext
set new_symbol_browser_ext $ext
if {[winfo exists .ins]} {
raise .ins
return
}
if {![info exists insert_symbol(regex)]} { set insert_symbol(regex) {}}
toplevel .ins
frame .ins.top -takefocus 0
frame .ins.top2 -takefocus 0
@ -5007,28 +5008,25 @@ proc insert_symbol {{paths {}} {maxdepth -1} {ext {.*}}} {
-readonlybackground [option get . background {}] -takefocus 0
label .ins.top.pat_l -text Pattern:
entry .ins.top.pat_e -width 20 -highlightcolor red -highlightthickness 2 \
-highlightbackground [option get . background {}]
-textvariable insert_symbol(regex) -highlightbackground [option get . background {}]
label .ins.top.dir_l -text { Symbol ref: }
entry .ins.top.dir_e -width 40 -state readonly \
-readonlybackground [option get . background {}] -takefocus 0
label .ins.top.ext_l -text Ext:
entry .ins.top.ext_e -width 15 -takefocus 0 -state normal -textvariable new_symbol_browser_ext
if {[info exists insert_symbol(regex)]} {
.ins.top.pat_e insert 0 $insert_symbol(regex)
}
bind .ins <KeyPress-Escape> {.ins.bottom.dismiss invoke}
bind .ins <KeyRelease> "
if {{%K} eq {Tab} && {%W} eq {.ins.center.left.l}} {
insert_symbol_filelist [list $paths] [list $maxdepth]
insert_symbol_preview [list $paths]
insert_symbol_preview
} elseif {{%K} eq {Tab} && {%W} eq {.ins.center.leftdir.l}} {
insert_symbol_filelist [list $paths] [list $maxdepth]
}
"
bind .ins.center.leftdir.l <<ListboxSelect>> "insert_symbol_filelist [list $paths] [list $maxdepth]"
bind .ins.center.left.l <<ListboxSelect>> "insert_symbol_preview [list $paths]"
bind .ins.center.left.l <Enter> "insert_symbol_focusin [list $paths] [list $maxdepth]"
bind .ins.center.left.l <<ListboxSelect>> "insert_symbol_preview"
bind .ins.center.left.l <Enter> "xschem abort_operation"
label .ins.bottom.n -text { N. of items:}
label .ins.bottom.nitems -textvariable insert_symbol(nitems)
button .ins.bottom.dismiss -takefocus 0 -text Dismiss -command {
@ -5051,7 +5049,7 @@ proc insert_symbol {{paths {}} {maxdepth -1} {ext {.*}}} {
pack .ins.top.ext_l -side left
pack .ins.top.ext_e -side left
set insert_symbol(dirs) [get_list_of_dirs_with_symbols $paths $maxdepth $insert_symbol(ext)]
set insert_symbol(dirs) [get_list_of_dirs_with_symbols $paths $maxdepth $new_symbol_browser_ext]
set insert_symbol(dirtails) {}
foreach i $insert_symbol(dirs) {
lappend insert_symbol(dirtails) [file tail $i]
@ -5072,9 +5070,11 @@ proc insert_symbol {{paths {}} {maxdepth -1} {ext {.*}}} {
lappend insert_symbol(dirs) $fff
}
insert_symbol_filelist $paths $maxdepth
# insert_symbol_filelist $paths $maxdepth
# tkwait window .ins
# xschem set semaphore [expr {[xschem get semaphore] -1}]
if {[info exists insert_symbol(dirindex)]} {.ins.center.leftdir.l selection set $insert_symbol(dirindex)}
if {[info exists insert_symbol(fileindex)]} {.ins.center.left.l selection set $insert_symbol(fileindex)}
return {}
}
#######################################################################