1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
pub use glk_sys::{event_t, glkdate_t, glktimeval_t, stream_result_t};
pub use glk_sys::{frefid_t, schanid_t, strid_t, winid_t};
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct gestalt(pub u32);
impl gestalt {
pub const Version: Self = Self(0);
pub const CharInput: Self = Self(1);
pub const LineInput: Self = Self(2);
pub const CharOutput: Self = Self(3);
pub const MouseInput: Self = Self(4);
pub const Timer: Self = Self(5);
pub const Graphics: Self = Self(6);
pub const DrawImage: Self = Self(7);
pub const Sound: Self = Self(8);
pub const SoundVolume: Self = Self(9);
pub const SoundNotify: Self = Self(10);
pub const Hyperlinks: Self = Self(11);
pub const HyperlinkInput: Self = Self(12);
pub const SoundMusic: Self = Self(13);
pub const GraphicsTransparency: Self = Self(14);
pub const Unicode: Self = Self(15);
pub const UnicodeNorm: Self = Self(16);
pub const LineInputEcho: Self = Self(17);
pub const LineTerminators: Self = Self(18);
pub const LineTerminatorKey: Self = Self(19);
pub const DateTime: Self = Self(20);
pub const Sound2: Self = Self(21);
pub const ResourceStream: Self = Self(22);
pub const GraphicsCharInput: Self = Self(23);
pub const GarglkText: Self = Self(0x1100);
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct gestalt_CharOutput(pub u32);
impl gestalt_CharOutput {
pub const CannotPrint: Self = Self(0);
pub const ApproxPrint: Self = Self(1);
pub const ExactPrint: Self = Self(2);
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct evtype(pub u32);
impl evtype {
pub const None: Self = Self(0);
pub const Timer: Self = Self(1);
pub const CharInput: Self = Self(2);
pub const LineInput: Self = Self(3);
pub const MouseInput: Self = Self(4);
pub const Arrange: Self = Self(5);
pub const Redraw: Self = Self(6);
pub const SoundNotify: Self = Self(7);
pub const Hyperlink: Self = Self(8);
pub const VolumeNotify: Self = Self(9);
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct keycode(pub u32);
impl keycode {
pub const Unknown: Self = Self(0xffffffff);
pub const Left: Self = Self(0xfffffffe);
pub const Right: Self = Self(0xfffffffd);
pub const Up: Self = Self(0xfffffffc);
pub const Down: Self = Self(0xfffffffb);
pub const Return: Self = Self(0xfffffffa);
pub const Delete: Self = Self(0xfffffff9);
pub const Escape: Self = Self(0xfffffff8);
pub const Tab: Self = Self(0xfffffff7);
pub const PageUp: Self = Self(0xfffffff6);
pub const PageDown: Self = Self(0xfffffff5);
pub const Home: Self = Self(0xfffffff4);
pub const End: Self = Self(0xfffffff3);
pub const Func1: Self = Self(0xffffffef);
pub const Func2: Self = Self(0xffffffee);
pub const Func3: Self = Self(0xffffffed);
pub const Func4: Self = Self(0xffffffec);
pub const Func5: Self = Self(0xffffffeb);
pub const Func6: Self = Self(0xffffffea);
pub const Func7: Self = Self(0xffffffe9);
pub const Func8: Self = Self(0xffffffe8);
pub const Func9: Self = Self(0xffffffe7);
pub const Func10: Self = Self(0xffffffe6);
pub const Func11: Self = Self(0xffffffe5);
pub const Func12: Self = Self(0xffffffe4);
pub fn from_char(ch: char) -> Self {
Self(u32::from(ch))
}
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct style(pub u32);
impl style {
pub const Normal: Self = Self(0);
pub const Emphasized: Self = Self(1);
pub const Preformatted: Self = Self(2);
pub const Header: Self = Self(3);
pub const Subheader: Self = Self(4);
pub const Alert: Self = Self(5);
pub const Note: Self = Self(6);
pub const BlockQuote: Self = Self(7);
pub const Input: Self = Self(8);
pub const User1: Self = Self(9);
pub const User2: Self = Self(10);
pub const NUMSTYLES: Self = Self(11);
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct wintype(pub u32);
impl wintype {
pub const AllTypes: Self = Self(0);
pub const Pair: Self = Self(1);
pub const Blank: Self = Self(2);
pub const TextBuffer: Self = Self(3);
pub const TextGrid: Self = Self(4);
pub const Graphics: Self = Self(5);
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct winmethod(pub u32);
impl winmethod {
pub const Left: Self = Self(0x00);
pub const Right: Self = Self(0x01);
pub const Above: Self = Self(0x02);
pub const Below: Self = Self(0x03);
pub const DirMask: Self = Self(0x0f);
pub const Fixed: Self = Self(0x10);
pub const Proportional: Self = Self(0x20);
pub const DivisionMask: Self = Self(0xf0);
pub const Border: Self = Self(0x000);
pub const NoBorder: Self = Self(0x100);
pub const BorderMask: Self = Self(0x100);
pub fn dir(&self) -> Self {
return Self(self.0 & Self::DirMask.0);
}
pub fn division(&self) -> Self {
return Self(self.0 & Self::DivisionMask.0);
}
pub fn border(&self) -> Self {
return Self(self.0 & Self::BorderMask.0);
}
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct fileusage(pub u32);
impl fileusage {
pub const Data: Self = Self(0x00);
pub const SavedGame: Self = Self(0x01);
pub const Transcript: Self = Self(0x02);
pub const InputRecord: Self = Self(0x03);
pub const TypeMask: Self = Self(0x0f);
pub const TextMode: Self = Self(0x100);
pub const BinaryMode: Self = Self(0x000);
pub fn get_type(&self) -> Self {
Self(self.0 & Self::TypeMask.0)
}
pub fn is_text(&self) -> bool {
(self.0 & Self::TextMode.0) != 0
}
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct filemode(pub u32);
impl filemode {
pub const Write: Self = Self(0x01);
pub const Read: Self = Self(0x02);
pub const ReadWrite: Self = Self(0x03);
pub const WriteAppend: Self = Self(0x05);
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct seekmode(pub u32);
impl seekmode {
pub const Start: Self = Self(0);
pub const Current: Self = Self(1);
pub const End: Self = Self(2);
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct stylehint(pub u32);
impl stylehint {
pub const Indentation: Self = Self(0);
pub const ParaIndentation: Self = Self(1);
pub const Justification: Self = Self(2);
pub const Size: Self = Self(3);
pub const Weight: Self = Self(4);
pub const Oblique: Self = Self(5);
pub const Proportional: Self = Self(6);
pub const TextColor: Self = Self(7);
pub const BackColor: Self = Self(8);
pub const ReverseColor: Self = Self(9);
pub const NUMHINTS: Self = Self(10);
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct stylehint_just(pub u32);
impl stylehint_just {
pub const LeftFlush: Self = Self(0);
pub const LeftRight: Self = Self(1);
pub const Centered: Self = Self(2);
pub const RightFlush: Self = Self(3);
}