add Alt-c command for copy object and create nets to connected terminals

This commit is contained in:
stefan schippers 2023-09-25 23:23:08 +02:00
parent cfc87392d2
commit a4b597cfc2
6 changed files with 83 additions and 24 deletions

View File

@ -38,6 +38,7 @@ p{padding: 15px 30px 10px;}
This list is available in XSCHEM in the <kbd>Help</kbd> menu This list is available in XSCHEM in the <kbd>Help</kbd> menu
</p> </p>
<pre class="code" style="height: 600px;"> <pre class="code" style="height: 600px;">
XSCHEM MOUSE BINDINGS XSCHEM MOUSE BINDINGS
---------------------------------------------------------------------- ----------------------------------------------------------------------
LeftButton Clear selection and select a graphic object LeftButton Clear selection and select a graphic object
@ -51,13 +52,16 @@ ctrl + LeftButton if an 'url' or 'tclcommand' property is defined on
tclcommand tclcommand
LeftButton drag Select objects by area, clearing previous selection LeftButton drag Select objects by area, clearing previous selection
"[shift] left button drag" and "[shift] ctrl-left
shift + LeftButton drag Select objects by area, without clearing button drag" commands are swapped if enable_stretch
previous selection is set.
Ctrl + LeftButton drag Select objects by area to perform a Ctrl + LeftButton drag Select objects by area to perform a
subsequent 'stretch' move operation subsequent 'stretch' move operation
shift + LeftButton drag Select objects by area, without clearing
previous selection
Shift + Select objects by area without unselecting Shift + Select objects by area without unselecting
Ctrl + LeftButton drag to perform a subsequent 'stretch' move operation Ctrl + LeftButton drag to perform a subsequent 'stretch' move operation
@ -69,10 +73,11 @@ Ctrl + Right Button Select all connected wires/labels/pins, stopping at
Alt + RightButton Cut wire at mouse position (creates 2 adjacent wires) Alt + RightButton Cut wire at mouse position (creates 2 adjacent wires)
aligns the cut point to current snap setting. aligns the cut point to current snap setting.
Alt + Shift + RightButton Alt + Shift + RightButton
Cut wire at mouse position (creates 2 adjacent wires) Cut wire at mouse position (creates 2 adjacent wires)
does not align cut point to current snap setting. does not align cut point to current snap setting.
Mouse Wheel Zoom in / out Mouse Wheel Zoom in / out
MidButton drag Pan viewable area MidButton drag Pan viewable area
@ -129,7 +134,8 @@ shift 'A' Toggle show netlist
Shift 'B' Edit/add header/license metadata to the schematic/symbol file. Shift 'B' Edit/add header/license metadata to the schematic/symbol file.
ctrl 'b' Toggle show text in symbol ctrl 'b' Toggle show text in symbol
alt 'b' Toggle show symbol details / only bounding boxes alt 'b' Toggle show symbol details / only bounding boxes
- 'c' Copy selected obj. - 'c' Copy selected objects, 'c' and 'alt-c' commands are swapped if enable_stretch is set
Alt 'c' Copy selected objects, insert wires when separating touching instance pins/wires
ctrl 'c' Save to clipboard ctrl 'c' Save to clipboard
shift 'C' Start arc placement shift 'C' Start arc placement
shift+ctrl 'C' Start circle placement shift+ctrl 'C' Start circle placement
@ -173,9 +179,10 @@ alt+shift 'l' add lab_wire.sym to schematic
alt 'l' add lab_pin.sym to schematic alt 'l' add lab_pin.sym to schematic
ctrl+shift 'o' Load most recent schematic ctrl+shift 'o' Load most recent schematic
ctrl 'o' Load schematic ctrl 'o' Load schematic
- 'm' Move selected objects - 'm' Move selected objects. 'm' and 'ctrl-m' commands are swapped if enable_stretch is set
ctrl 'm' Move selected objects, stretching wires attached to them ctrl 'm' Move selected objects, stretching wires attached to them
shift 'M' Move selected objects, insert wire when separating touching instance pins/wires Alt 'm' Move selected objects, insert wires when separating touching instance pins/wires
shift 'M' Move selected objects, insert wires when separating touching instance pins/wires
Stretch wires that land on selected instance pins. Stretch wires that land on selected instance pins.
shift 'N' Top level only netlist shift 'N' Top level only netlist
- 'n' Hierarchical Netlist - 'n' Hierarchical Netlist
@ -195,9 +202,9 @@ ctrl 'q' Exit XSCHEM
alt 'r' Rotate objects around their anchor points alt 'r' Rotate objects around their anchor points
shift 'R' Rotate shift 'R' Rotate
- 'r' Start rect - 'r' Start rect
's' run simulation (asks confirmation)
shift 'S' Change element order shift 'S' Change element order
ctrl+shift 'S' Save as schematic ctrl+shift 'S' Save as schematic
's' run simulation (asks confirmation)
ctrl 's' Save schematic ctrl 's' Save schematic
alt 's' Reload current schematic from disk alt 's' Reload current schematic from disk
ctrl+alt 's' Save-as symbol ctrl+alt 's' Save-as symbol
@ -219,7 +226,7 @@ shift 'X' Highlight discrepancies between object ports and attache
shift 'Z' Zoom in shift 'Z' Zoom in
ctrl 'z' Zoom out ctrl 'z' Zoom out
- '?' Help - '?' Help
- '&amp;' Join / break / collapse wires - '&amp; Join / break / collapse wires
shift '*' Postscript/pdf print shift '*' Postscript/pdf print
ctr+shift '*' Xpm/png print ctr+shift '*' Xpm/png print
alt+shift '*' Svg print alt+shift '*' Svg print

