1------------------------------------------------------------------------------
2--                                                                          --
3--                           GPR PROJECT MANAGER                            --
4--                                                                          --
5--          Copyright (C) 2001-2015, Free Software Foundation, Inc.         --
6--                                                                          --
7-- This library is free software;  you can redistribute it and/or modify it --
8-- under terms of the  GNU General Public License  as published by the Free --
9-- Software  Foundation;  either version 3,  or (at your  option) any later --
10-- version. This library is distributed in the hope that it will be useful, --
11-- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- --
12-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            --
13--                                                                          --
14-- As a special exception under Section 7 of GPL version 3, you are granted --
15-- additional permissions described in the GCC Runtime Library Exception,   --
16-- version 3.1, as published by the Free Software Foundation.               --
17--                                                                          --
18-- You should have received a copy of the GNU General Public License and    --
19-- a copy of the GCC Runtime Library Exception along with this program;     --
20-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
21-- <http://www.gnu.org/licenses/>.                                          --
22--                                                                          --
23------------------------------------------------------------------------------
24
25--  This package contains low level output routines for writing error messages
26--  and informational output.
27
28pragma Warnings (Off);
29--  This package is used also by GNATCOLL.Projects
30with System.OS_Lib; use System.OS_Lib;
31pragma Warnings (On);
32
33package GPR.Output is
34   pragma Elaborate_Body;
35
36   type Output_Proc is access procedure (S : String);
37   --  This type is used for the Set_Special_Output procedure. If Output_Proc
38   --  is called, then instead of lines being written to standard error or
39   --  standard output, a call is made to the given procedure for each line,
40   --  passing the line with an end of line character (which is a single
41   --  ASCII.LF character, even in systems which normally use CR/LF or some
42   --  other sequence for line end).
43
44   -----------------
45   -- Subprograms --
46   -----------------
47
48   procedure Set_Special_Output (P : Output_Proc);
49   --  Sets subsequent output to call procedure P. If P is null, then the call
50   --  cancels the effect of a previous call, reverting the output to standard
51   --  error or standard output depending on the mode at the time of previous
52   --  call. Any exception generated by calls to P is simply propagated to
53   --  the caller of the routine causing the write operation.
54
55   procedure Cancel_Special_Output;
56   --  Cancels the effect of a call to Set_Special_Output, if any. The output
57   --  is then directed to standard error or standard output depending on the
58   --  last call to Set_Standard_Error or Set_Standard_Output. It is never an
59   --  error to call Cancel_Special_Output. It has the same effect as calling
60   --  Set_Special_Output (null).
61
62   procedure Set_Standard_Error;
63   --  Sets subsequent output to appear on the standard error file (whatever
64   --  that might mean for the host operating system, if anything) when
65   --  no special output is in effect. When a special output is in effect,
66   --  the output will appear on standard error only after special output
67   --  has been cancelled.
68
69   procedure Set_Standard_Output;
70   --  Sets subsequent output to appear on the standard output file (whatever
71   --  that might mean for the host operating system, if anything) when no
72   --  special output is in effect. When a special output is in effect, the
73   --  output will appear on standard output only after special output has been
74   --  cancelled. Output to standard output is the default mode before any call
75   --  to either of the Set procedures.
76
77   function Column return Pos;
78   pragma Inline (Column);
79   --  Returns the number of the column about to be written (e.g. a value of 1
80   --  means the current line is empty).
81
82   procedure Write_Char (C : Character);
83   --  Write one character to the standard output file. If the character is LF,
84   --  this is equivalent to Write_Eol.
85
86   procedure Write_Eol;
87   --  Write an end of line (whatever is required by the system in use, e.g.
88   --  CR/LF for DOS, or LF for Unix) to the standard output file. This routine
89   --  also empties the line buffer, actually writing it to the file. Note that
90   --  Write_Eol is the only routine that causes any actual output to be
91   --  written. Trailing spaces are removed.
92
93   procedure Write_Int (Val : Int);
94   --  Write an integer value with no leading blanks or zeroes. Negative values
95   --  are preceded by a minus sign).
96
97   procedure Write_Str (S : String);
98   --  Write a string of characters to the standard output file. Note that
99   --  end of line is normally handled separately using WRITE_EOL, but it is
100   --  allowable for the string to contain LF (but not CR) characters, which
101   --  are properly interpreted as end of line characters. The string may also
102   --  contain horizontal tab characters.
103
104   procedure Write_Line (S : String);
105   --  Equivalent to Write_Str (S) followed by Write_Eol;
106
107end GPR.Output;
108