with Console;         use Console;
with Global_Options;  use Global_Options;

package body Traversal.Display is

   Total : Natural := 0;
   --  The total number of solutions displayed. We declare it here, rather than
   --  the private part of the package, because it is not incremented when the
   --  Display_Output switch is set to false and would thus be useless to child
   --  units. When Display_Output is false we don't want Show to do anything,
   --  especially not take a lock on the mutex since that would be a global
   --  bottleneck, and incrementing Total would require taking the lock.

   Display : constant Any_Device := Any_Device (Instance);
   --  The class-wide view of the display device

   ----------
   -- Show --
   ----------

   procedure Show (Solution : in Trail;  On : in Maze.Reference) is
      Solution_Location : constant Location := Safe_Position (Display.all, On);
   begin
      if Display_Output then
         Total := Total + 1;
         Traversal.Show (Solution);
         Put (Display.all,
              Integer'Image (Total) & " solution(s) ",
              Solution_Location);
      end if;
   end Show;

end Traversal.Display;

