home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / vrac / adaada.zip / ADAADA.ZIP / SRC / CW_ADA / CW_BFEX_.ADA < prev    next >
Text File  |  1994-10-12  |  9KB  |  366 lines

  1. -- Copyright (c) 1994 ARINC Research Corporation
  2. -- From material copyright (c) 1991, 1992 Premia Corporation
  3. --
  4. -- This material may be reproduced by or for the US Government pursuant 
  5. -- to the copyright license under DFAR Clause 252.227-7013 (1988)
  6. --
  7. -- Developed for US Air Force under contract no. F41608-90-D-0544-0005
  8. --
  9. -- MODIFICATIONS
  10. --   94/06 - J. Neuse, SD/OSE/EA  - Initial code
  11. --   94/10 - O. Sluder, SD/OSE/EA - Cleanup
  12.  
  13. with CW_TYPES;
  14. with SYSTEM;
  15. with CW_SMAN;
  16.  
  17. -- *************
  18. -- *           *
  19. -- *  CW_BFEX  *  BODY
  20. -- *           *
  21. -- *************
  22.  
  23. package body CW_BFEX is
  24.  
  25.   -- The following pragmas are required by the Meridian OpenAda for
  26.   -- Windows 2.0 compiler in the package spec and body of code to be
  27.   -- included in a DLL, or an application calling the DLL will 
  28.   -- general protection fault
  29.   pragma SUPPRESS (elaboration_check);
  30.   pragma SUPPRESS (storage_check);
  31.  
  32.   -- ....................
  33.   -- .                  .
  34.   -- .  PosCurrentChar  .  BODY
  35.   -- .                  .
  36.   -- ....................
  37.  
  38.   function PosCurrentChar return CHARACTER is
  39.  
  40.     Return_Word : CW_TYPES.WORD := 0;
  41.     Return_Char : CHARACTER;
  42.  
  43.     -- .......................
  44.     -- .                     .
  45.     -- .  CW_PosCurrentChar  .  SPEC
  46.     -- .                     .
  47.     -- .......................
  48.  
  49.     function CW_PosCurrentChar return CW_TYPES.WORD;
  50.     pragma INTERFACE (windows, CW_PosCurrentChar, "_PosCurrentChar");
  51.  
  52.   begin
  53.     Return_Word := CW_PosCurrentChar;
  54.  
  55.     if CW_TYPES."<" (Return_Word, CW_TYPES.EOF_CHAR) then
  56.       Return_Char := CHARACTER'VAL (Return_Word);
  57.     else
  58.       Return_Char := ASCII.SUB;
  59.     end if;
  60.  
  61.     return Return_Char;
  62.  
  63.   end PosCurrentChar;
  64.  
  65.   -- .............
  66.   -- .           .
  67.   -- .  PosInit  .  BODY
  68.   -- .           .
  69.   -- .............
  70.  
  71.   function PosInit (offset : in long_integer) return BOOLEAN is
  72.  
  73.     Return_Bool : CW_TYPES.BOOL;
  74.  
  75.     -- ................
  76.     -- .              .
  77.     -- .  CW_PosInit  .  SPEC
  78.     -- .              .
  79.     -- ................
  80.  
  81.     function CW_PosInit (offset : in CW_TYPES.LONG) return CW_TYPES.BOOL;
  82.     pragma INTERFACE (windows, CW_PosInit, "_PosInit");
  83.  
  84.   begin
  85.  
  86.     Return_Bool := CW_PosInit (CW_TYPES.LONG (offset));
  87.  
  88.     return BOOLEAN'VAL (Return_Bool);
  89.   end PosInit;
  90.  
  91.   -- .................
  92.   -- .               .
  93.   -- .  PosNextChar  .  BODY
  94.   -- .               .
  95.   -- .................
  96.  
  97.   function PosNextChar return CHARACTER is
  98.  
  99.     Return_Word : CW_TYPES.WORD := 0;
  100.     Return_Char : CHARACTER;
  101.  
  102.     -- ....................
  103.     -- .                  .
  104.     -- .  CW_PosNextChar  .  SPEC
  105.     -- .                  .
  106.     -- ....................
  107.  
  108.     function CW_PosNextChar return CW_TYPES.WORD;
  109.     pragma INTERFACE (windows, CW_PosNextChar, "_PosNextChar");
  110.  
  111.   begin
  112.     Return_Word := CW_PosNextChar;
  113.  
  114.     if CW_TYPES."<" (Return_Word, CW_TYPES.EOF_CHAR) then
  115.       Return_Char := CHARACTER'VAL (Return_Word);
  116.     else
  117.       Return_Char := ASCII.SUB;
  118.     end if;
  119.  
  120.     return Return_Char;
  121.  
  122.   end PosNextChar;
  123.  
  124.   -- .................
  125.   -- .               .
  126.   -- .  PosNextLine  .  BODY
  127.   -- .               .
  128.   -- .................
  129.  
  130.   function PosNextLine (Lines : in Long_Integer) return Long_Integer is
  131.  
  132.     Return_Long : CW_TYPES.LONG := 0;
  133.  
  134.     -- ....................
  135.     -- .                  .
  136.     -- .  CW_PosNextLine  .  SPEC
  137.     -- .                  .
  138.     -- ....................
  139.  
  140.     function CW_PosNextLine (Lines : in Long_Integer) return CW_TYPES.LONG;
  141.     pragma INTERFACE (windows, CW_PosNextLine, "_PosNextLine");
  142.  
  143.   begin
  144.     Return_Long := CW_PosNextLine (Lines);
  145.     return Long_Integer (Return_Long);
  146.   end PosNextLine;
  147.  
  148.   -- .................
  149.   -- .               .
  150.   -- .  PosPrevChar  .  BODY
  151.   -- .               .
  152.   -- .................
  153.  
  154.   function PosPrevChar return CHARACTER is
  155.  
  156.     Return_Word : CW_TYPES.WORD := 0;
  157.     Return_Char : CHARACTER;
  158.  
  159.     -- ....................
  160.     -- .                  .
  161.     -- .  CW_PosPrevChar  .  SPEC
  162.     -- .                  .
  163.     -- ....................
  164.  
  165.     function CW_PosPrevChar return CW_TYPES.WORD;
  166.     pragma INTERFACE (windows, CW_PosPrevChar, "_PosPrevChar");
  167.  
  168.   begin
  169.     Return_Word := CW_PosPrevChar;
  170.  
  171.     if CW_TYPES."<" (Return_Word, CW_TYPES.EOF_CHAR) then
  172.       Return_Char := CHARACTER'VAL (Return_Word);
  173.     else
  174.       Return_Char := ASCII.SUB;
  175.     end if;
  176.  
  177.     return Return_Char;
  178.  
  179.   end PosPrevChar;
  180.  
  181.   -- .................
  182.   -- .               .
  183.   -- .  PosPrevLine  .  BODY
  184.   -- .               .
  185.   -- .................
  186.  
  187.   function PosPrevLine (Lines : in Long_Integer) return Long_Integer is
  188.  
  189.     Return_Long : CW_TYPES.LONG := 0;
  190.  
  191.     -- ....................
  192.     -- .                  .
  193.     -- .  CW_PosPrevLine  .  SPEC
  194.     -- .                  .
  195.     -- ....................
  196.  
  197.     function CW_PosPrevLine (Lines : in Long_Integer) return CW_TYPES.LONG;
  198.     pragma INTERFACE (windows, CW_PosPrevLine, "_PosPrevLine");
  199.  
  200.   begin
  201.     Return_Long := CW_PosPrevLine (Lines);
  202.     return Long_Integer (Return_Long);
  203.   end PosPrevLine;
  204.  
  205.   -- ..............
  206.   -- .            .
  207.   -- .  PosQLine  .  BODY
  208.   -- .            .
  209.   -- ..............
  210.  
  211.   function PosQLine return Long_Integer is
  212.  
  213.     Return_Long : CW_TYPES.LONG := 0;
  214.  
  215.     -- .................
  216.     -- .               .
  217.     -- .  CW_PosQLine  .  SPEC
  218.     -- .               .
  219.     -- .................
  220.  
  221.     function CW_PosQLine return CW_TYPES.LONG;
  222.     pragma INTERFACE (windows, CW_PosQLine, "_PosQLine");
  223.  
  224.   begin
  225.     Return_Long := CW_PosQLine;
  226.     return Long_Integer (Return_Long);
  227.   end PosQLine;
  228.  
  229.   -- ................
  230.   -- .              .
  231.   -- .  PosQOffset  .  BODY
  232.   -- .              .
  233.   -- ................
  234.  
  235.   function PosQOffset return Long_Integer is
  236.  
  237.     Return_Long : CW_TYPES.LONG := 0;
  238.  
  239.     -- ...................
  240.     -- .                 .
  241.     -- .  CW_PosQOffset  .  SPEC
  242.     -- .                 .
  243.     -- ...................
  244.  
  245.     function CW_PosQOffset return CW_TYPES.LONG;
  246.     pragma INTERFACE (windows, CW_PosQOffset, "_PosQOffset");
  247.  
  248.   begin
  249.     Return_Long := CW_PosQOffset;
  250.     return Long_Integer (Return_Long);
  251.   end PosQOffset;
  252.  
  253.   -- .................
  254.   -- .               .
  255.   -- .  PosSetColor  .  BODY
  256.   -- .               .
  257.   -- .................
  258.   --
  259.     -- NOTES
  260.     --   Data type integer was chosen for the color parameter based on 
  261.     --   Codewright's documentation. Page 78 of the Programmer's Reference 
  262.     --   indicates that the color is passed as specified in Appendix A of 
  263.     --   the User's Manual. Appendix A specifies that a byte is used to 
  264.     --   encode foreground and background colors. Each nibble of the byte 
  265.     --   holds one color. Other color functions listed in Appendix A use 
  266.     --   an integer to pass color, so the integer type was chosen for this 
  267.     --   implementation.
  268.  
  269.   procedure PosSetColor (color : in integer;
  270.                          count : in long_integer) is
  271.  
  272.     Passed_Word  : CW_TYPES.WORD := 0;
  273.     Passed_Count : CW_TYPES.LONG := 0;
  274.  
  275.     -- ....................
  276.     -- .                  .
  277.     -- .  CW_PosSetColor  .  SPEC
  278.     -- .                  .
  279.     -- ....................
  280.  
  281.     procedure CW_PosSetColor (color : in CW_TYPES.WORD;
  282.                               count : in CW_TYPES.LONG);
  283.     pragma INTERFACE (windows, CW_PosSetColor, "_PosSetColor");
  284.  
  285.   begin
  286.  
  287.     Passed_Word  := CW_TYPES.WORD (color);
  288.     Passed_Count := CW_TYPES.LONG (count);
  289.  
  290.     CW_PosSetColor (Passed_Word, Passed_Count);
  291.  
  292.   end PosSetColor;
  293.  
  294.   -- .................
  295.   -- .               .
  296.   -- .  BufReadChar  .  BODY
  297.   -- .               .
  298.   -- .................
  299.  
  300.   function BufReadChar return CHARACTER is
  301.  
  302.     Return_Int : INTEGER;
  303.  
  304.     -- ....................
  305.     -- .                  .
  306.     -- .  CW_BufReadChar  .  SPEC
  307.     -- .                  .
  308.     -- ....................
  309.  
  310.     function CW_BufReadChar return INTEGER;
  311.     pragma INTERFACE (windows, CW_BufReadChar, "BufReadChar");
  312.  
  313.   begin -- procedure BufReadChar
  314.  
  315.     Return_Int := CW_BufReadChar;
  316.     return CHARACTER'VAL (Return_Int);
  317.  
  318.   end BufReadChar;
  319.  
  320.   -- ................
  321.   -- .              .
  322.   -- .  BufReadStr  .  BODY
  323.   -- .              .
  324.   -- ................
  325.  
  326.   procedure BufReadStr (str : in out string) is
  327.  
  328.     Addr : SYSTEM.ADDRESS;
  329.  
  330.     -- ...................
  331.     -- .                 .
  332.     -- .  CW_BufReadStr  .  SPEC
  333.     -- .                 .
  334.     -- ...................
  335.  
  336.     function CW_BufReadStr (count : in LONG_INTEGER) return SYSTEM.ADDRESS;
  337.     pragma INTERFACE (windows, CW_BufReadStr, "BufReadStr");
  338.  
  339.   begin -- procedure BufReadStr
  340.  
  341.     Addr := CW_BufReadStr (LONG_INTEGER (str'LAST));
  342.  
  343.   Assign_Str:
  344.     declare
  345.       Temp_Str : string (1 .. str'LAST);
  346.       for Temp_Str use at Addr;
  347.       i : integer := 1;
  348.     begin -- Assign_Str
  349.  
  350.       while Temp_Str (i) /= ASCII.NUL loop
  351.         i := i + 1;
  352.       end loop;
  353.  
  354.       str (1 .. (i - 1)) := temp_str (1 .. (i - 1));
  355.       str (i)            := ASCII.CR;
  356.  
  357.     end Assign_Str;
  358.  
  359.     --  Must deallocate the memory allocated by CW_BufReadStr since
  360.     --  that string is no longer used after this function.
  361.     CW_SMAN.StrFree (Addr);
  362.  
  363.   end BufReadStr;
  364.  
  365. end CW_BFEX;
  366.