Add File menu commands to open empty schematic or symbol in new window

This commit is contained in:
Stefan Frederik 2021-10-09 00:41:39 +02:00
parent 813f80e955
commit 205bda387a
7 changed files with 45 additions and 5 deletions

View File

@ -163,6 +163,8 @@ shift 'N' Hierarchical netlist
- 'n' Netlist
ctrl 'n' New schematic
ctrl+shift 'N' New symbol
alt 'n' Empty schematic in new window
alt+shift 'N' Empty symbol in new window
shift 'O' Toggle Light / Dark colorscheme
ctrl 'o' Load schematic
alt 'p' Add symbol pin

View File

@ -273,15 +273,20 @@ void new_window(const char *cell, int symbol)
} else if (!pid2) {
/* child of child */
if(!cell || !cell[0]) {
execl(xschem_executable,xschem_executable,"-b", NULL);
if(!symbol)
execl(xschem_executable,xschem_executable,"-b", "--tcl",
"set netlist_type spice; set XSCHEM_START_WINDOW {}", NULL);
else
execl(xschem_executable,xschem_executable,"-b", "--tcl",
"set netlist_type symbol; set XSCHEM_START_WINDOW {}", NULL);
}
else if(!symbol) {
my_strncpy(f, cell, S(f));
execl(xschem_executable,xschem_executable,"-b",f, NULL);
execl(xschem_executable,xschem_executable,"-b", "--tcl", "set netlist_type spice", f, NULL);
}
else {
my_strncpy(f, cell, S(f));
execl(xschem_executable,xschem_executable,"-b",f, NULL);
execl(xschem_executable,xschem_executable,"-b", "--tcl", "set netlist_type symbol", f, NULL);
}
} else {
/* error */

View File

@ -1223,6 +1223,16 @@ int callback(int event, int mx, int my, KeySym key,
copy_objects(START);
break;
}
if(key=='n' && state==Mod1Mask) /* Empty schematic in new window */
{
if(xctx->semaphore >= 2) break;
tcleval("xschem new_window");
}
if(key=='N' && state==(ShiftMask|Mod1Mask) ) /* Empty symbol in new window */
{
if(xctx->semaphore >= 2) break;
tcleval("xschem new_symbol_window");
}
if(key=='n' && state==ControlMask) /* New schematic */
{
if(xctx->semaphore >= 2) break;

View File

@ -123,6 +123,8 @@ shift 'N' Hierarchical netlist
- 'n' Netlist
ctrl 'n' New schematic
ctrl+shift 'N' New symbol
alt 'n' Empty schematic in new window
alt+shift 'N' Empty symbol in new window
shift 'O' Toggle Light / Dark colorscheme
ctrl 'o' Load schematic
alt 'p' Add symbol pin

View File

@ -1089,8 +1089,13 @@ void load_schematic(int load_symbols, const char *filename, int reset_undo) /* 2
set_modify(0);
clear_drawing();
for(i=0;;i++) {
if(i == 0) my_snprintf(name, S(name), "%s.sch", "untitled");
else my_snprintf(name, S(name), "%s-%d.sch", "untitled", i);
if(netlist_type == CAD_SYMBOL_ATTRS) {
if(i == 0) my_snprintf(name, S(name), "%s.sym", "untitled");
else my_snprintf(name, S(name), "%s-%d.sym", "untitled", i);
} else {
if(i == 0) my_snprintf(name, S(name), "%s.sch", "untitled");
else my_snprintf(name, S(name), "%s-%d.sch", "untitled", i);
}
if(stat(name, &buf)) break;
}
my_snprintf(xctx->sch[xctx->currsch], S(xctx->sch[xctx->currsch]), "%s/%s", pwd_dir, name);

View File

@ -1570,6 +1570,14 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
Tcl_ResetResult(interp);
}
else if(!strcmp(argv[1],"new_symbol_window"))
{
cmd_found = 1;
if(argc==2) new_window("",1);
else new_window(argv[2],1);
Tcl_ResetResult(interp);
}
else if(!strcmp(argv[1],"new_window"))
{
cmd_found = 1;

View File

@ -3846,6 +3846,14 @@ if { ( $::OS== "Windows" || [string length [lindex [array get env DISPLAY] 1] ]
xschem clear SYMBOL
}
toolbar_create FileNewSym {xschem clear SYMBOL} "New Symbol"
.menubar.file.menu add command -label "New empty Schematic window" -accelerator {Alt+N} \
-command {
xschem new_window
}
.menubar.file.menu add command -label "New empty Symbol window" -accelerator {Alt+Shift+N} \
-command {
xschem new_symbol_window
}
.menubar.file.menu add command -label "Open" -command "xschem load" -accelerator {Ctrl+O}
toolbar_create FileOpen "xschem load" "Open File"
.menubar.file.menu add command -label "Delete files" -command "xschem delete_files" -accelerator {Shift-D}