added `d` to unselect object under the mouse, `Shift-D` to unselect by area, both work with or without infix_interface, moved delete files to `Ctrl-d`, update keybinding docs

This commit is contained in:
stefan schippers 2025-02-06 04:20:57 +01:00
parent 0c4cdb3ea1
commit 7926a833be
4 changed files with 71 additions and 18 deletions

View File

@ -156,7 +156,9 @@ 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
alt 'C' Toggle dim/brite background with rest of layers alt 'C' Toggle dim/brite background with rest of layers
shift 'D' Delete files ctrl 'd' Delete files
- 'd' Unselect selected object under the mouse pointer
shift 'D' Unselect selected objects by area
ctrl 'e' Back to parent schematic ctrl 'e' Back to parent schematic
- 'e' Descend to schematic - 'e' Descend to schematic
alt 'e' Edit selected schematic in a new window alt 'e' Edit selected schematic in a new window

View File

@ -1571,6 +1571,16 @@ static int end_place_move_copy_zoom()
return 0; return 0;
} }
static void unselect_at_mouse_pos(int mx, int my)
{
xctx->last_command = 0;
xctx->mx_save = mx; xctx->my_save = my;
xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap;
select_object(xctx->mousex, xctx->mousey, 0, 0, NULL);
rebuild_selected_array(); /* sets or clears xctx->ui_state SELECTION flag */
}
void snapped_wire(double c_snap) void snapped_wire(double c_snap)
{ {
double x, y; double x, y;
@ -1590,11 +1600,22 @@ void snapped_wire(double c_snap)
} }
} }
static int check_menu_start_commands(double c_snap) static int check_menu_start_commands(double c_snap, int mx, int my)
{ {
dbg(1, "check_menu_start_commands(): ui_state=%x, ui_state2=%x last_command=%d\n", dbg(1, "check_menu_start_commands(): ui_state=%x, ui_state2=%x last_command=%d\n",
xctx->ui_state, xctx->ui_state2, xctx->last_command); xctx->ui_state, xctx->ui_state2, xctx->last_command);
if((xctx->ui_state & MENUSTART) && (xctx->ui_state2 & MENUSTARTDESEL) ) {
if(xctx->ui_state & DESEL_CLICK) {
unselect_at_mouse_pos(mx, my);
} else { /* unselect by area */
xctx->mx_save = mx; xctx->my_save = my;
xctx->mx_double_save=xctx->mousex;
xctx->my_double_save=xctx->mousey;
xctx->ui_state |= DESEL_AREA;
}
return 1;
}
if((xctx->ui_state & MENUSTART) && (xctx->ui_state2 & MENUSTARTWIRECUT)) { if((xctx->ui_state & MENUSTART) && (xctx->ui_state2 & MENUSTARTWIRECUT)) {
break_wires_at_point(xctx->mousex_snap, xctx->mousey_snap, 1); break_wires_at_point(xctx->mousex_snap, xctx->mousey_snap, 1);
return 1; return 1;
@ -2510,7 +2531,7 @@ int rstate; /* (reduced state, without ShiftMask) */
/* determine direction of a rectangle selection (or unselection with ALT key) */ /* determine direction of a rectangle selection (or unselection with ALT key) */
if(xctx->ui_state & STARTSELECT && !(xctx->ui_state & (PLACE_SYMBOL | STARTPAN | PLACE_TEXT)) ) { if(xctx->ui_state & STARTSELECT && !(xctx->ui_state & (PLACE_SYMBOL | STARTPAN | PLACE_TEXT)) ) {
/* Unselect by area : determine direction */ /* Unselect by area : determine direction */
if( (state & Button1Mask) && SET_MODMASK) { if( ((state & Button1Mask) && SET_MODMASK) || (xctx->ui_state & DESEL_AREA)) {
if(mx >= xctx->mx_save) xctx->nl_dir = 0; if(mx >= xctx->mx_save) xctx->nl_dir = 0;
else xctx->nl_dir = 1; else xctx->nl_dir = 1;
select_rect(enable_stretch, RUBBER,0); select_rect(enable_stretch, RUBBER,0);
@ -2563,12 +2584,13 @@ int rstate; /* (reduced state, without ShiftMask) */
} }
} }
/* Unselect by area */ /* Unselect by area */
if((state & Button1Mask) && (SET_MODMASK) && !(state & ShiftMask) && if( (((state & Button1Mask) && SET_MODMASK) || (xctx->ui_state & DESEL_AREA)) &&
!(xctx->ui_state & STARTPAN) && !xctx->shape_point_selected && !(state & ShiftMask) &&
!(xctx->ui_state & STARTPAN) &&
!xctx->shape_point_selected &&
!(xctx->ui_state & STARTSELECT) &&
!(xctx->ui_state & (PLACE_SYMBOL | PLACE_TEXT))) { /* unselect area */ !(xctx->ui_state & (PLACE_SYMBOL | PLACE_TEXT))) { /* unselect area */
if( !(xctx->ui_state & STARTSELECT)) { select_rect(enable_stretch, START,0);
select_rect(enable_stretch, START,0);
}
} }
/* Select by area. Shift pressed */ /* Select by area. Shift pressed */
else if((state&Button1Mask) && (state & ShiftMask) && !(xctx->ui_state & STARTWIRE) && else if((state&Button1Mask) && (state & ShiftMask) && !(xctx->ui_state & STARTWIRE) &&
@ -3979,7 +4001,33 @@ int rstate; /* (reduced state, without ShiftMask) */
draw(); draw();
break; break;
} }
if(key=='D' && rstate == 0) /* delete files */ if(key=='d' && rstate == 0) /* unselect object under the mouse */
{
if(infix_interface) {
unselect_at_mouse_pos(mx, my);
} else {
xctx->ui_state |= (MENUSTART | DESEL_CLICK);
xctx->ui_state2 = MENUSTARTDESEL;
}
break;
}
if(key=='D' && rstate == 0) /* unselect by area */
{
if( !(xctx->ui_state & STARTPAN) && !xctx->shape_point_selected &&
!(xctx->ui_state & (PLACE_SYMBOL | PLACE_TEXT)) && !(xctx->ui_state & STARTSELECT)) {
if(infix_interface) {
xctx->mx_save = mx; xctx->my_save = my;
xctx->mx_double_save=xctx->mousex;
xctx->my_double_save=xctx->mousey;
xctx->ui_state |= DESEL_AREA;
} else {
xctx->ui_state |= MENUSTART;
xctx->ui_state2 = MENUSTARTDESEL;
}
}
break;
}
if(key=='d' && rstate == ControlMask) /* delete files */
{ {
if(xctx->semaphore >= 2) break; if(xctx->semaphore >= 2) break;
delete_files(); delete_files();
@ -4120,12 +4168,7 @@ int rstate; /* (reduced state, without ShiftMask) */
} }
/* Alt - Button1 click to unselect */ /* Alt - Button1 click to unselect */
else if(button==Button1 && (SET_MODMASK) ) { else if(button==Button1 && (SET_MODMASK) ) {
xctx->last_command = 0; unselect_at_mouse_pos(mx, my);
xctx->mx_save = mx; xctx->my_save = my;
xctx->mx_double_save=xctx->mousex_snap;
xctx->my_double_save=xctx->mousey_snap;
select_object(xctx->mousex, xctx->mousey, 0, 0, NULL);
rebuild_selected_array(); /* sets or clears xctx->ui_state SELECTION flag */
} }
/* Middle button press (Button2) will pan the schematic. */ /* Middle button press (Button2) will pan the schematic. */
@ -4165,7 +4208,7 @@ int rstate; /* (reduced state, without ShiftMask) */
break; break;
} }
/* handle all object insertions started from Tools/Edit menu */ /* handle all object insertions started from Tools/Edit menu */
if(check_menu_start_commands(c_snap)) break; if(check_menu_start_commands(c_snap, mx, my)) break;
/* complete the pending STARTWIRE, STARTRECT, STARTZOOM, STARTCOPY ... operations */ /* complete the pending STARTWIRE, STARTRECT, STARTZOOM, STARTCOPY ... operations */
if(end_place_move_copy_zoom()) break; if(end_place_move_copy_zoom()) break;
@ -4303,6 +4346,7 @@ int rstate; /* (reduced state, without ShiftMask) */
waves_callback(event, mx, my, key, button, aux, state); waves_callback(event, mx, my, key, button, aux, state);
break; break;
} }
xctx->ui_state &= ~DESEL_CLICK;
dbg(1, "release: shape_point_selected=%d\n", xctx->shape_point_selected); dbg(1, "release: shape_point_selected=%d\n", xctx->shape_point_selected);
/* bring up context menu if no pending operation */ /* bring up context menu if no pending operation */
if(state == Button3Mask && xctx->semaphore <2) { if(state == Button3Mask && xctx->semaphore <2) {
@ -4378,6 +4422,7 @@ int rstate; /* (reduced state, without ShiftMask) */
select_rect(enable_stretch, END,-1); select_rect(enable_stretch, END,-1);
} }
} }
xctx->ui_state &= ~DESEL_AREA;
rebuild_selected_array(); rebuild_selected_array();
my_snprintf(str, S(str), "mouse = %.16g %.16g - selected: %d path: %s", my_snprintf(str, S(str), "mouse = %.16g %.16g - selected: %d path: %s",
xctx->mousex_snap, xctx->mousey_snap, xctx->lastsel, xctx->sch_path[xctx->currsch] ); xctx->mousex_snap, xctx->mousey_snap, xctx->lastsel, xctx->sch_path[xctx->currsch] );

