Fixed a number of places in the Tcl code where "snap" had been used

to force internal units to be used;  this usage is now deprecated
and needed to be changed to the "units" command.  Also:  Fixed a
separate issue with getting both "view bbox" and "view get" to
return values in the currently selected units.  Also:  Fixed an
issue with "property" when setting a property to a list passed as
a single value (e.g., "property FIXED_BBOX [box values]"), which
needed to null the string after each value.
This commit is contained in:
R. Timothy Edwards 2026-02-24 15:59:21 -05:00
parent 95baea1c22
commit afca58f162
11 changed files with 113 additions and 79 deletions

View File

@ -1 +1 @@
8.3.606
8.3.607

View File

@ -2625,6 +2625,16 @@ CmdDoProperty(
if (isspace(*value) && (*value != '\0')) value++;
if (!isspace(*value))
{
char *spptr, spchar;
/* cmdParseCoord() can only handle one value at a
* time, so look ahead and null out the next space
* character if there is one.
*/
spptr = value + 1;
while (!isspace(*spptr) && (*spptr != '\0')) spptr++;
spchar = *spptr;
*spptr = '\0';
if (proptype == PROPERTY_TYPE_INTEGER)
{
if (sscanf(value, "%d", &propvalue) != 1)
@ -2653,6 +2663,7 @@ CmdDoProperty(
((proplen % 2) == 0) ? TRUE : FALSE);
proprec->prop_value.prop_integer[proplen] = propvalue;
}
*spptr = spchar;
while (!isspace(*value) && (*value != '\0')) value++;
}
}

View File

@ -156,6 +156,9 @@ cmdScaleCoord(
* "snap" setting. This behavior remains in effect until the "units"
* command is used, in which case units follow the selected units
* value indepedendently of the snap setting.
*
* Updated 12/24/2026 to handle space-separated values (in which
* *endptr may be a space as well as NULL).
*/
if (DBWUnits == DBW_UNITS_DEFAULT)
curunits = DBWSnapToGrid;
@ -163,19 +166,22 @@ cmdScaleCoord(
curunits = DBWUnits & DBW_UNITS_TYPE_MASK;
if ((*endptr == 'l')
|| ((*endptr == '\0') && (curunits == DBW_UNITS_LAMBDA)))
|| (((*endptr == '\0') || isspace(*endptr))
&& (curunits == DBW_UNITS_LAMBDA)))
{
/* lambda or default units */
dval *= (double)DBLambda[1];
dval /= (double)DBLambda[0];
}
else if ((*endptr == 'i')
|| ((*endptr == '\0') && (curunits == DBW_UNITS_INTERNAL)))
|| (((*endptr == '\0') || isspace(*endptr))
&& (curunits == DBW_UNITS_INTERNAL)))
{
/* internal units */
}
else if ((*endptr == 'g')
|| ((*endptr == '\0') && (curunits == DBW_UNITS_USER)))
|| (((*endptr == '\0') || isspace(*endptr))
&& (curunits == DBW_UNITS_USER)))
{
/* grid units */
if (w == (MagWindow *)NULL)
@ -203,11 +209,12 @@ cmdScaleCoord(
dval += (double)crec->dbw_gridRect.r_ybot;
}
}
else if (*endptr == '\0' && (curunits == DBW_UNITS_MICRONS))
else if (((*endptr == '\0') || isspace(*endptr))
&& (curunits == DBW_UNITS_MICRONS))
{
mscale = 1000;
}
else
else if (*endptr != '\0')
{
/* natural units referred to the current cifoutput style */
if (*(endptr + 1) == 'm')
@ -249,7 +256,7 @@ cmdScaleCoord(
mscale = -1;
}
}
if ((mscale != -1) && !isspace(*endptr))
if (mscale != -1)
dval /= CIFGetOutputScale(mscale);
curval = round(dval);
@ -297,9 +304,13 @@ cmdScaleCoord(
parseop = PARSEOP_DIV;
endptr++;
break;
default:
case ' ':
case '\t':
endptr++;
break;
default:
/* Should this flag an error? */
return retval;
}
if (parseop != PARSEOP_NONE) break;
}

