File tree 4 files changed +48
-5
lines changed
4 files changed +48
-5
lines changed Original file line number Diff line number Diff line change 1
1
OCAMLC = ocamlc
2
2
OCAMLOPT = ocamlopt
3
3
4
- AR = ocamlmklib
4
+ INTERFACES = pretty_types.cmi pretty.cmi
5
+ OPT_IMPLS = pretty.cmx
6
+ BYTE_IMPLS = pretty.cmo
5
7
6
- INTERFACES = pretty_types.mli pretty .mli
7
- IMPLEMENTATIONS = pretty.ml
8
+ % .cmi : % .mli
9
+ $( OCAMLC ) -o $@ -c $<
8
10
9
- pretty : $(INTERFACES ) $(IMPLEMENTATIONS )
10
- $(AR ) -o $@ $^
11
+ % .cmo : % .ml
12
+ $(OCAMLC ) -o $@ -c $<
13
+
14
+ % .cmx : % .ml
15
+ $(OCAMLOPT ) -o $@ -c $<
16
+
17
+ byte : $(INTERFACES ) $(BYTE_IMPLS )
18
+ $(OCAMLC ) -a -o pretty.cma unix.cma $(BYTE_IMPLS )
19
+
20
+ opt : $(INTERFACES ) $(OPT_IMPLS )
21
+ $(OCAMLOPT ) -a -o pretty.cmxa unix.cmxa $(OPT_IMPLS )
11
22
12
23
clean :
13
24
rm -f * .{a,cm* ,o,out}
Original file line number Diff line number Diff line change @@ -6,6 +6,15 @@ Supports the following functionality:
6
6
- Clearing/erasing text;
7
7
- Text attributes/colours.
8
8
9
+ Changes: 2012/07/19
10
+ - Fixed Makefile;
11
+ - Changed interface for Pretty.noecho_aux.
12
+
13
+ Changes: 2012/07/18
14
+ - No-echo utility functions;
15
+ - Required dependency: unix module;
16
+ - Turned off dynamic loading in Makefile.
17
+
9
18
More features to come!
10
19
11
20
For reference of ANSI/VT100 see: http://www.termsys.demon.co.uk/vtansi.htm
Original file line number Diff line number Diff line change @@ -135,3 +135,16 @@ let print_string ?(attrs = []) ?(x = -1) ?(y = -1) str =
135
135
in print_string (" \027 [" ^ y ^ " ;" ^ x ^ " H" ));
136
136
137
137
print_string_attrs ~attrs: attrs str
138
+
139
+ let noecho_aux fd f =
140
+ let open Unix in
141
+ let attrs = tcgetattr stdin in
142
+ tcsetattr fd TCSANOW { attrs with c_echo = false };
143
+ let ret = try f fd with
144
+ | ex -> tcsetattr fd TCSANOW attrs; raise ex
145
+ in
146
+ tcsetattr fd TCSANOW attrs; ret
147
+
148
+ let noecho_read_line () = noecho_aux Unix. stdin (fun fd -> read_line () )
149
+ let noecho_read_int () = noecho_aux Unix. stdin (fun fd -> read_int () )
150
+ let noecho_read_float () = noecho_aux Unix. stdin (fun fd -> read_float () )
Original file line number Diff line number Diff line change @@ -79,3 +79,13 @@ val print_custom : attribute list -> unit
79
79
* Supports printing text with decorative attributes applied.
80
80
*)
81
81
val print_string : ?attrs : attribute list -> ?x : int -> ?y : int -> string -> unit
82
+
83
+ (* Turn of echoing whilst reading input.
84
+ *
85
+ * NOTE:
86
+ * Restores echoing after completion.
87
+ *)
88
+ val noecho_aux : Unix .file_descr -> (Unix .file_descr -> 'a ) -> 'a
89
+ val noecho_read_line : unit -> string
90
+ val noecho_read_int : unit -> int
91
+ val noecho_read_float : unit -> float
You can’t perform that action at this time.
0 commit comments