View File

@ -96,7 +96,9 @@ 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
alt 'C' Toggle dim/brite background with rest of layers alt 'C' Toggle dim/brite background with rest of layers
shift 'D' Delete files ctrl 'd' Delete files
- 'd' Unselect selected object under the mouse pointer
shift 'D' Unselect selected objects by area
ctrl 'e' Back to parent schematic ctrl 'e' Back to parent schematic
- 'e' Descend to schematic - 'e' Descend to schematic
alt 'e' Edit selected schematic in a new window alt 'e' Edit selected schematic in a new window

View File

@ -229,7 +229,9 @@ extern char win_temp_dir[PATH_MAX];
#define START_SYMPIN 16384U #define START_SYMPIN 16384U
#define GRAPHPAN 32768U /* bit 15 */ #define GRAPHPAN 32768U /* bit 15 */
#define MENUSTART 65536U /* bit 16 */ #define MENUSTART 65536U /* bit 16 */
#define GRABSCREEN 131072 /* bit 17 */ #define GRABSCREEN 131072U /* bit 17 */
#define DESEL_CLICK 262144U /* bit 18 */
#define DESEL_AREA 524288U /* bit 19 */
#define SELECTED 1U /* used in the .sel field for selected objs. */ #define SELECTED 1U /* used in the .sel field for selected objs. */
#define SELECTED1 2U /* first point selected... */ #define SELECTED1 2U /* first point selected... */
@ -238,6 +240,7 @@ extern char win_temp_dir[PATH_MAX];
#define SELECTED4 16U #define SELECTED4 16U
/* sub states encoded in global ui_state2 to reduce ui_state bits usage */ /* sub states encoded in global ui_state2 to reduce ui_state bits usage */
/* also used when infix_interface=0 */
#define MENUSTARTWIRE 1U /* start wire invoked from menu */ #define MENUSTARTWIRE 1U /* start wire invoked from menu */
#define MENUSTARTLINE 2U /* start line invoked from menu */ #define MENUSTARTLINE 2U /* start line invoked from menu */
#define MENUSTARTRECT 4U /* start rect invoked from menu */ #define MENUSTARTRECT 4U /* start rect invoked from menu */
@ -250,6 +253,7 @@ extern char win_temp_dir[PATH_MAX];
#define MENUSTARTWIRECUT 512U #define MENUSTARTWIRECUT 512U
#define MENUSTARTWIRECUT2 1024U /* do not align cut point to snap */ #define MENUSTARTWIRECUT2 1024U /* do not align cut point to snap */
#define MENUSTARTCOPY 2048U #define MENUSTARTCOPY 2048U
#define MENUSTARTDESEL 4096U
#define WIRE 1 /* types of defined objects */ #define WIRE 1 /* types of defined objects */
#define xRECT 2 #define xRECT 2