X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=Ada95%2Fsamples%2Frain.adb;h=d673018eb0363ad80a1f2977665e5bcf2394e985;hp=c576f3f38c23cf2aa5ac48a47e5b45e18f6be968;hb=6208c89f98f1cf9fe0980bd8e791846ce007a13d;hpb=a8987e73ec254703634802b4f7ee30d3a485524d diff --git a/Ada95/samples/rain.adb b/Ada95/samples/rain.adb index c576f3f3..d673018e 100644 --- a/Ada95/samples/rain.adb +++ b/Ada95/samples/rain.adb @@ -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 -- @@ -36,10 +36,12 @@ -- Author: Laurent Pautet -- Modified by: Juergen Pfeifer, 1997 -- Version Control --- $Revision: 1.6 $ +-- $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; @@ -54,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; @@ -87,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; @@ -97,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; @@ -151,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;