]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - Ada95/samples/sample.adb
ncurses 6.0 - patch 20180120
[ncurses.git] / Ada95 / samples / sample.adb
index 8b3d55d5fe268352dbf379226f35dbe1df1782ec..9b3759f0c53a478a230f4323bd6e5a47075f3529 100644 (file)
@@ -6,27 +6,41 @@
 --                                                                          --
 --                                 B O D Y                                  --
 --                                                                          --
 --                                                                          --
 --                                 B O D Y                                  --
 --                                                                          --
---  Version 00.92                                                           --
+------------------------------------------------------------------------------
+-- Copyright (c) 1998-2008,2011 Free Software Foundation, Inc.              --
+--                                                                          --
+-- Permission is hereby granted, free of charge, to any person obtaining a  --
+-- copy of this software and associated documentation files (the            --
+-- "Software"), to deal in the Software without restriction, including      --
+-- without limitation the rights to use, copy, modify, merge, publish,      --
+-- distribute, distribute with modifications, sublicense, and/or sell       --
+-- copies of the Software, and to permit persons to whom the Software is    --
+-- furnished to do so, subject to the following conditions:                 --
 --                                                                          --
 --                                                                          --
---  The ncurses Ada95 binding is copyrighted 1996 by                        --
---  Juergen Pfeifer, Email: Juergen.Pfeifer@T-Online.de                     --
+-- The above copyright notice and this permission notice shall be included  --
+-- in all copies or substantial portions of the Software.                   --
 --                                                                          --
 --                                                                          --
---  Permission is hereby granted to reproduce and distribute this           --
---  binding by any means and for any fee, whether alone or as part          --
---  of a larger distribution, in source or in binary form, PROVIDED         --
---  this notice is included with any such distribution, and is not          --
---  removed from any of its header files. Mention of ncurses and the        --
---  author of this binding in any applications linked with it is            --
---  highly appreciated.                                                     --
+-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  --
+-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               --
+-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   --
+-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   --
+-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    --
+-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    --
+-- THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               --
 --                                                                          --
 --                                                                          --
---  This binding comes AS IS with no warranty, implied or expressed.        --
+-- Except as contained in this notice, the name(s) of the above copyright   --
+-- holders shall not be used in advertising or otherwise to promote the     --
+-- sale, use or other dealings in this Software without prior written       --
+-- authorization.                                                           --
 ------------------------------------------------------------------------------
 ------------------------------------------------------------------------------
+--  Author:  Juergen Pfeifer, 1996
 --  Version Control
 --  Version Control
---  $Revision: 1.5 $
+--  $Revision: 1.18 $
+--  $Date: 2011/03/23 00:44:12 $
+--  Binding Version 01.00
 ------------------------------------------------------------------------------
 with Text_IO;
 
 ------------------------------------------------------------------------------
 with Text_IO;
 
-with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
 with Ada.Exceptions; use Ada.Exceptions;
 
 with Terminal_Interface.Curses; use Terminal_Interface.Curses;
 with Ada.Exceptions; use Ada.Exceptions;
 
 with Terminal_Interface.Curses; use Terminal_Interface.Curses;
@@ -36,7 +50,6 @@ with Terminal_Interface.Curses.Menus.Menu_User_Data;
 with Terminal_Interface.Curses.Menus.Item_User_Data;
 
 with Sample.Manifest; use Sample.Manifest;
 with Terminal_Interface.Curses.Menus.Item_User_Data;
 
 with Sample.Manifest; use Sample.Manifest;
-with Sample.Helpers; use Sample.Helpers;
 with Sample.Function_Key_Setting; use Sample.Function_Key_Setting;
 with Sample.Keyboard_Handler; use Sample.Keyboard_Handler;
 with Sample.Header_Handler; use Sample.Header_Handler;
 with Sample.Function_Key_Setting; use Sample.Function_Key_Setting;
 with Sample.Keyboard_Handler; use Sample.Keyboard_Handler;
 with Sample.Header_Handler; use Sample.Header_Handler;
@@ -76,11 +89,12 @@ package body Sample is
 
          package Mh is new Sample.Menu_Demo.Handler (My_Driver);
 
 
          package Mh is new Sample.Menu_Demo.Handler (My_Driver);
 
