[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 : jwilke 1.2 \ Output 13feb93py
22 :    
23 :     has-os [IF]
24 :     0 Value outfile-id ( -- file-id ) \ gforth
25 :    
26 :     : (type) ( c-addr u -- ) \ gforth
27 :     outfile-id write-file drop \ !! use ?DUP-IF THROW ENDIF instead of DROP ?
28 :     ;
29 :    
30 :     : (emit) ( c -- ) \ gforth
31 :     outfile-id emit-file drop \ !! use ?DUP-IF THROW ENDIF instead of DROP ?
32 :     ;
33 :     [THEN]
34 :    
35 :     Defer type ( c-addr u -- ) \ core
36 :     ' (type) IS Type
37 :    
38 :     Defer emit ( c -- ) \ core
39 :     ' (Emit) IS Emit
40 :    
41 :     Defer key ( -- c ) \ core
42 :     ' (key) IS key
43 :    
44 :     : (.") "lit count type ;
45 :     : (S") "lit count ;
46 :    
47 : anton 1.1 \ Input 13feb93py
48 :    
49 :     07 constant #bell ( -- c ) \ gforth
50 :     08 constant #bs ( -- c ) \ gforth
51 :     09 constant #tab ( -- c ) \ gforth
52 :     7F constant #del ( -- c ) \ gforth
53 :     0D constant #cr ( -- c ) \ gforth
54 :     \ the newline key code
55 :     0C constant #ff ( -- c ) \ gforth
56 :     0A constant #lf ( -- c ) \ gforth
57 :    
58 :     : bell #bell emit [ has-os [IF] ] outfile-id flush-file drop [ [THEN] ] ;
59 :     : cr ( -- ) \ core
60 :     \ emit a newline
61 :     [ ?? has-crlf [IF] ] #cr emit #lf emit
62 :     [ [ELSE] ] #lf emit
63 :     [ [THEN] ]
64 :     ;
65 :    
66 :     1 [IF]
67 :     \ space spaces 21mar93py
68 :     decimal
69 :     Create spaces ( u -- ) \ core
70 :     bl 80 times \ times from target compiler! 11may93jaw
71 :     DOES> ( u -- )
72 :     swap
73 :     0 max 0 ?DO I' I - &80 min 2dup type +LOOP drop ;
74 :     Create backspaces
75 :     08 80 times \ times from target compiler! 11may93jaw
76 :     DOES> ( u -- )
77 :     swap
78 :     0 max 0 ?DO I' I - &80 min 2dup type +LOOP drop ;
79 :     hex
80 :     : space ( -- ) \ core
81 :     1 spaces ;
82 :     [ELSE]
83 :     : space bl emit ;
84 :     : spaces 0 max 0 ?DO space LOOP ;
85 :    
86 :     [THEN]
87 :    

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help