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.
This commit is contained in:
Tim Edwards 2017-12-14 16:05:32 -05:00
parent ff87869724
commit 8faf572604
2 changed files with 26 additions and 3 deletions

View File

@ -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;
}

View File

@ -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
}