]> ncurses.scripts.mit.edu Git - ncurses.git/blob - Ada95/samples/sample-menu_demo-handler.adb
ncurses 4.1
[ncurses.git] / Ada95 / samples / sample-menu_demo-handler.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                       GNAT ncurses Binding Samples                       --
4 --                                                                          --
5 --                          Sample.Menu_Demo.Handler                        --
6 --                                                                          --
7 --                                 B O D Y                                  --
8 --                                                                          --
9 --  Version 00.92                                                           --
10 --                                                                          --
11 --  The ncurses Ada95 binding is copyrighted 1996 by                        --
12 --  Juergen Pfeifer, Email: Juergen.Pfeifer@T-Online.de                     --
13 --                                                                          --
14 --  Permission is hereby granted to reproduce and distribute this           --
15 --  binding by any means and for any fee, whether alone or as part          --
16 --  of a larger distribution, in source or in binary form, PROVIDED         --
17 --  this notice is included with any such distribution, and is not          --
18 --  removed from any of its header files. Mention of ncurses and the        --
19 --  author of this binding in any applications linked with it is            --
20 --  highly appreciated.                                                     --
21 --                                                                          --
22 --  This binding comes AS IS with no warranty, implied or expressed.        --
23 ------------------------------------------------------------------------------
24 --  Version Control
25 --  $Revision: 1.2 $
26 ------------------------------------------------------------------------------
27 with Sample.Menu_Demo.Aux;
28 with Sample.Explanation; use Sample.Explanation;
29
30 package body Sample.Menu_Demo.Handler is
31
32    package Aux renames Sample.Menu_Demo.Aux;
33
34    procedure Drive_Me (M     : in Menu;
35                        Title : in String := "")
36    is
37       L : Line_Count;
38       C : Column_Count;
39       Y : Line_Position;
40       X : Column_Position;
41    begin
42       Aux.Geometry (M, L, C, Y, X);
43       Drive_Me (M, Y, X, Title);
44    end Drive_Me;
45
46    procedure Drive_Me (M     : in Menu;
47                        Lin   : in Line_Position;
48                        Col   : in Column_Position;
49                        Title : in String := "")
50    is
51       Pan : Panel := Aux.Create (M, Title, Lin, Col);
52       V   : Cursor_Visibility := Invisible;
53    begin
54       Set_Cursor_Visibility (V);
55       loop
56          declare
57             K : Key_Code := Aux.Get_Request (M, Pan);
58             R : Driver_Result := Driver (M, K);
59          begin
60             case R is
61                when Menu_Ok => null;
62                when Unknown_Request =>
63                   if My_Driver (M, K, Pan) then
64                      exit;
65                   end if;
66                when others => Beep;
67             end case;
68          end;
69       end loop;
70       Set_Cursor_Visibility (V);
71       Aux.Destroy (M, Pan);
72    end Drive_Me;
73
74 end Sample.Menu_Demo.Handler;