]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - Ada95/samples/rain.adb
ncurses 5.9 - patch 20140412
[ncurses.git] / Ada95 / samples / rain.adb
index f769733cd4a2a8ce99f3f00269e806c4ad58169b..d673018eb0363ad80a1f2977665e5bcf2394e985 100644 (file)
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              --
 --                                                                          --
 -- Permission is hereby granted, free of charge, to any person obtaining a  --
 -- copy of this software and associated documentation files (the            --
 ------------------------------------------------------------------------------
 --  Author:  Laurent Pautet <pautet@gnat.com>
 --  Modified by:  Juergen Pfeifer, 1997
---  Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
 --  Version Control
---  $Revision: 1.5 $
+--  $Revision: 1.8 $
+--  $Date: 2008/08/30 21:38:07 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 --                                                                          --
+with ncurses2.util; use ncurses2.util;
 with Ada.Numerics.Float_Random; use Ada.Numerics.Float_Random;
 with Status; use Status;
 with Terminal_Interface.Curses; use Terminal_Interface.Curses;
@@ -55,6 +56,10 @@ procedure Rain is
    Xpos    : array (1 .. 5) of X_Position;
    Ypos    : array (1 .. 5) of Y_Position;
 
+   done : Boolean;
+
+   c : Key_Code;
+
    N : Integer;
 
    G : Generator;
@@ -88,6 +93,7 @@ begin
 
    Visibility := Invisible;
    Set_Cursor_Visibility (Visibility);
+   Set_Timeout_Mode (Standard_Window, Non_Blocking, 0);
 
    Max_X := Lines - 5;
    Max_Y := Columns - 5;
@@ -98,7 +104,8 @@ begin
    end loop;
 
    N := 1;
-   while Process.Continue loop
+   done := False;
+   while not done and Process.Continue loop
 
       X := X_Position (Float (Max_X) * Random (G)) + 2;
       Y := Y_Position (Float (Max_Y) * Random (G)) + 2;
@@ -152,12 +159,21 @@ begin
       Xpos (N) := X;
       Ypos (N) := Y;
 
-      Refresh;
+      c := Getchar;
+      case c is
+      when Character'Pos ('q') => done := True;
+      when Character'Pos ('Q') => done := True;
+      when Character'Pos ('s') => Set_NoDelay_Mode (Standard_Window, False);
+      when Character'Pos (' ') => Set_NoDelay_Mode (Standard_Window, True);
+      when others => null;
+      end case;
+
       Nap_Milli_Seconds (50);
    end loop;
 
    Visibility := Normal;
    Set_Cursor_Visibility (Visibility);
    End_Windows;
+   Curses_Free_All;
 
 end Rain;