View File

@ -45,10 +45,12 @@ view [get|bbox|llx lly urx ury]
center and scale the screen view of the layout window to fit the layout. <P>
<B>view bbox</B> returns the bounding box dimensions of the layout,
in the coordinate system of the layout. <P>
in the coordinate system of the layout (according to the units
set by the "units" command). <P>
<B>view get</B> returns the coordinates of the screen limits in
the coordinate system of the layout (internal database units). <P>
the coordinate system of the layout (according to the units set
by the "units" command). <P>
<B>view</B> <I>llx lly urx ury</I> sets the view so that the
corners of the screen are at the indicated positions in the

View File

@ -120,61 +120,61 @@ macro Control_XK_space "tool wiring"
# Arrow keys (X11 versions only)
macro XK_Left "scroll l .1 w"
macro Shift_XK_Left "scroll l 1 w"
macro Control_XK_Left "box grow w 1"
macro Control_Shift_XK_Left "box shrink e 1"
macro Control_XK_Left "box grow w 1i"
macro Control_Shift_XK_Left "box shrink e 1i"
macro XK_Right "scroll r .1 w"
macro Shift_XK_Right "scroll r 1 w"
macro Control_XK_Right "box grow e 1"
macro Control_Shift_XK_Right "box shrink w 1"
macro Control_XK_Right "box grow e 1i"
macro Control_Shift_XK_Right "box shrink w 1i"
macro XK_Up "scroll u .1 w"
macro Shift_XK_Up "scroll u 1 w"
macro Control_XK_Up "box grow n 1"
macro Control_Shift_XK_Up "box shrink s 1"
macro Control_XK_Up "box grow n 1i"
macro Control_Shift_XK_Up "box shrink s 1i"
macro XK_Down "scroll d .1 w"
macro Shift_XK_Down "scroll d 1 w"
macro Control_XK_Down "box grow s 1"
macro Control_Shift_XK_Down "box shrink n 1"
macro Control_XK_Down "box grow s 1i"
macro Control_Shift_XK_Down "box shrink n 1i"
# Keypad keys (X11 versions only)
# Functions duplicated for use both with Num_Lock ON and OFF
macro XK_KP_Delete "box size 0 0"
macro XK_KP_Insert "box size 4 4"
macro XK_KP_0 "box size 7 2"
macro Shift_XK_KP_0 "box size 7 2"
macro XK_0 "box size 7 2"
macro Control_XK_KP_0 "box size 2 7"
macro Control_XK_KP_Insert "box size 2 7"
macro XK_KP_End "move sw 1"
macro XK_KP_Down "move d 1"
macro XK_KP_2 "stretch d 1"
macro XK_KP_Insert "box size 4l 4l"
macro XK_KP_0 "box size 7l 2l"
macro Shift_XK_KP_0 "box size 7l 2l"
macro XK_0 "box size 7l 2l"
macro Control_XK_KP_0 "box size 2l 7l"
macro Control_XK_KP_Insert "box size 2l 7l"
macro XK_KP_End "move sw 1i"
macro XK_KP_Down "move d 1i"
macro XK_KP_2 "stretch d 1i"
macro Shift_XK_KP_2 "stretch d 1"
macro Shift_XK_KP_Down "stretch d 1"
macro Shift_XK_KP_Down "move d 1"
macro Control_XK_KP_Down "stretch d 1i"
macro XK_2 "stretch d 1"
macro XK_KP_Next "move se 1"
macro XK_KP_Left "move l 1"
macro XK_KP_4 "stretch l 1"
macro XK_2 "stretch d 1i"
macro XK_KP_Next "move se 1i"
macro XK_KP_Left "move l 1i"
macro XK_KP_4 "stretch l 1i"
macro Shift_XK_KP_4 "stretch l 1"
macro Shift_XK_KP_Left "stretch l 1"
macro Shift_XK_KP_Left "move l 1"
macro Control_XK_KP_Left "stretch l 1i"
macro XK_4 "stretch l 1"
macro XK_4 "stretch l 1i"
macro XK_KP_Begin "findbox zoom"
macro XK_KP_5 "findbox"
macro Shift_XK_KP_5 "findbox"
macro XK_5 "findbox"
macro XK_KP_Right "move r 1"
macro XK_KP_6 "stretch r 1"
macro XK_KP_Right "move r 1i"
macro XK_KP_6 "stretch r 1i"
macro Shift_XK_KP_6 "stretch r 1"
macro Shift_XK_KP_Right "stretch r 1"
macro Shift_XK_KP_Right "move r 1"
macro Control_XK_KP_Right "stretch r 1i"
macro XK_6 "stretch r 1"
macro XK_KP_Home "move nw 1"
macro XK_KP_Up "move u 1"
macro XK_KP_8 "stretch u 1"
macro XK_6 "stretch r 1i"
macro XK_KP_Home "move nw 1i"
macro XK_KP_Up "move u 1i"
macro XK_KP_8 "stretch u 1i"
macro Shift_XK_KP_8 "stretch u 1"
macro Shift_XK_KP_Up "stretch u 1"
macro Shift_XK_KP_Up "move u 1"
macro Control_XK_KP_Up "stretch u 1i"
macro XK_8 "stretch u 1"
macro XK_KP_Prior "move ne 1"
macro XK_8 "stretch u 1i"
macro XK_KP_Prior "move ne 1i"
# Scroll wheel bindings
macro XK_Pointer_Button4 "scroll u .05 w"
macro XK_Pointer_Button5 "scroll d .05 w"

