fix "saveas SYMBOL" changing current_type to SYMBOL even if user canceled the action; allow "@" in node names as this is used in some backannotated CDL netlists
This commit is contained in:
parent
e1751d5f58
commit
020c61bc3d
|
|
@ -461,7 +461,7 @@ int save(int confirm) /* 20171006 add confirm */
|
|||
return cancel;
|
||||
}
|
||||
|
||||
void saveas(const char *f) /* changed name from ask_save_file to saveas 20121201 */
|
||||
void saveas(const char *f, int type) /* changed name from ask_save_file to saveas 20121201 */
|
||||
{
|
||||
char name[PATH_MAX+1000];
|
||||
char filename[PATH_MAX];
|
||||
|
|
@ -469,7 +469,7 @@ void saveas(const char *f) /* changed name from ask_save_file to saveas 2012120
|
|||
char *p;
|
||||
if(!f && has_x) {
|
||||
my_strncpy(filename , abs_sym_path(schematic[currentsch], ""), S(filename));
|
||||
if(current_type == SCHEMATIC) {
|
||||
if(type == SCHEMATIC) {
|
||||
my_snprintf(name, S(name), "save_file_dialog {Save file} .sch.sym INITIALLOADDIR {%s}", filename);
|
||||
} else {
|
||||
if( (p = strrchr(filename, '.')) && !strcmp(p, ".sch") ) {
|
||||
|
|
@ -487,6 +487,7 @@ void saveas(const char *f) /* changed name from ask_save_file to saveas 2012120
|
|||
else res[0]='\0';
|
||||
|
||||
if(!res[0]) return; /* 20071104 */
|
||||
current_type = type;
|
||||
dbg(1, "saveas(): res = %s\n", res);
|
||||
save_schematic(res);
|
||||
Tcl_VarEval(interp, "update_recent_file {", res,"}", NULL);
|
||||
|
|
|
|||
|
|
@ -709,8 +709,8 @@ int callback(int event, int mx, int my, KeySym key,
|
|||
if(key=='s' && (state == ControlMask) ) /* save 20121201 */
|
||||
{
|
||||
if(semaphore >= 2) break;
|
||||
if(!strcmp(schematic[currentsch],"")) { /* 20170622 check if unnamed schematic, use saveas in this case... */
|
||||
saveas(NULL);
|
||||
if(!strcmp(schematic[currentsch],"") || strstr(schematic[currentsch], "untitled")) { /* check if unnamed schematic, use saveas in this case */
|
||||
saveas(NULL, current_type);
|
||||
} else {
|
||||
save(1);
|
||||
}
|
||||
|
|
@ -719,14 +719,13 @@ int callback(int event, int mx, int my, KeySym key,
|
|||
if(key=='s' && state == (ControlMask | Mod1Mask) ) /* save as symbol */
|
||||
{
|
||||
if(semaphore >= 2) break;
|
||||
current_type=SYMBOL;
|
||||
saveas(NULL);
|
||||
saveas(NULL, SYMBOL);
|
||||
break;
|
||||
}
|
||||
if(key=='S' && state == (ShiftMask | ControlMask)) /* save as schematic */
|
||||
{
|
||||
if(semaphore >= 2) break;
|
||||
saveas(NULL);
|
||||
saveas(NULL, current_type);
|
||||
break;
|
||||
}
|
||||
if(key=='e' && state == 0) /* descend to schematic */
|
||||
|
|
|
|||
|
|
@ -126,11 +126,11 @@ const char *expandlabel(const char *s, int *m)
|
|||
%x rest
|
||||
|
||||
|
||||
ID [-#+_\\/=a-zA-Z0-9]*[-#+/_\\/=a-zA-Z]+[-#+_\\/=a-zA-Z0-9]*
|
||||
ID [-#+_\\/=a-zA-Z0-9]*[-#@+/_\\/=a-zA-Z]+[-#@+_\\/=a-zA-Z0-9]*
|
||||
ID_NUM [-#+_\\/=a-zA-Z0-9]+
|
||||
|
||||
ID_EXT ([-#+/=_a-zA-Z][-#\\/:.=_+a-zA-Z0-9]*)|([-#+/.=_a-zA-Z][-#\\/:=_+a-zA-Z0-9]*)
|
||||
ID_EXT_PARENTHESIS [-#+/=_a-zA-Z][-#\\/:.=_+a-zA-Z0-9]*\([-#\\/:.=_+a-zA-Z0-9]*\)
|
||||
ID_EXT ([-#+/=_a-zA-Z][-#@\\/:.=_+a-zA-Z0-9]*)|([-#+/.=_a-zA-Z][-#@\\/:=_+a-zA-Z0-9]*)
|
||||
ID_EXT_PARENTHESIS [-#+/=_a-zA-Z][-#@\\/:.=_+a-zA-Z0-9]*\([-#@\\/:.=_+a-zA-Z0-9]*\)
|
||||
|
||||
%%
|
||||
^(alias|ipin|iopin|opin)[+ \n]+[^+\n ]+/[\n +]+ {
|
||||
|
|
|
|||
|
|
@ -890,13 +890,24 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
prepared_hilight_structs=0;
|
||||
draw();
|
||||
} else if(!strcmp(argv[1],"saveas")) {
|
||||
if(argc == 3) saveas(argv[2]);
|
||||
else saveas(NULL);
|
||||
if(argc == 4) {
|
||||
const char *f;
|
||||
f = !strcmp(argv[2],"") ? NULL : argv[2];
|
||||
if(!strcmp(argv[3], "SCHEMATIC")) saveas(f, SCHEMATIC);
|
||||
else if(!strcmp(argv[3], "SYMBOL")) saveas(f, SYMBOL);
|
||||
else saveas(f, current_type);
|
||||
}
|
||||
else if(argc == 3) {
|
||||
const char *f;
|
||||
f = !strcmp(argv[2],"") ? NULL : argv[2];
|
||||
saveas(f, current_type);
|
||||
}
|
||||
else saveas(NULL, current_type);
|
||||
} else if(!strcmp(argv[1],"save")) {
|
||||
dbg(1, "xschem(): saving: current schematic\n");
|
||||
|
||||
if(!strcmp(schematic[currentsch],"")) { /* 20170622 check if unnamed schematic, use saveas in this case... */
|
||||
saveas(NULL);
|
||||
saveas(NULL, current_type);
|
||||
} else {
|
||||
save(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -696,7 +696,7 @@ extern void schematic_in_new_window(void);
|
|||
extern void symbol_in_new_window(void);
|
||||
extern void new_window(const char *cell, int symbol);
|
||||
extern void ask_new_file(void);
|
||||
extern void saveas(const char *f);
|
||||
extern void saveas(const char *f, int type);
|
||||
extern const char *get_file_path(char *f);
|
||||
extern int save(int confirm);
|
||||
extern struct hilight_hashentry *bus_hilight_lookup(const char *token, int value, int remove) ;
|
||||
|
|
|
|||
|
|
@ -3312,7 +3312,7 @@ font configure Underline-Font -underline true -size 24
|
|||
} "Reload File"
|
||||
.menubar.file.menu add command -label "Save as" -command "xschem saveas" -accelerator {Ctrl+Shift+S}
|
||||
.menubar.file.menu add command -label "Save as symbol" \
|
||||
-command "xschem set current_type SYMBOL; xschem saveas" -accelerator {Ctrl+Alt+S}
|
||||
-command "xschem saveas {} SYMBOL" -accelerator {Ctrl+Alt+S}
|
||||
# added svg, png 20171022
|
||||
.menubar.file.menu add command -label "PDF Export" -command "xschem print pdf" -accelerator {*}
|
||||
.menubar.file.menu add command -label "PNG Export" -command "xschem print png" -accelerator {Ctrl+*}
|
||||
|
|
|
|||
Loading…
Reference in New Issue