From 58cdbc53566978d5af44b8a920c193919911ada9 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Sun, 21 Mar 2021 12:02:43 -0400 Subject: [PATCH] Made the "select short" command a bit easier to use (and more in line with the existing documentation) by not requiring the net containing the two labels to be selected before running the "select short" command. The command now first checks if the labels exist in the selection, and if not, the command effectively executes "goto label1 ; select net" and then continues as previously implemented. --- VERSION | 2 +- select/selOps.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 8db3b356..c8e7cc7e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.3.144 +8.3.145 diff --git a/select/selOps.c b/select/selOps.c index 7eb2f9a8..e71ed7ce 100644 --- a/select/selOps.c +++ b/select/selOps.c @@ -22,6 +22,7 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/ #endif /* not lint */ #include +#include #include "utils/magic.h" #include "utils/geometry.h" @@ -717,6 +718,43 @@ SelectShort(char *lab1, char *lab2) destlab = selLabel; } + /* Was nothing selected? Then run the equivalent of "goto lab1 ; select net */ + if (srclab == NULL && destlab == NULL) + { + CellUse *use; + TileType ttype; + Rect rect; + SearchContext scx; + MagWindow *window; + DBWclientRec *crec; + int windowMask; + + window = ToolGetBoxWindow(&rect, &windowMask); + if (!window) return NULL; + + use = (CellUse *)window->w_surfaceID; + ttype = CmdFindNetProc(lab1, use, &rect, FALSE); + if (ttype == TT_SPACE) return NULL; + + bzero(&scx, sizeof(SearchContext)); + scx.scx_use = use; + scx.scx_trans = GeoIdentityTransform; + scx.scx_area = rect; + crec = (DBWclientRec *)window->w_clientData; + + SelectNet(&scx, ttype, crec->dbw_bitmask, (Rect *)NULL, FALSE); + + for (selLabel = SelectDef->cd_labels; selLabel != NULL; selLabel = + selLabel->lab_next) + { + if ((srclab == NULL) && Match(lab1, selLabel->lab_text)) + srclab = selLabel; + + if ((destlab == NULL) && Match(lab2, selLabel->lab_text)) + destlab = selLabel; + } + } + /* Must be able to find both labels */ if (srclab == NULL || destlab == NULL) return NULL;