Index: user/marc/box.rx =================================================================== --- user/marc/box.rx +++ user/marc/box.rx @@ -4,13 +4,14 @@ ( Copyright [c] 2011, Marc Simpson ) ( License: ISC ) ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) ( Example usage: ) ( ) -( [1] here 10 , 20 , 30 , 3 .cells ) -( [2] here .cell ) -( [3] thread' : ) +( [1] here 10 , 20 , 30 , 3 .cells ) +( [2] here .cell ) +( [3] thread' : ) +( [4] 668 .thread ) ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) include introspection.rx chain: box' @@ -42,16 +43,19 @@ @escCell [ toString escCell off ] [ instr? [ [ escCell on ] ifTrue ] [ xt->name ] if ] if ; : .lookup ( a- ) '| putc space lookup .pads space '| putc ; - : .edge ( - ) '+ putc '- @boxWidth 2 - putcs '+ putc ; - : .rule ( - ) '| putc '- @boxWidth 2 - putcs '| putc ; + : .fill ( c- ) @boxWidth @boxMargin 2 - - putcs ; + : .edge ( - ) '+ putc '- .fill '+ putc ; + : .rule ( - ) '| putc '- .fill '| putc ; ( --[ Diagram for N contiguous cells ]---------------------- ) - here dup 6 allot constant boxtbl + 6 constant boxRows + + here dup boxRows allot constant boxtbl [ ( a- ) .edge drop ; ] over ! 1+ [ ( a- ) .boxedn ; ] over ! 1+ [ ( a- ) .rule drop ; ] over ! 1+ [ ( a- ) @ .boxedn ; ] over ! 1+ [ ( a- ) @ .lookup ; ] over ! 1+ @@ -73,18 +77,19 @@ : findRet ( a-na ) 1 swap repeat dup ret? if; swap 1+ swap 1+ again ; ---reveal--- : .cells ( an- ) - dup box/line @ > - [ box/line @ - push @box/line (.cells) drop + pop .cells ] + dup @box/line > + [ @box/line - push @box/line (.cells) drop + pop .cells ] [ (.cells) 2drop drop ] if ; : .cell ( a- ) 1 .cells ; - : thread' ( "- ) ' dup findRet drop .cells ; + : .thread ( a- ) dup findRet drop .cells ; + : thread' ( "- ) ' .thread ; }} ;chain global with box' ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ )