From b8bfaa50663d61720071699247ff2ec5510a672a Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Fri, 3 May 2019 09:14:25 -0400 Subject: [PATCH 1/2] Corrected command option "select [more|less] cell ", which was not recognizing the more|less option and therefore failing to search for the instance , rendering the command non-functional. --- commands/CmdRS.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commands/CmdRS.c b/commands/CmdRS.c index ec2698f3..692e82bb 100644 --- a/commands/CmdRS.c +++ b/commands/CmdRS.c @@ -1349,7 +1349,8 @@ Okay: * click" code. */ - if ((cmd->tx_argc == 3) && (optionArgs == &cmd->tx_argv[2])) + if ((cmd->tx_argc == 3) && (optionArgs == &cmd->tx_argv[2]) && + (more == FALSE) && (less == FALSE)) { use = lastUse = scx.scx_use; p.p_x = scx.scx_use->cu_xlo; From fc7249b04c446cd204b42ad09d6336b1b8713363 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Fri, 3 May 2019 10:13:06 -0400 Subject: [PATCH 2/2] Extended the "port" command to operate on labels in non-edit cells as long as the command is not attempting to modify the port. Attempts to modify ports in non-edit cells result in an error message that is more helpful than the previous "Exactly one label must be present..." text. --- commands/CmdLQ.c | 108 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 99 insertions(+), 9 deletions(-) diff --git a/commands/CmdLQ.c b/commands/CmdLQ.c index bb72d6c0..7f3f2310 100644 --- a/commands/CmdLQ.c +++ b/commands/CmdLQ.c @@ -1004,6 +1004,54 @@ CmdPolygon(w, cmd) freeMagic(plist); } +/*----------------------------------------------------------------------*/ +/* cmdPortLabelFunc() --- */ +/*----------------------------------------------------------------------*/ + +int +cmdPortLabelFunc1(scx, label, tpath, cdata) + SearchContext *scx; + Label *label; + TerminalPath *tpath; + ClientData cdata; +{ + Label **rlab = (Label **)cdata; + + if (GEO_SURROUND(&scx->scx_area, &label->lab_rect)) + { + if (*rlab != NULL) + { + // More than one label in the area; ambiguous. + *rlab = NULL; + return 1; + } + *rlab = label; + } + return 0; +} + +int +cmdPortLabelFunc2(scx, label, tpath, cdata) + SearchContext *scx; + Label *label; + TerminalPath *tpath; + ClientData cdata; +{ + Label **rlab = (Label **)cdata; + + if (GEO_OVERLAP(&scx->scx_area, &label->lab_rect)) + { + if (*rlab != NULL) + { + // More than one label in the area; ambiguous. + *rlab = NULL; + return 1; + } + *rlab = label; + } + return 0; +} + /*----------------------------------------------------------------------*/ /* portFindLabel --- */ /* */ @@ -1015,12 +1063,13 @@ CmdPolygon(w, cmd) /*----------------------------------------------------------------------*/ Label * -portFindLabel(editDef, port, unique) +portFindLabel(editDef, port, unique, nonEdit) CellDef *editDef; bool unique; bool port; + bool *nonEdit; // TRUE if label is not in the edit cell { - bool found; + int found; Label *lab, *sl; Rect editBox; @@ -1029,33 +1078,62 @@ portFindLabel(editDef, port, unique) */ ToolGetEditBox(&editBox); - found = FALSE; + found = 0; + if (nonEdit) *nonEdit = FALSE; lab = NULL; for (sl = editDef->cd_labels; sl != NULL; sl = sl->lab_next) { if (GEO_OVERLAP(&editBox, &sl->lab_rect)) { - if (found == TRUE) + if (found > 0) { /* Let's do this again with the GEO_SURROUND function */ /* and see if we come up with only one label. */ - found = FALSE; + found = 0; for (sl = editDef->cd_labels; sl != NULL; sl = sl->lab_next) { if (GEO_SURROUND(&editBox, &sl->lab_rect)) { - if (found == TRUE && unique == TRUE) return NULL; + if (found > 0 && unique == TRUE) return NULL; lab = sl; - found = TRUE; + found++; } } break; } lab = sl; - found = TRUE; + found++; + if (nonEdit) *nonEdit = FALSE; } } + + /* If no label was found, then search the hierarchy under the box. */ + /* The calling routine may determine whether a label that is not in */ + /* the edit cell may be valid for the command (e.g., if querying */ + /* but not changing values). */ + + if (found == 0) + { + SearchContext scx; + scx.scx_area = editBox; + scx.scx_use = EditCellUse; + scx.scx_trans = GeoIdentityTransform; + + /* First check for exactly one label surrounded by the cursor box. */ + /* If that fails, check for exactly one label overlapping the */ + /* cursor box. */ + + DBTreeSrLabels(&scx, &DBAllButSpaceBits, 0, NULL, TF_LABEL_ATTACH, + cmdPortLabelFunc1, (ClientData) &lab); + if (lab == NULL) + DBTreeSrLabels(&scx, &DBAllButSpaceBits, 0, NULL, TF_LABEL_ATTACH, + cmdPortLabelFunc2, (ClientData) &lab); + + if (lab != NULL) + if (nonEdit) *nonEdit = TRUE; + } + return lab; } /* @@ -1121,6 +1199,7 @@ CmdPort(w, cmd) int i, idx, pos, type, option, argc; unsigned short dirmask; bool found; + bool nonEdit = FALSE; Label *lab, *sl; Rect editBox, tmpArea; CellDef *editDef = EditCellUse->cu_def; @@ -1254,7 +1333,7 @@ CmdPort(w, cmd) if (option != PORT_LAST) { if (lab == NULL) - lab = portFindLabel(editDef, TRUE, TRUE); + lab = portFindLabel(editDef, TRUE, TRUE, &nonEdit); if (option == PORT_EXISTS) { @@ -1297,6 +1376,17 @@ CmdPort(w, cmd) } } + /* Check for options that cannot operate on a non-edit cell label */ + if (nonEdit) + { + if ((option == PORT_MAKE) || (option == PORT_MAKEALL) || + (option == PORT_REMOVE) || (argc == 3)) + { + TxError("Cannot modify a port in an non-edit cell.\n"); + return; + } + } + /* Handle all command options */ switch (option) {