70 lines
1.9 KiB
Plaintext
70 lines
1.9 KiB
Plaintext
|
DEFINITION MODULE Terminal;
|
|||
|
(*
|
|||
|
Terminal Input/Output
|
|||
|
|
|||
|
|
|||
|
Derived from the Lilith Modula-2 system developed by the
|
|||
|
group of Prof. N. Wirth at ETH Zurich, Switzerland.
|
|||
|
*)
|
|||
|
|
|||
|
|
|||
|
EXPORT QUALIFIED Read, KeyPressed, ReadAgain, ReadString,
|
|||
|
Write, WriteString, WriteLn;
|
|||
|
|
|||
|
|
|||
|
PROCEDURE Read (VAR ch: CHAR);
|
|||
|
(*- Read a character from the terminal.
|
|||
|
out: ch character that was read.
|
|||
|
|
|||
|
The character is not echoed.
|
|||
|
Code ASCII.cr from keyboard is transformed into System.EOL.
|
|||
|
*)
|
|||
|
|
|||
|
PROCEDURE KeyPressed (): BOOLEAN;
|
|||
|
(*- Test if a character is available to Read from terminal.
|
|||
|
*)
|
|||
|
|
|||
|
PROCEDURE ReadAgain;
|
|||
|
(*- Undo the last read: Make the last character be re-read.
|
|||
|
*)
|
|||
|
|
|||
|
PROCEDURE ReadString(VAR string: ARRAY OF CHAR);
|
|||
|
(*- Read a line from the terminal.
|
|||
|
out: string receives the text of the line
|
|||
|
|
|||
|
Characters are accepted (and echoed) from the keyboard until <cr>
|
|||
|
is entered. The <cr> is not returned or echoed.
|
|||
|
<del> and <bs> can be used for editing.
|
|||
|
Tabs may be entered, but are expanded into blanks immediately.
|
|||
|
No other control characters may be entered.
|
|||
|
*)
|
|||
|
|
|||
|
PROCEDURE Write (ch: CHAR);
|
|||
|
(*- Write a character to the terminal.
|
|||
|
in: ch character to be written.
|
|||
|
|
|||
|
If terminal output has not been redirected, the following
|
|||
|
interpretations are made:
|
|||
|
|
|||
|
System.EOL (36C) = go to beginning of next line
|
|||
|
ASCII.ff (14C) = clear screen and set cursor home
|
|||
|
ASCII.del (177C) = erase the last character on the left
|
|||
|
ASCII.bs (10C) = move 1 character to the left
|
|||
|
ASCII.cr (15C) = go to beginning of current line
|
|||
|
ASCII.lf (12C) = move 1 line down, same column
|
|||
|
*)
|
|||
|
|
|||
|
PROCEDURE WriteString (string: ARRAY OF CHAR);
|
|||
|
(*- Write a string to the terminal.
|
|||
|
in: string string to be written.
|
|||
|
|
|||
|
The string can be terminated by a NUL (0C).
|
|||
|
*)
|
|||
|
|
|||
|
PROCEDURE WriteLn;
|
|||
|
(*- Write a new-line to the terminal.
|
|||
|
[Equivalent to Write(EOL)]
|
|||
|
*)
|
|||
|
|
|||
|
END Terminal.
|
|||
|
|