View File

@ -963,8 +963,23 @@ void enable_layers(void)
} }
} }
/* Add wires when moving instances or wires */
short connect_by_kissing(void) /* not used... */
void clear_partial_selected_wires(void)
{
int j;
rebuild_selected_array();
for(j=0; j < xctx->lastsel; ++j) if(xctx->sel_array[j].type == WIRE) {
int wire = xctx->sel_array[j].n;
select_wire(wire, 0, 1);
}
rebuild_selected_array();
}
/* Add wires when moving instances or wires
* action: 1 to select, 0 to unselect */
short connect_by_kissing(int action)
{ {
xSymbol *symbol; xSymbol *symbol;
int npin, i, j; int npin, i, j;

View File

@ -2233,7 +2233,8 @@ int draw_xhair = tclgetboolvar("draw_crosshair");
move_objects(START,0,0,0); move_objects(START,0,0,0);
break; break;
} }
if(key=='M' && state==ShiftMask && !(xctx->ui_state & (STARTMOVE | STARTCOPY))) /* move selection */ if(((key == 'M' && state == ShiftMask) || (key == 'm' && EQUAL_MODMASK)) &&
!(xctx->ui_state & (STARTMOVE | STARTCOPY))) /* move selection */
{ {
xctx->mx_double_save=xctx->mousex_snap; xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap; xctx->my_double_save=xctx->mousey_snap;
@ -2242,7 +2243,8 @@ int draw_xhair = tclgetboolvar("draw_crosshair");
move_objects(START,0,0,0); move_objects(START,0,0,0);
break; break;
} }
if(key=='m' && state==ControlMask && !(xctx->ui_state & (STARTMOVE | STARTCOPY))) /* move selection */ if(key=='m' && (state==ControlMask) &&
!(xctx->ui_state & (STARTMOVE | STARTCOPY))) /* move selection */
{ {
xctx->mx_double_save=xctx->mousex_snap; xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap; xctx->my_double_save=xctx->mousey_snap;
@ -2252,6 +2254,17 @@ int draw_xhair = tclgetboolvar("draw_crosshair");
break; break;
} }
if(key=='c' && EQUAL_MODMASK && /* duplicate selection */
!(xctx->ui_state & (STARTMOVE | STARTCOPY)))
{
if(xctx->semaphore >= 2) break;
tclsetintvar("connect_by_kissing", 2); /* 2 will be used to reset var to 0 at end of move */
xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap;
copy_objects(START);
break;
}
if(key=='c' && state==0 && /* duplicate selection */ if(key=='c' && state==0 && /* duplicate selection */
!(xctx->ui_state & (STARTMOVE | STARTCOPY))) !(xctx->ui_state & (STARTMOVE | STARTCOPY)))
{ {

View File

@ -11,13 +11,16 @@ ctrl + LeftButton if an 'url' or 'tclcommand' property is defined on
tclcommand tclcommand
LeftButton drag Select objects by area, clearing previous selection LeftButton drag Select objects by area, clearing previous selection
"[shift] left button drag" and "[shift] ctrl-left
shift + LeftButton drag Select objects by area, without clearing button drag" commands are swapped if enable_stretch
previous selection is set.
Ctrl + LeftButton drag Select objects by area to perform a Ctrl + LeftButton drag Select objects by area to perform a
subsequent 'stretch' move operation subsequent 'stretch' move operation
shift + LeftButton drag Select objects by area, without clearing
previous selection
Shift + Select objects by area without unselecting Shift + Select objects by area without unselecting
Ctrl + LeftButton drag to perform a subsequent 'stretch' move operation Ctrl + LeftButton drag to perform a subsequent 'stretch' move operation
@ -90,7 +93,8 @@ shift 'A' Toggle show netlist
Shift 'B' Edit/add header/license metadata to the schematic/symbol file. Shift 'B' Edit/add header/license metadata to the schematic/symbol file.
ctrl 'b' Toggle show text in symbol ctrl 'b' Toggle show text in symbol
alt 'b' Toggle show symbol details / only bounding boxes alt 'b' Toggle show symbol details / only bounding boxes
- 'c' Copy selected obj. - 'c' Copy selected objects, 'c' and 'alt-c' commands are swapped if enable_stretch is set
Alt 'c' Copy selected objects, insert wires when separating touching instance pins/wires
ctrl 'c' Save to clipboard ctrl 'c' Save to clipboard
shift 'C' Start arc placement shift 'C' Start arc placement
shift+ctrl 'C' Start circle placement shift+ctrl 'C' Start circle placement
@ -134,9 +138,10 @@ alt+shift 'l' add lab_wire.sym to schematic
alt 'l' add lab_pin.sym to schematic alt 'l' add lab_pin.sym to schematic
ctrl+shift 'o' Load most recent schematic ctrl+shift 'o' Load most recent schematic
ctrl 'o' Load schematic ctrl 'o' Load schematic
- 'm' Move selected objects - 'm' Move selected objects. 'm' and 'ctrl-m' commands are swapped if enable_stretch is set
ctrl 'm' Move selected objects, stretching wires attached to them ctrl 'm' Move selected objects, stretching wires attached to them
shift 'M' Move selected objects, insert wire when separating touching instance pins/wires Alt 'm' Move selected objects, insert wires when separating touching instance pins/wires
shift 'M' Move selected objects, insert wires when separating touching instance pins/wires
Stretch wires that land on selected instance pins. Stretch wires that land on selected instance pins.
shift 'N' Top level only netlist shift 'N' Top level only netlist
- 'n' Hierarchical Netlist - 'n' Hierarchical Netlist

View File

@ -658,6 +658,9 @@ void copy_objects(int what)
xctx->rotatelocal=0; xctx->rotatelocal=0;
dbg(1, "copy_objects(): START copy\n"); dbg(1, "copy_objects(): START copy\n");
rebuild_selected_array(); rebuild_selected_array();
if(tclgetintvar("connect_by_kissing") == 2) xctx->kissing = connect_by_kissing(1);
else xctx->kissing = 0;
save_selection(1); save_selection(1);
xctx->deltax = xctx->deltay = 0.0; xctx->deltax = xctx->deltay = 0.0;
xctx->movelastsel = xctx->lastsel; xctx->movelastsel = xctx->lastsel;
@ -669,6 +672,12 @@ void copy_objects(int what)
{ {
char *str = NULL; /* 20161122 overflow safe */ char *str = NULL; /* 20161122 overflow safe */
draw_selection(xctx->gctiled,0); draw_selection(xctx->gctiled,0);
if(xctx->kissing) {
pop_undo(0, 0);
if(tclgetintvar("connect_by_kissing") == 2) tclsetintvar("connect_by_kissing", 0);
}
#if defined(FIX_BROKEN_TILED_FILL) || !defined(__unix__) #if defined(FIX_BROKEN_TILED_FILL) || !defined(__unix__)
MyXCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gc[0], xctx->xrect[0].x, xctx->xrect[0].y, MyXCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gc[0], xctx->xrect[0].x, xctx->xrect[0].y,
xctx->xrect[0].width, xctx->xrect[0].height, xctx->xrect[0].x, xctx->xrect[0].y); xctx->xrect[0].width, xctx->xrect[0].height, xctx->xrect[0].x, xctx->xrect[0].y);
@ -708,12 +717,21 @@ void copy_objects(int what)
{ {
int l, firstw, firsti; int l, firstw, firsti;
int floaters = there_are_floaters(); int floaters = there_are_floaters();
if(tclgetintvar("connect_by_kissing") == 2) {
tclsetintvar("connect_by_kissing", 0);
}
if(!floaters) bbox(START, 0.0 , 0.0 , 0.0 , 0.0); if(!floaters) bbox(START, 0.0 , 0.0 , 0.0 , 0.0);
newpropcnt=0; newpropcnt=0;
xctx->push_undo();
firstw = firsti = 1;
if( !xctx->kissing ) {
dbg(1, "copy_objects(): push undo state\n");
xctx->push_undo();
}
firstw = firsti = 1;
draw_selection(xctx->gctiled,0); draw_selection(xctx->gctiled,0);
update_symbol_bboxes(0, 0); update_symbol_bboxes(0, 0);
/* build list before copying and recalculating prepare_netlist_structs() */ /* build list before copying and recalculating prepare_netlist_structs() */
@ -1088,7 +1106,7 @@ void move_objects(int what, int merge, double dx, double dy)
xctx->deltax = xctx->deltay = 0.0; xctx->deltax = xctx->deltay = 0.0;
rebuild_selected_array(); rebuild_selected_array();
/* if connect_by_kissing==2 it was set in callback.c ('M' command) */ /* if connect_by_kissing==2 it was set in callback.c ('M' command) */
if(tclgetintvar("connect_by_kissing")) xctx->kissing = connect_by_kissing(); if(tclgetintvar("connect_by_kissing")) xctx->kissing = connect_by_kissing(1);
else xctx->kissing = 0; else xctx->kissing = 0;
xctx->movelastsel = xctx->lastsel; xctx->movelastsel = xctx->lastsel;
if(xctx->lastsel==1 && xctx->sel_array[0].type==ARC && if(xctx->lastsel==1 && xctx->sel_array[0].type==ARC &&

View File

@ -1354,7 +1354,8 @@ extern int place_symbol(int pos, const char *symbol_name, double x, double y, sh
const char *inst_props, int draw_sym, int first_call, int to_push_undo); const char *inst_props, int draw_sym, int first_call, int to_push_undo);
extern void place_net_label(int type); extern void place_net_label(int type);
extern void attach_labels_to_inst(int interactive); extern void attach_labels_to_inst(int interactive);
extern short connect_by_kissing(void); extern void clear_partial_selected_wires(void);
extern short connect_by_kissing(int action); /* action: 1 to select, 0 to unselect */
extern void delete_files(void); extern void delete_files(void);
extern int sym_vs_sch_pins(void); extern int sym_vs_sch_pins(void);
extern char *get_generator_command(const char *str); extern char *get_generator_command(const char *str);