]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/m2/gm2-libs-log/Terminal.mod
Update copyright years.
[thirdparty/gcc.git] / gcc / m2 / gm2-libs-log / Terminal.mod
CommitLineData
1eee94d3
GM
1(* Terminal.mod provides a Logitech 3.0 compatible and PIM [234] compatible.
2
a945c346 3Copyright (C) 2004-2024 Free Software Foundation, Inc.
1eee94d3
GM
4Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
5
6This file is part of GNU Modula-2.
7
8GNU Modula-2 is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 3, or (at your option)
11any later version.
12
13GNU Modula-2 is distributed in the hope that it will be useful, but
14WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16General Public License for more details.
17
18Under Section 7 of GPL version 3, you are granted additional
19permissions described in the GCC Runtime Library Exception, version
203.1, as published by the Free Software Foundation.
21
22You should have received a copy of the GNU General Public License and
23a copy of the GCC Runtime Library Exception along with this program;
24see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25<http://www.gnu.org/licenses/>. *)
26
27IMPLEMENTATION MODULE Terminal ;
28
29IMPORT Termbase ;
30FROM ASCII IMPORT nul, cr, tab, lf ;
31
32
33(*
34 Read - reads a single character, ch, from the underlying Termbase
35 module.
36*)
37
38PROCEDURE Read (VAR ch: CHAR) ;
39BEGIN
40 Termbase.Read(ch)
41END Read ;
42
43
44(*
45 ReadAgain - makes the last character readable again.
46*)
47
48PROCEDURE ReadAgain ;
49BEGIN
50END ReadAgain ;
51
52
53(*
54 KeyPressed - returns TRUE if a character can be read without blocking
55 the caller.
56*)
57
58PROCEDURE KeyPressed () : BOOLEAN ;
59BEGIN
60 RETURN( Termbase.KeyPressed() )
61END KeyPressed ;
62
63
64(*
65 Write - writes a single character to the Termbase module.
66*)
67
68PROCEDURE Write (ch: CHAR) ;
69BEGIN
70 Termbase.Write(ch)
71END Write ;
72
73
74(*
75 ReadString - reads a sequence of characters.
76 Tabs are expanded into 8 spaces and <cr> or <lf> terminates
77 the string.
78*)
79
80PROCEDURE ReadString (VAR s: ARRAY OF CHAR) ;
81VAR
82 t, h, i: CARDINAL ;
83BEGIN
84 i := 0 ;
85 h := HIGH(s) ;
86 IF i<=h
87 THEN
88 REPEAT
89 Read(s[i]) ;
90 IF (s[i]=cr) OR (s[i]=lf)
91 THEN
92 s[i] := nul ;
93 (* successful *)
94 RETURN
95 ELSIF s[i]=tab
96 THEN
97 t := 0 ;
98 REPEAT
99 s[i] := ' ' ;
100 INC(i) ;
101 IF i>h
102 THEN
103 RETURN
104 END ;
105 INC(t)
106 UNTIL t=8
107 END ;
108 INC(i)
109 UNTIL i>h
110 END
111END ReadString ;
112
113
114(*
115 WriteString - writes out a string which is terminated by a <nul>
116 character or the end of string HIGH(s).
117*)
118
119PROCEDURE WriteString (s: ARRAY OF CHAR) ;
120VAR
121 i, h: CARDINAL ;
122BEGIN
123 h := HIGH(s) ;
124 i := 0 ;
125 WHILE (i<=h) AND (s[i]#nul) DO
126 Write(s[i]) ;
127 INC(i)
128 END
129END WriteString ;
130
131
132(*
133 WriteLn - writes a lf character.
134*)
135
136PROCEDURE WriteLn ;
137BEGIN
138 Write(lf)
139END WriteLn ;
140
141
142END Terminal.