-         I : constant Item_Array (1 .. 4) :=
+         I : Item_Array_Access := new Item_Array'
            (New_Item ("Curses Core Demo"),
             New_Item ("Menu Demo"),
             New_Item ("Form Demo"),
            (New_Item ("Curses Core Demo"),
             New_Item ("Menu Demo"),
             New_Item ("Form Demo"),
-            New_Item ("Text IO Demo"));
+            New_Item ("Text IO Demo"),
+            Null_Item);
 
          M : Menu := New_Menu (I);
 
 
          M : Menu := New_Menu (I);
 
@@ -97,7 +111,7 @@ package body Sample is
                if K = QUIT then
                   return True;
                elsif K = SELECT_ITEM then
                if K = QUIT then
                   return True;
                elsif K = SELECT_ITEM then
-                  if Idx in 1 .. 4 then
+                  if Idx <= 4 then
                      Hide (Pan);
                      Update_Panels;
                   end if;
                      Hide (Pan);
                      Update_Panels;
                   end if;
@@ -108,7 +122,7 @@ package body Sample is
                      when 4 => Sample.Text_IO_Demo.Demo;
                      when others => null;
                   end case;
                      when 4 => Sample.Text_IO_Demo.Demo;
                      when others => null;
                   end case;
-                  if Idx in 1 .. 4 then
+                  if Idx <= 4 then
                      Top (Pan);
                      Show (Pan);
                      Update_Panels;
                      Top (Pan);
                      Show (Pan);
                      Update_Panels;
@@ -121,7 +135,7 @@ package body Sample is
 
       begin
 
 
       begin
 
-         if Item_Count (M) /= I'Length then
+         if (1 + Item_Count (M)) /= I'Length then
             raise Constraint_Error;
          end if;
 
             raise Constraint_Error;
          end if;
 
@@ -129,7 +143,7 @@ package body Sample is
          Ud.Set_User_Data (M, D1);
 
          I1 := new User_Data'(Data => 1174);
          Ud.Set_User_Data (M, D1);
 
          I1 := new User_Data'(Data => 1174);
-         Id.Set_User_Data (I (1), I1);
+         Id.Set_User_Data (I.all (1), I1);
 
          Set_Spacing (Men => M, Row => 2);
 
 
          Set_Spacing (Men => M, Row => 2);
 
@@ -142,11 +156,12 @@ package body Sample is
          pragma Assert (D1 = D2);
          pragma Assert (D1.Data = D2.Data);
 
          pragma Assert (D1 = D2);
          pragma Assert (D1.Data = D2.Data);
 
-         Id.Get_User_Data (I (1), I2);
+         Id.Get_User_Data (I.all (1), I2);
          pragma Assert (I1 = I2);
          pragma Assert (I1.Data = I2.Data);
 
          Delete (M);
          pragma Assert (I1 = I2);
          pragma Assert (I1.Data = I2.Data);
 
          Delete (M);
+         Free (I, True);
       end Main_Menu;
 
    begin
       end Main_Menu;
 
    begin
@@ -176,12 +191,12 @@ package body Sample is
 
          Set_Soft_Label_Key_Attributes (Color => Header_Color);
          --  This propagates the attributes to the label window
 
          Set_Soft_Label_Key_Attributes (Color => Header_Color);
          --  This propagates the attributes to the label window
-         Clear_Soft_Label_Keys; Restore_Soft_Label_Keys;
+         Refresh_Soft_Label_Keys;
       end if;
 
       Init_Keyboard_Handler;
 
       end if;
 
       Init_Keyboard_Handler;
 
-      Set_Echo_Mode (FALSE);
+      Set_Echo_Mode (False);
       Set_Raw_Mode;
       Set_Meta_Mode;
       Set_KeyPad_Mode;
       Set_Raw_Mode;
       Set_Meta_Mode;
       Set_KeyPad_Mode;
@@ -190,6 +205,7 @@ package body Sample is
       --  We have some fixed key throughout this sample
       Main_Menu;
       End_Windows;
       --  We have some fixed key throughout this sample
       Main_Menu;
       End_Windows;
+      Curses_Free_All;
 
    exception
       when Event : others =>
 
    exception
       when Event : others =>