|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
\ ==============================================================================
\
\ RubyFORTH -- Copyright (C) 2007-8, Marc Simpson (GPL).
\
\ Block to text converter. Assumes 64x16 blocks.
\
\ ==============================================================================
\ --[ Tools ]-------------------------------------------------------------------
: hr ( n -- ) 0 do char - emit loop ;
\ --[ Variables ]---------------------------------------------------------------
variable block-file
variable block#
\ --[ File Words ]--------------------------------------------------------------
: set-block-file ( filename$ -- ) r/o open block-file ! 0 block# ! ;
: read-next-line ( -- readline$ ) block-file @ 64 read ;
\ --[ Printing ]----------------------------------------------------------------
: spaces ( n -- ) 0 do space loop ;
: .margin ( -- ) ." | " ;
: .filler ( -- ) .margin 64 spaces .margin ;
: .line ( -- ) .margin read-next-line type .margin cr ;
: .heading ( -- )
block# @ dup 0 > if .filler then
cr ." +----[ Block: " 3 .r space
." ]-----------------------------------------------+"
cr .filler cr
;
\ --[ Blocks ]------------------------------------------------------------------
: eob? ( -- f ) block-file @ eof? ;
: block++ ( -- ) 1 block# +! ;
: .block ( -- ) .heading 16 0 do eob? if unloop else .line then loop ;
: .blocks ( -- ) cr begin eob? not while .block block++ repeat 67 hr ;
\ --[ Toplevel ]----------------------------------------------------------------
: deblock ( filename$ -- ) set-block-file .blocks ;
: deblock: ( "filename" -- ) bl parse deblock ;
\ ------------------------------------------------------------------------------