FormatRow |
HyperLib.gtl |
985 |
1012 |
let FormatRow(t, ColumnWidths) = \formatted output of a tuple by column widths
{ let w = 0 in
let f = getfont() in
FormatLines := 0;
for i = 0 to order t - 1 in
{ let X = $(t i) in
let x, y = curX(), curY() in
let tx = gettextcolour() in
let Rj = 0 in
if i < order ColumnWidths do w := ColumnWidths i;
if i < order FormatColour do textcolour(FormatColour i);
if isdate X do { X := date2string X } else
if isref X do { X := r2s X." "; Rj := 1 };
if isi64 X do { Rj := 1 };
if isnum X do { X := X:(10, i >= order FormatDecimal -> 2| FormatDecimal i)." "; Rj := 1 };
if istuple X do X := Tuple2String X;
if isstring X & length X & X 0 = ">" do { X := stern X." "; Rj := 1 };
if Rj do { coord(w-textlength " ", 0); justify(RIGHT, HORIZONTAL) };
if isstring X do (FormatMulti -> FitMulti| FitText)(#X, w) else
if islambda X do X() else
X;
if Rj do justify(LEFT, HORIZONTAL);
FormatSeperator;
textcolour tx;
absco(x+w, y)
};
coord(0, FormatLines*curL())
} in