when double clcking (or hitting `q`) to edit attributes if instance has lab=... or value=... select the RHS and position insertion cursor, focus textbox. Add Shift-T bindkey for toggle *_ignore flag

This commit is contained in:
stefan schippers 2024-02-17 02:58:53 +01:00
parent 91829bf99d
commit 20add157c2
7 changed files with 65 additions and 31 deletions

View File

@ -208,6 +208,7 @@ ctrl 's' Save schematic
alt 's' Reload current schematic from disk
ctrl+alt 's' Save-as symbol
- 't' Place text
shift 'T' Toggle *_ignore flag on selected instances
alt 'u' Align to current grid selected objects
shift 'U' Redo
- 'u' Undo

View File

@ -1853,6 +1853,39 @@ void copy_symbol(xSymbol *dest_sym, xSymbol *src_sym)
}
}
void toggle_ignore(void)
{
int i, n, first = 1, remove = 0;
char *attr;
if(xctx->netlist_type == CAD_VERILOG_NETLIST) attr="verilog_ignore";
else if(xctx->netlist_type == CAD_VHDL_NETLIST) attr="vhdl_ignore";
else if(xctx->netlist_type == CAD_TEDAX_NETLIST) attr="tedax_ignore";
else if(xctx->netlist_type == CAD_SPICE_NETLIST) attr="spice_ignore";
else attr = NULL;
if(attr) {
rebuild_selected_array();
for(n=0; n < xctx->lastsel; ++n) {
if(xctx->sel_array[n].type == ELEMENT) {
i = xctx->sel_array[n].n;
if(first) {
xctx->push_undo();
first = 0;
}
remove = 0;
if(!strboolcmp(get_tok_value(xctx->inst[i].prop_ptr, attr, 0), "true")) remove = 1;
if(remove) {
my_strdup(_ALLOC_ID_, &xctx->inst[i].prop_ptr, subst_token(xctx->inst[i].prop_ptr, attr, NULL));
} else {
my_strdup(_ALLOC_ID_, &xctx->inst[i].prop_ptr, subst_token(xctx->inst[i].prop_ptr, attr, "true"));
}
set_inst_flags(&xctx->inst[i]);
set_modify(1);
}
}
draw();
}
}
/* what = 1: start
* what = 0 : end : should NOT be called if match_symbol() has been executed between start & end
*/

View File

