| 1 |
with Ada.Command_Line; |
| 2 |
with Ada.Exceptions; |
| 3 |
with Ada.Strings.Fixed; |
| 4 |
package body ARM_Texinfo is |
| 5 |
|
| 6 |
-- Copyright (C) 2003, 2007, 2010 - 2013, 2015, 2017, 2018, 2020 Stephen Leake. All Rights Reserved. |
| 7 |
-- E-Mail: [email protected] |
| 8 |
-- |
| 9 |
-- This library is free software; you can redistribute it and/or |
| 10 |
-- modify it under terms of the GNU General Public License as |
| 11 |
-- published by the Free Software Foundation; either version 3, or (at |
| 12 |
-- your option) any later version. This library is distributed in the |
| 13 |
-- hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
| 14 |
-- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 15 |
-- PURPOSE. See the GNU General Public License for more details. You |
| 16 |
-- should have received a copy of the GNU General Public License |
| 17 |
-- distributed with this program; see file gnu-3-0.txt. If not, write to |
| 18 |
-- the Free Software Foundation, 59 Temple Place - Suite 330, Boston, |
| 19 |
-- MA 02111-1307, USA. |
| 20 |
|
| 21 |
-- --------------------------------------- |
| 22 |
-- |
| 23 |
-- Edit History: |
| 24 |
-- |
| 25 |
-- Ancient - S L - Developed package as add-on to Arm_Form. |
| 26 |
-- 10/19/11 - RLB - Integrated outside-developed package into Arm_Form. |
| 27 |
-- Commented out/replaced Ada 2005 features (this is |
| 28 |
-- Ada 95 code). Updated for a few other changes since |
| 29 |
-- the last update. |
| 30 |
-- 10/25/11 - RLB - Added old insertion version to Revised_Clause_Header. |
| 31 |
-- 4/ 1/12 - S L - Implemented remaining Texinfo implementation. |
| 32 |
-- 4/22/12 - S L - Move @dircategory, @direntry before first @node. |
| 33 |
-- 4/28/12 - S L - Add @w{} after @anchor; otherwise following whitespace |
| 34 |
-- is dropped. |
| 35 |
-- 8/31/12 - RLB - Added Output_Path. |
| 36 |
-- 10/18/12 - RLB - Added additional hanging styles. |
| 37 |
-- 11/26/12 - RLB - Added subdivision names to Clause_Header and |
| 38 |
-- Revised_Clause_Header. |
| 39 |
-- 3/12/13 - S L - use correct version in direntry |
| 40 |
|
| 41 |
|
| 42 |
use Ada.Text_IO; |
| 43 |
|
| 44 |
Indentation : constant := 5; |
| 45 |
|
| 46 |
-- VERSION: This is fragile; it changes with each version of the manual. |
| 47 |
Index_Clause_Name : constant String := "Index"; |
| 48 |
Operators_Clause : constant String := "operators"; |
| 49 |
Last_Index_Clause : constant Character := 'Y'; |
| 50 |
|
| 51 |
---------- |
| 52 |
-- local subprograms |
| 53 |
|
| 54 |
procedure Check_Not_In_Paragraph (Output_Object : in Texinfo_Output_Type) |
| 55 |
is begin |
| 56 |
if Output_Object.In_Paragraph then |
| 57 |
Ada.Exceptions.Raise_Exception |
| 58 |
(ARM_Output.Not_Valid_Error'Identity, |
| 59 |
"In paragraph"); |
| 60 |
end if; |
| 61 |
end Check_Not_In_Paragraph; |
| 62 |
|
| 63 |
procedure Check_Valid (Output_Object : in Texinfo_Output_Type) |
| 64 |
is begin |
| 65 |
if not Output_Object.Is_Valid then |
| 66 |
Ada.Exceptions.Raise_Exception |
| 67 |
(ARM_Output.Not_Valid_Error'Identity, |
| 68 |
"Not valid object"); |
| 69 |
end if; |
| 70 |
end Check_Valid; |
| 71 |
|
| 72 |
procedure Unexpected_State (Output_Object : in Texinfo_Output_Type) |
| 73 |
is begin |
| 74 |
Ada.Exceptions.Raise_Exception |
| 75 |
(ARM_Output.Not_Valid_Error'Identity, |
| 76 |
"Unexpected state: " & State_Type'Image (Output_Object.State)); |
| 77 |
end Unexpected_State; |
| 78 |
|
| 79 |
procedure Escape_Put |
| 80 |
(Output_Object : in Texinfo_Output_Type; |
| 81 |
Char : in Character; |
| 82 |
Preserve_Space : in Boolean := False) |
| 83 |
is begin |
| 84 |
-- Escape special chars |
| 85 |
if Char = '@' then |
| 86 |
Put (Output_Object.File, "@@"); |
| 87 |
elsif Char = '{' then |
| 88 |
Put (Output_Object.File, "@{"); |
| 89 |
elsif Char = '}' then |
| 90 |
Put (Output_Object.File, "@}"); |
| 91 |
elsif Char = ''' then |
| 92 |
-- Avoid makeinfo converting '' into " |
| 93 |
Put (Output_Object.File, "'@w{}"); |
| 94 |
elsif Char = '`' then |
| 95 |
-- Avoid makeinfo converting `` into " |
| 96 |
Put (Output_Object.File, "`@w{}"); |
| 97 |
elsif Char = '-' then |
| 98 |
Put (Output_Object.File, "@minus{}"); |
| 99 |
elsif Char = ' ' and Preserve_Space then |
| 100 |
-- Don't allow collapsing spaces |
| 101 |
Put (Output_Object.File, "@w{ }"); |
| 102 |
elsif Char = '\' then |
| 103 |
-- This confuses texi2dvi if not escaped. |
| 104 |
Put (Output_Object.File, "@code{\}"); |
| 105 |
else |
| 106 |
Put (Output_Object.File, Char); |
| 107 |
end if; |
| 108 |
end Escape_Put; |
| 109 |
|
| 110 |
procedure Escape_Put |
| 111 |
(Output_Object : in Texinfo_Output_Type; |
| 112 |
Text : in String; |
| 113 |
Preserve_Space : in Boolean := False) |
| 114 |
is begin |
| 115 |
for I in Text'Range loop |
| 116 |
Escape_Put (Output_Object, Text (I), Preserve_Space); |
| 117 |
end loop; |
| 118 |
end Escape_Put; |
| 119 |
|
| 120 |
procedure End_Title_Page (Output_Object : in out Texinfo_Output_Type) |
| 121 |
is |
| 122 |
use ARM_Contents; |
| 123 |
|
| 124 |
procedure Put_Top_Menu_Item |
| 125 |
(Title : in Title_Type; |
| 126 |
Level : in Level_Type; |
| 127 |
Clause_Number : in Clause_Number_Type; |
| 128 |
Version : in ARM_Contents.Change_Version_Type; |
| 129 |
Quit : out Boolean) |
| 130 |
is |
| 131 |
pragma Unreferenced (Version); -- we are only concerned with version 2 |
| 132 |
First_Part : String (1 .. 14); -- Get all Titles aligned. |
| 133 |
begin |
| 134 |
Quit := False; |
| 135 |
|
| 136 |
case Level is |
| 137 |
when Section | Normative_Annex | Informative_Annex | Plain_Annex => |
| 138 |
Ada.Strings.Fixed.Move |
| 139 |
(Source => |
| 140 |
"* " & |
| 141 |
Make_Clause_Number (Level, Clause_Number) & |
| 142 |
" ::", |
| 143 |
Target => First_Part); |
| 144 |
|
| 145 |
Put_Line (Output_Object.File, First_Part & Title); |
| 146 |
|
| 147 |
when Unnumbered_Section | Clause | Subclause | Subsubclause => |
| 148 |
null; |
| 149 |
|
| 150 |
when ARM_Contents.Dead_Clause => |
| 151 |
raise Program_Error with "Dead_Clause header??"; |
| 152 |
-- No headers for dead clauses. |
| 153 |
|
| 154 |
end case; |
| 155 |
end Put_Top_Menu_Item; |
| 156 |
|
| 157 |
procedure Put_Top_Menu is new For_Each (Put_Top_Menu_Item); |
| 158 |
begin |
| 159 |
|
| 160 |
Put_Line (Output_Object.File, "@w{}"); -- Terminate unneeded "@center", silence warning. |
| 161 |
|
| 162 |
Put_Line (Output_Object.File, "@menu"); |
| 163 |
Put_Line (Output_Object.File, "* Front Matter:: Copyright, Foreword, etc."); -- Not a section in ARM sources |
| 164 |
Put_Top_Menu; |
| 165 |
Put_Line (Output_Object.File, "* Index :: Index"); -- Not in ARM sources |
| 166 |
Put_Line (Output_Object.File, "@end menu"); |
| 167 |
|
| 168 |
-- @node current |
| 169 |
Put_Line (Output_Object.File, "@node Front Matter"); |
| 170 |
Put_Line (Output_Object.File, "@chapter Front Matter"); |
| 171 |
end End_Title_Page; |
| 172 |
|
| 173 |
procedure Get_Clause_Section |
| 174 |
(Clause_String : in String; |
| 175 |
Section_Number : out ARM_Contents.Section_Number_Type; |
| 176 |
Clause_Integer : out Natural) |
| 177 |
is |
| 178 |
-- This is a partial inverse of ARM_Contents.Make_Clause_Number. |
| 179 |
-- |
| 180 |
-- Clause_String has "section.clause.subclause", possibly no subclause. |
| 181 |
-- |
| 182 |
-- "section" can be a number, a letter "N", or "Annex N", where |
| 183 |
-- |
| 184 |
-- 'N' = Character'Val (Character'Pos('A') + (Section_Number - ANNEX_START) |
| 185 |
|
| 186 |
Section_Dot : constant Natural := Ada.Strings.Fixed.Index (Source => Clause_String, Pattern => "."); |
| 187 |
|
| 188 |
Clause_Dot : constant Natural := Ada.Strings.Fixed.Index |
| 189 |
(Source => Clause_String (Section_Dot + 1 .. Clause_String'Last), |
| 190 |
Pattern => "."); |
| 191 |
|
| 192 |
use type ARM_Contents.Section_Number_Type; |
| 193 |
begin |
| 194 |
if Section_Dot = 8 then |
| 195 |
-- Section is "Annex N" |
| 196 |
Section_Number := ARM_Contents.ANNEX_START + |
| 197 |
Character'Pos (Clause_String (Clause_String'First + 6)) - Character'Pos ('A'); |
| 198 |
elsif Character'Pos (Clause_String (Clause_String'First)) >= Character'Pos ('A') then |
| 199 |
-- Section is letter. |
| 200 |
Section_Number := ARM_Contents.ANNEX_START + |
| 201 |
Character'Pos (Clause_String (Clause_String'First)) - Character'Pos ('A'); |
| 202 |
else |
| 203 |
Section_Number := ARM_Contents.Section_Number_Type'Value |
| 204 |
(Clause_String (Clause_String'First .. Section_Dot - 1)); |
| 205 |
end if; |
| 206 |
|
| 207 |
if Clause_Dot = 0 then |
| 208 |
Clause_Integer := Natural'Value |
| 209 |
(Clause_String (Section_Dot + 1 .. Clause_String'Last)); |
| 210 |
else |
| 211 |
Clause_Integer := Natural'Value |
| 212 |
(Clause_String (Section_Dot + 1 .. Clause_Dot - 1)); |
| 213 |
end if; |
| 214 |
end Get_Clause_Section; |
| 215 |
|
| 216 |
procedure Handle_Indent |
| 217 |
(Output_Object : in Texinfo_Output_Type; |
| 218 |
Texinfo_Item : in String; |
| 219 |
Extra_Indent : in ARM_Output.Paragraph_Indent_Type := 0) |
| 220 |
is |
| 221 |
use type ARM_Output.Paragraph_Indent_Type; |
| 222 |
begin |
| 223 |
for I in 1 .. Output_Object.Indent + Extra_Indent loop |
| 224 |
Put_Line (Output_Object.File, Texinfo_Item); |
| 225 |
end loop; |
| 226 |
end Handle_Indent; |
| 227 |
|
| 228 |
procedure Handle_Indent |
| 229 |
(Output_Object : in Texinfo_Output_Type; |
| 230 |
Containing_Item : in String; |
| 231 |
Final_Item : in String; |
| 232 |
Extra_Indent : in ARM_Output.Paragraph_Indent_Type := 0) |
| 233 |
is |
| 234 |
use type ARM_Output.Paragraph_Indent_Type; |
| 235 |
begin |
| 236 |
for I in 1 .. Output_Object.Indent + Extra_Indent - 1 loop |
| 237 |
Put_Line (Output_Object.File, Containing_Item); |
| 238 |
end loop; |
| 239 |
Put_Line (Output_Object.File, Final_Item); |
| 240 |
end Handle_Indent; |
| 241 |
|
| 242 |
procedure Handle_Indent_End |
| 243 |
(Output_Object : in Texinfo_Output_Type; |
| 244 |
Containing_Item : in String; |
| 245 |
Final_Item : in String; |
| 246 |
Extra_Indent : in ARM_Output.Paragraph_Indent_Type := 0) |
| 247 |
is |
| 248 |
use type ARM_Output.Paragraph_Indent_Type; |
| 249 |
begin |
| 250 |
Put_Line (Output_Object.File, Final_Item); |
| 251 |
for I in 1 .. Output_Object.Indent + Extra_Indent - 1 loop |
| 252 |
Put_Line (Output_Object.File, Containing_Item); |
| 253 |
end loop; |
| 254 |
end Handle_Indent_End; |
| 255 |
|
| 256 |
procedure Add_To_Column_Item (Output_Object : in out Texinfo_Output_Type; Text : in String) |
| 257 |
is begin |
| 258 |
if Output_Object.Column_Text (Output_Object.Current_Column) = null or else |
| 259 |
Output_Object.Column_Text (Output_Object.Current_Column).Row /= Output_Object.Current_Row |
| 260 |
then |
| 261 |
-- Start a new row. |
| 262 |
Output_Object.Column_Text (Output_Object.Current_Column) := |
| 263 |
new Column_Text_Item_Type' |
| 264 |
(Text => (others => ' '), |
| 265 |
Length => 0, |
| 266 |
Row => Output_Object.Current_Row, |
| 267 |
Next => Output_Object.Column_Text (Output_Object.Current_Column)); |
| 268 |
end if; |
| 269 |
|
| 270 |
if Output_Object.Column_Text (Output_Object.Current_Column).Length + Text'Length > |
| 271 |
Output_Object.Column_Text (Output_Object.Current_Column).Text'Length |
| 272 |
then |
| 273 |
Ada.Exceptions.Raise_Exception |
| 274 |
(ARM_Output.Not_Valid_Error'Identity, |
| 275 |
"Column item full, but more text: " & |
| 276 |
Output_Object.Column_Text (Output_Object.Current_Column).Text |
| 277 |
(1 .. Output_Object.Column_Text (Output_Object.Current_Column).Length)); |
| 278 |
else |
| 279 |
declare |
| 280 |
Current_Text : Column_Text_Item_Type renames Output_Object.Column_Text (Output_Object.Current_Column).all; |
| 281 |
begin |
| 282 |
Current_Text.Text (Current_Text.Length + 1 .. Current_Text.Length + Text'Length) := Text; |
| 283 |
|
| 284 |
Current_Text.Length := Current_Text.Length + Text'Length; |
| 285 |
|
| 286 |
if Output_Object.Column_Widths (Output_Object.Current_Column) < Current_Text.Length then |
| 287 |
Output_Object.Column_Widths (Output_Object.Current_Column) := Current_Text.Length; |
| 288 |
end if; |
| 289 |
end; |
| 290 |
end if; |
| 291 |
end Add_To_Column_Item; |
| 292 |
|
| 293 |
procedure Pad_Columns (Output_Object : in out Texinfo_Output_Type) |
| 294 |
-- Ensure that all columns have the same number of (possibly |
| 295 |
-- empty) rows, for table headers. |
| 296 |
is |
| 297 |
Item : Column_Text_Ptr; |
| 298 |
First_New_Row : Natural; |
| 299 |
begin |
| 300 |
for Col in 1 .. Output_Object.Column_Count loop |
| 301 |
Item := Output_Object.Column_Text (Col); |
| 302 |
if Item = null then |
| 303 |
First_New_Row := 1; |
| 304 |
else |
| 305 |
First_New_Row := Item.Row + 1; |
| 306 |
end if; |
| 307 |
|
| 308 |
for I in First_New_Row .. Output_Object.Max_Row loop |
| 309 |
Output_Object.Column_Text (Col) := |
| 310 |
new Column_Text_Item_Type' |
| 311 |
(Text => (others => ' '), |
| 312 |
Length => 1, |
| 313 |
Row => I, |
| 314 |
Next => Output_Object.Column_Text (Col)); |
| 315 |
end loop; |
| 316 |
end loop; |
| 317 |
end Pad_Columns; |
| 318 |
|
| 319 |
procedure Output_Column_Widths (Output_Object : in out Texinfo_Output_Type) |
| 320 |
is begin |
| 321 |
New_Line (Output_Object.File); |
| 322 |
Put (Output_Object.File, "@multitable "); |
| 323 |
for I in 1 .. Output_Object.Column_Count loop |
| 324 |
Put |
| 325 |
(Output_Object.File, |
| 326 |
" {" & |
| 327 |
String'(1 .. Output_Object.Column_Widths (I) => 'w') & |
| 328 |
"}"); |
| 329 |
end loop; |
| 330 |
end Output_Column_Widths; |
| 331 |
|
| 332 |
procedure Output_Columns (Output_Object : in out Texinfo_Output_Type) |
| 333 |
is |
| 334 |
Row : Natural := 1; |
| 335 |
Item : Column_Text_Ptr; |
| 336 |
Temp : Column_Text_Ptr; |
| 337 |
begin |
| 338 |
Rows : |
| 339 |
loop |
| 340 |
New_Line (Output_Object.File); |
| 341 |
Put (Output_Object.File, "@item "); |
| 342 |
|
| 343 |
-- For all columns, output the items for this row. Note that |
| 344 |
-- the last row is at the front of each column list; the |
| 345 |
-- first row is at the end. We delete the rows as we output |
| 346 |
-- them, so the one we want is always at the end of the |
| 347 |
-- column list. |
| 348 |
Columns : |
| 349 |
for Col in 1 .. Output_Object.Column_Count loop |
| 350 |
Item := Output_Object.Column_Text (Col); |
| 351 |
|
| 352 |
if Item = null then |
| 353 |
-- Previously finished column |
| 354 |
null; |
| 355 |
|
| 356 |
elsif Item.Next = null then |
| 357 |
-- This is the last item in the column. |
| 358 |
if Item.Row /= Row then |
| 359 |
-- This column is empty for this row. |
| 360 |
Item := null; |
| 361 |
else |
| 362 |
-- Output Item, and mark that we're done outputing |
| 363 |
-- this column. |
| 364 |
Output_Object.Column_Text (Col) := null; |
| 365 |
end if; |
| 366 |
else |
| 367 |
-- Find first item for this row in the column. |
| 368 |
while Item.Next /= null and then Item.Next.Row /= Row loop |
| 369 |
Item := Item.Next; |
| 370 |
end loop; |
| 371 |
|
| 372 |
-- Output Item.Next, take it out of list. |
| 373 |
Temp := Item; |
| 374 |
Item := Item.Next; |
| 375 |
Temp.Next := null; |
| 376 |
end if; |
| 377 |
|
| 378 |
if Item /= null then |
| 379 |
-- Output the item |
| 380 |
Escape_Put (Output_Object, Item.Text (1 .. Item.Length), Preserve_Space => True); |
| 381 |
Free (Item); |
| 382 |
|
| 383 |
if Col /= Output_Object.Column_Count then |
| 384 |
Put (Output_Object.File, " @tab "); |
| 385 |
end if; |
| 386 |
|
| 387 |
else |
| 388 |
-- This column is empty for this row |
| 389 |
if Col < Output_Object.Column_Count then |
| 390 |
Put (Output_Object.File, " @tab "); |
| 391 |
end if; |
| 392 |
end if; |
| 393 |
end loop Columns; |
| 394 |
|
| 395 |
if Output_Object.Column_Text = Column_Text_Ptrs_Type'(others => null) then |
| 396 |
-- We've output everything. |
| 397 |
exit Rows; |
| 398 |
end if; |
| 399 |
|
| 400 |
-- End the row: |
| 401 |
Row := Row + 1; |
| 402 |
end loop Rows; |
| 403 |
end Output_Columns; |
| 404 |
|
| 405 |
procedure Index_Menu (Output_Object : in out Texinfo_Output_Type) |
| 406 |
is begin |
| 407 |
-- In order to create a texinfo index, we would have to put @cindex |
| 408 |
-- entries in each section; it then builds a searchable index. Here we |
| 409 |
-- have the reverse information; an already compiled list of |
| 410 |
-- references. This is done in after creating this texinfo file, by |
| 411 |
-- the elisp code in arm-texi-index.el. |
| 412 |
New_Line (Output_Object.File); |
| 413 |
Put_Line (Output_Object.File, "@menu"); |
| 414 |
Put_Line (Output_Object.File, "* operators::"); |
| 415 |
Put_Line (Output_Object.File, "* A::"); |
| 416 |
Put_Line (Output_Object.File, "* B::"); |
| 417 |
Put_Line (Output_Object.File, "* C::"); |
| 418 |
Put_Line (Output_Object.File, "* D::"); |
| 419 |
Put_Line (Output_Object.File, "* E::"); |
| 420 |
Put_Line (Output_Object.File, "* F::"); |
| 421 |
Put_Line (Output_Object.File, "* G::"); |
| 422 |
Put_Line (Output_Object.File, "* H::"); |
| 423 |
Put_Line (Output_Object.File, "* I::"); |
| 424 |
Put_Line (Output_Object.File, "* J::"); |
| 425 |
Put_Line (Output_Object.File, "* K::"); |
| 426 |
Put_Line (Output_Object.File, "* L::"); |
| 427 |
Put_Line (Output_Object.File, "* M::"); |
| 428 |
Put_Line (Output_Object.File, "* N::"); |
| 429 |
Put_Line (Output_Object.File, "* O::"); |
| 430 |
Put_Line (Output_Object.File, "* P::"); |
| 431 |
Put_Line (Output_Object.File, "* Q::"); |
| 432 |
Put_Line (Output_Object.File, "* R::"); |
| 433 |
Put_Line (Output_Object.File, "* S::"); |
| 434 |
Put_Line (Output_Object.File, "* T::"); |
| 435 |
Put_Line (Output_Object.File, "* U::"); |
| 436 |
Put_Line (Output_Object.File, "* V::"); |
| 437 |
Put_Line (Output_Object.File, "* W::"); |
| 438 |
Put_Line (Output_Object.File, "* X::"); |
| 439 |
Put_Line (Output_Object.File, "* Y::"); |
| 440 |
-- Put_Line (Output_Object.File, "* Z::"); -- VERSION: No entries in Z |
| 441 |
Put_Line (Output_Object.File, "@end menu"); |
| 442 |
|
| 443 |
-- @node current |
| 444 |
Put_Line (Output_Object.File, "@node " & Operators_Clause); |
| 445 |
|
| 446 |
Put_Line (Output_Object.File, "@section operators"); |
| 447 |
end Index_Menu; |
| 448 |
|
| 449 |
---------- |
| 450 |
-- Public subprograms. Alphabetical order |
| 451 |
|
| 452 |
procedure AI_Reference |
| 453 |
(Output_Object : in out Texinfo_Output_Type; |
| 454 |
Text : in String; |
| 455 |
AI_Number : in String) |
| 456 |
is begin |
| 457 |
Ordinary_Text (Output_Object, AI_Number & Text); |
| 458 |
end AI_Reference; |
| 459 |
|
| 460 |
procedure Category_Header |
| 461 |
(Output_Object : in out Texinfo_Output_Type; |
| 462 |
Header_Text : String) |
| 463 |
is begin |
| 464 |
Check_Not_In_Paragraph (Output_Object); |
| 465 |
|
| 466 |
-- Can't be in a multi-column setting. |
| 467 |
-- |
| 468 |
-- Don't use @heading; that causes a weird underline in info, |
| 469 |
-- that isn't centered! |
| 470 |
Put_Line (Output_Object.File, "@center @emph{" & Header_Text & "}"); |
| 471 |
New_Line (Output_Object.File, 2); |
| 472 |
end Category_Header; |
| 473 |
|
| 474 |
procedure Clause_Header |
| 475 |
(Output_Object : in out Texinfo_Output_Type; |
| 476 |
Header_Text : in String; |
| 477 |
Level : in ARM_Contents.Level_Type; |
| 478 |
Clause_Number : in String; |
| 479 |
Top_Level_Subdivision_Name : in ARM_Output.Top_Level_Subdivision_Name_Kind; |
| 480 |
No_Page_Break : in Boolean := False) |
| 481 |
is |
| 482 |
pragma Unreferenced (No_Page_Break); |
| 483 |
pragma Unreferenced (Top_Level_Subdivision_Name); |
| 484 |
Title : constant String := Clause_Number & " " & Header_Text; |
| 485 |
|
| 486 |
use ARM_Contents; |
| 487 |
|
| 488 |
Section_Number : Section_Number_Type; |
| 489 |
Clause_Integer : Natural; |
| 490 |
|
| 491 |
procedure Put_Clause_Menu_Item |
| 492 |
(Item_Title : in Title_Type; |
| 493 |
Item_Level : in Level_Type; |
| 494 |
Item_Clause_Number : in Clause_Number_Type; |
| 495 |
Version : in ARM_Contents.Change_Version_Type; |
| 496 |
Quit : out Boolean) |
| 497 |
is |
| 498 |
pragma Unreferenced (Version); -- only version 2 |
| 499 |
First_Part : String (1 .. 14); -- Get all Titles aligned. |
| 500 |
begin |
| 501 |
Quit := False; |
| 502 |
|
| 503 |
case Item_Level is |
| 504 |
when Section | Unnumbered_Section | |
| 505 |
Normative_Annex | Informative_Annex | Plain_Annex | |
| 506 |
Subclause | Subsubclause => |
| 507 |
-- We are doing Clause here |
| 508 |
null; |
| 509 |
|
| 510 |
when Clause => |
| 511 |
if Item_Clause_Number.Section < Section_Number then |
| 512 |
null; |
| 513 |
|
| 514 |
elsif Item_Clause_Number.Section = Section_Number then |
| 515 |
Ada.Strings.Fixed.Move |
| 516 |
(Source => |
| 517 |
"* " & |
| 518 |
Make_Clause_Number (Item_Level, Item_Clause_Number) & |
| 519 |
" ::", |
| 520 |
Target => First_Part); |
| 521 |
|
| 522 |
Put_Line (Output_Object.File, First_Part & Item_Title); |
| 523 |
else |
| 524 |
Quit := True; |
| 525 |
end if; |
| 526 |
when Dead_Clause => |
| 527 |
raise Program_Error with "Dead Clause in menu??"; -- No dead clauses should be output. |
| 528 |
end case; |
| 529 |
end Put_Clause_Menu_Item; |
| 530 |
|
| 531 |
procedure Put_Clause_Menu is new For_Each (Put_Clause_Menu_Item); |
| 532 |
|
| 533 |
procedure Put_Subclause_Menu_Item |
| 534 |
(Item_Title : in Title_Type; |
| 535 |
Item_Level : in Level_Type; |
| 536 |
Item_Clause_Number : in Clause_Number_Type; |
| 537 |
Version : in ARM_Contents.Change_Version_Type; |
| 538 |
Quit : out Boolean) |
| 539 |
is |
| 540 |
pragma Unreferenced (Version); -- only version 2 |
| 541 |
First_Part : String (1 .. 14); -- Get all Titles aligned. |
| 542 |
begin |
| 543 |
Quit := False; |
| 544 |
|
| 545 |
case Item_Level is |
| 546 |
when Section | Unnumbered_Section | |
| 547 |
Normative_Annex | Informative_Annex | Plain_Annex | |
| 548 |
Clause | Subsubclause => |
| 549 |
-- We are doing Subclause here |
| 550 |
null; |
| 551 |
|
| 552 |
when Subclause => |
| 553 |
if Item_Clause_Number.Section < Section_Number then |
| 554 |
null; |
| 555 |
|
| 556 |
elsif Item_Clause_Number.Section = Section_Number then |
| 557 |
if Item_Clause_Number.Clause < Clause_Integer then |
| 558 |
null; |
| 559 |
|
| 560 |
elsif Item_Clause_Number.Clause = Clause_Integer then |
| 561 |
Ada.Strings.Fixed.Move |
| 562 |
(Source => |
| 563 |
"* " & |
| 564 |
Make_Clause_Number (Item_Level, Item_Clause_Number) & |
| 565 |
" ::", |
| 566 |
Target => First_Part); |
| 567 |
|
| 568 |
Put_Line (Output_Object.File, First_Part & Item_Title); |
| 569 |
else |
| 570 |
Quit := True; |
| 571 |
end if; |
| 572 |
else |
| 573 |
Quit := True; |
| 574 |
end if; |
| 575 |
when Dead_Clause => |
| 576 |
raise Program_Error with "Dead clause in submenu??"; -- No dead clauses should be output. |
| 577 |
end case; |
| 578 |
end Put_Subclause_Menu_Item; |
| 579 |
|
| 580 |
procedure Put_Subclause_Menu is new For_Each (Put_Subclause_Menu_Item); |
| 581 |
|
| 582 |
begin |
| 583 |
Check_Not_In_Paragraph (Output_Object); |
| 584 |
|
| 585 |
-- Handle special cases |
| 586 |
if Clause_Number = "" and Header_Text = "Table of Contents" then |
| 587 |
-- Actual contents output in TOC_Marker below. |
| 588 |
return; |
| 589 |
|
| 590 |
elsif Header_Text = "The Standard Libraries" then |
| 591 |
-- This section has no content; don't confuse makeinfo. |
| 592 |
return; |
| 593 |
|
| 594 |
elsif Header_Text = Index_Clause_Name then |
| 595 |
|
| 596 |
Put_Line (Output_Object.File, "@node " & Index_Clause_Name); |
| 597 |
|
| 598 |
Put_Line (Output_Object.File, "@chapter Index"); |
| 599 |
Output_Object.State := Index_Start; |
| 600 |
|
| 601 |
return; |
| 602 |
end if; |
| 603 |
|
| 604 |
case Level is |
| 605 |
when Section | Normative_Annex | Informative_Annex | Plain_Annex => |
| 606 |
-- Menu of these done at @node Top |
| 607 |
null; |
| 608 |
|
| 609 |
when Unnumbered_Section => |
| 610 |
-- Unnumbered sections are not in ARM_Contents, but there's |
| 611 |
-- currently only one of them, so they are not worth adding; |
| 612 |
-- just hard-code the menu here. |
| 613 |
Get_Clause_Section (Clause_Number, Section_Number, Clause_Integer); |
| 614 |
|
| 615 |
if Section_Number = 0 and Clause_Integer = 1 then |
| 616 |
New_Line (Output_Object.File); |
| 617 |
Put_Line (Output_Object.File, "@menu"); |
| 618 |
Put_Line (Output_Object.File, "* 0.1 :: Foreword to this version of the Ada Reference Manual"); |
| 619 |
Put_Line (Output_Object.File, "* 0.2 :: Foreword"); |
| 620 |
Put_Line (Output_Object.File, "* 0.3 :: Introduction"); |
| 621 |
Put_Line (Output_Object.File, "* 0.99 :: International Standard"); |
| 622 |
Put_Line (Output_Object.File, "@end menu"); |
| 623 |
end if; |
| 624 |
|
| 625 |
when Clause => |
| 626 |
-- Output menu of Clauses in this section, if we haven't already |
| 627 |
Get_Clause_Section (Clause_Number, Section_Number, Clause_Integer); |
| 628 |
|
| 629 |
if Output_Object.Menu_Section /= Section_Number then |
| 630 |
Put_Line (Output_Object.File, "@menu"); |
| 631 |
Put_Clause_Menu; |
| 632 |
Put_Line (Output_Object.File, "@end menu"); |
| 633 |
Output_Object.Menu_Section := Section_Number; |
| 634 |
Output_Object.Menu_Clause := 0; |
| 635 |
end if; |
| 636 |
|
| 637 |
when Subclause => |
| 638 |
-- Output menu of Subclauses in this Clause, if we haven't already |
| 639 |
Get_Clause_Section (Clause_Number, Section_Number, Clause_Integer); |
| 640 |
|
| 641 |
if Output_Object.Menu_Section = Section_Number and |
| 642 |
Output_Object.Menu_Clause /= Clause_Integer |
| 643 |
then |
| 644 |
Put_Line (Output_Object.File, "@menu"); |
| 645 |
Put_Subclause_Menu; |
| 646 |
Put_Line (Output_Object.File, "@end menu"); |
| 647 |
Output_Object.Menu_Clause := Clause_Integer; |
| 648 |
end if; |
| 649 |
|
| 650 |
when Subsubclause => |
| 651 |
Ada.Exceptions.Raise_Exception |
| 652 |
(ARM_Output.Not_Valid_Error'Identity, |
| 653 |
"Clause_Header: Subsubclause"); |
| 654 |
|
| 655 |
when Dead_Clause => |
| 656 |
Ada.Exceptions.Raise_Exception |
| 657 |
(ARM_Output.Not_Valid_Error'Identity, |
| 658 |
"Clause_Header: Dead_clause"); |
| 659 |
|
| 660 |
end case; |
| 661 |
|
| 662 |
Put_Line (Output_Object.File, "@node " & Clause_Number); |
| 663 |
|
| 664 |
case Level is |
| 665 |
when Section => |
| 666 |
Put_Line (Output_Object.File, "@chapter " & Title); |
| 667 |
|
| 668 |
when Normative_Annex | Informative_Annex | Plain_Annex => |
| 669 |
Put_Line (Output_Object.File, "@chapter " & Title); |
| 670 |
|
| 671 |
when Clause | Unnumbered_Section => |
| 672 |
Put_Line (Output_Object.File, "@section " & Title); |
| 673 |
|
| 674 |
when Subclause => |
| 675 |
Put_Line (Output_Object.File, "@subsection " & Title); |
| 676 |
|
| 677 |
when Subsubclause => |
| 678 |
Put_Line (Output_Object.File, "@subsubsection " & Title); |
| 679 |
|
| 680 |
when Dead_Clause => |
| 681 |
raise Program_Error with "Dead_Clause in header?"; -- No output of dead clauses. |
| 682 |
end case; |
| 683 |
|
| 684 |
end Clause_Header; |
| 685 |
|
| 686 |
procedure Clause_Reference |
| 687 |
(Output_Object : in out Texinfo_Output_Type; |
| 688 |
Text : in String; |
| 689 |
Clause_Number : in String) |
| 690 |
is begin |
| 691 |
case Output_Object.State is |
| 692 |
when Contents => |
| 693 |
null; |
| 694 |
|
| 695 |
when Multi_Column | Table_Header => |
| 696 |
-- If this happens, we need to store escaped text in columns. |
| 697 |
Ada.Exceptions.Raise_Exception |
| 698 |
(ARM_Output.Not_Valid_Error'Identity, |
| 699 |
"clause reference in multi-column"); |
| 700 |
|
| 701 |
when Normal => |
| 702 |
if Text = Clause_Number then |
| 703 |
Put |
| 704 |
(Output_Object.File, |
| 705 |
"@ref{" & |
| 706 |
Clause_Number & |
| 707 |
"}"); |
| 708 |
else |
| 709 |
Put |
| 710 |
(Output_Object.File, |
| 711 |
"@ref{" & |
| 712 |
Clause_Number & |
| 713 |
"} " & |
| 714 |
Text); |
| 715 |
end if; |
| 716 |
|
| 717 |
when Title | Index_Start | Index => |
| 718 |
Unexpected_State (Output_Object); |
| 719 |
|
| 720 |
end case; |
| 721 |
end Clause_Reference; |
| 722 |
|
| 723 |
procedure Close (Output_Object : in out Texinfo_Output_Type) |
| 724 |
is begin |
| 725 |
Check_Valid (Output_Object); |
| 726 |
|
| 727 |
Put_Line (Output_Object.File, "@bye"); |
| 728 |
|
| 729 |
Close (Output_Object.File); |
| 730 |
|
| 731 |
Output_Object.Is_Valid := False; |
| 732 |
end Close; |
| 733 |
|
| 734 |
procedure Create |
| 735 |
(Output_Object : in out Texinfo_Output_Type; |
| 736 |
File_Prefix : in String; |
| 737 |
Output_Path : in String; |
| 738 |
Change_Version : in ARM_Contents.Change_Version_Type; |
| 739 |
Title : in String) |
| 740 |
is |
| 741 |
File_Name : constant String := Output_Path & |
| 742 |
Ada.Strings.Fixed.Trim (File_Prefix, Ada.Strings.Right) & |
| 743 |
".texinfo"; |
| 744 |
begin |
| 745 |
if Output_Object.Is_Valid then |
| 746 |
Ada.Exceptions.Raise_Exception |
| 747 |
(ARM_Output.Not_Valid_Error'Identity, |
| 748 |
"Already valid object"); |
| 749 |
end if; |
| 750 |
|
| 751 |
Output_Object.Is_Valid := True; |
| 752 |
|
| 753 |
Create (Output_Object.File, Out_File, File_Name); |
| 754 |
|
| 755 |
Put_Line (Output_Object.File, "\input texinfo"); |
| 756 |
Put_Line (Output_Object.File, "@documentencoding ISO-8859-1"); |
| 757 |
Put_Line (Output_Object.File, "@dircategory GNU Ada tools"); |
| 758 |
|
| 759 |
Put_Line (Output_Object.File, "@direntry"); |
| 760 |
case Change_Version is |
| 761 |
when '2' => |
| 762 |
Put_Line (Output_Object.File, "* Ada 2005 Reference Manual: (arm2005)."); |
| 763 |
Put_Line (Output_Object.File, "* Annotated ARM 2005: (aarm2005)."); |
| 764 |
when '3' => |
| 765 |
Put_Line (Output_Object.File, "* Ada 2012 Reference Manual: (arm2012)."); |
| 766 |
Put_Line (Output_Object.File, "* Annotated ARM 2012: (aarm2012)."); |
| 767 |
when '4' => |
| 768 |
Put_Line (Output_Object.File, "* Ada 2012 Reference Manual: (arm2012)."); |
| 769 |
Put_Line (Output_Object.File, "* Annotated ARM 2012: (aarm2012)."); |
| 770 |
when '5' => |
| 771 |
Put_Line (Output_Object.File, "* Ada 202x Draft 25 Reference Manual: (arm2020)."); |
| 772 |
Put_Line (Output_Object.File, "* Annotated ARM 202x Draft 25: (aarm2020)."); |
| 773 |
when others => |
| 774 |
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); |
| 775 |
raise ARM_Output.Not_Valid_Error with "arm_texi.adb: unsupported Change_Version" & Change_Version'Image; |
| 776 |
end case; |
| 777 |
Put_Line (Output_Object.File, "@end direntry"); |
| 778 |
|
| 779 |
Put_Line (Output_Object.File, "@settitle " & Title); |
| 780 |
Put_Line (Output_Object.File, "@paragraphindent none"); |
| 781 |
Put_Line (Output_Object.File, "@exampleindent" & Integer'Image (Indentation)); |
| 782 |
|
| 783 |
Put_Line (Output_Object.File, "@node Top"); |
| 784 |
Put_Line (Output_Object.File, "@top " & Title); |
| 785 |
|
| 786 |
Output_Object.State := ARM_Texinfo.Title; |
| 787 |
Output_Object.First_Word_Last := 0; |
| 788 |
|
| 789 |
end Create; |
| 790 |
|
| 791 |
procedure DR_Reference |
| 792 |
(Output_Object : in out Texinfo_Output_Type; |
| 793 |
Text : in String; |
| 794 |
DR_Number : in String) |
| 795 |
is begin |
| 796 |
Ordinary_Text (Output_Object, DR_Number & Text); |
| 797 |
end DR_Reference; |
| 798 |
|
| 799 |
procedure End_Hang_Item (Output_Object : in out Texinfo_Output_Type) |
| 800 |
is |
| 801 |
use ARM_Output; |
| 802 |
begin |
| 803 |
Output_Object.End_Hang_Seen := True; |
| 804 |
|
| 805 |
case Output_Object.Style is |
| 806 |
when Normal | |
| 807 |
Wide_Above | |
| 808 |
Small | |
| 809 |
Small_Wide_Above | |
| 810 |
Header | |
| 811 |
Small_Header | |
| 812 |
Syntax_Summary => |
| 813 |
|
| 814 |
Handle_Indent (Output_Object, "@quotation"); |
| 815 |
|
| 816 |
when Index | |
| 817 |
Title => |
| 818 |
null; |
| 819 |
|
| 820 |
when Examples | |
| 821 |
Small_Examples | |
| 822 |
Swiss_Examples | |
| 823 |
Small_Swiss_Examples => |
| 824 |
|
| 825 |
Handle_Indent (Output_Object, "@example"); |
| 826 |
|
| 827 |
when Bulleted | |
| 828 |
Small_Bulleted => |
| 829 |
|
| 830 |
Handle_Indent (Output_Object, "@itemize"); |
| 831 |
|
| 832 |
when Nested_Bulleted | |
| 833 |
Small_Nested_Bulleted => |
| 834 |
|
| 835 |
Handle_Indent (Output_Object, "@itemize", Extra_Indent => 1); |
| 836 |
|
| 837 |
when Enumerated | |
| 838 |
Small_Enumerated => |
| 839 |
|
| 840 |
-- Number has just been output; start text. |
| 841 |
Put (Output_Object.File, "@w{ }"); |
| 842 |
|
| 843 |
when Giant_Hanging | |
| 844 |
Small_Giant_Hanging | |
| 845 |
Wide_Hanging | |
| 846 |
Small_Wide_Hanging | |
| 847 |
Medium_Hanging | |
| 848 |
Small_Medium_Hanging | |
| 849 |
Narrow_Hanging | |
| 850 |
Small_Narrow_Hanging | |
| 851 |
Hanging_in_Bulleted | |
| 852 |
Small_Hanging_in_Bulleted => |
| 853 |
|
| 854 |
New_Line (Output_Object.File); |
| 855 |
Handle_Indent (Output_Object, "@quotation"); |
| 856 |
|
| 857 |
end case; |
| 858 |
|
| 859 |
end End_Hang_Item; |
| 860 |
|
| 861 |
procedure Text_Format |
| 862 |
(Output_Object : in out Texinfo_Output_Type; |
| 863 |
Format : in ARM_Output.Format_Type) |
| 864 |
is begin |
| 865 |
-- We only handle italic, for annotated syntax item names |
| 866 |
if Format.Italic /= Output_Object.Format.Italic then |
| 867 |
-- Info format does not support fonts, so we use <> |
| 868 |
Put (Output_Object.File, (if Format.Italic then '<' else '>')); |
| 869 |
end if; |
| 870 |
Output_Object.Format := Format; |
| 871 |
end Text_Format; |
| 872 |
|
| 873 |
procedure End_Paragraph (Output_Object : in out Texinfo_Output_Type) |
| 874 |
is |
| 875 |
use ARM_Output; |
| 876 |
begin |
| 877 |
Output_Object.In_Paragraph := False; |
| 878 |
|
| 879 |
case Output_Object.State is |
| 880 |
when Contents => |
| 881 |
null; |
| 882 |
|
| 883 |
when Multi_Column => |
| 884 |
-- Skip a row, to separate paragraphs in a column. |
| 885 |
Output_Object.Current_Row := Output_Object.Current_Row + 2; |
| 886 |
|
| 887 |
when Title => |
| 888 |
if Output_Object.Line_Empty then |
| 889 |
null; |
| 890 |
else |
| 891 |
New_Line (Output_Object.File, 2); |
| 892 |
Put (Output_Object.File, "@center "); |
| 893 |
Output_Object.Line_Empty := True; |
| 894 |
end if; |
| 895 |
|
| 896 |
when Normal => |
| 897 |
case Output_Object.Style is |
| 898 |
when Normal | |
| 899 |
Wide_Above | |
| 900 |
Small | |
| 901 |
Small_Wide_Above | |
| 902 |
Header | |
| 903 |
Small_Header | |
| 904 |
Syntax_Summary => |
| 905 |
|
| 906 |
New_Line (Output_Object.File); |
| 907 |
Handle_Indent (Output_Object, "@end quotation"); |
| 908 |
New_Line (Output_Object.File); |
| 909 |
|
| 910 |
when Index | |
| 911 |
Title => |
| 912 |
|
| 913 |
New_Line (Output_Object.File, 2); |
| 914 |
|
| 915 |
when Examples | |
| 916 |
Small_Examples | |
| 917 |
Swiss_Examples | |
| 918 |
Small_Swiss_Examples => |
| 919 |
|
| 920 |
New_Line (Output_Object.File); |
| 921 |
Handle_Indent (Output_Object, "@end example"); |
| 922 |
New_Line (Output_Object.File); |
| 923 |
|
| 924 |
when Bulleted | |
| 925 |
Small_Bulleted => |
| 926 |
|
| 927 |
New_Line (Output_Object.File); |
| 928 |
if Output_Object.Paragraph_No_Prefix then |
| 929 |
Handle_Indent (Output_Object, "@end quotation"); |
| 930 |
else |
| 931 |
Handle_Indent_End (Output_Object, "@end quotation", "@end itemize"); |
| 932 |
end if; |
| 933 |
New_Line (Output_Object.File); |
| 934 |
|
| 935 |
when Nested_Bulleted | |
| 936 |
Small_Nested_Bulleted => |
| 937 |
|
| 938 |
New_Line (Output_Object.File); |
| 939 |
if Output_Object.Paragraph_No_Prefix then |
| 940 |
Handle_Indent (Output_Object, "@end quotation"); |
| 941 |
else |
| 942 |
Handle_Indent_End (Output_Object, "@end quotation", "@end itemize", Extra_Indent => 1); |
| 943 |
end if; |
| 944 |
New_Line (Output_Object.File); |
| 945 |
|
| 946 |
when Enumerated | |
| 947 |
Small_Enumerated => |
| 948 |
|
| 949 |
New_Line (Output_Object.File); |
| 950 |
if Output_Object.Paragraph_No_Prefix then |
| 951 |
Handle_Indent (Output_Object, "@end quotation"); |
| 952 |
else |
| 953 |
Handle_Indent_End (Output_Object, "@end quotation", "@end itemize"); |
| 954 |
end if; |
| 955 |
New_Line (Output_Object.File); |
| 956 |
|
| 957 |
when Giant_Hanging | |
| 958 |
Small_Giant_Hanging | |
| 959 |
Wide_Hanging | |
| 960 |
Small_Wide_Hanging | |
| 961 |
Medium_Hanging | |
| 962 |
Small_Medium_Hanging | |
| 963 |
Narrow_Hanging | |
| 964 |
Small_Narrow_Hanging | |
| 965 |
Hanging_in_Bulleted | |
| 966 |
Small_Hanging_in_Bulleted => |
| 967 |
|
| 968 |
New_Line (Output_Object.File); |
| 969 |
if Output_Object.End_Hang_Seen then |
| 970 |
Handle_Indent (Output_Object, "@end quotation"); |
| 971 |
end if; |
| 972 |
New_Line (Output_Object.File); |
| 973 |
|
| 974 |
end case; |
| 975 |
|
| 976 |
when Index_Start => |
| 977 |
Output_Object.State := Index; |
| 978 |
|
| 979 |
Index_Menu (Output_Object); |
| 980 |
|
| 981 |
when Index => |
| 982 |
-- Keep index items tightly grouped. |
| 983 |
Put_Line (Output_Object.File, "@*"); |
| 984 |
|
| 985 |
when Table_Header => |
| 986 |
Unexpected_State (Output_Object); |
| 987 |
|
| 988 |
end case; |
| 989 |
Output_Object.Paragraph_No_Prefix := False; |
| 990 |
end End_Paragraph; |
| 991 |
|
| 992 |
procedure Hard_Space (Output_Object : in out Texinfo_Output_Type) |
| 993 |
is begin |
| 994 |
case Output_Object.State is |
| 995 |
when Contents => |
| 996 |
null; |
| 997 |
|
| 998 |
when Multi_Column | Table_Header => |
| 999 |
-- Can't do line breaks in columns |
| 1000 |
Add_To_Column_Item (Output_Object, " "); |
| 1001 |
|
| 1002 |
when Title => |
| 1003 |
if Output_Object.Line_Empty then |
| 1004 |
null; |
| 1005 |
else |
| 1006 |
Put (Output_Object.File, "@w{ }"); |
| 1007 |
end if; |
| 1008 |
|
| 1009 |
when Normal | Index_Start | Index => |
| 1010 |
Put (Output_Object.File, "@w{ }"); |
| 1011 |
end case; |
| 1012 |
end Hard_Space; |
| 1013 |
|
| 1014 |
procedure Index_Line_Break |
| 1015 |
(Output_Object : in out Texinfo_Output_Type; |
| 1016 |
Clear_Keep_with_Next : in Boolean) |
| 1017 |
is |
| 1018 |
pragma Unreferenced (Clear_Keep_with_Next); |
| 1019 |
begin |
| 1020 |
Put_Line (Output_Object.File, "@*"); |
| 1021 |
end Index_Line_Break; |
| 1022 |
|
| 1023 |
procedure Index_Reference |
| 1024 |
(Output_Object : in out Texinfo_Output_Type; |
| 1025 |
Text : in String; |
| 1026 |
Index_Key : in Natural; |
| 1027 |
Clause_Number : in String) |
| 1028 |
is |
| 1029 |
pragma Unreferenced (Clause_Number); |
| 1030 |
-- Text is clause_number & paragraph number (optional). |
| 1031 |
begin |
| 1032 |
Put (Output_Object.File, "@ref{" & Integer'Image (Index_Key) & ", " & Text & "}"); |
| 1033 |
end Index_Reference; |
| 1034 |
|
| 1035 |
procedure Index_Target |
| 1036 |
(Output_Object : in out Texinfo_Output_Type; |
| 1037 |
Index_Key : in Natural) |
| 1038 |
is begin |
| 1039 |
-- Add an empty non-break object, because @anchor ignores |
| 1040 |
-- whitespace after it, which often occurs in the current |
| 1041 |
-- Scribe-like source. |
| 1042 |
Put (Output_Object.File, "@anchor{" & Integer'Image (Index_Key) & "}@w{}"); |
| 1043 |
end Index_Target; |
| 1044 |
|
| 1045 |
procedure Line_Break (Output_Object : in out Texinfo_Output_Type) |
| 1046 |
is |
| 1047 |
use ARM_Output; |
| 1048 |
begin |
| 1049 |
case Output_Object.State is |
| 1050 |
when Title => |
| 1051 |
if Output_Object.Line_Empty then |
| 1052 |
null; |
| 1053 |
else |
| 1054 |
Put_Line (Output_Object.File, "@*"); |
| 1055 |
Output_Object.Line_Empty := True; |
| 1056 |
end if; |
| 1057 |
|
| 1058 |
when Contents => |
| 1059 |
null; |
| 1060 |
|
| 1061 |
when Multi_Column | Table_Header => |
| 1062 |
Output_Object.Current_Row := Output_Object.Current_Row + 1; |
| 1063 |
if Output_Object.Max_Row < Output_Object.Current_Row then |
| 1064 |
Output_Object.Max_Row := Output_Object.Current_Row; |
| 1065 |
end if; |
| 1066 |
|
| 1067 |
when Index_Start => |
| 1068 |
-- This doesn't happen |
| 1069 |
Ada.Exceptions.Raise_Exception |
| 1070 |
(ARM_Output.Not_Valid_Error'Identity, |
| 1071 |
"Line_Break Index_Start"); |
| 1072 |
|
| 1073 |
when Normal | Index => |
| 1074 |
case Output_Object.Style is |
| 1075 |
when Normal | |
| 1076 |
Wide_Above | |
| 1077 |
Small | |
| 1078 |
Small_Wide_Above | |
| 1079 |
Header | |
| 1080 |
Small_Header | |
| 1081 |
Syntax_Summary | |
| 1082 |
Index | |
| 1083 |
Title => |
| 1084 |
|
| 1085 |
Put_Line (Output_Object.File, "@*"); |
| 1086 |
|
| 1087 |
when Examples | |
| 1088 |
Small_Examples | |
| 1089 |
Swiss_Examples | |
| 1090 |
Small_Swiss_Examples => |
| 1091 |
|
| 1092 |
New_Line (Output_Object.File); |
| 1093 |
|
| 1094 |
when Bulleted | |
| 1095 |
Small_Bulleted | |
| 1096 |
Nested_Bulleted | |
| 1097 |
Small_Nested_Bulleted | |
| 1098 |
Enumerated | |
| 1099 |
Small_Enumerated | |
| 1100 |
Giant_Hanging | |
| 1101 |
Small_Giant_Hanging | |
| 1102 |
Wide_Hanging | |
| 1103 |
Small_Wide_Hanging | |
| 1104 |
Medium_Hanging | |
| 1105 |
Small_Medium_Hanging | |
| 1106 |
Narrow_Hanging | |
| 1107 |
Small_Narrow_Hanging | |
| 1108 |
Hanging_in_Bulleted | |
| 1109 |
Small_Hanging_in_Bulleted => |
| 1110 |
|
| 1111 |
Put_Line (Output_Object.File, "@*"); |
| 1112 |
|
| 1113 |
end case; |
| 1114 |
|
| 1115 |
end case; |
| 1116 |
end Line_Break; |
| 1117 |
|
| 1118 |
procedure Local_Link |
| 1119 |
(Output_Object : in out Texinfo_Output_Type; |
| 1120 |
Text : in String; |
| 1121 |
Target : in String; |
| 1122 |
Clause_Number : in String) |
| 1123 |
is |
| 1124 |
pragma Unreferenced (Target); |
| 1125 |
pragma Unreferenced (Clause_Number); |
| 1126 |
begin |
| 1127 |
-- These are typically references to words in the grammar |
| 1128 |
-- summary. Mildly useful, but the best we can do is: |
| 1129 |
-- |
| 1130 |
-- "@ref{" & Target & "," & Text & "}" |
| 1131 |
-- |
| 1132 |
-- makeinfo prepends 'see' and postpends '.', so it screws up |
| 1133 |
-- the text. For example, section 2.1 (1) ends up with "the |
| 1134 |
-- @ref{S0229, compilation}s." => "the see compilation: S0229." |
| 1135 |
-- Emacs info-mode suppresses the ': S0229', but not the 'see' |
| 1136 |
-- and the trailing '.'. So we just output the text. |
| 1137 |
Ordinary_Text (Output_Object, Text); |
| 1138 |
end Local_Link; |
| 1139 |
|
| 1140 |
procedure Local_Link_End |
| 1141 |
(Output_Object : in out Texinfo_Output_Type; |
| 1142 |
Target : in String; |
| 1143 |
Clause_Number : in String) |
| 1144 |
is begin |
| 1145 |
-- These work better than local links, because they are not in |
| 1146 |
-- the middle of plurals. First use is section 3.1 (1). |
| 1147 |
Put (Output_Object.File, " (@pxref{" & Target & "," & Clause_Number & "})"); |
| 1148 |
end Local_Link_End; |
| 1149 |
|
| 1150 |
procedure Local_Link_Start |
| 1151 |
(Output_Object : in out Texinfo_Output_Type; |
| 1152 |
Target : in String; |
| 1153 |
Clause_Number : in String) |
| 1154 |
is |
| 1155 |
pragma Unreferenced (Output_Object); |
| 1156 |
pragma Unreferenced (Target); |
| 1157 |
pragma Unreferenced (Clause_Number); |
| 1158 |
begin |
| 1159 |
-- implemented in Local_Link_End |
| 1160 |
null; |
| 1161 |
end Local_Link_Start; |
| 1162 |
|
| 1163 |
procedure Local_Target |
| 1164 |
(Output_Object : in out Texinfo_Output_Type; |
| 1165 |
Text : in String; |
| 1166 |
Target : in String) |
| 1167 |
is begin |
| 1168 |
-- Add an empty non-break object, because @anchor ignores |
| 1169 |
-- whitespace after it, which often occurs in the current |
| 1170 |
-- Scheme source. |
| 1171 |
Put (Output_Object.File, "@anchor{" & Target & "}@w{}"); |
| 1172 |
Ordinary_Text (Output_Object, Text); |
| 1173 |
end Local_Target; |
| 1174 |
|
| 1175 |
procedure New_Column (Output_Object : in out Texinfo_Output_Type) |
| 1176 |
is begin |
| 1177 |
if Output_Object.Column_Count >= 4 then |
| 1178 |
Output_Object.Current_Column := Output_Object.Current_Column + 1; |
| 1179 |
Output_Object.Current_Row := 1; |
| 1180 |
end if; |
| 1181 |
end New_Column; |
| 1182 |
|
| 1183 |
procedure New_Page |
| 1184 |
(Output_Object : in out Texinfo_Output_Type; |
| 1185 |
Kind : ARM_Output.Page_Kind_Type := ARM_Output.Any_Page) |
| 1186 |
is |
| 1187 |
pragma Unreferenced (Kind); |
| 1188 |
pragma Unreferenced (Output_Object); |
| 1189 |
begin |
| 1190 |
-- No such thing in Info. |
| 1191 |
null; |
| 1192 |
end New_Page; |
| 1193 |
|
| 1194 |
procedure Ordinary_Character |
| 1195 |
(Output_Object : in out Texinfo_Output_Type; |
| 1196 |
Char : in Character) |
| 1197 |
is |
| 1198 |
Copyright : constant String := "Copyright"; |
| 1199 |
begin |
| 1200 |
case Output_Object.State is |
| 1201 |
when Contents => |
| 1202 |
null; |
| 1203 |
|
| 1204 |
when Multi_Column | Table_Header => |
| 1205 |
Add_To_Column_Item (Output_Object, "" & Char); |
| 1206 |
|
| 1207 |
when Title => |
| 1208 |
-- Check for end of title page; indicated by line starting with "Copyright" |
| 1209 |
if Output_Object.Line_Empty then |
| 1210 |
if Output_Object.First_Word_Last > 0 then |
| 1211 |
if Copyright (Output_Object.First_Word_Last + 1) = Char then |
| 1212 |
Output_Object.First_Word_Last := Output_Object.First_Word_Last + 1; |
| 1213 |
Output_Object.First_Word (Output_Object.First_Word_Last) := Char; |
| 1214 |
|
| 1215 |
if Output_Object.First_Word_Last = Copyright'Last then |
| 1216 |
End_Title_Page (Output_Object); |
| 1217 |
Output_Object.State := Normal; |
| 1218 |
Ordinary_Text (Output_Object, Output_Object.First_Word (1 .. Output_Object.First_Word_Last)); |
| 1219 |
end if; |
| 1220 |
else |
| 1221 |
-- First word is not Copyright; output it |
| 1222 |
Ordinary_Text (Output_Object, Output_Object.First_Word (1 .. Output_Object.First_Word_Last)); |
| 1223 |
Output_Object.Line_Empty := False; |
| 1224 |
end if; |
| 1225 |
else |
| 1226 |
-- No non-space seen yet |
| 1227 |
if Char = ' ' then |
| 1228 |
null; |
| 1229 |
elsif Char = Copyright (1) then |
| 1230 |
Output_Object.First_Word_Last := 1; |
| 1231 |
Output_Object.First_Word (1) := Char; |
| 1232 |
else |
| 1233 |
Escape_Put (Output_Object, Char); |
| 1234 |
Output_Object.Line_Empty := False; |
| 1235 |
end if; |
| 1236 |
end if; |
| 1237 |
else |
| 1238 |
-- Line already has stuff on it |
| 1239 |
Escape_Put (Output_Object, Char); |
| 1240 |
end if; |
| 1241 |
|
| 1242 |
when Normal => |
| 1243 |
Output_Object.Line_Empty := Char /= ' '; |
| 1244 |
|
| 1245 |
Escape_Put (Output_Object, Char); |
| 1246 |
|
| 1247 |
when Index_Start => |
| 1248 |
Escape_Put (Output_Object, Char); |
| 1249 |
if Char = '&' then |
| 1250 |
-- give debugger a place to break |
| 1251 |
Put_Line ("first index entry"); |
| 1252 |
end if; |
| 1253 |
|
| 1254 |
when Index => |
| 1255 |
case Char is |
| 1256 |
when ' ' | ',' | '[' | ']' => |
| 1257 |
Put (Output_Object.File, Char); |
| 1258 |
|
| 1259 |
when 'A' .. Last_Index_Clause => |
| 1260 |
-- Index section heading |
| 1261 |
|
| 1262 |
-- @node current |
| 1263 |
Put_Line (Output_Object.File, "@node " & Char); |
| 1264 |
|
| 1265 |
-- Add non-break space so Emacs info will use big bold |
| 1266 |
-- font for single letter titles. |
| 1267 |
Put_Line (Output_Object.File, "@section " & Char & "@w{ }"); |
| 1268 |
|
| 1269 |
when others => |
| 1270 |
Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, "Unexpected char in Index: " & Char); |
| 1271 |
end case; |
| 1272 |
end case; |
| 1273 |
end Ordinary_Character; |
| 1274 |
|
| 1275 |
procedure Ordinary_Text |
| 1276 |
(Output_Object : in out Texinfo_Output_Type; |
| 1277 |
Text : in String) |
| 1278 |
is begin |
| 1279 |
case Output_Object.State is |
| 1280 |
when Contents => |
| 1281 |
null; |
| 1282 |
|
| 1283 |
when Multi_Column | Table_Header => |
| 1284 |
Add_To_Column_Item (Output_Object, Text); |
| 1285 |
|
| 1286 |
when Normal | Title | Index_Start | Index => |
| 1287 |
Output_Object.Line_Empty := False; |
| 1288 |
|
| 1289 |
Escape_Put (Output_Object, Text); |
| 1290 |
end case; |
| 1291 |
end Ordinary_Text; |
| 1292 |
|
| 1293 |
procedure Picture |
| 1294 |
(Output_Object : in out Texinfo_Output_Type; |
| 1295 |
Name : in String; |
| 1296 |
Descr : in String; |
| 1297 |
Alignment : in ARM_Output.Picture_Alignment; |
| 1298 |
Height, Width : in Natural; |
| 1299 |
Border : in ARM_Output.Border_Kind) |
| 1300 |
is |
| 1301 |
pragma Unreferenced (Border); |
| 1302 |
pragma Unreferenced (Width); |
| 1303 |
pragma Unreferenced (Height); |
| 1304 |
pragma Unreferenced (Alignment); |
| 1305 |
pragma Unreferenced (Name); |
| 1306 |
begin |
| 1307 |
Ada.Exceptions.Raise_Exception |
| 1308 |
(ARM_Output.Not_Valid_Error'Identity, |
| 1309 |
"Picture: " & Descr); |
| 1310 |
end Picture; |
| 1311 |
|
| 1312 |
procedure Revised_Clause_Header |
| 1313 |
(Output_Object : in out Texinfo_Output_Type; |
| 1314 |
New_Header_Text : in String; |
| 1315 |
Old_Header_Text : in String; |
| 1316 |
Level : in ARM_Contents.Level_Type; |
| 1317 |
Clause_Number : in String; |
| 1318 |
Version : in ARM_Contents.Change_Version_Type; |
| 1319 |
Old_Version : in ARM_Contents.Change_Version_Type; |
| 1320 |
Top_Level_Subdivision_Name : in ARM_Output.Top_Level_Subdivision_Name_Kind; |
| 1321 |
No_Page_Break : in Boolean := False) |
| 1322 |
is |
| 1323 |
pragma Unreferenced (Version); |
| 1324 |
pragma Unreferenced (Old_Version); |
| 1325 |
pragma Unreferenced (Old_Header_Text); |
| 1326 |
begin |
| 1327 |
Clause_Header (Output_Object, New_Header_Text, Level, Clause_Number, |
| 1328 |
Top_Level_Subdivision_Name, No_Page_Break); |
| 1329 |
end Revised_Clause_Header; |
| 1330 |
|
| 1331 |
procedure Section |
| 1332 |
(Output_Object : in out Texinfo_Output_Type; |
| 1333 |
Section_Title : in String; |
| 1334 |
Section_Name : in String) |
| 1335 |
is |
| 1336 |
pragma Unreferenced (Section_Name); |
| 1337 |
pragma Unreferenced (Section_Title); |
| 1338 |
pragma Unreferenced (Output_Object); |
| 1339 |
begin |
| 1340 |
-- This is redundant with the various Clause functions |
| 1341 |
null; |
| 1342 |
end Section; |
| 1343 |
|
| 1344 |
procedure Separator_Line |
| 1345 |
(Output_Object : in out Texinfo_Output_Type; |
| 1346 |
Is_Thin : Boolean := True) |
| 1347 |
is begin |
| 1348 |
-- Can't be in a multi-column setting. |
| 1349 |
New_Line (Output_Object.File); |
| 1350 |
if Is_Thin then |
| 1351 |
Put_Line (Output_Object.File, "----------"); |
| 1352 |
else |
| 1353 |
Put_Line (Output_Object.File, "=========="); |
| 1354 |
end if; |
| 1355 |
end Separator_Line; |
| 1356 |
|
| 1357 |
procedure Set_Columns |
| 1358 |
(Output_Object : in out Texinfo_Output_Type; |
| 1359 |
Number_of_Columns : in ARM_Output.Column_Count) |
| 1360 |
is begin |
| 1361 |
Check_Valid (Output_Object); |
| 1362 |
Check_Not_In_Paragraph (Output_Object); |
| 1363 |
|
| 1364 |
-- 2 and 3 column formats are displayed without any columns. |
| 1365 |
-- This is mainly used for the syntax cross-reference and |
| 1366 |
-- index, and these definitely look better without columns. |
| 1367 |
-- |
| 1368 |
-- 4 or more columns are output as a table. Note that we assume |
| 1369 |
-- such items are formated with explicit New_Column calls, and |
| 1370 |
-- do not contain any nested paragraph formats. |
| 1371 |
|
| 1372 |
case Output_Object.State is |
| 1373 |
when Normal => |
| 1374 |
if Number_of_Columns >= 4 then |
| 1375 |
Output_Object.State := Multi_Column; |
| 1376 |
Output_Object.Current_Column := 1; |
| 1377 |
Output_Object.Current_Row := 1; |
| 1378 |
Output_Object.Column_Widths := (others => 0); |
| 1379 |
|
| 1380 |
-- Accumulate all column rows in Output_Text, then output |
| 1381 |
-- when done, so we can set the correct column width in |
| 1382 |
-- the header. Each column is a linked list of allocated |
| 1383 |
-- Column_Text_Item_Type. |
| 1384 |
else |
| 1385 |
null; |
| 1386 |
end if; |
| 1387 |
|
| 1388 |
when Multi_Column => |
| 1389 |
if Number_of_Columns = 1 then |
| 1390 |
-- Finished accumulating columns, output the columns as a table. |
| 1391 |
Output_Column_Widths (Output_Object); |
| 1392 |
Output_Columns (Output_Object); |
| 1393 |
New_Line (Output_Object.File); |
| 1394 |
Put_Line (Output_Object.File, "@end multitable"); |
| 1395 |
New_Line (Output_Object.File); |
| 1396 |
|
| 1397 |
Output_Object.State := Normal; |
| 1398 |
else |
| 1399 |
Ada.Exceptions.Raise_Exception |
| 1400 |
(ARM_Output.Not_Valid_Error'Identity, "New multi-column section before end of old"); |
| 1401 |
end if; |
| 1402 |
|
| 1403 |
when Index_Start | Index => |
| 1404 |
null; |
| 1405 |
|
| 1406 |
when Table_Header | Contents | Title => |
| 1407 |
Unexpected_State (Output_Object); |
| 1408 |
end case; |
| 1409 |
|
| 1410 |
Output_Object.Column_Count := Number_of_Columns; |
| 1411 |
end Set_Columns; |
| 1412 |
|
| 1413 |
procedure Soft_Hyphen_Break (Output_Object : in out Texinfo_Output_Type) |
| 1414 |
is begin |
| 1415 |
Put (Output_Object.File, "@-"); |
| 1416 |
end Soft_Hyphen_Break; |
| 1417 |
|
| 1418 |
procedure Soft_Line_Break (Output_Object : in out Texinfo_Output_Type) |
| 1419 |
is begin |
| 1420 |
case Output_Object.State is |
| 1421 |
when Contents | Title => |
| 1422 |
null; |
| 1423 |
|
| 1424 |
when Normal | Index_Start | Index => |
| 1425 |
Put (Output_Object.File, "@-"); |
| 1426 |
|
| 1427 |
when Multi_Column | Table_Header => |
| 1428 |
Unexpected_State (Output_Object); |
| 1429 |
|
| 1430 |
end case; |
| 1431 |
end Soft_Line_Break; |
| 1432 |
|
| 1433 |
procedure Special_Character |
| 1434 |
(Output_Object : in out Texinfo_Output_Type; |
| 1435 |
Char : in ARM_Output.Special_Character_Type) |
| 1436 |
is begin |
| 1437 |
-- We use Ordinary_Text, so this is output to columns when appropriate. |
| 1438 |
case Char is |
| 1439 |
when ARM_Output.EM_Dash => |
| 1440 |
Ordinary_Text (Output_Object, "--"); |
| 1441 |
when ARM_Output.EN_Dash => |
| 1442 |
Ordinary_Text (Output_Object, "-"); -- used for '-' in binary_adding_operator |
| 1443 |
when ARM_Output.GEQ => |
| 1444 |
Ordinary_Text (Output_Object, ">="); |
| 1445 |
when ARM_Output.LEQ => |
| 1446 |
Ordinary_Text (Output_Object, "<="); |
| 1447 |
when ARM_Output.NEQ => |
| 1448 |
Ordinary_Text (Output_Object, "/="); |
| 1449 |
when ARM_Output.PI => |
| 1450 |
Ordinary_Text (Output_Object, "PI"); |
| 1451 |
|
| 1452 |
when ARM_Output.Left_Ceiling => |
| 1453 |
case Output_Object.State is |
| 1454 |
when Multi_Column | Table_Header => |
| 1455 |
Ada.Exceptions.Raise_Exception |
| 1456 |
(ARM_Output.Not_Valid_Error'Identity, |
| 1457 |
"Info does not support ceiling in multi-column"); |
| 1458 |
when Contents => |
| 1459 |
null; |
| 1460 |
|
| 1461 |
when Normal | Index_Start | Index => |
| 1462 |
Put (Output_Object.File, "@code{ceiling("); |
| 1463 |
|
| 1464 |
when Title => |
| 1465 |
Unexpected_State (Output_Object); |
| 1466 |
|
| 1467 |
end case; |
| 1468 |
|
| 1469 |
when ARM_Output.Right_Ceiling => |
| 1470 |
case Output_Object.State is |
| 1471 |
when Multi_Column | Table_Header => |
| 1472 |
Ada.Exceptions.Raise_Exception |
| 1473 |
(ARM_Output.Not_Valid_Error'Identity, |
| 1474 |
"Info does not support ceiling in multi-column"); |
| 1475 |
when Contents => |
| 1476 |
null; |
| 1477 |
|
| 1478 |
when Normal | Index_Start | Index => |
| 1479 |
Put (Output_Object.File, ")}"); |
| 1480 |
|
| 1481 |
when Title => |
| 1482 |
Unexpected_State (Output_Object); |
| 1483 |
|
| 1484 |
end case; |
| 1485 |
|
| 1486 |
when ARM_Output.Left_Floor => |
| 1487 |
case Output_Object.State is |
| 1488 |
when Multi_Column | Table_Header => |
| 1489 |
Ada.Exceptions.Raise_Exception |
| 1490 |
(ARM_Output.Not_Valid_Error'Identity, |
| 1491 |
"Info does not support floor in multi-column"); |
| 1492 |
when Contents => |
| 1493 |
null; |
| 1494 |
|
| 1495 |
when Normal | Index_Start | Index => |
| 1496 |
Put (Output_Object.File, "@code{floor("); |
| 1497 |
|
| 1498 |
when Title => |
| 1499 |
Unexpected_State (Output_Object); |
| 1500 |
|
| 1501 |
end case; |
| 1502 |
|
| 1503 |
when ARM_Output.Right_Floor => |
| 1504 |
case Output_Object.State is |
| 1505 |
when Multi_Column | Table_Header => |
| 1506 |
Ada.Exceptions.Raise_Exception |
| 1507 |
(ARM_Output.Not_Valid_Error'Identity, |
| 1508 |
"Info does not support floor in multi-column"); |
| 1509 |
when Contents => |
| 1510 |
null; |
| 1511 |
|
| 1512 |
when Normal | Index_Start | Index => |
| 1513 |
Put (Output_Object.File, ")}"); |
| 1514 |
|
| 1515 |
when Title => |
| 1516 |
Unexpected_State (Output_Object); |
| 1517 |
|
| 1518 |
end case; |
| 1519 |
|
| 1520 |
when ARM_Output.Thin_Space => |
| 1521 |
Ordinary_Text (Output_Object, " "); |
| 1522 |
|
| 1523 |
when ARM_Output.Left_Quote => |
| 1524 |
Ordinary_Text (Output_Object, "`"); |
| 1525 |
|
| 1526 |
when ARM_Output.Right_Quote => |
| 1527 |
Ordinary_Text (Output_Object, "'"); |
| 1528 |
|
| 1529 |
when ARM_Output.Left_Double_Quote => |
| 1530 |
Ordinary_Text (Output_Object, """"); |
| 1531 |
|
| 1532 |
when ARM_Output.Right_Double_Quote => |
| 1533 |
Ordinary_Text (Output_Object, """"); |
| 1534 |
|
| 1535 |
when ARM_Output.Small_Dotless_I => |
| 1536 |
Ordinary_Text (Output_Object, "i"); |
| 1537 |
|
| 1538 |
when ARM_Output.Capital_Dotted_I => |
| 1539 |
Ordinary_Text (Output_Object, "I"); |
| 1540 |
end case; |
| 1541 |
end Special_Character; |
| 1542 |
|
| 1543 |
procedure Start_Paragraph |
| 1544 |
(Output_Object : in out Texinfo_Output_Type; |
| 1545 |
Style : in ARM_Output.Paragraph_Style_Type; |
| 1546 |
Indent : in ARM_Output.Paragraph_Indent_Type; |
| 1547 |
Number : in String; |
| 1548 |
No_Prefix : in Boolean := False; |
| 1549 |
Tab_Stops : in ARM_Output.Tab_Info := ARM_Output.NO_TABS; |
| 1550 |
No_Breaks : in Boolean := False; |
| 1551 |
Keep_with_Next : in Boolean := False; |
| 1552 |
Space_After : in ARM_Output.Space_After_Type := ARM_Output.Normal; |
| 1553 |
Justification : in ARM_Output.Justification_Type := ARM_Output.Default) |
| 1554 |
is |
| 1555 |
pragma Unreferenced (Justification); |
| 1556 |
pragma Unreferenced (Space_After); |
| 1557 |
pragma Unreferenced (Keep_with_Next); |
| 1558 |
pragma Unreferenced (No_Breaks); |
| 1559 |
pragma Unreferenced (Tab_Stops); |
| 1560 |
|
| 1561 |
use ARM_Output; |
| 1562 |
|
| 1563 |
begin |
| 1564 |
Check_Valid (Output_Object); |
| 1565 |
Check_Not_In_Paragraph (Output_Object); |
| 1566 |
Output_Object.Paragraph_No_Prefix := No_Prefix; |
| 1567 |
|
| 1568 |
-- Note: makeinfo will do most of the formatting, so No_Breaks, |
| 1569 |
-- Keep_with_Next, Space_After, and Justification have no |
| 1570 |
-- effect here. In addition, info format has no support for |
| 1571 |
-- fonts, so the font aspects of Style are ignored as well. But |
| 1572 |
-- we try to respect the indentation and margin aspects. |
| 1573 |
|
| 1574 |
-- TexInfo does not directly support tabs, but does use a fixed |
| 1575 |
-- font, so we could emulate them. But then we'd have to track |
| 1576 |
-- output characters; let's see if we really need it. |
| 1577 |
|
| 1578 |
case Output_Object.State is |
| 1579 |
when Contents => |
| 1580 |
null; |
| 1581 |
|
| 1582 |
when Normal => |
| 1583 |
if Number'Length > 0 then |
| 1584 |
Put_Line (Output_Object.File, Number & " @*"); |
| 1585 |
end if; |
| 1586 |
|
| 1587 |
Output_Object.In_Paragraph := True; |
| 1588 |
Output_Object.Style := Style; |
| 1589 |
Output_Object.Indent := Indent; |
| 1590 |
|
| 1591 |
case Style is |
| 1592 |
when Normal | |
| 1593 |
Wide_Above | |
| 1594 |
Small | |
| 1595 |
Small_Wide_Above | |
| 1596 |
Header | |
| 1597 |
Small_Header | |
| 1598 |
Syntax_Summary => |
| 1599 |
|
| 1600 |
Handle_Indent (Output_Object, "@quotation"); |
| 1601 |
|
| 1602 |
when Index | |
| 1603 |
Title => |
| 1604 |
|
| 1605 |
null; |
| 1606 |
|
| 1607 |
when Examples | |
| 1608 |
Small_Examples | |
| 1609 |
Swiss_Examples | |
| 1610 |
Small_Swiss_Examples => |
| 1611 |
|
| 1612 |
Handle_Indent (Output_Object, "@example"); |
| 1613 |
|
| 1614 |
when Bulleted | |
| 1615 |
Small_Bulleted => |
| 1616 |
|
| 1617 |
if No_Prefix then |
| 1618 |
Handle_Indent (Output_Object, "@quotation"); |
| 1619 |
else |
| 1620 |
Handle_Indent (Output_Object, "@quotation", "@itemize @bullet"); |
| 1621 |
Put_Line (Output_Object.File, "@item "); |
| 1622 |
end if; |
| 1623 |
|
| 1624 |
when Nested_Bulleted | |
| 1625 |
Small_Nested_Bulleted => |
| 1626 |
|
| 1627 |
if No_Prefix then |
| 1628 |
Handle_Indent (Output_Object, "@quotation"); |
| 1629 |
else |
| 1630 |
Handle_Indent (Output_Object, "@quotation", "@itemize @bullet", Extra_Indent => 1); |
| 1631 |
Put_Line (Output_Object.File, "@item "); |
| 1632 |
end if; |
| 1633 |
|
| 1634 |
when Enumerated | |
| 1635 |
Small_Enumerated => |
| 1636 |
|
| 1637 |
Handle_Indent (Output_Object, "@quotation", "@itemize @w{}"); |
| 1638 |
Put (Output_Object.File, "@item "); |
| 1639 |
|
| 1640 |
when Giant_Hanging | |
| 1641 |
Small_Giant_Hanging | |
| 1642 |
Wide_Hanging | |
| 1643 |
Small_Wide_Hanging | |
| 1644 |
Medium_Hanging | |
| 1645 |
Small_Medium_Hanging | |
| 1646 |
Narrow_Hanging | |
| 1647 |
Small_Narrow_Hanging | |
| 1648 |
Hanging_in_Bulleted | |
| 1649 |
Small_Hanging_in_Bulleted => |
| 1650 |
|
| 1651 |
if No_Prefix then |
| 1652 |
-- Still in hanging part |
| 1653 |
Handle_Indent (Output_Object, "@quotation"); |
| 1654 |
Output_Object.End_Hang_Seen := True; |
| 1655 |
else |
| 1656 |
Output_Object.End_Hang_Seen := False; |
| 1657 |
end if; |
| 1658 |
|
| 1659 |
end case; |
| 1660 |
|
| 1661 |
when Index_Start | Index | Title | Multi_Column | Table_Header => |
| 1662 |
if Number'Length > 0 then |
| 1663 |
Unexpected_State (Output_Object); |
| 1664 |
end if; |
| 1665 |
|
| 1666 |
Output_Object.In_Paragraph := True; |
| 1667 |
Output_Object.Style := Style; |
| 1668 |
Output_Object.Indent := Indent; |
| 1669 |
|
| 1670 |
end case; |
| 1671 |
|
| 1672 |
end Start_Paragraph; |
| 1673 |
|
| 1674 |
procedure Start_Table |
| 1675 |
(Output_Object : in out Texinfo_Output_Type; |
| 1676 |
Columns : in ARM_Output.Column_Count; |
| 1677 |
First_Column_Width : in ARM_Output.Column_Count; |
| 1678 |
Last_Column_Width : in ARM_Output.Column_Count; |
| 1679 |
Alignment : in ARM_Output.Column_Text_Alignment; |
| 1680 |
No_Page_Break : in Boolean; |
| 1681 |
Has_Border : in Boolean; |
| 1682 |
Small_Text_Size : in Boolean; |
| 1683 |
Header_Kind : in ARM_Output.Header_Kind_Type) |
| 1684 |
is |
| 1685 |
pragma Unreferenced (Small_Text_Size); |
| 1686 |
pragma Unreferenced (Has_Border); |
| 1687 |
pragma Unreferenced (No_Page_Break); |
| 1688 |
pragma Unreferenced (Alignment); |
| 1689 |
pragma Unreferenced (Last_Column_Width); |
| 1690 |
pragma Unreferenced (First_Column_Width); |
| 1691 |
use ARM_Output; |
| 1692 |
begin |
| 1693 |
Output_Object.Column_Count := Columns; |
| 1694 |
case Header_Kind is |
| 1695 |
when Both_Caption_and_Header => |
| 1696 |
New_Line (Output_Object.File); |
| 1697 |
-- Next text output will be the caption, which we don't |
| 1698 |
-- format in any special way (first example is F.3.2 (19)). |
| 1699 |
-- Then Table_Marker (End_Caption) is called, which will |
| 1700 |
-- start the actual table. |
| 1701 |
|
| 1702 |
when Header_Only => |
| 1703 |
-- Same as Table_Marker, End_Caption. |
| 1704 |
case Columns is |
| 1705 |
when 1 => |
| 1706 |
Ada.Exceptions.Raise_Exception |
| 1707 |
(ARM_Output.Not_Valid_Error'Identity, |
| 1708 |
"Table with 1 column"); |
| 1709 |
|
| 1710 |
when 2 => |
| 1711 |
-- @table doesn't work inside @display; PDFTex fails with @table here. |
| 1712 |
-- https://lists.gnu.org/archive/html/bug-texinfo/2004-10/txtJLetHrEhdc.txt |
| 1713 |
New_Line (Output_Object.File); |
| 1714 |
Put_Line (Output_Object.File, "@multitable {wwwwwwwwww} {wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww}"); |
| 1715 |
Put (Output_Object.File, "@headitem "); |
| 1716 |
|
| 1717 |
when others => |
| 1718 |
New_Line (Output_Object.File); |
| 1719 |
Put (Output_Object.File, "@multitable"); |
| 1720 |
Output_Object.State := Table_Header; |
| 1721 |
Output_Object.Current_Column := 1; |
| 1722 |
Output_Object.Current_Row := 1; |
| 1723 |
Output_Object.Max_Row := 0; |
| 1724 |
-- The next text output via Ordinary_Text or |
| 1725 |
-- Ordinary_Character is the table headers. We |
| 1726 |
-- capture them in Output_Object.Column_Text, and |
| 1727 |
-- use them to set the table column widths. |
| 1728 |
end case; |
| 1729 |
|
| 1730 |
when No_Headers => |
| 1731 |
null; |
| 1732 |
|
| 1733 |
end case; |
| 1734 |
end Start_Table; |
| 1735 |
|
| 1736 |
procedure Tab (Output_Object : in out Texinfo_Output_Type) |
| 1737 |
is begin |
| 1738 |
case Output_Object.State is |
| 1739 |
when Contents => |
| 1740 |
null; |
| 1741 |
|
| 1742 |
when Multi_Column | Table_Header => |
| 1743 |
Ada.Exceptions.Raise_Exception |
| 1744 |
(ARM_Output.Not_Valid_Error'Identity, |
| 1745 |
"Tab in multi-column"); |
| 1746 |
|
| 1747 |
when Title => |
| 1748 |
if Output_Object.Line_Empty then |
| 1749 |
null; |
| 1750 |
else |
| 1751 |
Put (Output_Object.File, "@w{ }"); |
| 1752 |
end if; |
| 1753 |
|
| 1754 |
when Normal | Index_Start | Index => |
| 1755 |
-- Just three spaces for now, for indented trees |
| 1756 |
Put (Output_Object.File, "@w{ }"); |
| 1757 |
|
| 1758 |
end case; |
| 1759 |
end Tab; |
| 1760 |
|
| 1761 |
procedure Table_Marker |
| 1762 |
(Output_Object : in out Texinfo_Output_Type; |
| 1763 |
Marker : in ARM_Output.Table_Marker_Type) |
| 1764 |
is begin |
| 1765 |
case Marker is |
| 1766 |
when ARM_Output.End_Caption => |
| 1767 |
-- Start the actual table |
| 1768 |
case Output_Object.Column_Count is |
| 1769 |
when 1 => |
| 1770 |
Ada.Exceptions.Raise_Exception |
| 1771 |
(ARM_Output.Not_Valid_Error'Identity, |
| 1772 |
"Table with 1 column"); |
| 1773 |
|
| 1774 |
when 2 => |
| 1775 |
New_Line (Output_Object.File); |
| 1776 |
Put_Line (Output_Object.File, "@multitable {wwwwwwwwww} {wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww}"); |
| 1777 |
Put (Output_Object.File, "@headitem "); |
| 1778 |
|
| 1779 |
when others => |
| 1780 |
New_Line (Output_Object.File); |
| 1781 |
Put (Output_Object.File, "@multitable"); |
| 1782 |
Output_Object.State := Table_Header; |
| 1783 |
Output_Object.Current_Column := 1; |
| 1784 |
Output_Object.Current_Row := 1; |
| 1785 |
Output_Object.Max_Row := 0; |
| 1786 |
-- The next text output via Ordinary_Text or |
| 1787 |
-- Ordinary_Character is the table headers. We |
| 1788 |
-- capture them in Output_Object.Column_Text, and |
| 1789 |
-- use them to set the table column widths. |
| 1790 |
end case; |
| 1791 |
|
| 1792 |
when ARM_Output.End_Item => |
| 1793 |
case Output_Object.State is |
| 1794 |
when Table_Header => |
| 1795 |
Output_Object.Current_Column := Output_Object.Current_Column + 1; |
| 1796 |
Output_Object.Current_Row := 1; |
| 1797 |
|
| 1798 |
when Normal => |
| 1799 |
case Output_Object.Column_Count is |
| 1800 |
when 2 => |
| 1801 |
New_Line (Output_Object.File); |
| 1802 |
Put (Output_Object.File, "@tab "); |
| 1803 |
|
| 1804 |
when others => |
| 1805 |
Put (Output_Object.File, " @tab "); |
| 1806 |
end case; |
| 1807 |
|
| 1808 |
when Multi_Column | Contents | Title | Index_Start | Index => |
| 1809 |
Unexpected_State (Output_Object); |
| 1810 |
end case; |
| 1811 |
|
| 1812 |
when ARM_Output.End_Header => |
| 1813 |
case Output_Object.State is |
| 1814 |
when Table_Header => |
| 1815 |
Output_Object.State := Normal; |
| 1816 |
|
| 1817 |
for I in 1 .. Output_Object.Column_Count loop |
| 1818 |
Put |
| 1819 |
(Output_Object.File, |
| 1820 |
" {" & |
| 1821 |
Output_Object.Column_Text (I).Text (1 .. Output_Object.Column_Text (I).Length) & |
| 1822 |
"}"); |
| 1823 |
end loop; |
| 1824 |
|
| 1825 |
New_Line (Output_Object.File); |
| 1826 |
|
| 1827 |
Put (Output_Object.File, "@item "); |
| 1828 |
|
| 1829 |
Pad_Columns (Output_Object); |
| 1830 |
Output_Columns (Output_Object); |
| 1831 |
New_Line (Output_Object.File); |
| 1832 |
Put (Output_Object.File, "@item "); |
| 1833 |
Output_Object.Current_Column := 1; |
| 1834 |
|
| 1835 |
when Normal => |
| 1836 |
-- A two-column table; header has been output |
| 1837 |
New_Line (Output_Object.File); |
| 1838 |
Put (Output_Object.File, "@item "); |
| 1839 |
|
| 1840 |
when Contents | Multi_Column | Title | Index_Start | Index => |
| 1841 |
Unexpected_State (Output_Object); |
| 1842 |
end case; |
| 1843 |
|
| 1844 |
when ARM_Output.End_Row | ARM_Output.End_Row_Next_Is_Last => |
| 1845 |
New_Line (Output_Object.File); |
| 1846 |
Put (Output_Object.File, "@item "); |
| 1847 |
Output_Object.Current_Column := 1; |
| 1848 |
|
| 1849 |
when ARM_Output.End_Table => |
| 1850 |
New_Line (Output_Object.File); |
| 1851 |
Put_Line (Output_Object.File, "@end multitable"); |
| 1852 |
|
| 1853 |
end case; |
| 1854 |
end Table_Marker; |
| 1855 |
|
| 1856 |
procedure TOC_Marker |
| 1857 |
(Output_Object : in out Texinfo_Output_Type; |
| 1858 |
For_Start : in Boolean) |
| 1859 |
is begin |
| 1860 |
-- We use menus, not @contents (since makeinfo ignores |
| 1861 |
-- @contents in info mode). The menus (including the top menu) |
| 1862 |
-- are generated from data stored in ARM_Contents during the |
| 1863 |
-- scan pass. |
| 1864 |
|
| 1865 |
if For_Start then |
| 1866 |
Output_Object.State := Contents; |
| 1867 |
-- Ignore futher output until For_Start = False. |
| 1868 |
else |
| 1869 |
Output_Object.State := Normal; |
| 1870 |
end if; |
| 1871 |
end TOC_Marker; |
| 1872 |
|
| 1873 |
procedure Unicode_Character |
| 1874 |
(Output_Object : in out Texinfo_Output_Type; |
| 1875 |
Char : in ARM_Output.Unicode_Type) |
| 1876 |
is begin |
| 1877 |
-- Used in section 2.3 Identifiers examples, 2.5 character |
| 1878 |
-- literals examples, 2.6 string literals examples, 3.3.1 |
| 1879 |
-- Object Declarations examples, 4.4 Expressions examples |
| 1880 |
Put (Output_Object.File, "[Unicode" & ARM_Output.Unicode_Type'Image (Char) & "]"); |
| 1881 |
end Unicode_Character; |
| 1882 |
|
| 1883 |
procedure URL_Link |
| 1884 |
(Output_Object : in out Texinfo_Output_Type; |
| 1885 |
Text : in String; |
| 1886 |
URL : in String) |
| 1887 |
is begin |
| 1888 |
Put (Output_Object.File, "@uref{" & URL & "," & Text & "}"); |
| 1889 |
end URL_Link; |
| 1890 |
|
| 1891 |
end ARM_Texinfo; |