gnoga_2.1.2_5f127c56/demo/logo/logo-controller.adb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
-------------------------------------------------------------------------------
-- NAME (body)                  : logo-controller.adb
-- AUTHOR                       : Pascal Pignard
-- ROLE                         : User interface control unit.
-- NOTES                        : Ada 2012, GNOGA 1.4 beta
--
-- COPYRIGHT                    : (c) Pascal Pignard 2018
-- LICENCE                      : CeCILL V2 (http://www.cecill.info)
-- CONTACT                      : http://blady.pagesperso-orange.fr
-------------------------------------------------------------------------------

with Gnoga.Gui.Base;
with Gnoga.Gui.View.Grid;
with Gnoga.Gui.Plugin.Pixi;
with Gnoga.Gui.Plugin.Ace_Editor;
with Gnoga.Gui.Navigator;
with ZanyBlue.Text.Locales;

with Logo.View;
with Logo.Parser;
with Logo.Engine;
with logo_messages.logo_Strings;

package body Logo.Controller is

   procedure On_Click (Object : in out Gnoga.Gui.Base.Base_Type'Class);

   procedure On_Click (Object : in out Gnoga.Gui.Base.Base_Type'Class) is
      View : constant Logo.View.Default_View_Access := Logo.View.Default_View_Access (Object.Parent.Parent);
   begin
      View.Label_Text.Put_Line ("Click");
--        gnoga.log(ada.Tags.Expanded_Name(Object.Parent.Parent'tag));
   end On_Click;

   task type Interpreter (View : Logo.View.Default_View_Access) is
      entry Start;
   end Interpreter;

   task body Interpreter is
   begin
      accept Start;
      loop
         View.Console.Put (logo_messages.logo_Strings.Format_ACTN (View.Locale));
         Logo.Engine.Action (Logo.Engine.Decode (View.Console.Get_Line, View.Primitives), View);
      end loop;
   end Interpreter;

   procedure Default
     (Main_Window : in out Gnoga.Gui.Window.Window_Type'Class;
      Connection  :        access Gnoga.Application.Multi_Connect.Connection_Holder_Type)
   is
      pragma Unreferenced (Connection);
      View   : constant Logo.View.Default_View_Access := new Logo.View.Default_View_Type;
      Worker : Interpreter (View);
   begin
      View.Dynamic;
      Gnoga.Gui.Plugin.Pixi.Load_PIXI (Main_Window);
      Gnoga.Gui.Plugin.Ace_Editor.Load_Ace_Editor (Main_Window);

      View.Locale :=
        ZanyBlue.Text.Locales.Make_Locale_Narrow (Gnoga.Gui.Navigator.Language (Main_Window) & ".ISO8859-1");
      Main_Window.Document.Title (logo_messages.logo_Strings.Format_TITL (View.Locale));
--        Gnoga.Server.Connection.HTML_On_Close
--          (Main_Window.Connection_ID,
--           logo_messages.logo_Strings.Format_APPE (View.Locale));

      Logo.Parser.Fill (View.Primitives, View.Locale);
      View.Create (Main_Window, Gnoga.Gui.View.Grid.Horizontal_Split);
      --        View.Click_Button.On_Click_Handler (On_Click'Access);
      Gnoga.Activate_Exception_Handler (Worker'Identity);
      Worker.Start;
   end Default;

begin
   Gnoga.Application.Multi_Connect.On_Connect_Handler (Default'Access, "default");
end Logo.Controller;