View File

@ -46,14 +46,14 @@ proc magic::drccallback {command} {
}
zoom {
if {$value != {}} {
set snaptype [snap]
snap internal
set curunits [units]
units internal
box values {*}$value
magic::suspendall
magic::findbox zoom
magic::zoom 2
magic::resumeall
snap $snaptype
units $curunits
}
}
}

View File

@ -250,10 +250,10 @@ proc magic::change_label {} {
setlabel size ${lsize}um
}
if {$loff != ""} {
set oldsnap [snap list]
snap internal
set oldunits [units]
units internal
setlabel offset [join $loff]
snap $oldsnap
units $oldunits
}
if {$lrot != ""} {
setlabel rotate $lrot

View File

@ -813,8 +813,8 @@ proc magic::gencell_change {instname gencell_type library parameters} {
return
}
set snaptype [snap list]
snap internal
set curunits [units]
units internal
set savebox [box values]
catch {setpoint 0 0 $Opts(focus)}
@ -881,7 +881,7 @@ proc magic::gencell_change {instname gencell_type library parameters} {
}
identify $newinstname
eval "box values $savebox"
snap $snaptype
units $curunits
# Update window
if {$gname != $old_gname} {
@ -940,8 +940,8 @@ proc magic::gencell_change_orig {instname gencell_type library parameters} {
return
}
set snaptype [snap list]
snap internal
set curunits [units]
units internal
set savebox [box values]
catch {setpoint 0 0 $Opts(focus)}
@ -969,7 +969,7 @@ proc magic::gencell_change_orig {instname gencell_type library parameters} {
}
identify $newinstname
eval "box values $savebox"
snap $snaptype
units $curunits
resumeall
redraw
}
@ -1092,8 +1092,8 @@ proc magic::gencell_create {gencell_type library parameters {orient 0}} {
set parameters [dict remove $parameters gencell]
}
set snaptype [snap list]
snap internal
set curunits [units]
units internal
set savebox [box values]
catch {setpoint 0 0 $Opts(focus)}
@ -1123,7 +1123,7 @@ proc magic::gencell_create {gencell_type library parameters {orient 0}} {
identify $newinstname
set instname $newinstname
}
snap $snaptype
units $curunits
resumeall
redraw
return $instname

View File

@ -138,7 +138,11 @@ proc magic::pushstack {{name ""}} {
if {[catch {lindex $editstack end}]} {
set editstack {}
}
# Protect against changing units by always using internal units
set curunits [units]
units internal
lappend editstack [view get]
units $curunits
lappend editstack [cellname list window]
set ltag [tag load]
tag load {}
@ -158,10 +162,11 @@ proc magic::popstack {} {
tag load {}
suspendall
load [lindex $editstack end]
set snaptype [snap]
snap internal
# Protect against changing units by always using internal units
set curunits [units]
units internal
view [lindex $editstack end-1]
snap $snaptype
units $curunits
catch {magic::cellmanager}
catch {magic::captions}
resumeall
@ -186,8 +191,8 @@ proc magic::clearstack {} {
proc magic::pushbox {{values {}}} {
global boxstack
set snaptype [snap list]
snap internal
set curunits [units]
units internal
if {[catch {set boxstack}]} {
set boxstack {}
}
@ -196,7 +201,7 @@ proc magic::pushbox {{values {}}} {
} else {
lappend boxstack $values
}
snap $snaptype
units $curunits
return
}
@ -210,8 +215,8 @@ proc magic::pushbox {{values {}}} {
proc magic::popbox {{type values}} {
global boxstack
set snaptype [snap list]
snap internal
set curunits [units]
units internal
if {[catch {set boxstack}]} {
error "No stack"
} elseif {$boxstack == {}} {
@ -231,7 +236,7 @@ proc magic::popbox {{type values}} {
}
}
set boxstack [lrange $boxstack 0 end-1]
snap $snaptype
units $curunits
return $b
}
@ -355,8 +360,8 @@ proc magic::ruler {{text {}} {orient auto}} {
set mmx [expr {($llx + $urx) / 2}]
set mmy [expr {($lly + $ury) / 2}]
set snapsave [snap]
snap internal
set curunits [units]
units internal
if {$orient == "horizontal"} {
element add line l1_$Opts(rulers) black $llx $lly $llx $ury
@ -410,7 +415,7 @@ proc magic::ruler {{text {}} {orient auto}} {
element configure l3_$Opts(rulers) flags arrowbottom
}
}
snap $snapsave
units $curunits
}
#---------------------------------------------------------------------

View File

@ -828,9 +828,9 @@ proc magic::setscrollvalues {win} {
global Opts
*bypass logcommands suspend
set svalues [${win} view get]
set curunits [units list]
units internal noprint
set svalues [${win} view get]
set bvalues [${win} view bbox]
units {*}$curunits

View File

@ -820,22 +820,27 @@ windViewCmd(w, cmd)
if (!strncmp(cmd->tx_argv[1], "get", 3))
{
char *vllx, *vlly, *vurx, *vury;
vllx = DBWPrintValue(w->w_surfaceArea.r_xbot, w, TRUE);
vlly = DBWPrintValue(w->w_surfaceArea.r_ybot, w, FALSE);
vurx = DBWPrintValue(w->w_surfaceArea.r_xtop, w, TRUE);
vury = DBWPrintValue(w->w_surfaceArea.r_ytop, w, FALSE);
/* NOTE: The surface area is in screen (pixel) coordinates
* and so does not follow the "units" display type.
*/
#ifndef MAGIC_WRAPPER
TxPrintf("(%d, %d) to (%d, %d)\n",
w->w_surfaceArea.r_xbot, w->w_surfaceArea.r_ybot,
w->w_surfaceArea.r_xtop, w->w_surfaceArea.r_ytop);
TxPrintf("(%s, %s) to (%s, %s)\n", vllx, vlly, vurx, vury);
#else
Tcl_ListObjAppendElement(magicinterp, listxy,
Tcl_NewIntObj((int)w->w_surfaceArea.r_xbot));
Tcl_NewStringObj(vllx, -1));
Tcl_ListObjAppendElement(magicinterp, listxy,
Tcl_NewIntObj((int)w->w_surfaceArea.r_ybot));
Tcl_NewStringObj(vlly, -1));
Tcl_ListObjAppendElement(magicinterp, listxy,
Tcl_NewIntObj((int)w->w_surfaceArea.r_xtop));
Tcl_NewStringObj(vurx, -1));
Tcl_ListObjAppendElement(magicinterp, listxy,
Tcl_NewIntObj((int)w->w_surfaceArea.r_ytop));
Tcl_NewStringObj(vury, -1));
Tcl_SetObjResult(magicinterp, listxy);
#endif
}