[Code Refactoring]: Modified the source code for compatibility with the upstream repo (due to 'infix_wire' feature integration with new name 'infix_interface')

This commit is contained in:
Chayan Deb 2025-01-18 15:43:43 +05:30
commit 2f558ea1e0
11 changed files with 224 additions and 80 deletions

View File

@ -779,6 +779,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
<li><kbd> lastsel </kbd> number of selected objects </li> <li><kbd> lastsel </kbd> number of selected objects </li>
<li><kbd> line_width </kbd> get line width </li> <li><kbd> line_width </kbd> get line width </li>
<li><kbd> lines </kbd> (xschem get lines n) number of lines on layer 'n' </li> <li><kbd> lines </kbd> (xschem get lines n) number of lines on layer 'n' </li>
<li><kbd> modified </kbd> schematic is in modified state (needs a save) </li>
<li><kbd> netlist_name </kbd> netlist name if set. If 'fallback' given get default name </li> <li><kbd> netlist_name </kbd> netlist name if set. If 'fallback' given get default name </li>
<li><kbd> netlist_type </kbd> get current netlist type (spice/vhdl/verilog/tedax) </li> <li><kbd> netlist_type </kbd> get current netlist type (spice/vhdl/verilog/tedax) </li>
<li><kbd> no_draw </kbd> disable drawing </li> <li><kbd> no_draw </kbd> disable drawing </li>
@ -875,9 +876,11 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
if returned value is 0 it means that last searched attribute did not exist </pre> if returned value is 0 it means that last searched attribute did not exist </pre>
<li><kbd> globals</kbd></li><pre> <li><kbd> globals</kbd></li><pre>
Return various global variables used in the program </pre> Return various global variables used in the program </pre>
<li><kbd> go_back [notitle]</kbd></li><pre> <li><kbd> go_back [what]</kbd></li><pre>
Go up one level (pop) in hierarchy Go up one level (pop) in hierarchy
if integer 'notitle' given pass it to the go_back() function (1=do not update window title) </pre> if integer 'what' given pass it to the go_back() function
what = 1: ask confirm save if current schematic modified.
what = 2: do not reset window title </pre>
<li><kbd> grabscreen</kbd></li><pre> <li><kbd> grabscreen</kbd></li><pre>
grab root window </pre> grab root window </pre>
<li><kbd> hash_file file [skip_path_lines]</kbd></li><pre> <li><kbd> hash_file file [skip_path_lines]</kbd></li><pre>

View File

@ -2409,13 +2409,20 @@ int descend_schematic(int instnumber, int fallback, int alert, int set_title)
return 1; return 1;
} }
void go_back(int confirm, int set_title) /* 20171006 add confirm */ /*
* what:
* 1: ask gui user confirm if schematic modified
* 2: do *NOT* reset window title
*/
void go_back(int what)
{ {
int save_ok; int save_ok;
int from_embedded_sym; int from_embedded_sym;
int save_modified; int save_modified;
char filename[PATH_MAX]; char filename[PATH_MAX];
int prev_sch_type; int prev_sch_type;
int confirm = what & 1;
int set_title = !(confirm & 2);
save_ok=1; save_ok=1;
dbg(1,"go_back(): sch[xctx->currsch]=%s\n", xctx->sch[xctx->currsch]); dbg(1,"go_back(): sch[xctx->currsch]=%s\n", xctx->sch[xctx->currsch]);
@ -2429,9 +2436,13 @@ void go_back(int confirm, int set_title) /* 20171006 add confirm */
tcleval("ask_save_optional"); tcleval("ask_save_optional");
if(!strcmp(tclresult(), "yes") ) save_ok = save_schematic(xctx->sch[xctx->currsch], 0); if(!strcmp(tclresult(), "yes") ) save_ok = save_schematic(xctx->sch[xctx->currsch], 0);
else if(!strcmp(tclresult(), "") ) return; else if(!strcmp(tclresult(), "") ) return;
} else {
save_ok = save_schematic(xctx->sch[xctx->currsch], 0);
} }
/* do not automatically save if confirm==0. Script developers should take care of this */
/*
* else {
* save_ok = save_schematic(xctx->sch[xctx->currsch], 0);
* }
*/
} }
if(save_ok==0) { if(save_ok==0) {
fprintf(errfp, "go_back(): file opening for write failed! %s \n", xctx->current_name); fprintf(errfp, "go_back(): file opening for write failed! %s \n", xctx->current_name);
@ -2458,7 +2469,7 @@ void go_back(int confirm, int set_title) /* 20171006 add confirm */
/* by default) to parent schematic if going back from embedded symbol */ /* by default) to parent schematic if going back from embedded symbol */
my_strncpy(filename, xctx->sch[xctx->currsch], S(filename)); my_strncpy(filename, xctx->sch[xctx->currsch], S(filename));
load_schematic(1, filename, (set_title & 1), 1); load_schematic(1, filename, set_title, 1);
/* if we are returning from a symbol created from a generator don't set modified flag on parent /* if we are returning from a symbol created from a generator don't set modified flag on parent
* as these symbols can not be edited / saved as embedded * as these symbols can not be edited / saved as embedded
* xctx->sch_inst_number[xctx->currsch + 1] == -1 --> we came from an inst with no embed flag set */ * xctx->sch_inst_number[xctx->currsch + 1] == -1 --> we came from an inst with no embed flag set */

View File

@ -1903,7 +1903,7 @@ static void context_menu_action(double mx, double my)
descend_symbol(); descend_symbol();
break; break;
case 14: case 14:
go_back(1, 1); go_back(1);
break; break;
case 15: /* copy selection into clipboard */ case 15: /* copy selection into clipboard */
rebuild_selected_array(); rebuild_selected_array();
@ -2749,6 +2749,7 @@ int rstate; /* (reduced state, without ShiftMask) */
{ {
int prev_state = xctx->ui_state; int prev_state = xctx->ui_state;
if(xctx->semaphore >= 2) break; if(xctx->semaphore >= 2) break;
<<<<<<< HEAD
if(infix_interface) { if(infix_interface) {
start_wire(xctx->mousex_snap, xctx->mousey_snap); start_wire(xctx->mousex_snap, xctx->mousey_snap);
@ -2756,6 +2757,15 @@ int rstate; /* (reduced state, without ShiftMask) */
tcleval("set constr_mv 0"); tcleval("set constr_mv 0");
xctx->constr_mv = 0; xctx->constr_mv = 0;
} }
=======
if(infix_interface) {
start_wire(xctx->mousex_snap, xctx->mousey_snap);
if(prev_state == STARTWIRE) {
tcleval("set constr_mv 0" );
xctx->constr_mv=0;
}
>>>>>>> 025823f14c8ca1f9562a1c452fffe267c7120905
} else { } else {
xctx->last_command = 0; xctx->last_command = 0;
xctx->ui_state |= MENUSTART; xctx->ui_state |= MENUSTART;
@ -2808,8 +2818,13 @@ int rstate; /* (reduced state, without ShiftMask) */
if(xctx->semaphore >= 2) break; if(xctx->semaphore >= 2) break;
dbg(1, "callback(): start polygon\n"); dbg(1, "callback(): start polygon\n");
if(infix_interface) { if(infix_interface) {
<<<<<<< HEAD
xctx->mx_double_save = xctx->mousex_snap; xctx->mx_double_save = xctx->mousex_snap;
xctx->my_double_save = xctx->mousey_snap; xctx->my_double_save = xctx->mousey_snap;
=======
xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap;
>>>>>>> 025823f14c8ca1f9562a1c452fffe267c7120905
xctx->last_command = 0; xctx->last_command = 0;
new_polygon(PLACE, xctx->mousex_snap, xctx->mousey_snap); new_polygon(PLACE, xctx->mousex_snap, xctx->mousey_snap);
} else { } else {
@ -2964,12 +2979,20 @@ int rstate; /* (reduced state, without ShiftMask) */
if(key=='r' /* && !xctx->ui_state */ && rstate==0) /* start rect */ if(key=='r' /* && !xctx->ui_state */ && rstate==0) /* start rect */
{ {
dbg(1, "callback(): start rect\n"); dbg(1, "callback(): start rect\n");
<<<<<<< HEAD
=======
if(xctx->semaphore >= 2) break;
>>>>>>> 025823f14c8ca1f9562a1c452fffe267c7120905
if(infix_interface) { if(infix_interface) {
xctx->mx_double_save=xctx->mousex_snap; xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap; xctx->my_double_save=xctx->mousey_snap;
xctx->last_command = 0; xctx->last_command = 0;
new_rect(PLACE,xctx->mousex_snap, xctx->mousey_snap); new_rect(PLACE,xctx->mousex_snap, xctx->mousey_snap);
<<<<<<< HEAD
} else{ } else{
=======
} else {
>>>>>>> 025823f14c8ca1f9562a1c452fffe267c7120905
xctx->ui_state |= MENUSTART; xctx->ui_state |= MENUSTART;
xctx->ui_state2 = MENUSTARTRECT; xctx->ui_state2 = MENUSTARTRECT;
} }
@ -3069,7 +3092,7 @@ int rstate; /* (reduced state, without ShiftMask) */
if( (key=='e' && rstate == ControlMask) || (key==XK_BackSpace)) /* back */ if( (key=='e' && rstate == ControlMask) || (key==XK_BackSpace)) /* back */
{ {
if(xctx->semaphore >= 2) break; if(xctx->semaphore >= 2) break;
go_back(1, 1);break; go_back(1);break;
} }
if(key=='a' && rstate == 0) /* make symbol */ if(key=='a' && rstate == 0) /* make symbol */
@ -3474,7 +3497,11 @@ int rstate; /* (reduced state, without ShiftMask) */
if(key=='l' /* && !xctx->ui_state */ && rstate == 0) /* start line */ if(key=='l' /* && !xctx->ui_state */ && rstate == 0) /* start line */
{ {
int prev_state = xctx->ui_state; int prev_state = xctx->ui_state;
<<<<<<< HEAD
if(xctx->semaphore>=2) break; if(xctx->semaphore>=2) break;
=======
if(xctx->semaphore >= 2) break;
>>>>>>> 025823f14c8ca1f9562a1c452fffe267c7120905
if(infix_interface) { if(infix_interface) {
start_line(xctx->mousex_snap, xctx->mousey_snap); start_line(xctx->mousex_snap, xctx->mousey_snap);
if(prev_state == STARTLINE) { if(prev_state == STARTLINE) {

View File

@ -3827,7 +3827,8 @@ void draw_graph(int i, const int flags, Graph_ctx *gr, void *ct)
clear_cairo_surface(xctx->cairo_ctx, gr->sx1, gr->sy1, sw, sh); clear_cairo_surface(xctx->cairo_ctx, gr->sx1, gr->sy1, sw, sh);
#endif #endif
autoload = !strboolcmp(get_tok_value(r->prop_ptr,"autoload", 0), "1"); autoload = !strboolcmp(get_tok_value(r->prop_ptr,"autoload", 0), "1");
if(autoload == 0) autoload = 2; /* 2: switch */ if(autoload == 0) autoload = 2; /* 2: switch */
else if(autoload == 1) autoload = 33; /* 1: read, 32: no_warning */
/* graph box, gridlines and axes */ /* graph box, gridlines and axes */
draw_graph_grid(gr, ct); draw_graph_grid(gr, ct);
/* get data to plot */ /* get data to plot */

View File

@ -590,7 +590,7 @@ static void read_raw_data_block(int binary, FILE *fd, Raw *raw, int ac)
* 157 i(v1) current * 157 i(v1) current
* Binary: * Binary:
*/ */
static int read_dataset(FILE *fd, Raw **rawptr, const char *type) static int read_dataset(FILE *fd, Raw **rawptr, const char *type, int no_warning)
{ {
int variables = 0, i, done_points = 0; int variables = 0, i, done_points = 0;
char *line = NULL, *varname = NULL, *lowerline = NULL; char *line = NULL, *varname = NULL, *lowerline = NULL;
@ -716,7 +716,7 @@ static int read_dataset(FILE *fd, Raw **rawptr, const char *type)
if(n < 1) { if(n < 1) {
dbg(0, "read_dataset(): WAARNING: malformed raw file, aborting\n"); dbg(0, "read_dataset(): WAARNING: malformed raw file, aborting\n");
extra_rawfile(3, NULL, NULL, -1.0, -1.0); extra_rawfile(3, NULL, NULL, -1.0, -1.0);
/* free_rawfile(rawptr, 0); */ /* free_rawfile(rawptr, 0, 0); */
exit_status = 0; exit_status = 0;
goto read_dataset_done; goto read_dataset_done;
} }
@ -749,7 +749,7 @@ static int read_dataset(FILE *fd, Raw **rawptr, const char *type)
if(n < 1) { if(n < 1) {
dbg(0, "read_dataset(): WAARNING: malformed raw file, aborting\n"); dbg(0, "read_dataset(): WAARNING: malformed raw file, aborting\n");
extra_rawfile(3, NULL, NULL, -1.0, -1.0); extra_rawfile(3, NULL, NULL, -1.0, -1.0);
/* free_rawfile(rawptr, 0); */ /* free_rawfile(rawptr, 0, 0); */
exit_status = 0; exit_status = 0;
goto read_dataset_done; goto read_dataset_done;
} }
@ -763,7 +763,7 @@ static int read_dataset(FILE *fd, Raw **rawptr, const char *type)
if(n < 1) { if(n < 1) {
dbg(0, "read_dataset(): WAARNING: malformed raw file, aborting\n"); dbg(0, "read_dataset(): WAARNING: malformed raw file, aborting\n");
extra_rawfile(3, NULL, NULL, -1.0, -1.0); extra_rawfile(3, NULL, NULL, -1.0, -1.0);
/* free_rawfile(rawptr, 0); */ /* free_rawfile(rawptr, 0, 0); */
exit_status = 0; exit_status = 0;
goto read_dataset_done; goto read_dataset_done;
} }
@ -786,7 +786,7 @@ static int read_dataset(FILE *fd, Raw **rawptr, const char *type)
if(n < 2) { if(n < 2) {
dbg(0, "read_dataset(): WAARNING: malformed raw file, aborting\n"); dbg(0, "read_dataset(): WAARNING: malformed raw file, aborting\n");
extra_rawfile(3, NULL, NULL, -1.0, -1.0); extra_rawfile(3, NULL, NULL, -1.0, -1.0);
/* free_rawfile(rawptr, 0); */ /* free_rawfile(rawptr, 0, 0); */
exit_status = 0; exit_status = 0;
goto read_dataset_done; goto read_dataset_done;
} }
@ -838,7 +838,7 @@ static int read_dataset(FILE *fd, Raw **rawptr, const char *type)
/* no analysis was found: delete */ /* no analysis was found: delete */
if(exit_status != 1) { if(exit_status != 1) {
free_rawfile(rawptr, 0); free_rawfile(rawptr, 0, no_warning);
} }
read_dataset_done: read_dataset_done:
if(line) my_free(_ALLOC_ID_, &line); if(line) my_free(_ALLOC_ID_, &line);
@ -851,18 +851,22 @@ static int read_dataset(FILE *fd, Raw **rawptr, const char *type)
return exit_status; return exit_status;
} }
void free_rawfile(Raw **rawptr, int dr) void free_rawfile(Raw **rawptr, int dr, int no_warning)
{ {
int i; int i;
Raw *raw; Raw *raw;
if(!rawptr || !*rawptr) { if(!rawptr || !*rawptr) {
dbg(0, "free_rawfile(): no raw file to clear\n"); if(!no_warning) {
dbg(0, "free_rawfile(): no raw file to clear\n");
}
if(dr) draw(); if(dr) draw();
return; return;
} }
raw = *rawptr; raw = *rawptr;
dbg(0, "free_rawfile(): clearing data\n"); if(!no_warning) {
dbg(0, "free_rawfile(): clearing data\n");
}
if(raw->names) { if(raw->names) {
for(i = 0 ; i < raw->nvars; ++i) { for(i = 0 ; i < raw->nvars; ++i) {
my_free(_ALLOC_ID_, &raw->names[i]); my_free(_ALLOC_ID_, &raw->names[i]);
@ -954,7 +958,7 @@ int raw_read_from_attr(Raw **rawptr, const char *type, double sweep1, double swe
fwrite(s, decoded_length, 1, fd); fwrite(s, decoded_length, 1, fd);
fclose(fd); fclose(fd);
my_free(_ALLOC_ID_, &s); my_free(_ALLOC_ID_, &s);
res = raw_read(tmp_filename, rawptr, type, sweep1, sweep2); res = raw_read(tmp_filename, rawptr, type, 0, sweep1, sweep2);
unlink(tmp_filename); unlink(tmp_filename);
} else { } else {
dbg(0, "raw_read_from_attr(): failed to open file %s for reading\n", tmp_filename); dbg(0, "raw_read_from_attr(): failed to open file %s for reading\n", tmp_filename);
@ -995,7 +999,7 @@ int raw_add_vector(const char *varname, const char *expr, int sweep_idx)
} }
/* read a ngspice raw file (with data portion in binary format) */ /* read a ngspice raw file (with data portion in binary format) */
int raw_read(const char *f, Raw **rawptr, const char *type, double sweep1, double sweep2) int raw_read(const char *f, Raw **rawptr, const char *type, int no_warning, double sweep1, double sweep2)
{ {
int res = 0; int res = 0;
FILE *fd; FILE *fd;
@ -1021,7 +1025,7 @@ int raw_read(const char *f, Raw **rawptr, const char *type, double sweep1, doubl
int_hash_init(&raw->table, HASHSIZE); int_hash_init(&raw->table, HASHSIZE);
fd = fopen(f, fopen_read_mode); fd = fopen(f, fopen_read_mode);
if(fd) { if(fd) {
if((res = read_dataset(fd, rawptr, type)) == 1) { if((res = read_dataset(fd, rawptr, type, no_warning)) == 1) {
int i; int i;
set_modify(-2); /* clear text floater caches */ set_modify(-2); /* clear text floater caches */
my_strdup2(_ALLOC_ID_, &raw->rawfile, f); my_strdup2(_ALLOC_ID_, &raw->rawfile, f);
@ -1035,8 +1039,10 @@ int raw_read(const char *f, Raw **rawptr, const char *type, double sweep1, doubl
dbg(0, "points=%d, vars=%d, datasets=%d sim_type=%s\n", dbg(0, "points=%d, vars=%d, datasets=%d sim_type=%s\n",
raw->allpoints, raw->nvars, raw->datasets, raw->sim_type ? raw->sim_type : "<NULL>"); raw->allpoints, raw->nvars, raw->datasets, raw->sim_type ? raw->sim_type : "<NULL>");
} else { } else {
/* free_rawfile(rawptr, 0); */ /* do not free: already done in read_dataset()->extra_rawfile() */ /* free_rawfile(rawptr, 0, 0); */ /* do not free: already done in read_dataset()->extra_rawfile() */
dbg(0, "raw_read(): no useful data found\n"); if(!no_warning) {
dbg(0, "raw_read(): no useful data found\n");
}
} }
fclose(fd); fclose(fd);
if(has_x) { if(has_x) {
@ -1050,7 +1056,9 @@ int raw_read(const char *f, Raw **rawptr, const char *type, double sweep1, doubl
} }
return res; return res;
} }
dbg(0, "raw_read(): failed to open file %s for reading\n", f); if(!no_warning) {
dbg(0, "raw_read(): failed to open file %s for reading\n", f);
}
return 0; return 0;
} }
@ -1168,6 +1176,7 @@ int new_rawfile(const char *name, const char *type, const char *sweepvar,
* what == 3: remove a raw file. If no filename given remove all * what == 3: remove a raw file. If no filename given remove all
* what == 4: print info * what == 4: print info
* what == 5: switch back to previous * what == 5: switch back to previous
* if bit 5 (32) of what is set do not issue warnings
* return 1 if sucessfull, 0 otherwise * return 1 if sucessfull, 0 otherwise
*/ */
int extra_rawfile(int what, const char *file, const char *type, double sweep1, double sweep2) int extra_rawfile(int what, const char *file, const char *type, double sweep1, double sweep2)
@ -1175,11 +1184,13 @@ int extra_rawfile(int what, const char *file, const char *type, double sweep1, d
int i; int i;
int ret = 1; int ret = 1;
char f[PATH_MAX]; char f[PATH_MAX];
int no_warning = what & 32;
what &= 0xf; /* remove warning bit */
if(type && !type[0]) type = NULL; /* empty string as type will be considered NULL */ if(type && !type[0]) type = NULL; /* empty string as type will be considered NULL */
dbg(1, "extra_rawfile(): what=%d, file=%s, type=%s\n", dbg(1, "extra_rawfile(): what=%d, no_warning=%d, file=%s, type=%s\n",
what, file ? file : "<NULL>", type ? type : "<NULL>"); what, no_warning, file ? file : "<NULL>", type ? type : "<NULL>");
if(what == 0) return 0; if(what == 0) return 0;
/* if not already done insert base raw file (if there is one) into xctx->extra_raw_arr[0] */ /* if not already done insert base raw file (if there is one) into xctx->extra_raw_arr[0] */
if(xctx->raw && xctx->extra_raw_n == 0) { if(xctx->raw && xctx->extra_raw_n == 0) {
@ -1208,7 +1219,9 @@ int extra_rawfile(int what, const char *file, const char *type, double sweep1, d
xctx->extra_raw_n++; xctx->extra_raw_n++;
} else { } else {
ret = 0; /* not found so did not switch */ ret = 0; /* not found so did not switch */
dbg(0, "extra_rawfile() read: %s not found or no \"%s\" analysis\n", f, type); if(!no_warning) {
dbg(0, "extra_rawfile() read: %s not found or no \"%s\" analysis\n", f, type);
}
if(xctx->extra_raw_n) { /* only restore if raw wiles were not deleted due to a failure in read_raw() */ if(xctx->extra_raw_n) { /* only restore if raw wiles were not deleted due to a failure in read_raw() */
xctx->raw = save; /* restore */ xctx->raw = save; /* restore */
xctx->extra_prev_idx = xctx->extra_idx; xctx->extra_prev_idx = xctx->extra_idx;
@ -1239,7 +1252,7 @@ int extra_rawfile(int what, const char *file, const char *type, double sweep1, d
Raw *save; Raw *save;
save = xctx->raw; save = xctx->raw;
xctx->raw = NULL; xctx->raw = NULL;
read_ret = raw_read(f, &xctx->raw, type, sweep1, sweep2); read_ret = raw_read(f, &xctx->raw, type, no_warning, sweep1, sweep2);
if(read_ret) { if(read_ret) {
dbg(1, "extra_rawfile(): read %s %s, switch to it. raw->sim_type=%s\n", f, dbg(1, "extra_rawfile(): read %s %s, switch to it. raw->sim_type=%s\n", f,
type ? type : "<NULL>", xctx->raw->sim_type ? xctx->raw->sim_type : "<NULL>"); type ? type : "<NULL>", xctx->raw->sim_type ? xctx->raw->sim_type : "<NULL>");
@ -1249,7 +1262,9 @@ int extra_rawfile(int what, const char *file, const char *type, double sweep1, d
xctx->extra_raw_n++; xctx->extra_raw_n++;
} else { } else {
ret = 0; /* not found so did not switch */ ret = 0; /* not found so did not switch */
dbg(0, "extra_rawfile() read: %s not found or no \"%s\" analysis\n", f, type ? type : "<unspecified>"); if(!no_warning) {
dbg(0, "extra_rawfile() read: %s not found or no \"%s\" analysis\n", f, type ? type : "<unspecified>");
}
if(xctx->extra_raw_n) { /* only restore if raw wiles were not deleted due to a failure in read_raw() */ if(xctx->extra_raw_n) { /* only restore if raw wiles were not deleted due to a failure in read_raw() */
xctx->raw = save; /* restore */ xctx->raw = save; /* restore */
xctx->extra_prev_idx = xctx->extra_idx; xctx->extra_prev_idx = xctx->extra_idx;
@ -1290,7 +1305,9 @@ int extra_rawfile(int what, const char *file, const char *type, double sweep1, d
xctx->extra_prev_idx = xctx->extra_idx; xctx->extra_prev_idx = xctx->extra_idx;
xctx->extra_idx = i; xctx->extra_idx = i;
} else { } else {
dbg(0, "extra_rawfile() switch: %s not found or no %s analysis\n", f, type ? type : "<NULL>"); if(!no_warning) {
dbg(0, "extra_rawfile() switch: %s not found or no %s analysis\n", f, type ? type : "<NULL>");
}
ret = 0; ret = 0;
} }
} else { /* switch to next */ } else { /* switch to next */
@ -1310,7 +1327,7 @@ int extra_rawfile(int what, const char *file, const char *type, double sweep1, d
if(!file) { /* clear all */ if(!file) { /* clear all */
if(xctx->extra_raw_n == 0) ret = 0; if(xctx->extra_raw_n == 0) ret = 0;
for(i = 0; i < xctx->extra_raw_n; i++) { for(i = 0; i < xctx->extra_raw_n; i++) {
free_rawfile(&xctx->extra_raw_arr[i], 0); free_rawfile(&xctx->extra_raw_arr[i], 0, no_warning);
} }
tcleval("array unset ngspice::ngspice_data"); tcleval("array unset ngspice::ngspice_data");
xctx->raw = NULL; xctx->raw = NULL;
@ -1327,11 +1344,11 @@ int extra_rawfile(int what, const char *file, const char *type, double sweep1, d
!strcmp(xctx->extra_raw_arr[i]->rawfile, f) && !strcmp(xctx->extra_raw_arr[i]->rawfile, f) &&
!strcmp(xctx->extra_raw_arr[i]->sim_type, type) !strcmp(xctx->extra_raw_arr[i]->sim_type, type)
) { ) {
free_rawfile(&xctx->extra_raw_arr[i], 0); free_rawfile(&xctx->extra_raw_arr[i], 0, no_warning);
found++; found++;
continue; continue;
} else if( !(type && type[0]) && !strcmp(xctx->extra_raw_arr[i]->rawfile, f)) { } else if( !(type && type[0]) && !strcmp(xctx->extra_raw_arr[i]->rawfile, f)) {
free_rawfile(&xctx->extra_raw_arr[i], 0); free_rawfile(&xctx->extra_raw_arr[i], 0, no_warning);
found++; found++;
continue; continue;
} }

View File

@ -1455,6 +1455,12 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
} }
} }
break; break;
case 'm':
if(!strcmp(argv[2], "modified")) { /* schematic is in modified state (needs a save) */
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
Tcl_SetResult(interp, my_itoa(xctx->modified),TCL_VOLATILE);
}
break;
case 'n': case 'n':
if(!strcmp(argv[2], "netlist_name")) { /* netlist name if set. If 'fallback' given get default name */ if(!strcmp(argv[2], "netlist_name")) { /* netlist name if set. If 'fallback' given get default name */
if(argc > 3 && !strcmp(argv[3], "fallback")) { if(argc > 3 && !strcmp(argv[3], "fallback")) {
@ -2093,17 +2099,19 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
#endif #endif
} }
/* go_back [notitle] /* go_back [what]
* Go up one level (pop) in hierarchy * Go up one level (pop) in hierarchy
* if integer 'notitle' given pass it to the go_back() function (1=do not update window title) */ * if integer 'what' given pass it to the go_back() function
* what = 1: ask confirm save if current schematic modified.
* what = 2: do not reset window title */
else if(!strcmp(argv[1], "go_back")) else if(!strcmp(argv[1], "go_back"))
{ {
int set_title = 1; int what = 1;
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;} if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
if(argc > 2 ) { if(argc > 2 ) {
set_title = atoi(argv[2]); what = atoi(argv[2]);
} }
if((xctx->semaphore == 0)) go_back(1, set_title); if((xctx->semaphore == 0)) go_back(what);
Tcl_ResetResult(interp); Tcl_ResetResult(interp);
} }
@ -4163,7 +4171,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
{ {
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;} if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
extra_rawfile(3, NULL, NULL, -1.0, -1.0); /* unload additional raw files */ extra_rawfile(3, NULL, NULL, -1.0, -1.0); /* unload additional raw files */
/* free_rawfile(&xctx->raw, 1); */ /* unload base (current) raw file */ /* free_rawfile(&xctx->raw, 1, 0); */ /* unload base (current) raw file */
draw(); draw();
Tcl_ResetResult(interp); Tcl_ResetResult(interp);
} }
@ -4183,14 +4191,14 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
* if(sch_waves_loaded() >= 0) { * if(sch_waves_loaded() >= 0) {
* tcleval("array unset ngspice::ngspice_data"); * tcleval("array unset ngspice::ngspice_data");
* extra_rawfile(3, NULL, NULL, -1.0, -1.0); * extra_rawfile(3, NULL, NULL, -1.0, -1.0);
* free_rawfile(&xctx->raw, 1); * free_rawfile(&xctx->raw, 1, 0);
* } else * } else
*/ */
if(argc > 2) { if(argc > 2) {
double sweep1 = -1.0, sweep2 = -1.0; double sweep1 = -1.0, sweep2 = -1.0;
tcleval("array unset ngspice::ngspice_data"); tcleval("array unset ngspice::ngspice_data");
extra_rawfile(3, NULL, NULL, -1.0, -1.0); extra_rawfile(3, NULL, NULL, -1.0, -1.0);
/* free_rawfile(&xctx->raw, 0); */ /* free_rawfile(&xctx->raw, 0, 0); */
my_snprintf(f, S(f),"regsub {^~/} {%s} {%s/}", argv[2], home_dir); my_snprintf(f, S(f),"regsub {^~/} {%s} {%s/}", argv[2], home_dir);
tcleval(f); tcleval(f);
my_strncpy(f, tclresult(), S(f)); my_strncpy(f, tclresult(), S(f));
@ -4198,8 +4206,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
sweep1 = atof_spice(argv[4]); sweep1 = atof_spice(argv[4]);
sweep2 = atof_spice(argv[5]); sweep2 = atof_spice(argv[5]);
} }
if(argc > 3) res = raw_read(f, &xctx->raw, argv[3], sweep1, sweep2); if(argc > 3) res = raw_read(f, &xctx->raw, argv[3], 0, sweep1, sweep2);
else res = raw_read(f, &xctx->raw, NULL, -1.0, -1.0); else res = raw_read(f, &xctx->raw, NULL, 0, -1.0, -1.0);
if(sch_waves_loaded() >= 0) { if(sch_waves_loaded() >= 0) {
draw(); draw();
} }
@ -4218,11 +4226,11 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;} if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
if(sch_waves_loaded() >= 0) { if(sch_waves_loaded() >= 0) {
extra_rawfile(3, NULL, NULL, -1.0, -1.0); extra_rawfile(3, NULL, NULL, -1.0, -1.0);
/* free_rawfile(&xctx->raw, 1); */ /* free_rawfile(&xctx->raw, 1, 0); */
draw(); draw();
} else { } else {
extra_rawfile(3, NULL, NULL, -1.0, -1.0); extra_rawfile(3, NULL, NULL, -1.0, -1.0);
/* free_rawfile(&xctx->raw, 0); */ /* free_rawfile(&xctx->raw, 0, 0); */
if(argc > 2) raw_read_from_attr(&xctx->raw, argv[2], -1.0, -1.0); if(argc > 2) raw_read_from_attr(&xctx->raw, argv[2], -1.0, -1.0);
else raw_read_from_attr(&xctx->raw, NULL, -1.0, -1.0); else raw_read_from_attr(&xctx->raw, NULL, -1.0, -1.0);
if(sch_waves_loaded() >= 0) { if(sch_waves_loaded() >= 0) {
@ -5763,14 +5771,14 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;} if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
if(sch_waves_loaded() >= 0) { if(sch_waves_loaded() >= 0) {
extra_rawfile(3, NULL, NULL, -1.0, -1.0); extra_rawfile(3, NULL, NULL, -1.0, -1.0);
/* free_rawfile(&xctx->raw, 1); */ /* free_rawfile(&xctx->raw, 1, 0); */
draw(); draw();
} else if(argc > 2) { } else if(argc > 2) {
my_snprintf(f, S(f),"regsub {^~/} {%s} {%s/}", argv[2], home_dir); my_snprintf(f, S(f),"regsub {^~/} {%s} {%s/}", argv[2], home_dir);
tcleval(f); tcleval(f);
my_strncpy(f, tclresult(), S(f)); my_strncpy(f, tclresult(), S(f));
extra_rawfile(3, NULL, NULL, -1.0, -1.0); extra_rawfile(3, NULL, NULL, -1.0, -1.0);
/* free_rawfile(&xctx->raw, 0); */ /* free_rawfile(&xctx->raw, 0, 0); */
table_read(f); table_read(f);
if(sch_waves_loaded() >= 0) { if(sch_waves_loaded() >= 0) {
draw(); draw();

View File

@ -1270,10 +1270,10 @@ extern char *base64_encode(const unsigned char *data, const size_t input_length,
extern unsigned char *ascii85_encode(const unsigned char *data, const size_t input_length, size_t *output_length); extern unsigned char *ascii85_encode(const unsigned char *data, const size_t input_length, size_t *output_length);
extern int raw_get_pos(const char *node, double value, int dset, int from_start, int to_end); extern int raw_get_pos(const char *node, double value, int dset, int from_start, int to_end);
extern int get_raw_index(const char *node, Int_hashentry **entry_ret); extern int get_raw_index(const char *node, Int_hashentry **entry_ret);
extern void free_rawfile(Raw **rawptr, int dr); extern void free_rawfile(Raw **rawptr, int dr, int no_warning);
extern int update_op(); extern int update_op();
extern int extra_rawfile(int what, const char *f, const char *type, double sweep1, double sweep2); extern int extra_rawfile(int what, const char *f, const char *type, double sweep1, double sweep2);
extern int raw_read(const char *f, Raw **rawptr, const char *type, double sweep1, double sweep2); extern int raw_read(const char *f, Raw **rawptr, const char *type, int no_warning, double sweep1, double sweep2);
extern int table_read(const char *f); extern int table_read(const char *f);
extern double get_raw_value(int dataset, int idx, int point); extern double get_raw_value(int dataset, int idx, int point);
extern int plot_raw_custom_data(int sweep_idx, int first, int last, const char *ntok, const char *yname); extern int plot_raw_custom_data(int sweep_idx, int first, int last, const char *ntok, const char *yname);
@ -1528,7 +1528,7 @@ extern void toggle_ignore(void);
extern void get_additional_symbols(int what); extern void get_additional_symbols(int what);
extern int change_sch_path(int instnumber, int dr); extern int change_sch_path(int instnumber, int dr);
extern int descend_schematic(int instnumber, int fallback, int alert, int set_title); extern int descend_schematic(int instnumber, int fallback, int alert, int set_title);
extern void go_back(int confirm, int set_title); extern void go_back(int what); /* what == 1: confirm save; what == 2: do not reset window title */
extern void clear_schematic(int cancel, int symbol); extern void clear_schematic(int cancel, int symbol);
extern void view_unzoom(double z); extern void view_unzoom(double z);
extern void view_zoom(double z); extern void view_zoom(double z);

View File

@ -7603,7 +7603,7 @@ set tctx::global_list {
graph_logy graph_private_cursor graph_rainbow graph_schname graph_sel_color graph_sel_wave graph_logy graph_private_cursor graph_rainbow graph_schname graph_sel_color graph_sel_wave
graph_selected graph_sort graph_unlocked graph_use_ctrl_key graph_selected graph_sort graph_unlocked graph_use_ctrl_key
hide_empty_graphs hide_symbols tctx::hsize hide_empty_graphs hide_symbols tctx::hsize
incr_hilight incremental_select infowindow_text intuitive_interface incr_hilight incremental_select infix_interface infowindow_text intuitive_interface
keep_symbols launcher_default_program keep_symbols launcher_default_program
light_colors line_width live_cursor2_backannotate local_netlist_dir lvs_ignore light_colors line_width live_cursor2_backannotate local_netlist_dir lvs_ignore
lvs_netlist measure_text netlist_dir netlist_show netlist_type no_ask_save lvs_netlist measure_text netlist_dir netlist_show netlist_type no_ask_save
@ -9066,6 +9066,7 @@ set_ne big_grid_points 0
set_ne draw_grid_axes 1 set_ne draw_grid_axes 1
set_ne persistent_command 0 set_ne persistent_command 0
set_ne intuitive_interface 1 set_ne intuitive_interface 1
set_ne infix_interface 1
set_ne autotrim_wires 0 set_ne autotrim_wires 0
set_ne infix_interface 0 set_ne infix_interface 0
set_ne orthogonal_wiring 1 set_ne orthogonal_wiring 1

View File

@ -201,6 +201,11 @@
#### default: 0 #### default: 0
# set persistent_command 1 # set persistent_command 1
#### if set to 0 users must click a point after hitting a command key
#### like 'w(ire)', 'l(ine)' and so on.
#### default is 1 (hitting the command key sets also the first point).
# set infix_interface 0
#### if set to 1 allow click & drag objects in the schematic #### if set to 1 allow click & drag objects in the schematic
#### to move them without keyboard commands ('m') #### to move them without keyboard commands ('m')
#### default: enabled (1) #### default: enabled (1)

View File

@ -21,8 +21,8 @@ v {xschem version=3.4.6 file_version=1.2
} }
G {} G {}
K {type=source K {type=source
format="@name @pinlist @VAR = @FUNC " format="@name @pinlist @VAR = @FUNC m=@m"
template="name=B1 VAR=I FUNC=\\"pwl(V(plus,minus),0,0, 1,10m, 2, 100m)\\""} template="name=B1 VAR=I FUNC=\\"'pwl(V(plus,minus),0,0, 1,10m, 2, 100m)'\\" m=1"}
V {} V {}
S {} S {}
E {} E {}

File diff suppressed because one or more lines are too long