bbt_0.0.6_807c8d3a/src/bbt-status_bar.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
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
with AnsiAda,
     Ada.Strings.Fixed,
     Ada.Text_IO;

use AnsiAda,
    Ada.Text_IO;

package body BBT.Status_Bar is

   Foreground_Colour : constant String := Foreground (90,   50, 200);
   Background_Colour : constant String := Background (140, 240, 250);

   Status_Line : String (1 .. 70);
   --  This is the only line that is printed in that package
   --  Fields are part of that line.
   --  When a field is updated, the whole line is printed.

   Activity_First_Row : constant Positive := 1;
   Activity_Last_Row  : constant Positive := 30;

   File_Name_First_Row : constant Positive := 34;
   File_Name_Last_Row  : constant Positive := 70;

   --  File_Name_Field : String (1 .. 30);
   --  Activity_Column : constant Positive := 2;
   --
   --  File_Name_Field  : String (1 .. 40);
   --  File_Name_Column : constant Positive := Activity_Column +
   --                      Activity_Field'Length + 2;
   -- Max_Event_Count  : Positive := 1;
   -- Event_Count      : Natural  := 0;

   Is_Enabled : Boolean := False;

   --  -------------------------------------------------------------------------
   procedure Enable is
   begin
      Is_Enabled := True;
   end Enable;

   procedure Disable is
   begin
      Is_Enabled := False;
   end Disable;

   --  -------------------------------------------------------------------------
   procedure Initialize_Progress_Bar (Max_Event : Positive) is
   begin
      null; -- Max_Event_Count := Max_Event;
   end Initialize_Progress_Bar;

   --  -------------------------------------------------------------------------
   --  function String_Part (Current_Idx : Natural) return Natural is
   --    (Current_Idx * (File_Name_Last_Row - File_Name_First_Row + 1) /
   --         Max_Event_Count);
   --  Return Idx of the Current/Max percent of the string

   --  -------------------------------------------------------------------------
   procedure Progress_Bar_Next_Step (File_Name : String) is
      use Ada.Strings;
      -- Progression_Idx : Positive;
   begin
      -- Event_Count := @ + 1;

      if Is_Enabled then
         -- Progression_Idx := String_Part (Event_Count);
         Ada.Strings.Fixed.Move ("   " & File_Name,
                                 Target  => Status_Line (File_Name_First_Row ..
                                   File_Name_Last_Row),
                                 Drop    => Right,
                                 Justify => Left,
                                 Pad     => Space);
         Put (Store);

         Put (Foreground_Colour & Background_Colour);
         Put (Position (1, 1) & Style_Wrap (Text       => Status_Line,
                                            Style      => Bright));
         --  Put (Style_Wrap (Text       => File_Name_Field
         --                   (Progression_Idx + 1 .. File_Name_Field'Last),
         --                   Style      => Invert));

         Put (Restore);
      end if;

   end Progress_Bar_Next_Step;

   --  -------------------------------------------------------------------------
   --  procedure Put_Results (Results : Documents.Test_Results_Count) is
   --  begin
   --     null;
   --  end Put_Results;

   --  -------------------------------------------------------------------------
   procedure Put_Activity (S : String) is
      use Ada.Strings;
   begin
      if Is_Enabled then
         Ada.Strings.Fixed.Move ("   " & S,
                                 Target  => Status_Line
                                   (Activity_First_Row .. Activity_Last_Row),
                                 Drop    => Right,
                                 Justify => Left,
                                 Pad     => Space);
         Put (Store);
         Put (Foreground_Colour & Background_Colour);
         Put (Position (1, 1) & Style_Wrap (Text       => Status_Line,
                                            Style      => Bright));
         Put (Restore);
      end if;
   end Put_Activity;

end BBT.Status_Bar;