-- TTY.Mesa Edited by
-- Evans on Jul 22, 1980 3:34 PM
-- Karlton on Sep 2, 1980 1:52 PM
-- Artibee on Aug 13, 1980 2:53 PM
-- Forrest on February 4, 1981 11:07 AM
-- McJones on February 4, 1981 11:10 AM

DIRECTORY
Ascii USING [CR],
Format USING [
DateFormat, LongSubString, LongSubStringDescriptor, NumberFormat],
Stream USING [Handle],
String USING [SubString],
Time USING [Packed];

TTY: DEFINITIONS =
BEGIN

-- Types

Handle: TYPE [1];

DateFormat: TYPE = Format.DateFormat;
LongSubStringDescriptor: TYPE = Format.LongSubStringDescriptor;
LongSubString: TYPE = Format.LongSubString;
NumberFormat: TYPE = Format.NumberFormat;

-- Signals

LineOverflow: SIGNAL [s: STRING] RETURNS [ns: STRING];
Rubout: SIGNAL;
NoBackingFile: ERROR; -- raised by BackingStream
OutOfInstances: ERROR; -- raised by Create

-- Starting and stopping

Create: PROCEDURE [name: STRING] RETURNS [h: Handle];
Destroy: PROCEDURE[h: Handle];

UserAbort: PROCEDURE RETURNS [yes: BOOLEAN];
ResetUserAbort: PROCEDURE;

-- Utilities

BackingStream: PROCEDURE [h: Handle] RETURNS [stream: Stream.Handle];
CharsAvailable: PROCEDURE [h: Handle] RETURNS [number: CARDINAL];
NewLine: PROCEDURE [h: Handle] RETURNS [yes: BOOLEAN];
PutBackChar: PROCEDURE [h: Handle, c: CHARACTER];
SetBackingSize: PROCEDURE [h: Handle, size: LONG CARDINAL];
SetEcho: PROCEDURE [h: Handle, new: BOOLEAN] RETURNS [old: BOOLEAN];

-- Read & write procedures

GetChar: PROCEDURE [h: Handle] RETURNS [c: CHARACTER];
PutChar: PROCEDURE [h: Handle, c: CHARACTER];
PutCR: PROCEDURE [h: Handle] = INLINE {PutChar[h, Ascii.CR]};
PutBlanks: PROCEDURE [h: Handle, n: CARDINAL ← 1];

GetString: PROCEDURE [
h: Handle, s: STRING, t: PROCEDURE [c: CHARACTER] RETURNS [yes: BOOLEAN]];
GetEditedString: PROCEDURE [
h: Handle, s: STRING,
t: PROCEDURE [c: CHARACTER] RETURNS [yes: BOOLEAN],
newstring: BOOLEAN]
RETURNS[c: CHARACTER];
PutString: PROCEDURE [h: Handle, s: STRING];
PutLongString: PROCEDURE [h: Handle, s: LONG STRING];

PutSubString: PROCEDURE [h: Handle, ss: String.SubString];
PutLongSubString: PROCEDURE [h: Handle, ss: LongSubString];

PutDate: PROCEDURE [
h: Handle, gmt: Time.Packed, format: DateFormat ← noSeconds];

GetID, GetLine: PROCEDURE [h: Handle, s: STRING];
PutLine: PROCEDURE [h: Handle, s: STRING] = INLINE
{PutString[h, s]; PutChar[h, Ascii.CR]};

GetNumber: PROCEDURE [h: Handle, default: UNSPECIFIED, radix: CARDINAL]
RETURNS [n: UNSPECIFIED];
GetLongNumber: PROC [h: Handle, default: LONG UNSPECIFIED, radix: CARDINAL]
RETURNS [n: LONG UNSPECIFIED];
PutNumber: PROCEDURE [h: Handle, n: UNSPECIFIED, format: NumberFormat];
PutLongNumber: PROC [h: Handle, n: LONG UNSPECIFIED, format: NumberFormat];

GetOctal: PROCEDURE [h: Handle] RETURNS [n: UNSPECIFIED];
GetLongOctal: PROCEDURE [h: Handle] RETURNS [n: LONG UNSPECIFIED];
PutOctal: PROCEDURE [h: Handle, n: UNSPECIFIED];
PutLongOctal: PROCEDURE [h: Handle, n: LONG UNSPECIFIED];

GetDecimal: PROCEDURE [h: Handle] RETURNS [n: INTEGER];
GetLongDecimal: PROCEDURE [h: Handle] RETURNS [n: LONG INTEGER];
PutDecimal: PROCEDURE [h: Handle, n: INTEGER];
PutLongDecimal: PROCEDURE [h: Handle, n: LONG INTEGER];

END.