| 1 |
with Ada.Text_IO; |
| 2 |
with Ada.Unchecked_Deallocation; |
| 3 |
with ARM_Output; |
| 4 |
with ARM_Contents; |
| 5 |
package ARM_Texinfo is |
| 6 |
|
| 7 |
-- |
| 8 |
-- Ada reference manual formatter. |
| 9 |
-- |
| 10 |
-- This package defines the TEXINFO output object. |
| 11 |
-- Output objects are responsible for implementing the details of |
| 12 |
-- a particular format. |
| 13 |
-- |
| 14 |
-- --------------------------------------- |
| 15 |
-- |
| 16 |
-- Copyright (C) 2003, 2007, 2011, 2013, 2018, 2020 Stephen Leake. All Rights Reserved. |
| 17 |
-- E-Mail: [email protected] |
| 18 |
-- |
| 19 |
-- This library is free software; you can redistribute it and/or |
| 20 |
-- modify it under terms of the GNU General Public License as |
| 21 |
-- published by the Free Software Foundation; either version 3, or (at |
| 22 |
-- your option) any later version. This library is distributed in the |
| 23 |
-- hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
| 24 |
-- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 25 |
-- PURPOSE. See the GNU General Public License for more details. You |
| 26 |
-- should have received a copy of the GNU General Public License |
| 27 |
-- distributed with this program; see file gnu-3-0.txt. If not, write to |
| 28 |
-- the Free Software Foundation, 59 Temple Place - Suite 330, Boston, |
| 29 |
-- MA 02111-1307, USA. |
| 30 |
|
| 31 |
-- --------------------------------------- |
| 32 |
-- |
| 33 |
-- Edit History: |
| 34 |
-- |
| 35 |
-- Ancient - S L - Developed package as add-on to Arm_Form. |
| 36 |
-- 10/19/11 - RLB - Integrated outside-developed package into Arm_Form. |
| 37 |
-- Commented out/replaced Ada 2005 features (this is |
| 38 |
-- Ada 95 code). Updated for a few other changes since |
| 39 |
-- the last update. |
| 40 |
-- 10/25/11 - RLB - Added old insertion version to Revised_Clause_Header. |
| 41 |
-- 4/ 1/12 - S L - Various revisions. |
| 42 |
-- 8/31/12 - RLB - Added Output_Path. |
| 43 |
-- 11/26/12 - RLB - Added subdivision names to Clause_Header and |
| 44 |
-- Revised_Clause_Header. |
| 45 |
|
| 46 |
type Texinfo_Output_Type is new ARM_Output.Output_Type with private; |
| 47 |
|
| 48 |
--not overriding - Ada 2005-only |
| 49 |
procedure Create |
| 50 |
(Output_Object : in out Texinfo_Output_Type; |
| 51 |
File_Prefix : in String; |
| 52 |
Output_Path : in String; |
| 53 |
Change_Version : in ARM_Contents.Change_Version_Type; |
| 54 |
Title : in String); |
| 55 |
-- Create an Output_Object for a document. |
| 56 |
|
| 57 |
-- overriding - Ada 2005-only |
| 58 |
procedure Close (Output_Object : in out Texinfo_Output_Type); |
| 59 |
|
| 60 |
-- overriding |
| 61 |
procedure Section |
| 62 |
(Output_Object : in out Texinfo_Output_Type; |
| 63 |
Section_Title : in String; |
| 64 |
Section_Name : in String); |
| 65 |
|
| 66 |
-- overriding |
| 67 |
procedure Set_Columns |
| 68 |
(Output_Object : in out Texinfo_Output_Type; |
| 69 |
Number_of_Columns : in ARM_Output.Column_Count); |
| 70 |
|
| 71 |
-- overriding |
| 72 |
procedure Start_Paragraph |
| 73 |
(Output_Object : in out Texinfo_Output_Type; |
| 74 |
Style : in ARM_Output.Paragraph_Style_Type; |
| 75 |
Indent : in ARM_Output.Paragraph_Indent_Type; |
| 76 |
Number : in String; |
| 77 |
No_Prefix : in Boolean := False; |
| 78 |
Tab_Stops : in ARM_Output.Tab_Info := ARM_Output.NO_TABS; |
| 79 |
No_Breaks : in Boolean := False; |
| 80 |
Keep_with_Next : in Boolean := False; |
| 81 |
Space_After : in ARM_Output.Space_After_Type := ARM_Output.Normal; |
| 82 |
Justification : in ARM_Output.Justification_Type := ARM_Output.Default); |
| 83 |
|
| 84 |
-- overriding |
| 85 |
procedure End_Paragraph (Output_Object : in out Texinfo_Output_Type); |
| 86 |
|
| 87 |
-- overriding |
| 88 |
procedure Category_Header |
| 89 |
(Output_Object : in out Texinfo_Output_Type; |
| 90 |
Header_Text : String); |
| 91 |
|
| 92 |
-- overriding |
| 93 |
procedure Clause_Header |
| 94 |
(Output_Object : in out Texinfo_Output_Type; |
| 95 |
Header_Text : in String; |
| 96 |
Level : in ARM_Contents.Level_Type; |
| 97 |
Clause_Number : in String; |
| 98 |
Top_Level_Subdivision_Name : in ARM_Output.Top_Level_Subdivision_Name_Kind; |
| 99 |
No_Page_Break : in Boolean := False); |
| 100 |
|
| 101 |
-- overriding |
| 102 |
procedure Revised_Clause_Header |
| 103 |
(Output_Object : in out Texinfo_Output_Type; |
| 104 |
New_Header_Text : in String; |
| 105 |
Old_Header_Text : in String; |
| 106 |
Level : in ARM_Contents.Level_Type; |
| 107 |
Clause_Number : in String; |
| 108 |
Version : in ARM_Contents.Change_Version_Type; |
| 109 |
Old_Version : in ARM_Contents.Change_Version_Type; |
| 110 |
Top_Level_Subdivision_Name : in ARM_Output.Top_Level_Subdivision_Name_Kind; |
| 111 |
No_Page_Break : in Boolean := False); |
| 112 |
|
| 113 |
-- overriding |
| 114 |
procedure TOC_Marker (Output_Object : in out Texinfo_Output_Type; |
| 115 |
For_Start : in Boolean); |
| 116 |
|
| 117 |
-- overriding |
| 118 |
procedure New_Page (Output_Object : in out Texinfo_Output_Type; |
| 119 |
Kind : ARM_Output.Page_Kind_Type := ARM_Output.Any_Page); |
| 120 |
|
| 121 |
-- overriding |
| 122 |
procedure New_Column (Output_Object : in out Texinfo_Output_Type); |
| 123 |
|
| 124 |
-- overriding |
| 125 |
procedure Separator_Line (Output_Object : in out Texinfo_Output_Type; |
| 126 |
Is_Thin : Boolean := True); |
| 127 |
|
| 128 |
-- overriding |
| 129 |
procedure Start_Table |
| 130 |
(Output_Object : in out Texinfo_Output_Type; |
| 131 |
Columns : in ARM_Output.Column_Count; |
| 132 |
First_Column_Width : in ARM_Output.Column_Count; |
| 133 |
Last_Column_Width : in ARM_Output.Column_Count; |
| 134 |
Alignment : in ARM_Output.Column_Text_Alignment; |
| 135 |
No_Page_Break : in Boolean; |
| 136 |
Has_Border : in Boolean; |
| 137 |
Small_Text_Size : in Boolean; |
| 138 |
Header_Kind : in ARM_Output.Header_Kind_Type); |
| 139 |
|
| 140 |
-- overriding |
| 141 |
procedure Table_Marker (Output_Object : in out Texinfo_Output_Type; |
| 142 |
Marker : in ARM_Output.Table_Marker_Type); |
| 143 |
|
| 144 |
-- overriding |
| 145 |
procedure Ordinary_Text (Output_Object : in out Texinfo_Output_Type; |
| 146 |
Text : in String); |
| 147 |
|
| 148 |
-- overriding |
| 149 |
procedure Ordinary_Character (Output_Object : in out Texinfo_Output_Type; |
| 150 |
Char : in Character); |
| 151 |
|
| 152 |
-- overriding |
| 153 |
procedure Hard_Space (Output_Object : in out Texinfo_Output_Type); |
| 154 |
|
| 155 |
-- overriding |
| 156 |
procedure Line_Break (Output_Object : in out Texinfo_Output_Type); |
| 157 |
|
| 158 |
-- overriding |
| 159 |
procedure Index_Line_Break (Output_Object : in out Texinfo_Output_Type; |
| 160 |
Clear_Keep_with_Next : in Boolean); |
| 161 |
|
| 162 |
-- overriding |
| 163 |
procedure Soft_Line_Break (Output_Object : in out Texinfo_Output_Type); |
| 164 |
|
| 165 |
-- overriding |
| 166 |
procedure Soft_Hyphen_Break (Output_Object : in out Texinfo_Output_Type); |
| 167 |
|
| 168 |
-- overriding |
| 169 |
procedure Tab (Output_Object : in out Texinfo_Output_Type); |
| 170 |
|
| 171 |
-- overriding |
| 172 |
procedure Special_Character |
| 173 |
(Output_Object : in out Texinfo_Output_Type; |
| 174 |
Char : in ARM_Output.Special_Character_Type); |
| 175 |
|
| 176 |
-- overriding |
| 177 |
procedure Unicode_Character |
| 178 |
(Output_Object : in out Texinfo_Output_Type; |
| 179 |
Char : in ARM_Output.Unicode_Type); |
| 180 |
|
| 181 |
-- overriding |
| 182 |
procedure End_Hang_Item (Output_Object : in out Texinfo_Output_Type); |
| 183 |
|
| 184 |
-- overriding |
| 185 |
procedure Text_Format |
| 186 |
(Output_Object : in out Texinfo_Output_Type; |
| 187 |
Format : in ARM_Output.Format_Type); |
| 188 |
|
| 189 |
-- overriding |
| 190 |
procedure Clause_Reference (Output_Object : in out Texinfo_Output_Type; |
| 191 |
Text : in String; |
| 192 |
Clause_Number : in String); |
| 193 |
|
| 194 |
-- overriding |
| 195 |
procedure Index_Target |
| 196 |
(Output_Object : in out Texinfo_Output_Type; |
| 197 |
Index_Key : in Natural); |
| 198 |
|
| 199 |
-- overriding |
| 200 |
procedure Index_Reference |
| 201 |
(Output_Object : in out Texinfo_Output_Type; |
| 202 |
Text : in String; |
| 203 |
Index_Key : in Natural; |
| 204 |
Clause_Number : in String); |
| 205 |
|
| 206 |
-- overriding |
| 207 |
procedure DR_Reference |
| 208 |
(Output_Object : in out Texinfo_Output_Type; |
| 209 |
Text : in String; |
| 210 |
DR_Number : in String); |
| 211 |
|
| 212 |
-- overriding |
| 213 |
procedure AI_Reference |
| 214 |
(Output_Object : in out Texinfo_Output_Type; |
| 215 |
Text : in String; |
| 216 |
AI_Number : in String); |
| 217 |
|
| 218 |
-- overriding |
| 219 |
procedure Local_Target |
| 220 |
(Output_Object : in out Texinfo_Output_Type; |
| 221 |
Text : in String; |
| 222 |
Target : in String); |
| 223 |
|
| 224 |
-- overriding |
| 225 |
procedure Local_Link |
| 226 |
(Output_Object : in out Texinfo_Output_Type; |
| 227 |
Text : in String; |
| 228 |
Target : in String; |
| 229 |
Clause_Number : in String); |
| 230 |
|
| 231 |
-- overriding |
| 232 |
procedure Local_Link_Start |
| 233 |
(Output_Object : in out Texinfo_Output_Type; |
| 234 |
Target : in String; |
| 235 |
Clause_Number : in String); |
| 236 |
|
| 237 |
-- overriding |
| 238 |
procedure Local_Link_End |
| 239 |
(Output_Object : in out Texinfo_Output_Type; |
| 240 |
Target : in String; |
| 241 |
Clause_Number : in String); |
| 242 |
|
| 243 |
-- overriding |
| 244 |
procedure URL_Link |
| 245 |
(Output_Object : in out Texinfo_Output_Type; |
| 246 |
Text : in String; |
| 247 |
URL : in String); |
| 248 |
|
| 249 |
-- overriding |
| 250 |
procedure Picture |
| 251 |
(Output_Object : in out Texinfo_Output_Type; |
| 252 |
Name : in String; |
| 253 |
Descr : in String; |
| 254 |
Alignment : in ARM_Output.Picture_Alignment; |
| 255 |
Height, Width : in Natural; |
| 256 |
Border : in ARM_Output.Border_Kind); |
| 257 |
|
| 258 |
private |
| 259 |
|
| 260 |
subtype Column_Index_Type is Integer range 1 .. 5; |
| 261 |
type Column_Text_Item_Type; |
| 262 |
type Column_Text_Ptr is access Column_Text_Item_Type; |
| 263 |
type Column_Text_Item_Type is record |
| 264 |
Text : String (1 .. 80); |
| 265 |
Length : Natural; |
| 266 |
Row : Natural; -- Which row in the column. |
| 267 |
Next : Column_Text_Ptr; |
| 268 |
end record; |
| 269 |
type Column_Text_Ptrs_Type is array (Column_Index_Type) of Column_Text_Ptr; |
| 270 |
type Column_Widths_Type is array (Column_Index_Type) of Natural; |
| 271 |
|
| 272 |
procedure Free is new Ada.Unchecked_Deallocation (Column_Text_Item_Type, Column_Text_Ptr); |
| 273 |
|
| 274 |
type State_Type is (Title, Contents, Table_Header, Multi_Column, Normal, Index_Start, Index); |
| 275 |
|
| 276 |
type Texinfo_Output_Type is new ARM_Output.Output_Type with record |
| 277 |
File : Ada.Text_IO.File_Type; |
| 278 |
Is_Valid : Boolean := False; |
| 279 |
|
| 280 |
State : State_Type; |
| 281 |
In_Paragraph : Boolean := False; -- Sub-state within major states |
| 282 |
Paragraph_No_Prefix : Boolean := False; |
| 283 |
Style : ARM_Output.Paragraph_Style_Type; |
| 284 |
Indent : ARM_Output.Paragraph_Indent_Type; |
| 285 |
Format : ARM_Output.Format_Type := ARM_Output.Normal_Format; |
| 286 |
End_Hang_Seen : Boolean; |
| 287 |
|
| 288 |
-- Detecting end of title page |
| 289 |
Line_Empty : Boolean := False; -- True if current line contains only whitespace. |
| 290 |
First_Word : String (1 .. 80); |
| 291 |
First_Word_Last : Natural; |
| 292 |
|
| 293 |
-- Building menus |
| 294 |
Menu_Section : ARM_Contents.Section_Number_Type := 0; |
| 295 |
Menu_Clause : Natural := 0; |
| 296 |
|
| 297 |
-- Table and Multi-Column format |
| 298 |
Column_Count : ARM_Output.Column_Count; |
| 299 |
Current_Column : Natural; |
| 300 |
Current_Row : Natural; |
| 301 |
Column_Text : Column_Text_Ptrs_Type := (others => null); |
| 302 |
Column_Widths : Column_Widths_Type; |
| 303 |
Max_Row : Natural := 0; |
| 304 |
end record; |
| 305 |
|
| 306 |
end ARM_Texinfo; |