home
/
code
/
cellular-automata.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add terminal color manipulation.
[cellular-automata.git]
/
polymorphism
/
001
/
src
/
polymorphism.ml
diff --git
a/polymorphism/001/src/polymorphism.ml
b/polymorphism/001/src/polymorphism.ml
index
af46bc5
..
cb65462
100644
(file)
--- a/
polymorphism/001/src/polymorphism.ml
+++ b/
polymorphism/001/src/polymorphism.ml
@@
-198,12
+198,30
@@
end
module Terminal : sig
module Terminal : sig
+ type color = [ `green
+ | `red
+ ]
+
+ val string_with_color : string -> color -> string
+
val clear : unit -> unit
val clear : unit -> unit
+
val reset : unit -> unit
end = struct
val reset : unit -> unit
end = struct
+ type color = [ `green
+ | `red
+ ]
+
let ansi_code_clear = "\027[2J" (* Clear screen *)
let ansi_code_reset = "\027[1;1H" (* Reset cursor position *)
let ansi_code_clear = "\027[2J" (* Clear screen *)
let ansi_code_reset = "\027[1;1H" (* Reset cursor position *)
+ let string_of_color = function
+ | `green -> "\027[0;32m"
+ | `red -> "\027[1;31m"
+
+ let string_with_color s c =
+ sprintf "%s%s\027[0m" (string_of_color c) s
+
let clear () =
print_string ansi_code_clear
let clear () =
print_string ansi_code_clear
This page took
0.02653 seconds
and
4
git commands to generate.