------------------------------------------------------------------------------ -- PURPOSE: Terminal handler package body for Network Protocols, R1000 -- version. -- -- -- NOTES: This program was produced by the Westinghouse Electric Corporation, -- as part of the STARS Foundation Ada Software procurement effort. -- -- (c) Copyright 1987 Westinghouse Electric Corporation -- (c) Copyright 1988 Westinghouse Electric Corporation - Updates -- All Rights Reserved. -- -- This material may be reproduced by or for the U.S. Government -- pursuant to the copyright licence under DOD FAR Suppl. Clause -- 52.227-7013 August 1984. -- Author : Chris Cooper and Elizabeth T. Hobbs -------------------------------------------------------------------------------- with Terminal; with System_Utilities; with Terminal_Specific; with Io_Exceptions; with Calendar; use Calendar; with Text_Io; with Log; with Editor; package body Terminal_Io is Err_Log : Text_Io.File_Type; Temp_Out, Temp_Err : Text_Io.File_Type; Term : Terminal.Port := Terminal.Current; Tty_Input : Device_Independent_Io.File_Type; Tty_Output : Device_Independent_Io.File_Type; Name : constant String := System_Utilities.Terminal_Name (Term); Form : constant String := "~echo, ~crlf, editing = none"; procedure Tty_Prep is begin Log.Set_Output ("Temp_Out"); Log.Set_Error ("Temp_Err"); Editor.Screen.Clear; Device_Independent_Io.Open (Tty_Input, Device_Independent_Io.In_File, Name, Form); Device_Independent_Io.Open (Tty_Output, Device_Independent_Io.Out_File, Name, Form); Terminal_Specific.Input.Flush (Tty_Input); end Tty_Prep; procedure Tty_Write_Flush is begin null; end Tty_Write_Flush; procedure Tty_Write (C : Device_Independent_Io.Byte) is begin Device_Independent_Io.Write (Tty_Output, C); end Tty_Write; procedure Tty_Read (C : out Device_Independent_Io.Byte; Got_One : out Boolean; Return_After : Duration := 0.0) is Start : Time; begin C := Byte'Val (Character'Pos (Ascii.Nul)); Got_One := False; Start := Clock; loop if not Device_Independent_Io.Is_Empty (Tty_Input) then Got_One := True; exit; else if Clock - Start >= Return_After then Got_One := False; return; end if; end if; end loop; Device_Independent_Io.Read (Tty_Input, C); end Tty_Read; procedure Tty_Restore is begin Device_Independent_Io.Close (Tty_Input); Device_Independent_Io.Close (Tty_Output); Log.Reset_Output; Log.Reset_Error; Editor.Screen.Redraw; begin Tty_Prep; end Terminal_Io;