diff --git a/src/xinit.c b/src/xinit.c index 8ffe0f5c..ff9e9835 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -1666,6 +1666,7 @@ static void create_new_window(int *window_count, const char *noconfirm, const ch tclvareval("set_bindings ", window_path[n], NULL); tclvareval("set_replace_key_binding ", window_path[n], NULL); tclvareval("save_ctx ", window_path[n], NULL); + tcleval("eval_user_startup_commands"); /* restore previous context, * because the Expose event after new window creation does a context switch prev win -> new win * @@ -2892,6 +2893,7 @@ int Tcl_AppInit(Tcl_Interp *inter) if(has_x) { tclsetintvar("tctx::max_new_windows", MAX_NEW_WINDOWS); tcleval("pack_widgets; set_bindings .drw"); + tcleval("eval_user_startup_commands"); } fs=tclgetintvar("fullscreen"); diff --git a/src/xschem.tcl b/src/xschem.tcl index 77d498b2..3f2844f5 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -9355,6 +9355,15 @@ proc source_user_tcl_files {} { } } +proc eval_user_startup_commands {} { + global user_startup_commands + if {[info exists user_startup_commands]} { + if {[catch {uplevel #0 $user_startup_commands} res]} { + puts "executing $user_startup_commands:\n\n$res" + } + } +} + proc eval_postinit_commands {} { global postinit_commands if {[info exists postinit_commands]} { diff --git a/src/xschemrc b/src/xschemrc index 8bcacf06..41516e38 100644 --- a/src/xschemrc +++ b/src/xschemrc @@ -540,6 +540,17 @@ # } # } +########################################################################### +#### TCL COMMANDS TO BE EXECUTED AFTER ANY NEW WINDOW CREATION +########################################################################### +#### this hook is useful to execute user UI code (like event binding, +#### new buttons / menu entries etc). +# set user_startup_commands { +# bind [xschem get current_win_path] { +# puts Hello +# } +# } + ########################################################################### #### TCL COMMANDS TO BE EXECUTED AFTER GENERATING NETLIST ###########################################################################