DEFINITION GEMIO; (* SJ 9.5.93 *) (* GEMIO is a standard module for text input/output in a window. It is * compatible with IO for TOS and for Chatwin. Therefore it is possible * to import IO and let the linker import GEMIO by defining an * environment variable LINK_IO=GEMIO. * GEMIO uses TermWin, so if you are shure to use a window for output, * it is more efficient to use TermWin instead of GEMIO. * * Note: When waiting for a key (ReadKey, ReadChar, ReadString), no other * events will be received. *) CONST left = 0; right = 1; center = 2; noadj = 3; leftadd = 4; rightadd = 5; (* format codes for WriteFInt and WriteReal. left : add character Fill in front of the number until Len is reached. right : add character Fill at the end of the number until Len is reached. center : add character Fill in front and at the end of the number until Len is reached. noadj : do not format the string. leftadd : adds as much characters Fill as Len determines in front of the number. rightadd : adds as much characters Fill as Len determines in front of the number. *) (* ---------------------------- input -----------------------------------*) PROCEDURE KeyPressed() : BOOLEAN; (* Returns true if there is a key available *) PROCEDURE ReadChar() : CHAR; (* Waits for a key to be pressed. The character is output before leaving ReadChar. Keys returning an ascii code smaller than " " are ignored. *) PROCEDURE ReadKey(VAR Shift : SET; VAR Scan : INTEGER; VAR Ascii : CHAR); (* Waits for a key to be pressed. The character is not output. All keys are returned without any interpretation. *) PROCEDURE ReadString(VAR Input : ARRAY OF CHAR); (* lets the user edit a string. He is not allowed to leave the line or to set the cursor left from the cursor position at the call of ReadString. Only return and enter will leave ReadString. *) PROCEDURE ReadInt(Base : INTEGER; VAR Value : LONGINT) : BOOLEAN; (* Reads a string using ReadString and converts it to an integer number using NumStr.ToLInt. It returns false if the input was no correct number. *) PROCEDURE ReadReal(VAR Value : REAL) : BOOLEAN; (* Reads a string using ReadString and converts it to a real number using NumStr.ToReal. It returns false if the input was no correct number. *) (* ---------------------------- output ----------------------------------*) PROCEDURE BufferOn; (* Switches to buffer output mode. Output done by WriteChar or WriteString is stored in a buffer and written on call of OutputBuffer or WriteLn. This is useful if a line is written by several calls of WriteChar, because it saves time. It can also be used if the output needs a correction afterwards. *) PROCEDURE BufferOff; (* Writes the buffer contents and switches to direct output mode. All output done by WriteChar and WriteString appears on the screen immediately. This is the default mode. *) PROCEDURE PrevOutMode; (* returns to the output mode that was used before the last call of BufferOn or BufferOff. *) PROCEDURE OutputBuffer; (* Writes the buffered output onto the screen *) PROCEDURE WriteChar(c : CHAR); (* Writes character c onto the screen (or into the buffer). Escape sequences are allowed *) PROCEDURE WriteString(Output : ARRAY OF CHAR); (* Output is written into the screen (or into the buffer if buffer is on). Escape sequences are allowed. *) PROCEDURE WriteLn; (* If buffer is on, the buffer is written and cleared. The rest of the line is deleted. The cursor is set into the following line in column 0. If the cursor is in the last line, the screen is scrolled up. *) PROCEDURE Return; (* same function as WriteLn, but the rest of the line is not deleted. Should be used after ReadString, because GEMDOS seems to restore the cursor position it had on call of GEMDOS.Cconrs, so that WriteLn would delete the string that was inputted. *) PROCEDURE WriteInt(Value : LONGINT); (* Writes a decimal integer value *) PROCEDURE WriteFInt(Value : LONGINT; Base,Adj,Len : INTEGER; Fill : CHAR); (* Writes an integer value with any base Base. For example, base 10 is decimal, 16 hexadecimal and so on. The string is formatted with Strings.Adjust. See definition of Strings for explanation of Adj,Len and Fill. *) PROCEDURE WriteReal(Value : REAL; n,Adj,Len : INTEGER; Fill : CHAR); (* Writes a real value with n digits after the decimal point. The string is formatted with Strings.Adjust. See definition of Strings for explanation of Adj,Len and Fill. *) PROCEDURE ClearToEOL; (* If buffer is on, the buffer is written and cleared. The rest of the line starting at the cursor position is cleared. *) (* ---------------------------- cursor ----------------------------------*) PROCEDURE CursorOn; (* switches cursor on. Nothing is done if already on *) PROCEDURE CursorOff; (* switches cursor off. Nothing is done if already off *) PROCEDURE SetCursor(Row,Col : INTEGER); (* sets the cursor at the desired position. *) PROCEDURE SetBufPos(Pos : INTEGER); (* Sets the cursor position in the output buffer. Position 0 is the first character written into the buffer. *) PROCEDURE GetBufPos() : INTEGER; (* returns the cursor position in the output buffer. Position 0 is the first character written into the buffer. *) PROCEDURE PrevBufPos; (* restores the cursor position of the buffer that was used before the last call of SetBufPos. *) PROCEDURE WrapOn; (* Enables wrap mode which automatically writes a character into the next line if the current one is full. *) PROCEDURE WrapOff; (* Disables wrap mode so that output will stop in the last line *) PROCEDURE CursorLeft; (* sets cursor one position to the left. Nothing happens in column 0. *) PROCEDURE CursorRight; (* sets cursor one position to the left. Nothing happens in last column. *) PROCEDURE CursorUp; (* sets cursor one row up. Nothing happens in row 0. *) PROCEDURE CursorDown; (* sets cursor one row down. The screen is scrolled up if the cursor was in the last row. *) PROCEDURE ClearHome; (* clears the screen and sets the cursor in the upper left corner. *) PROCEDURE ClearToEOS; (* If buffer is on, the buffer is written and cleared. Clears the rest of the screen starting at the cursor position. *) END GEMIO.