Release coccinelle-0.1
[bpt/coccinelle.git] / commons / ocamlextra / ANSITerminal.mli
1 (* File: ANSITerminal.mli
2
3 Copyright 2004 Troestler Christophe
4 Christophe.Troestler(at)umh.ac.be
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public License
8 version 2.1 as published by the Free Software Foundation, with the
9 special exception on linking described in file LICENSE.
10
11 This library is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file
14 LICENSE for more details.
15 *)
16 (** This module offers basic control of ANSI compliant terminals.
17
18 @author Christophe Troestler
19 @version 0.3
20 *)
21
22 (** {2 Color} *)
23
24 type color =
25 | Black | Red | Green | Yellow | Blue | Magenta | Cyan | White
26 | Default (** Default color of the terminal *)
27
28 (** Various styles for the text. [Blink] and [Hidden] may not work on
29 every terminal. *)
30 type style =
31 | Reset
32 | Bold | Underlined | Blink | Inverse | Hidden
33 | Foreground of color
34 | Background of color
35
36 val black : style (** Shortcut for [Foreground Black] *)
37 val red : style (** Shortcut for [Foreground Red] *)
38 val green : style (** Shortcut for [Foreground Green] *)
39 val yellow : style (** Shortcut for [Foreground Yellow] *)
40 val blue : style (** Shortcut for [Foreground Blue] *)
41 val magenta : style (** Shortcut for [Foreground Magenta] *)
42 val cyan : style (** Shortcut for [Foreground Cyan] *)
43 val white : style (** Shortcut for [Foreground White] *)
44 val default : style (** Shortcut for [Foreground Default] *)
45
46 val on_black : style (** Shortcut for [Background Black] *)
47 val on_red : style (** Shortcut for [Background Red] *)
48 val on_green : style (** Shortcut for [Background Green] *)
49 val on_yellow : style (** Shortcut for [Background Yellow] *)
50 val on_blue : style (** Shortcut for [Background Blue] *)
51 val on_magenta : style (** Shortcut for [Background Magenta] *)
52 val on_cyan : style (** Shortcut for [Background Cyan] *)
53 val on_white : style (** Shortcut for [Background White] *)
54 val on_default : style (** Shortcut for [Background Default] *)
55
56 val set_autoreset : bool -> unit
57 (** Turns the autoreset feature on and off. It defaults to on. *)
58
59 val print_string : style list -> string -> unit
60 (** [print_string attr txt] prints the string [txt] with the
61 attibutes [attr]. After printing, the attributes are
62 automatically reseted to the defaults, unless autoreset is turned
63 off. *)
64
65 val printf : style list -> ('a, unit, string, unit) format4 -> 'a
66 (** [printf attr format arg1 ... argN] prints the arguments
67 [arg1],...,[argN] according to [format] with the attibutes [attr].
68 After printing, the attributes are automatically reseted to the
69 defaults, unless autoreset is turned off. *)
70
71
72 (** {2 Erasing} *)
73
74 type loc = Above | Below | Screen
75
76 val erase : loc -> unit
77 (** [erase Above] erases everything before the position of the cursor.
78 [erase Below] erases everything after the position of the cursor.
79 [erase Screen] erases the whole screen.
80 *)
81
82
83 (** {2 Cursor} *)
84
85 val set_cursor : int -> int -> unit
86 (** [set_cursor x y] puts the cursor at position [(x,y)], [x]
87 indicating the column (the leftmost one being 1) and [y] being the
88 line (the topmost one being 1). If [x <= 0], the [x] coordinate
89 is unchanged; if [y <= 0], the [y] coordinate is unchanged. *)
90
91 val move_cursor : int -> int -> unit
92 (** [move_cursor x y] moves the cursor by [x] columns (to the right
93 if [x > 0], to the left if [x < 0]) and by [y] lines (downwards if
94 [y > 0] and upwards if [y < 0]). *)
95
96 val save_cursor : unit -> unit
97 (** [save_cursor()] saves the current position of the cursor. *)
98 val restore_cursor : unit -> unit
99 (** [restore_cursor()] replaces the cursor to the position saved
100 with [save_cursor()]. *)
101
102
103 (** {2 Scrolling} *)
104
105 val scroll : int -> unit
106 (** [scroll n] scrolls the terminal by [n] lines, up (creating new
107 lines at the bottom) if [n > 0] and down if [n < 0]. *)