1------------------------------------------------------------------------------
2--                                                                          --
3--                         GNAT RUN-TIME COMPONENTS                         --
4--                                                                          --
5--                       ADA.STRINGS.TEXT_OUTPUT.UTILS                      --
6--                                                                          --
7--                                 S p e c                                  --
8--                                                                          --
9--            Copyright (C) 2020, Free Software Foundation, Inc.            --
10--                                                                          --
11-- GNAT is free software;  you can  redistribute it  and/or modify it under --
12-- terms of the  GNU General Public License as published  by the Free Soft- --
13-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
14-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
17--                                                                          --
18-- As a special exception under Section 7 of GPL version 3, you are granted --
19-- additional permissions described in the GCC Runtime Library Exception,   --
20-- version 3.1, as published by the Free Software Foundation.               --
21--                                                                          --
22-- You should have received a copy of the GNU General Public License and    --
23-- a copy of the GCC Runtime Library Exception along with this program;     --
24-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
25-- <http://www.gnu.org/licenses/>.                                          --
26--                                                                          --
27-- GNAT was originally developed  by the GNAT team at  New York University. --
28-- Extensive contributions were provided by Ada Core Technologies Inc.      --
29--                                                                          --
30------------------------------------------------------------------------------
31
32package Ada.Strings.Text_Output.Utils with Pure is
33
34   --  This package provides utility functions on Sink'Class. These are
35   --  intended for use by Put_Image attributes, both the default versions
36   --  generated by the compiler, and user-defined ones.
37
38   procedure Full (S : in out Sink'Class) with Inline;
39   --  Must be called when the current chunk is full. Dispatches to
40   --  Full_Method.
41
42   procedure Flush (S : in out Sink'Class) with Inline;
43   --  Dispatches to Flush_Method
44
45   --  Full_Method and Flush_Method should be called only via Full and Flush
46
47   procedure Put_Character (S : in out Sink'Class; Item : Character);
48   procedure Put_Wide_Character (S : in out Sink'Class; Item : Wide_Character);
49   procedure Put_Wide_Wide_Character
50     (S : in out Sink'Class; Item : Wide_Wide_Character);
51   procedure Put_String (S : in out Sink'Class; Item : String);
52   procedure Put_Wide_String (S : in out Sink'Class; Item : Wide_String);
53   procedure Put_Wide_Wide_String
54     (S : in out Sink'Class; Item : Wide_Wide_String);
55   --  Encode characters or strings as UTF-8, and send them to S.
56
57   subtype Character_7 is
58     Character range Character'Val (0) .. Character'Val (2**7 - 1);
59   --  7-bit character. These are the same in both Latin-1 and UTF-8.
60
61   procedure Put_7bit (S : in out Sink'Class; Item : Character_7)
62     with Inline, Pre => Item /= NL;
63   procedure Put_7bit_NL (S : in out Sink'Class; Item : Character_7)
64     with Inline;
65   --  Put a 7-bit character, and adjust the Column. For Put_7bit_NL, Item can
66   --  be NL.
67
68   procedure Put_UTF_8 (S : in out Sink'Class; Item : UTF_8) with Inline;
69   procedure Put_UTF_8_Lines (S : in out Sink'Class; Item : UTF_8_Lines);
70   --  Send data that is already UTF-8 encoded (including 7-bit ASCII) to
71   --  S. These are more efficient than Put_String.
72
73   procedure New_Line (S : in out Sink'Class) with
74     Inline, Post => Column (S) = 1;
75   --  Puts the new-line character.
76
77   function Column (S : Sink'Class) return Positive with Inline;
78   --  Current output column. The Column is initially 1, and is incremented for
79   --  each 7-bit character output, except for the new-line character, which
80   --  sets Column back to 1. The next character to be output will go in this
81   --  column.
82
83   procedure Tab_To_Column (S : in out Sink'Class; Column : Positive);
84   --  Put spaces until we're at or past Column.
85
86   procedure Set_Indentation (S : in out Sink'Class; Amount : Natural)
87     with Inline;
88   function Indentation (S : Sink'Class) return Natural with Inline;
89   --  Indentation is initially 0. Set_Indentation sets it, and Indentation
90   --  returns it. This number of space characters are put at the start of
91   --  each nonempty line.
92
93   subtype Optional_Indentation is Integer range -1 .. Natural'Last;
94   Default : constant Optional_Indentation := -1;
95
96   procedure Indent
97     (S : in out Sink'Class; Amount : Optional_Indentation := Default)
98      with Inline;
99   procedure Outdent
100     (S : in out Sink'Class; Amount : Optional_Indentation := Default)
101      with Inline;
102   --  Increase/decrease Indentation by Amount. If Amount = Default, the amount
103   --  specified by the Indent_Amount parameter of the sink creation function
104   --  is used. The sink creation functions are New_Buffer, Create_File, and
105   --  Create_New_File.
106
107end Ada.Strings.Text_Output.Utils;
108