From 679348b7f8af2391fa74fa63636500e5f5722dc5 Mon Sep 17 00:00:00 2001 From: Stefan Schippers Date: Sat, 24 Oct 2020 23:46:19 +0200 Subject: [PATCH] "Delete files" menu command added --- doc/xschem_man/commands.html | 1 + src/actions.c | 13 +++++++++++++ src/callback.c | 18 ++++-------------- src/keys.help | 2 +- src/scheduler.c | 4 ++++ src/xschem.h | 1 + src/xschem.tcl | 1 + 7 files changed, 25 insertions(+), 15 deletions(-) diff --git a/doc/xschem_man/commands.html b/doc/xschem_man/commands.html index e0d8950b..37ca2f8e 100644 --- a/doc/xschem_man/commands.html +++ b/doc/xschem_man/commands.html @@ -113,6 +113,7 @@ shift 'C' Start arc placement shift+ctrl 'C' Start circle placement alt 'C' Toggle dim/brite background with rest of layers ctrl 'e' Back to parent schematic +shift 'D' Delete files - 'e' Descend to schematic alt 'e' Edit selected schematic in a new window '\' Toggle Full screen diff --git a/src/actions.c b/src/actions.c index caac9955..f772e2a9 100644 --- a/src/actions.c +++ b/src/actions.c @@ -895,6 +895,19 @@ void attach_labels_to_inst() /* offloaded from callback.c 20171005 */ draw(); bbox(END , 0.0 , 0.0 , 0.0 , 0.0); } +void delete_files(void) +{ + char str[PATH_MAX + 100]; + rebuild_selected_array(); + if(lastselected && selectedgroup[0].type==ELEMENT) { + my_snprintf(str, S(str), "delete_files {%s}", + abs_sym_path(xctx->inst[selectedgroup[0].n].name, "")); + } else { + my_snprintf(str, S(str), "delete_files {%s}", + abs_sym_path(xctx->sch[xctx->currsch], "")); + } + tcleval(str); +} void place_net_label(int type) { diff --git a/src/callback.c b/src/callback.c index 2b5d6004..67b271de 100644 --- a/src/callback.c +++ b/src/callback.c @@ -73,7 +73,7 @@ void start_wire(double mx, double my) int callback(int event, int mx, int my, KeySym key, int button, int aux, int state) { - char str[PATH_MAX];/* overflow safe 20161122 */ + char str[PATH_MAX + 100]; /* overflow safe 20161122 */ static char sel_or_clip[PATH_MAX] = "";/* overflow safe 20161122 */ struct stat buf; unsigned short sel; @@ -1286,25 +1286,15 @@ int callback(int event, int mx, int my, KeySym key, { if(semaphore >= 2) break; hide_symbols++; - if(hide_symbols == 3) hide_symbols = 0; + if(hide_symbols >= 3) hide_symbols = 0; tclsetvar("hide_symbols", hide_symbols == 2 ? "2" : hide_symbols == 1 ? "1" : "0"); draw(); break; } - if(key=='B' && state==ShiftMask) /* delete files */ + if(key=='D' && state==ShiftMask) /* delete files */ { - if(semaphore >= 2) break; - rebuild_selected_array(); - if(lastselected && selectedgroup[0].type==ELEMENT) { - my_snprintf(str, S(str), "delete_files {%s}", - abs_sym_path(xctx->inst[selectedgroup[0].n].name, "")); - } else { - my_snprintf(str, S(str), "delete_files {%s}", - abs_sym_path(xctx->sch[xctx->currsch], "")); - } - - tcleval(str); + delete_files(); break; } if(key=='x' && state == 0 ) /* new cad session */ diff --git a/src/keys.help b/src/keys.help index a2b51f2a..a2ac3e7d 100644 --- a/src/keys.help +++ b/src/keys.help @@ -66,12 +66,12 @@ shift 'A' Toggle show netlist - 'b' Merge file ctrl 'b' Toggle show text in symbol alt 'b' Toggle show symbol details / only bounding boxes -shift 'B' Delete files - 'c' Copy selected obj. ctrl 'c' Save to clipboard shift 'C' Start arc placement shift+ctrl 'C' Start circle placement alt 'C' Toggle dim/brite background with rest of layers +shift 'D' Delete files ctrl 'e' Back to parent schematic - 'e' Descend to schematic alt 'e' Edit selected schematic in a new window diff --git a/src/scheduler.c b/src/scheduler.c index e022a6b6..4ce21088 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -1477,6 +1477,10 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg } Tcl_ResetResult(interp); } + else if(!strcmp(argv[1],"delete_files")) + { + delete_files(); + } else if(!strcmp(argv[1],"rotate")) { diff --git a/src/xschem.h b/src/xschem.h index 1eb1a133..ebed0f69 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -904,6 +904,7 @@ extern int place_symbol(int pos, const char *symbol_name, double x, double y, in const char *inst_props, int draw_sym, int first_call); extern void place_net_label(int type); extern void attach_labels_to_inst(void); +extern void delete_files(void); extern int sym_vs_sch_pins(void); extern int match_symbol(const char name[]); extern int save_schematic(const char *); /* 20171020 added return value */ diff --git a/src/xschem.tcl b/src/xschem.tcl index d3829f78..9ef01f5b 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -3442,6 +3442,7 @@ font configure Underline-Font -underline true -size 24 toolbar_create FileNewSym {xschem clear SYMBOL} "New Symbol" .menubar.file.menu add command -label "Open" -command "xschem load" -accelerator {Ctrl+O} toolbar_create FileOpen "xschem load" "Open File" + .menubar.file.menu add command -label "Delete files" -command "xschem delete_files" -accelerator {Shift-D} menu .menubar.file.menu.recent -tearoff 0 setup_recent_menu