1 (* Copyright (C
) 1999-2006 Henry Cejtin
, Matthew Fluet
, Suresh
2 * Jagannathan
, and Stephen Weeks
.
4 * MLton is released under a BSD
-style license
.
5 * See the file MLton
-LICENSE for details
.
8 structure Console
: CONSOLE
=
11 (* Information from Chapter
20 of Linux Application Development
,
12 * by Johnson
and Troan
.
15 structure Background
=
17 datatype t
= Black | Red | Green | Brown | Blue | Magenta | Cyan | Gray
20 structure Foreground
=
23 DarkGray | BrightRed | BrightGreen | Yellow | BrightBlue
24 | BrightMagenta | BrightCyan | White
29 structure CharRendition
=
38 | UnderlineOnDefaultForeground
39 | UnderlineOffDefaultForeground
44 | Foreground
of Foreground
.t
45 | Background
of Background
.t
47 fun set(l
: t list
): string =
49 :: List.fold(rev l
, [], fn (c
, l
) =>
58 | UnderlineOff
=> "24"
59 | UnderlineOnDefaultForeground
=> "38"
60 | UnderlineOffDefaultForeground
=> "39"
63 | ReverseVideoOn
=> "7"
64 | ReverseVideoOff
=> "27"
66 let datatype z
= datatype Foreground
.t
73 | BrightMagenta
=> "35"
78 let datatype z
= datatype Background
.t
98 case Process
.getEnv
"COLUMNS" of
100 | SOME c
=> valOf(Int.fromString c
)
101 (* 300 is kind
of arbitrary
, but it
's what they
do in
102 * /etc
/sysconfig
/init
.
104 in concat
[esc
, "300C", esc
, Int.toString(columns
- c
), "D"]