[gforth] / gforth / kernel / io.fs  

gforth: gforth/kernel/io.fs


1 : anton 1.1 \ input output basics (extra since) 02mar97jaw
2 :    
3 :     \ Copyright (C) 1995-1997 Free Software Foundation, Inc.
4 :    
5 :     \ This file is part of Gforth.
6 :    
7 :     \ Gforth is free software; you can redistribute it and/or
8 :     \ modify it under the terms of the GNU General Public License
9 :     \ as published by the Free Software Foundation; either version 2
10 :     \ of the License, or (at your option) any later version.
11 :    
12 :     \ This program is distributed in the hope that it will be useful,
13 :     \ but WITHOUT ANY WARRANTY; without even the implied warranty of
14 :     \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 :     \ GNU General Public License for more details.
16 :    
17 :     \ You should have received a copy of the GNU General Public License
18 :     \ along with this program; if not, write to the Free Software
19 :     \ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 :    
21 :     \ Input 13feb93py
22 :    
23 :     07 constant #bell ( -- c ) \ gforth
24 :     08 constant #bs ( -- c ) \ gforth
25 :     09 constant #tab ( -- c ) \ gforth
26 :     7F constant #del ( -- c ) \ gforth
27 :     0D constant #cr ( -- c ) \ gforth
28 :     \ the newline key code
29 :     0C constant #ff ( -- c ) \ gforth
30 :     0A constant #lf ( -- c ) \ gforth
31 :    
32 :     : bell #bell emit [ has-os [IF] ] outfile-id flush-file drop [ [THEN] ] ;
33 :     : cr ( -- ) \ core
34 :     \ emit a newline
35 :     [ ?? has-crlf [IF] ] #cr emit #lf emit
36 :     [ [ELSE] ] #lf emit
37 :     [ [THEN] ]
38 :     ;
39 :    
40 :     1 [IF]
41 :     \ space spaces 21mar93py
42 :     decimal
43 :     Create spaces ( u -- ) \ core
44 :     bl 80 times \ times from target compiler! 11may93jaw
45 :     DOES> ( u -- )
46 :     swap
47 :     0 max 0 ?DO I' I - &80 min 2dup type +LOOP drop ;
48 :     Create backspaces
49 :     08 80 times \ times from target compiler! 11may93jaw
50 :     DOES> ( u -- )
51 :     swap
52 :     0 max 0 ?DO I' I - &80 min 2dup type +LOOP drop ;
53 :     hex
54 :     : space ( -- ) \ core
55 :     1 spaces ;
56 :     [ELSE]
57 :     : space bl emit ;
58 :     : spaces 0 max 0 ?DO space LOOP ;
59 :    
60 :     [THEN]
61 :    
62 :     \ Output 13feb93py
63 :    
64 :     has-os [IF]
65 :     0 Value outfile-id ( -- file-id ) \ gforth
66 :    
67 :     : (type) ( c-addr u -- ) \ gforth
68 :     outfile-id write-file drop \ !! use ?DUP-IF THROW ENDIF instead of DROP ?
69 :     ;
70 :    
71 :     : (emit) ( c -- ) \ gforth
72 :     outfile-id emit-file drop \ !! use ?DUP-IF THROW ENDIF instead of DROP ?
73 :     ;
74 :     [THEN]
75 :    
76 :     Defer type ( c-addr u -- ) \ core
77 :     ' (type) IS Type
78 :    
79 :     Defer emit ( c -- ) \ core
80 :     ' (Emit) IS Emit
81 :    
82 :     Defer key ( -- c ) \ core
83 :     ' (key) IS key
84 :    
85 :     : (.") "lit count type ;
86 :     : (S") "lit count ;
87 :    

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help