\ BOXTEXT.SEQ   Some simple boxes around text.          by Tom Zimmer

comment:

        BOXTEXT.SEQ

          A cute little routine that works like ." to print messages
        to the screen.  The difference here is that .BOX" requires an
        X and Y coordinate of where to start printing the message,
        and it also prints a box around your text string, with
        graphic line draw characters.  .BOX" is used as follows:

                : boxtest       ( --- )
                                10 10 .box" hello there"
                                15 20 .box" This is a box test" ;

          As you can see it is used like ." .

comment;

0 constant tx   0 constant ty
0 constant bx   0 constant by

: box           ( left top right bottom --- )
                =: by =: bx =: ty =: tx
                tx ty at
                218 FEMIT
                bx tx - 1- 0 max 0
               ?do      196 FEMIT
                loop    191 FEMIT
                tx by at
                192 FEMIT
                bx tx - 1- 0 max 0
               ?do      196 FEMIT
                loop    217 FEMIT
                by ty 1+
               ?do      tx i at 179 FEMIT
                        bx i at 179 FEMIT
                loop    ;

: (.box)        ( x y --- )
                X>"BUF
                >r over r@ c@ + 3 + over 2+ box
                tx 1+ ty 1+ at bl FEMIT r> count type bl FEMIT
                bx by 1+ at ;

: .box"         ( x y text --- )
                compile (.box) X," ; immediate


\s
: boxsample     ( --- )
                20 2
                do      i 2* i .box" Ziping along!"
                loop
                10 10 .box" hello this is a sample of BOXED TEXT"
                20 15 .box" Here is even more text!!" ;

boxsample

