load multiple files from command line, in tabbed or foating windows mode

This commit is contained in:
Stefan Frederik 2022-01-15 13:19:06 +01:00
parent 1167b97f2e
commit 3f017074be
4 changed files with 31 additions and 30 deletions

View File

@ -195,6 +195,8 @@ const char fopen_read_mode[] = "r";
/* ---------------------------------------------------------- */
/* Cmdline options (used at xinit, and then not used anymore) */
/* ---------------------------------------------------------- */
int cli_opt_argc;
char **cli_opt_argv = NULL;
int cli_opt_netlist_type = 0;
int cli_opt_flat_netlist = 0;
char cli_opt_plotfile[PATH_MAX] = "";

View File

@ -68,6 +68,7 @@ void child_handler(int signum)
int main(int argc, char **argv)
{
int i;
my_strdup(45, &xschem_executable, argv[0]);
signal(SIGINT, sig_handler);
signal(SIGSEGV, sig_handler);
@ -81,40 +82,24 @@ int main(int argc, char **argv)
#ifdef __unix__
if(!getenv("DISPLAY") || !getenv("DISPLAY")[0]) has_x=0;
#endif
process_options(argc, argv);
argc = process_options(argc, argv);
if(debug_var>=1 && !has_x)
fprintf(errfp, "main(): no DISPLAY set, assuming no X available\n");
#if 0
/* detach from console (fork a child and close std file descriptors) */
if(detach) {
#ifdef __unix__
pid_t pid = fork();
if(pid < 0) {
fprintf(errfp, "main(): fork() failed\n");
exit(EXIT_FAILURE);
}
if(pid == 0) {
/* The child becomes the daemon. */
/* Detach all standard I/O descriptors */
close(0); /* stdin */
close(1); /* stdout */
close(2); /* stderr */
setsid(); /* new session */
/* Ok, now detached */
}
else {
/* terminate parent */
exit(0);
}
#endif
}
#endif
/* if detach is 1 no interactive command shell is created ...
* using detach if no windowing exists (has_x == 0) is non sense so do nothing
*/
cli_opt_argc = argc;
cli_opt_argv = my_malloc(291, cli_opt_argc * sizeof(char *));
for(i = 0; i < cli_opt_argc; i++) {
cli_opt_argv[i] = NULL;
my_strdup(374, &cli_opt_argv[i], argv[i]);
}
if(detach && has_x) {
Tcl_FindExecutable(argv[0]); /* tcl stores executable name for its internal usage */
interp = Tcl_CreateInterp(); /* create the tcl interpreter */

View File

@ -695,6 +695,11 @@ void xwin_exit(void)
dbg(1, "xwin_exit(): deleted undo buffer\n");
if(errfp!=stderr) fclose(errfp);
errfp=stderr;
/* delete cmdline stuff */
for(i = 0 ; i < cli_opt_argc; i++) {
my_free(1141, &cli_opt_argv[i]);
}
my_free(1464, &cli_opt_argv);
if(!detach) printf("\n");
init_done=0; /* 20150409 to avoid multiple calls */
}
@ -1213,7 +1218,7 @@ static void destroy_window(int *window_count, const char *win_path)
savectx = xctx;
if(*window_count) {
int close = 0;
dbg(0, "new_schematic() destroy {%s}\n", win_path);
dbg(1, "new_schematic() destroy {%s}\n", win_path);
if(xctx->modified && has_x) {
tcleval("tk_messageBox -type okcancel -parent [xschem get topwindow] -message \""
"[get_cell [xschem get schname] 0]"
@ -2336,6 +2341,13 @@ int Tcl_AppInit(Tcl_Interp *inter)
tcleval("exit");
}
/* load additional files */
for(i = 2; i < cli_opt_argc; i++) {
tclvareval("xschem load_new_window ", cli_opt_argv[i], NULL);
}
/* */
/* END PROCESSING USER OPTIONS */
/* */

View File

@ -997,6 +997,8 @@ extern int detach; /* no TCL console */
extern const char fopen_read_mode[]; /* "r" on unix, "rb" on windows */
/*********** Cmdline options (used at xinit, and then not used anymore) ***********/
extern int cli_opt_argc;
extern char **cli_opt_argv;
extern int cli_opt_netlist_type;
extern int cli_opt_flat_netlist;
extern char cli_opt_plotfile[PATH_MAX];