DEFINITION MODULE Console;

(**********************************************************************
***************           Written by Ed Bartz           ***************
***************           Copyright  5/21/87            ***************
***************    This program may be redistributed    ***************
***************    or modified as long as these         ***************
***************    notices and all other references     ***************
***************    to the author remain intack.         ***************
***************    Also this may not be used for        ***************
***************    profit by anyone without the         ***************
***************    express permission of the author.    ***************
**********************************************************************)

  FROM Ports IMPORT MsgPortPtr;
  FROM Intuition IMPORT WindowPtr;
  FROM IO IMPORT IOStdReqPtr;

TYPE
  Conport = RECORD
     IO : IOStdReqPtr;
     msg : MsgPortPtr;
     buf : ARRAY [0..80] OF CHAR;
  END;

 PROCEDURE QueueRead(VAR Rport: Conport);
        (* queue up a read request to a console, show where to
         * put the character when ready to be returned.  Most
         * efficient if this is called right after console is
         * opened *)

 PROCEDURE OpenWRConsole(VAR Wport, Rport: Conport; w : WindowPtr):BOOLEAN;
(* Open a console device *)

 PROCEDURE OpenWConsole(VAR Wport: Conport; w : WindowPtr):BOOLEAN;
(* Open a console device *)

 PROCEDURE OpenRConsole(VAR Rport: Conport; w : WindowPtr):BOOLEAN;
(* Open a console device *)

 PROCEDURE CloseWRConsole(Wport, Rport: Conport);
(* Close a console device *)

 PROCEDURE CloseWConsole(Wport : Conport);
(* Close a console device *)

 PROCEDURE CloseRConsole(Rport: Conport);
(* Close a console device *)

 PROCEDURE PutChar(Wport: Conport; c: CHAR);
(* Output a single character to a specified console *)
 
 PROCEDURE Writestr(Wport: Conport; VAR s: ARRAY OF CHAR; len: LONGINT);
(* Output a stream of known length to a console *)

 PROCEDURE PutStr(Wport: Conport; VAR s: ARRAY OF CHAR);
(* Output a NULL-terminated string of characters to a console *)

 PROCEDURE MayGetChar(VAR Rport: Conport; VAR c: CHAR): BOOLEAN;
        (* see if there is a character to read.  If none, don't wait, 
         * come back with a value of FALSE *)
 
 PROCEDURE GetChar(VAR Rport: Conport; VAR c: CHAR);
        (* go and get a character; put the task to sleep if
         * there isn't one present *)

 PROCEDURE GetStr(VAR Rport, Wport: Conport; VAR s: ARRAY OF CHAR): BOOLEAN;
        (* get string from console device *)

END Console.
