2006-06-14 01:47:28 -04:00
|
|
|
! Copyright (C) 2003, 2006 Slava Pestov.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2005-08-19 21:46:12 -04:00
|
|
|
IN: io
|
2005-12-19 02:12:40 -05:00
|
|
|
USING: errors generic hashtables kernel namespaces sequences
|
|
|
|
strings styles ;
|
2005-08-19 21:46:12 -04:00
|
|
|
|
2005-12-19 02:12:40 -05:00
|
|
|
! Default stream
|
2005-12-16 21:12:35 -05:00
|
|
|
SYMBOL: stdio
|
|
|
|
|
|
|
|
: close ( -- ) stdio get stream-close ;
|
|
|
|
|
2005-12-19 02:12:40 -05:00
|
|
|
: readln ( -- string/f ) stdio get stream-readln ;
|
|
|
|
: read1 ( -- char/f ) stdio get stream-read1 ;
|
2005-12-16 21:12:35 -05:00
|
|
|
: read ( count -- string ) stdio get stream-read ;
|
|
|
|
|
|
|
|
: write1 ( char -- ) stdio get stream-write1 ;
|
|
|
|
: write ( string -- ) stdio get stream-write ;
|
|
|
|
: flush ( -- ) stdio get stream-flush ;
|
|
|
|
|
|
|
|
: terpri ( -- ) stdio get stream-terpri ;
|
2005-08-19 21:46:12 -04:00
|
|
|
: format ( string style -- ) stdio get stream-format ;
|
2005-12-16 22:24:39 -05:00
|
|
|
|
|
|
|
: with-nesting ( style quot -- )
|
|
|
|
swap stdio get with-nested-stream ;
|
2005-12-16 21:12:35 -05:00
|
|
|
|
2006-06-09 22:17:12 -04:00
|
|
|
: tabular-output ( grid style quot -- )
|
2006-06-14 02:27:57 -04:00
|
|
|
swap stdio get with-stream-table ;
|
2006-06-07 23:04:37 -04:00
|
|
|
|
2006-06-20 18:31:48 -04:00
|
|
|
: with-style ( style quot -- )
|
|
|
|
swap stdio get with-stream-style ;
|
|
|
|
|
2005-12-16 21:12:35 -05:00
|
|
|
: print ( string -- ) stdio get stream-print ;
|
2005-08-19 21:46:12 -04:00
|
|
|
|
|
|
|
: with-stream* ( stream quot -- )
|
2006-01-21 02:37:39 -05:00
|
|
|
[ swap stdio set call ] with-scope ; inline
|
|
|
|
|
|
|
|
: with-stream ( stream quot -- )
|
|
|
|
swap [ [ close ] cleanup ] with-stream* ; inline
|
2005-12-19 02:12:40 -05:00
|
|
|
|
2006-06-14 01:47:28 -04:00
|
|
|
: bl ( -- ) " " write ;
|
2005-12-19 02:12:40 -05:00
|
|
|
|
2006-06-14 01:47:28 -04:00
|
|
|
: write-object ( string object -- )
|
|
|
|
presented associate format ;
|
2006-05-19 00:19:08 -04:00
|
|
|
|
2006-06-14 01:47:28 -04:00
|
|
|
: write-outliner ( string object content -- )
|
|
|
|
outline associate [ write-object ] with-nesting ;
|