home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
VRAC
/
TVPROMPT.EXE
/
TV_PROMP.PKG
< prev
Wrap
Text File
|
1992-06-02
|
6KB
|
174 lines
with Doscall,
Reader,
Screen,
System,
Text_Io;
procedure TV_Prompt is
Copyright: constant String := "Copyright 1992, Tom Moran";
Copy_Owner: constant String :=
"This copy uploaded to Compuserve for use by anybody";
-- if a console input is longer than one line before a CR, stop
-- file scrolling until either a CR from the console or a long time
-- between console keystrokes.
Defer_To_Console_Duration: constant Duration := 3.0;
subtype Scroll_Rates is Character range '0' .. '9';
Scroll_Passage_Time: constant array (Scroll_Rates) of Duration
:= (0.0, 16.0, 15.0, 14.0, 13.0, 12.0, 10.0, 8.0, 6.0, 4.0);
Current_Scroll_Passage_Time: Duration := Screen.Initial_Scroll_Passage_Time;
procedure Act_On_Keyins is
Nothing : constant Character := Ascii.Nul;
This_Char: Character;
Keyed_String: Screen.Scrollable_Strings;
Keyed_Count: Natural := 0;
Stopped : Boolean := False; -- is scrolling stopped?
Long_Interjection: Boolean := False; -- long line w/o cr
function What_Char return Character is
-- return Nothing if no keyin
use System;
Regs : Doscall.Most_Regs;
B : Integer;
begin
Regs.Dx := 16#00FF#; -- test for input
Doscall.Dos_Call(16#06#, Regs);
if (Regs.Flags / 64) mod 2 /= 0 then
-- nothing typed
return Nothing;
end if;
B := Integer(Regs.Ax mod 256);
if B = 0 then
-- function key, skip next half
Regs.Dx := 16#00FF#; -- test for input
Doscall.Dos_Call(16#06#, Regs);
B := Character'Pos(Ascii.Cr);
elsif B < Character'Pos(' ') then
B := Character'Pos(Ascii.Cr);
elsif B > 127 then
B := Character'Pos(' ');
end if;
return Character'Val(B);
end What_Char;
begin -- Act_On_Keyins
Check_Keyboard:
loop
This_Char := What_Char;
if This_Char = Nothing then
delay 0.2;
else
if Keyed_Count = 0 then
-- first position, check for control
if This_Char = '.' then -- operator wants us to quit
exit Check_Keyboard;
elsif This_Char in Scroll_Rates then -- change to different speed
Screen.Scroller.Adjust_Speed(Scroll_Passage_Time(This_Char));
Stopped := This_Char = '0';
if not Stopped then
Current_Scroll_Passage_Time := Scroll_Passage_Time(This_Char);
end if;
elsif This_Char = '+' then -- faster! cut scroll passage time
Current_Scroll_Passage_Time
:= Current_Scroll_Passage_Time-Current_Scroll_Passage_Time/10;
Screen.Scroller.Adjust_Speed(Current_Scroll_Passage_Time);
Stopped := False;
elsif This_Char = '-' then -- slower! increase passage time
Current_Scroll_Passage_Time
:= Current_Scroll_Passage_Time+Current_Scroll_Passage_Time/10;
Screen.Scroller.Adjust_Speed(Current_Scroll_Passage_Time);
Stopped := False;
elsif This_Char /= Ascii.Cr and not Stopped then
-- continuation line
Keyed_String := " ";
Keyed_Count := 2;
Keyed_String(2) := This_Char;
end if;
else
-- not first char in line
if This_Char = Ascii.Cr then
Screen.Scroller.Put(Keyed_String, White_On_Black => True);
if Reader.Read_File'callable then
begin
select
Reader.Read_File.End_Defer;
else
null; -- it may not be defering anyway
end select;
exception
when Tasking_Error =>
null; -- OK if Reader.Read_File terminated between
-- 'if callable' and 'select'
end;
end if;
Long_Interjection := False;
Keyed_Count := 0;
else
Keyed_Count := Keyed_Count + 1;
Keyed_String(Keyed_Count) := This_Char;
if Long_Interjection
and then Reader.Read_File'callable then
begin
select
Reader.Read_File.Continue_Deferring;
else
null;
end select;
exception
when Tasking_Error =>
null; -- OK if read_file terminated
end;
end if;
if Keyed_Count = Screen.Scrollable_Strings'Last then
if (not Long_Interjection)
and then Reader.Read_File'callable then
begin
select
-- start read_file defering to console
Reader.Read_File.Defer(Defer_To_Console_Duration);
Long_Interjection := True;
or
delay 1.5;
end select;
exception
when Tasking_Error =>
null; -- OK if read_file terminated
end;
end if;
Screen.Scroller.Put(Keyed_String, White_On_Black => True);
Keyed_Count := 1; -- start rest of line with ' ' so +-. OK
Keyed_String := " ";
end if;
end if;
end if;
end if;
end loop Check_Keyboard;
end Act_On_Keyins;
begin -- TV_Prompt
Text_Io.Put(Copyright);
Text_Io.New_Line;
Text_Io.Put(Copy_Owner);
delay 1.0;
Screen.Scroller.Start_Up;
Reader.Read_File.Start_Up;
Act_On_Keyins;
if not Reader.Read_File'terminated then
-- tell it to die
select
Reader.Read_File.Premature_Death;
or
-- remembering that it may be delaying on a Defer to console
-- before it looks up and sees us calling
delay Defer_To_Console_Duration+1.0;
end select;
end if;
Screen.Scroller.Wind_Up;
end TV_Prompt;