Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/smlnj-lib/PP/devices/simple-textio-dev.sml
ViewVC logotype

Annotation of /sml/trunk/src/smlnj-lib/PP/devices/simple-textio-dev.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 651 - (view) (download)

1 : monnier 7 (* simple-textio-dev.sml
2 :     *
3 :     * COPYRIGHT (c) 1997 Bell Labs, Lucent Technologies.
4 :     *
5 :     * A simple (no styles) pretty-printing device for output to TextIO outstreams.
6 :     *)
7 :    
8 :     structure SimpleTextIODev : sig
9 :    
10 :     include PP_DEVICE
11 :    
12 :     val openDev : {dst : TextIO.outstream, wid : int} -> device
13 :    
14 :     end = struct
15 :    
16 :     datatype device = DEV of {
17 :     dst : TextIO.outstream,
18 :     wid : int
19 :     }
20 :    
21 :     (* no style support *)
22 :     type style = unit
23 :     fun sameStyle _ = true
24 :     fun pushStyle _ = ()
25 :     fun popStyle _ = ()
26 :     fun defaultStyle _ = ()
27 :    
28 :     val openDev = DEV
29 :    
30 :     (* maximum printing depth (in terms of boxes) *)
31 :     fun depth _ = NONE
32 :    
33 :     (* the width of the device *)
34 :     fun lineWidth (DEV{wid, ...}) = SOME wid
35 :     (* the suggested maximum width of text on a line *)
36 :     fun textWidth _ = NONE
37 :    
38 :     (* output some number of spaces to the device *)
39 :     fun space (DEV{dst, ...}, n) = TextIO.output (dst, StringCvt.padLeft #" " n "")
40 :    
41 :     (* output a new-line to the device *)
42 :     fun newline (DEV{dst, ...}) = TextIO.output1 (dst, #"\n")
43 :    
44 :     (* output a string/character in the current style to the device *)
45 :     fun string (DEV{dst, ...}, s) = TextIO.output (dst, s)
46 :     fun char (DEV{dst, ...}, c) = TextIO.output1 (dst, c)
47 :    
48 :     (* if the device is buffered, then flush any buffered output *)
49 :     fun flush (DEV{dst, ...}) = TextIO.flushOut dst
50 :    
51 :     end;
52 :    

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0