CVS: sml/src/smlnj-lib/PP/devices ansi-term-pp.sml,NONE,1.1 ansi-term-dev.sml,1.1,1.2 sources.cm,1.6,1.7 textio-pp.sml,1.2,1.3
John Reppy <[email protected]>
| Newsgroups | gmane.comp.lang.sml.smlnj.commits |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/smlnj/sml/src/smlnj-lib/PP/devices
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29262
Modified Files:
ansi-term-dev.sml sources.cm textio-pp.sml
Added Files:
ansi-term-pp.sml
Log Message:
Added PP stream based on ANSITermDev. ANSITermDev now sets the initial
mode based on the kind of the output stream (TTY enables styles).
--- NEW FILE: ansi-term-pp.sml ---
(* ansi-term-pp.sml
*
* COPYRIGHT (c) 2005 John Reppy (http://www.cs.uchicago.edu/~jhr)
* All rights reserved.
*)
structure ANSITermPP : sig
structure Tok : sig
include PP_TOKEN
where type style = ANSITermDev.style
val token : (ANSITermDev.style * string) -> token
end
include PP_STREAM
where type device = ANSITermDev.device
where type style = ANSITermDev.style
where type token = Tok.token
val openOut : {dst : TextIO.outstream, wid : int} -> stream
end = struct
structure Tok =
struct
type style = ANSITermDev.style
datatype token = Tok of (style * string)
fun string (Tok(sty, s)) = s
fun style (Tok(sty, s)) = sty
fun size (Tok(sty, s)) = String.size s
val token = Tok
end
structure PP = PPStreamFn (
structure Token = Tok
structure Device = ANSITermDev)
open PP
fun openOut arg = openStream(ANSITermDev.openDev arg)
end
Index: ansi-term-dev.sml
===================================================================
RCS file: /cvsroot/smlnj/sml/src/smlnj-lib/PP/devices/ansi-term-dev.sml,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ansi-term-dev.sml 7 Jul 2005 04:15:57 -0000 1.1
--- ansi-term-dev.sml 12 Jul 2005 22:08:28 -0000 1.2
***************
*** 152,161 ****
fun defaultStyle _ = []
! fun openDev {dst, wid} = let
! (* FIXME: compute mode based on file type *)val mode = true
in
! DEV{dst = dst, wid = wid, mode = ref mode, stk = ref[]}
end
(* maximum printing depth (in terms of boxes) *)
fun depth _ = NONE
--- 152,169 ----
fun defaultStyle _ = []
! (* return true if an outstream is a TTY *)
! fun isTTY outS = let
! val (TextPrimIO.WR{ioDesc, ...}, _) =
! TextIO.StreamIO.getWriter(TextIO.getOutstream outS)
in
! case ioDesc
! of SOME iod => (OS.IO.kind iod = OS.IO.Kind.tty)
! | _ => false
end
+ fun openDev {dst, wid} = DEV{
+ dst = dst, wid = wid, mode = ref(isTTY dst), stk = ref[]
+ }
+
(* maximum printing depth (in terms of boxes) *)
fun depth _ = NONE
Index: sources.cm
===================================================================
RCS file: /cvsroot/smlnj/sml/src/smlnj-lib/PP/devices/sources.cm,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** sources.cm 18 Oct 2004 21:45:30 -0000 1.6
--- sources.cm 12 Jul 2005 22:08:28 -0000 1.7
***************
*** 6,9 ****
--- 6,11 ----
structure TextIOPP
+ structure ANSITermDev
+ structure ANSITermPP
structure SimpleTextIODev
structure HTMLDev
***************
*** 11,14 ****
--- 13,17 ----
is
+
#if defined(NEW_CM)
$/basis.cm
***************
*** 23,26 ****
--- 26,31 ----
textio-pp.sml
+ ansi-term-dev.sml
+ ansi-term-pp.sml
simple-textio-dev.sml
string-token.sml
Index: textio-pp.sml
===================================================================
RCS file: /cvsroot/smlnj/sml/src/smlnj-lib/PP/devices/textio-pp.sml,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** textio-pp.sml 1 Jun 2000 18:33:54 -0000 1.2
--- textio-pp.sml 12 Jul 2005 22:08:28 -0000 1.3
***************
*** 10,13 ****
--- 10,14 ----
include PP_STREAM
+ where type token = string
val openOut : {dst : TextIO.outstream, wid : int} -> stream
***************
*** 15,29 ****
end = struct
- structure Tok : PP_TOKEN =
- struct
- type style = unit
- type token = Atom.atom
- val string = Atom.toString
- fun style _ = ()
- fun size s = String.size(Atom.toString s)
- end
-
structure PP = PPStreamFn (
! structure Token = Tok
structure Device = SimpleTextIODev)
--- 16,21 ----
end = struct
structure PP = PPStreamFn (
! structure Token = StringToken
structure Device = SimpleTextIODev)
-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar