1 (* Termbase.mod provides GNU Modula-2 with a PIM 234 compatible Termbase.
3 Copyright (C) 2004-2023 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 This file is part of GNU Modula-2.
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. *)
27 IMPLEMENTATION MODULE Termbase ;
29 FROM Storage IMPORT ALLOCATE, DEALLOCATE ;
30 FROM M2RTS IMPORT Halt ;
31 IMPORT Display, Keyboard ;
34 ReadMethods = POINTER TO RECORD
40 WriteMethod = POINTER TO RECORD
51 AssignRead - assigns a read procedure and status procedure for terminal
52 input. Done is set to TRUE if successful. Subsequent
53 Read and KeyPressed calls are mapped onto the user supplied
54 procedures. The previous read and status procedures are
55 uncovered and reused after UnAssignRead is called.
58 PROCEDURE AssignRead (rp: ReadProcedure; sp: StatusProcedure;
80 UnAssignRead - undo the last call to AssignRead and set Done to TRUE
84 PROCEDURE UnAssignRead (VAR Done: BOOLEAN) ;
95 rStack := rStack^.next ;
101 Read - reads a single character using the currently active read
105 PROCEDURE Read (VAR ch: CHAR) ;
109 Halt(__FILE__, __LINE__, __FUNCTION__, 'no active read procedure')
117 KeyPressed - returns TRUE if a character is available to be read.
120 PROCEDURE KeyPressed () : BOOLEAN ;
124 Halt(__FILE__, __LINE__, __FUNCTION__, 'no active status procedure')
126 RETURN( rStack^.s() )
132 AssignWrite - assigns a write procedure for terminal output.
133 Done is set to TRUE if successful. Subsequent
134 Write calls are mapped onto the user supplied
135 procedure. The previous write procedure is
136 uncovered and reused after UnAssignWrite is called.
139 PROCEDURE AssignWrite (wp: WriteProcedure; VAR Done: BOOLEAN) ;
159 UnAssignWrite - undo the last call to AssignWrite and set Done to TRUE
163 PROCEDURE UnAssignWrite (VAR Done: BOOLEAN) ;
174 wStack := wStack^.next ;
180 Write - writes a single character using the currently active write
184 PROCEDURE Write (VAR ch: CHAR) ;
188 Halt(__FILE__, __LINE__, __FUNCTION__, 'no active write procedure')
205 AssignRead(Keyboard.Read, Keyboard.KeyPressed, Done) ;
208 Halt(__FILE__, __LINE__, __FUNCTION__, 'failed to assign read routines from module Keyboard')
210 AssignWrite(Display.Write, Done) ;
213 Halt(__FILE__, __LINE__, __FUNCTION__, 'failed to assign write routine from module Display')