@ -1798,6 +1798,10 @@ int rstate; /* (reduced state, without ShiftMask) */
xctx->semaphore = save_sem;
break;
}
/* toggle spice_ignore, verilog_ignore, ... flag on selected instances. */
if(key == 'T' && rstate == 0) {
toggle_ignore();
}
if(key=='t' && rstate == 0) /* place text */
{
if(waves_selected(event, key, state, button)) {

View File

@ -168,6 +168,7 @@ ctrl 's' Save schematic
alt 's' Reload current schematic from disk
ctrl+alt 's' Save-as symbol
- 't' Place text
shift 'T' Toggle *_ignore flag on selected instances
alt 'u' Align to current grid selected objects
shift 'U' Redo
- 'u' Undo

View File

@ -5193,36 +5193,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
* * = {spice,verilog,vhdl,tedax} depending on current netlist mode */
else if(!strcmp(argv[1], "toggle_ignore"))
{
int i, n, first = 1, remove = 0;
char *attr;
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
if(xctx->netlist_type == CAD_VERILOG_NETLIST) attr="verilog_ignore";
else if(xctx->netlist_type == CAD_VHDL_NETLIST) attr="vhdl_ignore";
else if(xctx->netlist_type == CAD_TEDAX_NETLIST) attr="tedax_ignore";
else if(xctx->netlist_type == CAD_SPICE_NETLIST) attr="spice_ignore";
else attr = NULL;
if(attr) {
rebuild_selected_array();
for(n=0; n < xctx->lastsel; ++n) {
if(xctx->sel_array[n].type == ELEMENT) {
i = xctx->sel_array[n].n;
if(first) {
xctx->push_undo();
first = 0;
}
remove = 0;
if(!strboolcmp(get_tok_value(xctx->inst[i].prop_ptr, attr, 0), "true")) remove = 1;
if(remove) {
my_strdup(_ALLOC_ID_, &xctx->inst[i].prop_ptr, subst_token(xctx->inst[i].prop_ptr, attr, NULL));
} else {
my_strdup(_ALLOC_ID_, &xctx->inst[i].prop_ptr, subst_token(xctx->inst[i].prop_ptr, attr, "true"));
}
set_inst_flags(&xctx->inst[i]);
set_modify(1);
}
}
draw();
}
toggle_ignore();
Tcl_ResetResult(interp);
}

View File

@ -1481,6 +1481,7 @@ extern void read_record(int firstchar, FILE *fp, int dbg_level);
extern void create_sch_from_sym(void);
extern void get_sch_from_sym(char *filename, xSymbol *sym, int inst, int fallback);
extern const char *get_sym_name(int inst, int ndir, int ext);
extern void toggle_ignore(void);
extern void get_additional_symbols(int what);
extern int descend_schematic(int instnumber, int fallback, int alert);
extern void go_back(int confirm);

View File

@ -2235,6 +2235,7 @@ proc graph_add_nodes {} {
set change_done 0
foreach i $sel_idx {
set c [.graphdialog.center.left.list1 get $i]
# escape [ and ] characters.
set c [regsub -all {([][])} $c {\\\1}]
if { ![regexp "(^|\[ \t\n\])${c}($|\[ \t\n\])" $current_node_list]} {
if {$sel ne {}} {append sel $sep}
@ -2351,6 +2352,7 @@ proc graph_tag_nodes {txt} {
set col [xschem getprop rect 2 $graph_selected color]
set col [string trim $col " \n"]
}
# non capturing `tcleval(` at beginning and `)` at end
set regx {(?:tcleval\(\n*)?("[^"]+"|[^ \t\n)]+)(?:\))?}
set tt {}
set cc {}
@ -4931,7 +4933,7 @@ proc edit_prop {txtlabel} {
set retval_orig [.dialog.symprop get 1.0 {end - 1 chars}]
} else {
set retval [.dialog.symprop get 1.0 {end - 1 chars}]
regsub -all {(["\\])} $retval {\\\1} retval ;#" editor is confused by the previous quote
regsub -all {(["\\])} $retval {\\\1} retval ;# vim syntax fix "
set retval \"${retval}\"
set retval_orig [xschem subst_tok $retval_orig $old_selected_tok $retval]
}
@ -4974,6 +4976,26 @@ proc edit_prop {txtlabel} {
wm geometry .dialog $edit_prop_pos
}
set edit_symbol_prop_new_sel 0
tkwait visibility .dialog
# select text after value= or lab= and place cursor just before selection
set regx {value *= *("[^"]+"|[^ \t\n"]+)} ;# vim syntax fix "
set regx1 {value *= *[^ \n]}
set idx [.dialog.symprop search -regexp -nolinestop -count nchars $regx 1.0]
.dialog.symprop search -regexp -nolinestop -count len $regx1 1.0
incr len -1
if {$idx eq {} } {
set regx {lab *= *("[^"]+"|[^ \t\n"]+)} ;# vim syntax fix "
set regx1 {lab *= *[^ \n]}
set idx [.dialog.symprop search -regexp -nolinestop -count nchars $regx 1.0]
.dialog.symprop search -regexp -nolinestop -count len $regx1 1.0
incr len -1
}
if { $idx ne {} } {
.dialog.symprop tag add sel "$idx + $len chars" "$idx + $nchars chars"
.dialog.symprop mark set insert "$idx + $len chars"
}
focus .dialog.symprop
tkwait window .dialog
xschem set semaphore [expr {[xschem get semaphore] -1}]
return $tctx::rcode
@ -7358,7 +7380,7 @@ proc build_widgets { {topwin {} } } {
$topwin.menubar.prop.menu add command -label "Edit with editor" -command "xschem edit_vi_prop" -accelerator Shift+Q
$topwin.menubar.prop.menu add command -label "View" -command "xschem view_prop" -accelerator Ctrl+Shift+Q
$topwin.menubar.prop.menu add command -label "Toggle *_ignore attribute on selected instances" \
-command "xschem toggle_ignore"
-command "xschem toggle_ignore" -accelerator Shift+T
$topwin.menubar.prop.menu add command -label "Edit Header/License text" \
-command { update_schematic_header } -accelerator Shift+B
$topwin.menubar.prop.menu add command -background red -label "Edit file (danger!)" \