diff --git a/doc/xschem_man/developer_info.html b/doc/xschem_man/developer_info.html index 33adf7b2..587186bc 100644 --- a/doc/xschem_man/developer_info.html +++ b/doc/xschem_man/developer_info.html @@ -642,6 +642,8 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" if '3' argument is given combine '1' and '2'
  • copy
  •     Copy selection to clipboard 
    +
  • copy_hilights
  • +   Copy hilights hash table from previous schematic to new created tab/window 
  • copy_hierarchy to from
  •     Copy hierarchy info from tab/window "from" to tab/window "to"
        Example: xschem copy_hierarchy .drw .x1.drw 
    @@ -1768,6 +1770,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" + diff --git a/src/hilight.c b/src/hilight.c index d2b4cf83..2ad7e632 100644 --- a/src/hilight.c +++ b/src/hilight.c @@ -206,6 +206,38 @@ Hilight_hashentry *hier_hilight_hash_lookup(const char *token, int value, const return entry; } +/* copy hilight hash table to new created schematic. Used for Alt-e descend */ +void copy_hilights(void) +{ + int i; + Hilight_hashentry **entry, **new_entry; + Xschem_ctx *old_xctx = get_old_xctx(); + + for(i=0;ihilight_table[i]; + new_entry = &xctx->hilight_table[i]; + while(entry && *entry) { + Hilight_hashentry *new = (Hilight_hashentry *)my_calloc(_ALLOC_ID_, 1, sizeof( Hilight_hashentry )); + + if(*new_entry) (*new_entry) = new; + xctx->hilight_nets = 1; + + my_strdup2(_ALLOC_ID_, &(new->token), (*entry)->token); + my_strdup2(_ALLOC_ID_, &(new->path), (*entry)->path); + new->hash = (*entry)->hash; + new->oldvalue = (*entry)->oldvalue; + new->value = (*entry)->value; + new->time = (*entry)->time; + new->next = NULL; + + *new_entry = new; + entry = &(*entry)->next; + new_entry = &(*new_entry)->next; + } + if(*new_entry) (*new_entry)->next = NULL; + } +} + /* what: * 1: list only nets * 2: list only intances diff --git a/src/scheduler.c b/src/scheduler.c index 64554b15..85751494 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -669,6 +669,14 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg Tcl_ResetResult(interp); } + /* copy_hilights + * Copy hilights hash table from previous schematic to new created tab/window */ + else if(!strcmp(argv[1], "copy_hilights")) + { + if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;} + copy_hilights(); + Tcl_ResetResult(interp); + } /* copy_hierarchy to from * Copy hierarchy info from tab/window "from" to tab/window "to" @@ -1464,7 +1472,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg break; case 'l': if(!strcmp(argv[2], "last_created_window")) { /* return win_path of last created tab or window */ - Tcl_SetResult(interp, get_last_created_window(), TCL_VOLATILE); + Tcl_SetResult(interp, get_last_created_window_path(), TCL_VOLATILE); } else if(!strcmp(argv[2], "lastsel")) { /* number of selected objects */ if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;} diff --git a/src/xinit.c b/src/xinit.c index 45bd9edd..45c679b6 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -43,6 +43,7 @@ static char window_path[MAX_NEW_WINDOWS][WINDOW_PATH_SIZE]; /* ==0 if no additional windows/tabs, ==1 if one additional window/tab, ... */ static int window_count = 0; static int last_created_window = -1; +static Xschem_ctx *old_xctx; /* ----------------------------------------------------------------------- */ /* EWMH message handling routines 20071027... borrowed from wmctrl code */ @@ -95,7 +96,18 @@ char *get_window_path(int i) return window_path[i]; } -char *get_last_created_window(void) +Xschem_ctx *get_old_xctx(void) +{ + return old_xctx; +} + + +int get_last_created_window(void) +{ + return last_created_window; +} + +char *get_last_created_window_path(void) { if(last_created_window >= 0) { return window_path[last_created_window]; @@ -1653,6 +1665,7 @@ static void create_new_window(int *window_count, const char *noconfirm, const ch win_id = Tk_WindowId(Tk_NameToWindow(interp, window_path[n], mainwindow)); Tk_ChangeWindowAttributes(Tk_NameToWindow(interp, window_path[n], mainwindow), CWBackingStore, &winattr); } + old_xctx = xctx; xctx = NULL; alloc_xschem_data(toppath, window_path[n]); /* alloc data into xctx */ xctx->netlist_type = CAD_SPICE_NETLIST; /* for new windows start with spice netlist mode */ @@ -1764,6 +1777,7 @@ static void create_new_tab(int *window_count, const char *noconfirm, const char my_snprintf(win_path, S(win_path), ".x%d.drw", i); my_strncpy(window_path[i], win_path, S(window_path[i])); + old_xctx = xctx; xctx = NULL; alloc_xschem_data("", win_path); /* alloc data into xctx */ xctx->netlist_type = CAD_SPICE_NETLIST; /* for new windows start with spice netlist mode */ diff --git a/src/xschem.h b/src/xschem.h index b149e9fb..6afcf066 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -1535,10 +1535,12 @@ extern int get_tab_or_window_number(const char *win_path); extern void swap_tabs(void); extern void swap_windows(int dr); extern int check_loaded(const char *f, char *win_path); -extern char *get_last_created_window(void); +extern char *get_last_created_window_path(void); +extern int get_last_created_window(void); extern char *get_window_path(int i); extern int get_window_count(void); extern Xschem_ctx **get_save_xctx(void); +extern Xschem_ctx *get_old_xctx(void); extern void link_symbols_to_instances(int from); extern void load_ascii_string(char **ptr, FILE *fd); extern char *read_line(FILE *fp, int dbg_level); @@ -1737,6 +1739,7 @@ extern void propagate_hilights(int set, int clear, int mode); extern void select_connected_nets(int stop_at_junction); extern char *resolved_net(const char *net); extern void draw_hilight_net(int on_window); +extern void copy_hilights(void); extern void display_hilights(int what, char **str); extern void redraw_hilights(int clear); extern void set_tcl_netlist_type(void); diff --git a/src/xschem.tcl b/src/xschem.tcl index 4697cf75..281dc473 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -3988,6 +3988,7 @@ proc open_sub_schematic {{inst {}} {inst_number 0}} { set res [xschem schematic_in_new_window force] # if successfull descend into indicated sub-schematic if {$res} { + xschem copy_hilights xschem new_schematic switch [xschem get last_created_window] if { $rawfile ne {}} { if {$sim_type eq {op}} {