Debian Codegraph @

terps/tads/tads3/vmbiftio.h

raw symbols SCIP
1 /* $Header: d:/cvsroot/tads/tads3/vmbiftad.h,v 1.2 1999/05/17 02:52:29 MJRoberts Exp $ */
2
3 /*
4 * Copyright (c) 1998, 2002 Michael J. Roberts. All Rights Reserved.
5 *
6 * Please see the accompanying license file, LICENSE.TXT, for information
7 * on using and copying this software.
8 */
9 /*
10 Name
11 vmbiftad.h - function set definition - TADS I/O function set
12 Function
13
14 Notes
15
16 Modified
17 12/06/98 MJRoberts - Creation
18 */
19
20 #ifndef VMBIFTIO_H
21 #define VMBIFTIO_H
22
23 #include "os.h"
24 #include "vmbif.h"
25 #include "utf8.h"
26
27 /* ------------------------------------------------------------------------ */
28 /*
29 * TADS I/O function set built-in functions
30 */
31 class CVmBifTIO: public CVmBif
32 {
33 public:
34 /* function vector */
35 static vm_bif_desc bif_table[];
36
37 /*
38 * Input/output functions
39 */
40 static void say(VMG_ uint argc);
41 static void logging(VMG_ uint argc);
42 static void clearscreen(VMG_ uint argc);
43 static void more(VMG_ uint argc);
44 static void input(VMG_ uint argc);
45 static void inputkey(VMG_ uint argc);
46 static void inputevent(VMG_ uint argc);
47 static void inputdialog(VMG_ uint argc);
48 static void askfile(VMG_ uint argc);
49 static void timedelay(VMG_ uint argc);
50 static void sysinfo(VMG_ uint argc);
51 static void status_mode(VMG_ uint argc);
52 static void status_right(VMG_ uint argc);
53 static void res_exists(VMG_ uint argc);
54 static void set_script_file(VMG_ uint argc);
55 static void get_charset(VMG_ uint argc);
56 static void flush_output(VMG_ uint argc);
57 static void input_timeout(VMG_ uint argc);
58 static void input_cancel(VMG_ uint argc);
59 static void log_input_event(VMG_ uint argc);
60
61 /*
62 * banner window functions
63 */
64 static void banner_create(VMG_ uint argc);
65 static void banner_delete(VMG_ uint argc);
66 static void banner_say(VMG_ uint argc);
67 static void banner_clear(VMG_ uint argc);
68 static void banner_flush(VMG_ uint argc);
69 static void banner_size_to_contents(VMG_ uint argc);
70 static void banner_goto(VMG_ uint argc);
71 static void banner_set_text_color(VMG_ uint argc);
72 static void banner_set_screen_color(VMG_ uint argc);
73 static void banner_get_info(VMG_ uint argc);
74 static void banner_set_size(VMG_ uint argc);
75
76 /*
77 * log console functions
78 */
79 static void log_console_create(VMG_ uint argc);
80 static void log_console_close(VMG_ uint argc);
81 static void log_console_say(VMG_ uint argc);
82
83 protected:
84 /*
85 * Map an "extended" keystroke from raw (os_getc_raw, os_get_event) to
86 * portable UTF-8 representation. An extended keystroke is one of the
87 * CMD_xxx key sequences, which the os_xxx layer represents by
88 * returning a null (zero) byte followed by a CMD_xxx code. The caller
89 * should simply pass the second byte of the sequence here, and we'll
90 * provide a suitable key name. The buffer that 'buf' points to must
91 * be at least 32 bytes long.
92 *
93 * - For ALT keys, we'll return a name like '[alt-x]'.
94 *
95 * - For CMD_xxx codes, we'll return a key name enclosed in square
96 * brackets; for example, for a left cursor arrow key, we'll return
97 * '[left]'.
98 *
99 * - For unknown CMD_xxx keys, we'll return '[?]'.
100 */
101 static int map_ext_key(VMG_ char *buf, int extc);
102
103 /*
104 * Map a keystroke from raw (os_getc_raw) notation to a portable UTF-8
105 * representation. Takes an array of bytes giving the local character,
106 * which might be represented as a multi-byte sequence. The caller is
107 * responsible for calling raw_key_complete() to determine when enough
108 * bytes have been fetched from the osifc layer to form a complete
109 * character.
110 *
111 * - For backspace (ctrl-H or ASCII 127), we'll return '[bksp]'.
112 *
113 * - For ASCII 10 or 13, we'll return ASCII 10 ('\n')
114 *
115 * - For ASCII 9, we'll return ASCII 9 ('\t').
116 *
117 * - For other control characters, we'll return a name like '[ctrl-z]'.
118 *
119 * - For Escape, we'll return '[esc]'.
120 *
121 * - For any non-control character that isn't a CMD_xxx command code,
122 * we'll map the character to UTF-8 and return the resulting single
123 * character (which might, of course, be more than one byte long).
124 *
125 * Returns true if we found a valid mapping for the key, false if not
126 * (in which case the buffer will be filled in with '[?]'. The return
127 * buffer is always null-terminated.
128 */
129 static int map_raw_key(VMG_ char *buf, const char *c, size_t len);
130
131 /*
132 * Determine if the given byte sequence constitutes a complete
133 * character in the local character set. Returns true if so, false if
134 * not. Callers can use this to determine how many bytes must be
135 * fetched from the keyboard to complete an entire character sequence
136 * in the local character set, which can be important when using a
137 * multi-byte character set.
138 */
139 static int raw_key_complete(VMG_ const char *c, size_t len);
140
141 /* display one or more arguments to a given console */
142 static void say_to_console(VMG_ class CVmConsole *console, uint argc);
143
144 /* close the current script file */
145 static void close_script_file(VMG0_);
146 };
147
148
149 #endif /* VMBIFTIO_H */
150
151 /* ------------------------------------------------------------------------ */
152 /*
153 * TADS I/O function set vector. Define this only if VMBIF_DEFINE_VECTOR
154 * has been defined, so that this file can be included for the prototypes
155 * alone without defining the function vector.
156 *
157 * Note that this vector is specifically defined outside of the section of
158 * the file protected against multiple inclusion.
159 */
160 #ifdef VMBIF_DEFINE_VECTOR
161
162 /* TADS input/output functions */
163 vm_bif_desc CVmBifTIO::bif_table[] =
164 {
165 { &CVmBifTIO::say, 1, 0, TRUE }, /* 0 */
166 { &CVmBifTIO::logging, 1, 1, FALSE }, /* 1 */
167 { &CVmBifTIO::clearscreen, 0, 0, FALSE }, /* 2 */
168 { &CVmBifTIO::more, 0, 0, FALSE }, /* 3 */
169 { &CVmBifTIO::input, 0, 0, FALSE }, /* 4 */
170 { &CVmBifTIO::inputkey, 0, 0, FALSE }, /* 5 */
171 { &CVmBifTIO::inputevent, 0, 1, FALSE }, /* 6 */
172 { &CVmBifTIO::inputdialog, 5, 0, FALSE }, /* 7 */
173 { &CVmBifTIO::askfile, 4, 0, FALSE }, /* 8 */
174 { &CVmBifTIO::timedelay, 1, 0, FALSE }, /* 9 */
175 { &CVmBifTIO::sysinfo, 1, 0, TRUE }, /* 10 */
176 { &CVmBifTIO::status_mode, 1, 0, FALSE }, /* 11 */
177 { &CVmBifTIO::status_right, 1, 0, FALSE }, /* 12 */
178 { &CVmBifTIO::res_exists, 1, 0, FALSE }, /* 13 */
179 { &CVmBifTIO::set_script_file, 1, 1, FALSE }, /* 14 */
180 { &CVmBifTIO::get_charset, 1, 0, FALSE }, /* 15 */
181 { &CVmBifTIO::flush_output, 0, 0, FALSE }, /* 16 */
182 { &CVmBifTIO::input_timeout, 0, 1, FALSE }, /* 17 */
183 { &CVmBifTIO::input_cancel, 1, 0, FALSE }, /* 18 */
184
185 { &CVmBifTIO::banner_create, 8, 0, FALSE }, /* 19 */
186 { &CVmBifTIO::banner_delete, 1, 0, FALSE }, /* 20 */
187 { &CVmBifTIO::banner_clear, 1, 0, FALSE }, /* 21 */
188 { &CVmBifTIO::banner_say, 1, 0, TRUE }, /* 22 */
189 { &CVmBifTIO::banner_flush, 1, 0, FALSE }, /* 23 */
190 { &CVmBifTIO::banner_size_to_contents, 1, 0, FALSE }, /* 24 */
191 { &CVmBifTIO::banner_goto, 3, 0, FALSE }, /* 25 */
192 { &CVmBifTIO::banner_set_text_color, 3, 0, FALSE }, /* 26 */
193 { &CVmBifTIO::banner_set_screen_color, 2, 0, FALSE }, /* 27 */
194 { &CVmBifTIO::banner_get_info, 1, 0, FALSE }, /* 28 */
195 { &CVmBifTIO::banner_set_size, 4, 0, FALSE }, /* 29 */
196
197 { &CVmBifTIO::log_console_create, 3, 0, FALSE }, /* 30 */
198 { &CVmBifTIO::log_console_close, 1, 0, FALSE }, /* 31 */
199 { &CVmBifTIO::log_console_say, 1, 0, TRUE }, /* 32 */
200
201 { &CVmBifTIO::log_input_event, 1, 0, FALSE } /* 33 */
202 };
203
204 #endif /* VMBIF_DEFINE_VECTOR */