From 8faf57260491ecdb2d82b0d84904e019e810c4b0 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Thu, 14 Dec 2017 16:05:32 -0500 Subject: [PATCH] Corrected the "Text..." dialog to auto-update ports after making a port so that repeated uses of "apply" won't fail because the port number is already used. Corrected the "port remove" command, which didn't work, and corrected the script to do "port exists" before "port index" so that the latter won't complain if the label is not a port. Same changes made to magic-8.1. --- commands/CmdLQ.c | 5 +++-- tcltk/texthelper.tcl | 24 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/commands/CmdLQ.c b/commands/CmdLQ.c index 54c8d101..c51ba5bf 100644 --- a/commands/CmdLQ.c +++ b/commands/CmdLQ.c @@ -1248,7 +1248,7 @@ CmdPort(w, cmd) { /* Check for options that require only one selected port */ - if ((option != PORT_REMOVE) && (option != PORT_LAST)) + if (option != PORT_LAST) { if (lab == NULL) lab = portFindLabel(editDef, TRUE, TRUE); @@ -1273,9 +1273,10 @@ CmdPort(w, cmd) } if ((option != PORT_LAST) && lab == NULL) { - /* Let "port remove" work without complaining. */ + /* Let "port remove" fail without complaining. */ if (option != PORT_REMOVE) TxError("Exactly one label may be present under the cursor box.\n"); + return; } diff --git a/tcltk/texthelper.tcl b/tcltk/texthelper.tcl index a0259d99..33141be2 100644 --- a/tcltk/texthelper.tcl +++ b/tcltk/texthelper.tcl @@ -157,7 +157,12 @@ proc magic::analyze_labels {} { set oval [lindex [setlabel offset] 0] set lval [lindex [setlabel layer] 0] set kval [lindex [setlabel sticky] 0] - set pval [lindex [port index] 0] + set isport [lindex [port exists] 0] + if {$isport} { + set pval [lindex [port index] 0] + } else { + set pval -1 + } # Rescale internal units to microns set sval [lindex [setlabel size] 0] @@ -257,6 +262,18 @@ proc magic::change_label {} { setlabel layer $ltype } setlabel sticky $typesticky + + if {$typeport == 1 && $lport != ""} { + if {[port exists] == 0} { + port make $lport + } else { + port index $lport + } + } else { + if {[port exists] == 1} { + port remove + } + } } proc magic::make_new_label {} { @@ -306,6 +323,11 @@ proc magic::make_new_label {} { } if {$typeport == 1 && $lport != ""} { port make $lport + # Auto-increment the value to the next available port. + set pval [port last] + incr pval + .texthelper.port.tent delete 0 end + .texthelper.port.tent insert 0 $pval } else { port remove }