]> ncurses.scripts.mit.edu Git - ncurses.git/blob - Ada95/samples/sample-form_demo-handler.adb
ncurses 4.1
[ncurses.git] / Ada95 / samples / sample-form_demo-handler.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                       GNAT ncurses Binding Samples                       --
4 --                                                                          --
5 --                          Sample.Form_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 Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
28 with Sample.Form_Demo.Aux;
29 with Sample.Explanation; use Sample.Explanation;
30
31 package body Sample.Form_Demo.Handler is
32
33    package Aux renames Sample.Form_Demo.Aux;
34
35    procedure Drive_Me (F     : in Form;
36                        Title : in String := "")
37    is
38       L : Line_Count;
39       C : Column_Count;
40       Y : Line_Position;
41       X : Column_Position;
42    begin
43       Aux.Geometry (F, L, C, Y, X);
44       Drive_Me (F, Y, X, Title);
45    end Drive_Me;
46
47    procedure Drive_Me (F     : in Form;
48                        Lin   : in Line_Position;
49                        Col   : in Column_Position;
50                        Title : in String := "")
51    is
52       Pan : Panel := Aux.Create (F, Title, Lin, Col);
53       V   : Cursor_Visibility := Normal;
54       Handle_CRLF : Boolean := True;
55
56    begin
57       Set_Cursor_Visibility (V);
58       if Aux.Count_Active (F) = 1 then
59          Handle_CRLF := False;
60       end if;
61       loop
62          declare
63             K : Key_Code := Aux.Get_Request (F, Pan, Handle_CRLF);
64             R : Driver_Result;
65          begin
66             if (K = 13 or else K = 10) and then not Handle_CRLF then
67                R := Unknown_Request;
68             else
69                R := Driver (F, K);
70             end if;
71             case R is
72                when Form_Ok => null;
73                when Unknown_Request =>
74                   if My_Driver (F, K, Pan) then
75                      exit;
76                   end if;
77                when others => Beep;
78             end case;
79          end;
80       end loop;
81       Set_Cursor_Visibility (V);
82       Aux.Destroy (F, Pan);
83    end Drive_Me;
84
85 end Sample.Form_Demo.Handler;