From 9593d41f097e2e3972335a40f0778418feb7f666 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sat, 29 Apr 2023 00:28:24 +0200 Subject: [PATCH] persistent load file dialog (Shift-Insert) now correctly handles generator script selection (do nothing until user adds () or (param1,param2,...) to generator name). --- XSchemWin/XSchemWix/doc.wxs | 36 + XSchemWin/XSchemWix/heat_doc.wxs | 684 ++-- XSchemWin/XSchemWix/heat_xschem_library.wxs | 3858 ++++++++++--------- XSchemWin/XSchemWix/xschem_library.wxs | 56 +- doc/xschem_man/developer_info.html | 9 +- src/callback.c | 2 +- src/save.c | 2 +- src/xschem.h | 4 + src/xschem.tcl | 37 +- 9 files changed, 2446 insertions(+), 2242 deletions(-) diff --git a/XSchemWin/XSchemWix/doc.wxs b/XSchemWin/XSchemWix/doc.wxs index 13d0226e..58af3607 100644 --- a/XSchemWin/XSchemWix/doc.wxs +++ b/XSchemWin/XSchemWix/doc.wxs @@ -351,6 +351,18 @@ + + + + + + + + + + + + @@ -531,6 +543,15 @@ + + + + + + + + + @@ -660,6 +681,9 @@ + + + @@ -696,6 +720,9 @@ + + + @@ -1100,6 +1127,10 @@ + + + + @@ -1160,6 +1191,9 @@ + + + @@ -1203,6 +1237,7 @@ + @@ -1215,6 +1250,7 @@ + diff --git a/XSchemWin/XSchemWix/heat_doc.wxs b/XSchemWin/XSchemWix/heat_doc.wxs index f94be45e..5f234bf3 100644 --- a/XSchemWin/XSchemWix/heat_doc.wxs +++ b/XSchemWin/XSchemWix/heat_doc.wxs @@ -3,979 +3,1006 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + - + - + - + - + - + - + - + - + - + - + - + - + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1099,6 +1126,10 @@ + + + + @@ -1159,6 +1190,9 @@ + + + @@ -1202,6 +1236,7 @@ + @@ -1214,6 +1249,7 @@ + diff --git a/XSchemWin/XSchemWix/heat_xschem_library.wxs b/XSchemWin/XSchemWix/heat_xschem_library.wxs index 01775870..3978477f 100644 --- a/XSchemWin/XSchemWix/heat_xschem_library.wxs +++ b/XSchemWin/XSchemWix/heat_xschem_library.wxs @@ -3,5759 +3,5797 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -5980,7 +6018,12 @@ - + + + + + + @@ -7349,6 +7392,13 @@ + + + + + + + diff --git a/XSchemWin/XSchemWix/xschem_library.wxs b/XSchemWin/XSchemWix/xschem_library.wxs index 2aa6f55f..9340226e 100644 --- a/XSchemWin/XSchemWix/xschem_library.wxs +++ b/XSchemWin/XSchemWix/xschem_library.wxs @@ -658,8 +658,23 @@ - - + + + + + + + + + + + + + + + + + @@ -4770,6 +4785,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -5661,7 +5699,12 @@ - + + + + + + @@ -7030,6 +7073,13 @@ + + + + + + + diff --git a/doc/xschem_man/developer_info.html b/doc/xschem_man/developer_info.html index 9d9a65c9..316f6fa0 100644 --- a/doc/xschem_man/developer_info.html +++ b/doc/xschem_man/developer_info.html @@ -579,6 +579,8 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" attribute.
  • enable_layers
  •     Enable/disable layers depending on tcl array variable enable_layer() 
    +
  • escape_chars source
  • +   escape tcl special characters with backslash 
  • exit
  •     Exit the program, ask for confirm if current file modified. 
  • expandlabel lab
  • @@ -640,6 +642,10 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
          
  • yorigin y coordinate of origin
  • zoom zoom level
  • +
  • get_cell cell n_dirs
  • +   return result of get_cell function 
    +
  • get_cell_w_ext cell n_dirs
  • +   return result of get_cell_w_ext function 
  • getprop instance|instance_pin|symbol|text ref
  •        
            getprop instance inst
    @@ -748,6 +754,8 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
        Example: xschem instances_to_net PANEL
         --> { {Vsw} {plus} {580} {-560} } { {p2} {p} {660} {-440} }
             { {Vpanel1} {minus} {600} {-440} } 
    +
  • is_symgen symbol
  • +   tell if 'symbol' is agenerator (symbol(param1,param2,...) 
  • line x1 y1 x2 y2 [pos]
  •     Place a line on current layer (rectcolor) 
        if integer number 'pos' is given place line at indicated
    @@ -1163,7 +1171,6 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
     
     
     
    -
      
     
       
    diff --git a/src/callback.c b/src/callback.c
    index 875fad16..c36208d8 100644
    --- a/src/callback.c
    +++ b/src/callback.c
    @@ -1874,7 +1874,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
        }
        if((key==XK_Insert && (state & ShiftMask)) ||  (key == 'i' && state == ControlMask)) /* insert sym */
        {
    -     tcleval("load_file_dialog {Insert symbol} *.sym INITIALINSTDIR 2");
    +     tcleval("load_file_dialog {Insert symbol} {} INITIALINSTDIR 2");
          break;
        }
        if(key==XK_Insert || (key == 'I' && state == ShiftMask) ) /* insert sym */
    diff --git a/src/save.c b/src/save.c
    index a7695f72..16a8980b 100644
    --- a/src/save.c
    +++ b/src/save.c
    @@ -3168,7 +3168,7 @@ int load_sym_def(const char *name, FILE *embed_fd)
       generator = is_generator(cmd);
       if(generator) {
         cmd = get_generator_command(cmd);
    -    dbg(1, "l_s_d(): cmd=%s\n", cmd);
    +    dbg(1, "l_s_d(): generator: cmd=%s\n", cmd);
         if(cmd) {
           lcc[level].fd = popen(cmd, "r"); /* execute ss="/path/to/xxx par1 par2 ..." and pipe in the stdout */
           my_free(_ALLOC_ID_, &cmd);
    diff --git a/src/xschem.h b/src/xschem.h
    index f72ed99a..91e42609 100644
    --- a/src/xschem.h
    +++ b/src/xschem.h
    @@ -89,6 +89,8 @@
     #define xunlink unlink
     #define xfseek fseek
     #define xftell ftell
    +#define popen popen
    +#define pclose pclose
     #else
     #include 
     #define xunlink _unlink
    @@ -100,6 +102,8 @@ extern void change_to_unix_fn(char* fn);
     extern char win_temp_dir[PATH_MAX];
     #define xfseek _fseeki64
     #define xftell _ftelli64
    +#define popen _popen
    +#define pclose _pclose
     #endif
     
     #undef HAS_XCB
    diff --git a/src/xschem.tcl b/src/xschem.tcl
    index 80b1af69..9fed8f92 100644
    --- a/src/xschem.tcl
    +++ b/src/xschem.tcl
    @@ -2378,15 +2378,20 @@ proc is_xschem_file {f} {
       set score 0
       set instances 0
       set nline 0
    +  set generator 0
       if {$a} {
         puts stderr "Can not open file $f"
       } else {
         fconfigure $fd -translation binary
         while { [gets $fd line] >=0 } {
    +      # this is a script. not an xschem file
           if { $nline == 0 && [regexp {^#!} $line] } { 
    -        set ret GENERATOR
    -        break
    -      } ;# this is a script. not an xschem file
    +        #### too dangerous executing an arbitrary script...
    +        # close $fd
    +        # set fd [open "|$f"]
    +        set generator 1
    +        # continue
    +      }
           if { [regexp {^[TKGVSE] \{} $line] } { incr score }
           if { [regexp {^[BL] +[0-9]+ +[-0-9.eE]+ +[-0-9.eE]+ +[-0-9.eE]+ +[-0-9.eE]+ +\{} $line] } {incr score}
           if { [regexp {^N +[-0-9.eE]+ +[-0-9.eE]+ +[-0-9.eE]+ +[-0-9.eE]+ +\{} $line] } {incr score}
    @@ -2397,7 +2402,9 @@ proc is_xschem_file {f} {
           incr nline
         } 
         if { $score > 4 }  { set ret 1} ;# Heuristic decision :-)
    -    if { $ret ne {0}  && $ret ne {GENERATOR}} {
    +    if {$generator eq {1}} {
    +      set ret GENERATOR
    +    } elseif { $ret ne {0}} {
           if { $instances} {
             set ret SCHEMATIC
           } else { 
    @@ -2644,14 +2651,28 @@ proc myload_getresult {loadfile confirm_overwrt} {
         }
         set type [is_xschem_file "$fname"]
         if { $type eq {0}  || $type eq {GENERATOR} } {
    -      set answer [
    -        alert_ "$fname does not seem to be an xschem file...\nContinue?" {} 0 1]
    +      if { $type eq {0} } {
    +        set answer [alert_ "$fname does not seem to be an xschem file...\nContinue?" {} 0 1]
    +      } else { ;# $type == GENERATOR
    +        set answer 1
    +      }
           if { $answer eq {0}} {
             set myload_retval {}
             return {}
    -      } else {
    -        return "$fname"
    +      } else { ;# $answer == 1
    +        if { $type eq {GENERATOR} } {
    +          if { [regexp {\([^()]*\)$} $fname]} {
    +            return "$fname"
    +          } else {
    +            set myload_retval {}
    +            return {}
    +          }
    +        }
    +        # $type == 0 so return empty string
    +        set myload_retval {}
    +        return {}
           }
    +    # $type == SYMBOL or SCHEMATIC
         } elseif { $type ne {SYMBOL} && ($myload_ext eq {*.sym}) } { ;# SCHEMATIC
           set answer [
             alert_ "$fname does not seem to be a SYMBOL file...\nContinue?" {} 0 1]