Eliminated warnings about static functions declared with G_GNUC_INTERNAL
[projects/chimara/chimara.git] / src / doc.c
1 /*
2  * doc.c - Contains the short and long descriptions of all the documentation
3  *         sections in the Glk spec, as well as the GtkDoc comments for symbols
4  *         defined only in glk.h.
5  */
6
7 /**
8  * SECTION:glk-exiting
9  * @short_description: How to terminate a Glk program cleanly
10  * @include: glk.h
11  *
12  * A Glk program usually ends when the end of the glk_main() function is 
13  * reached. You can also terminate it earlier.
14  */ 
15
16 /**
17  * SECTION:glk-interrupt
18  * @short_description: Specifying an interrupt handler for cleaning up critical
19  * resources
20  * @include: glk.h
21  *
22  * Most platforms have some provision for interrupting a program —
23  * <keycombo action="simul"><keycap function="command">command</keycap>
24  * <keycap>period</keycap></keycombo> on the Macintosh, <keycombo 
25  * action="simul"><keycap function="control">control</keycap><keycap>C</keycap>
26  * </keycombo> in Unix, possibly a window manager item, or other possibilities.
27  * This can happen at any time, including while execution is nested inside one 
28  * of your own functions, or inside a Glk library function.
29  *
30  * If you need to clean up critical resources, you can specify an interrupt
31  * handler function.
32  */
33
34 /**
35  * SECTION:glk-tick
36  * @short_description: Yielding time to the operating system
37  * @include: glk.h
38  *
39  * Many platforms have some annoying thing that has to be done every so often,
40  * or the gnurrs come from the voodvork out and eat your computer.
41  * 
42  * Well, not really. But you should call glk_tick() every so often, just in
43  * case. It may be necessary to yield time to other applications in a
44  * cooperative-multitasking OS, or to check for player interrupts in an infinite
45  * loop.
46  */
47
48 /**
49  * SECTION:glk-types
50  * @short_description: Basic types used in Glk
51  * @include: glk.h
52  *
53  * For simplicity, all the arguments used in Glk calls are of a very few types.
54  * <variablelist>
55  *  <varlistentry>
56  *    <term>32-bit unsigned integer</term>
57  *    <listitem><para>Unsigned integers are used wherever possible, which is
58  *    nearly everywhere. This type is called #glui32.</para></listitem>
59  *  </varlistentry>
60  *  <varlistentry>
61  *    <term>32-bit signed integer</term>
62  *    <listitem><para>This type is called #glsi32. Rarely used.</para>
63  *    </listitem>
64  *  </varlistentry>
65  *  <varlistentry>
66  *    <term>References to library objects</term>
67  *    <listitem><para>These are pointers to opaque C structures; each library
68  *    will use different structures, so you can not and should not try to
69  *    manipulate their contents. See <link 
70  *    linkend="chimara-Opaque-Objects">Opaque Objects</link>.</para></listitem>
71  *  </varlistentry>
72  *  <varlistentry>
73  *    <term>Pointer to one of the above types</term>
74  *    <listitem><para>Pointer to a structure which consists entirely of the
75  *    above types.</para></listitem>
76  *  </varlistentry>
77  *  <varlistentry>
78  *    <term><type>unsigned char</type></term> 
79  *    <listitem><para>This is used only for Latin-1 text characters; see 
80  *    <link linkend="chimara-Character-Encoding">Character Encoding</link>.
81  *    </para></listitem>
82  *  </varlistentry>
83  *  <varlistentry>
84  *    <term>Pointer to <type>char</type></term> 
85  *    <listitem><para>Sometimes this means a null-terminated string; sometimes
86  *    an unterminated buffer, with length as a separate #glui32 argument. The
87  *    documentation says which.</para></listitem>
88  *  </varlistentry>
89  *  <varlistentry>
90  *    <term>Pointer to <type>void</type></term> 
91  *    <listitem><para>When nothing else will do.</para></listitem>
92  *  </varlistentry>
93  * </variablelist>
94  */
95
96 /**
97  * SECTION:glk-opaque-objects
98  * @short_description: Complex objects in Glk
99  * @include: glk.h
100  *
101  * Glk keeps track of a few classes of special objects. These are opaque to your
102  * program; you always refer to them using pointers to opaque C structures.
103  * 
104  * Currently, these classes are:
105  * <variablelist>
106  *  <varlistentry>
107  *    <term>Windows</term>
108  *    <listitem><para>Screen panels, used to input or output information.
109  *    </para></listitem>
110  *  </varlistentry>
111  *  <varlistentry>
112  *    <term>Streams</term>
113  *    <listitem><para>Data streams, to which you can input or output text.
114  *    </para>
115  *    <note><para>There are file streams and window streams, since you can
116  *    output data to windows or files.</para></note>
117  *    </listitem>
118  *  </varlistentry>
119  *  <varlistentry>
120  *    <term>File references</term>
121  *    <listitem><para>Pointers to files in permanent storage.</para>
122  *    <note><para>In Unix a file reference is a pathname; on the Mac, an
123  *    <type>FSSpec</type>. Actually there's a little more information included,
124  *    such as file type and whether it is a text or binary file.</para></note>
125  *    </listitem>
126  *  </varlistentry>
127  *  <varlistentry>
128  *    <term>Sound channels</term>
129  *    <listitem><para>Audio output channels.</para>
130  *    <note><para>Not all Glk libraries support sound.</para></note>
131  *    </listitem>
132  *  </varlistentry>
133  * </variablelist>
134  *
135  * <note><para>
136  * Note that there may be more object classes in future versions of the Glk API.
137  * </para></note>
138  * 
139  * When you create one of these objects, it is always possible that the creation
140  * will fail (due to lack of memory, or some other OS error.) When this happens,
141  * the allocation function will return %NULL (0) instead of a valid pointer. You
142  * should always test for this possibility.
143  * 
144  * %NULL is never the identifier of any object (window, stream, file reference,
145  * or sound channel). The value %NULL is often used to indicate <quote>no
146  * object</quote> or <quote>nothing</quote>, but it is not a valid reference. If
147  * a Glk function takes an object reference as an argument, it is illegal to
148  * pass in %NULL unless the function definition says otherwise.
149  * 
150  * The <filename class="headerfile">glk.h</filename> file defines types
151  * #winid_t, #strid_t, #frefid_t, #schanid_t to store references. These are
152  * pointers to struct #glk_window_struct, #glk_stream_struct, 
153  * #glk_fileref_struct, and #glk_schannel_struct respectively. It is, of course,
154  * illegal to pass one kind of pointer to a function which expects another.
155  * 
156  * <note><para>
157  * This is how you deal with opaque objects from a C program. If you are using
158  * Glk through a virtual machine, matters will probably be different. Opaque
159  * objects may be represented as integers, or as VM objects of some sort.
160  * </para></note>
161  * <refsect2 id="chimara-Rocks"><!-- Indeed it does. -->
162  * <title>Rocks</title>
163  * <para>
164  * Every one of these objects (window, stream, file reference, or sound channel)
165  * has a <quote>rock</quote> value. This is simply a 32-bit integer value which
166  * you provide, for your own purposes, when you create the object.
167  * </para>
168  * <note><para>The library &mdash; so to speak &mdash; stuffs this value under a
169  * rock for safe-keeping, and gives it back to you when you ask for it.
170  * </para></note>
171  * <note><para>If you don't know what to use the rocks for, provide 0 and forget
172  * about it.</para></note>
173  * </refsect2>
174  * <refsect2 id="chimara-Iterating-Through-Opaque-Objects">
175  * <title>Iteration Through Opaque Objects</title>
176  * <para>
177  * For each class of opaque objects, there is an iterate function, which you can
178  * use to obtain a list of all existing objects of that class. It takes the form
179  * |[
180  * <replaceable>CLASS</replaceable>id_t glk_<replaceable>CLASS</replaceable>_iterate(<replaceable>CLASS</replaceable>id_t <parameter>obj</parameter>, #glui32 *<parameter>rockptr</parameter>);
181  * ]|
182  * ...where <code><replaceable>CLASS</replaceable></code> represents one of the
183  * opaque object classes. 
184  * </para>
185  * <note><para>
186  *   So, at the current time, these are the functions glk_window_iterate(),
187  *   glk_stream_iterate(), glk_fileref_iterate(), and glk_schannel_iterate().  
188  *   There may be more classes in future versions of the spec; they all behave
189  *   the same.
190  * </para></note>
191  * <para>
192  * Calling <code>glk_<replaceable>CLASS</replaceable>_iterate(%NULL, r)</code>
193  * returns the first object; calling 
194  * <code>glk_<replaceable>CLASS</replaceable>_iterate(obj, r)</code> returns
195  * the next object, until there aren't any more, at which time it returns %NULL.
196  * </para>
197  * <para>
198  * The @rockptr argument is a pointer to a location; whenever  
199  * <code>glk_<replaceable>CLASS</replaceable>_iterate()</code> returns an
200  * object, the object's rock is stored in the location <code>(*@rockptr)</code>.
201  * If you don't want the rocks to be returned, you may set @rockptr to %NULL.
202  * </para>
203  * <para>
204  * You usually use this as follows:
205  * |[
206  * obj = glk_<replaceable>CLASS</replaceable>_iterate(NULL, NULL);
207  * while (obj) {
208  *    /* ...do something with obj... *<!-- -->/
209  *    obj = glk_<replaceable>CLASS</replaceable>_iterate(obj, NULL);
210  * }
211  * ]|
212  * </para>
213  * <para>
214  * If you create or destroy objects inside this loop, obviously, the results are
215  * unpredictable. However it is always legal to call 
216  * <code>glk_<replaceable>CLASS</replaceable>_iterate(obj, r)</code> as long as
217  * @obj is a valid object id, or %NULL.
218  * </para>
219  * <para>
220  * The order in which objects are returned is entirely arbitrary. The library
221  * may even rearrange the order every time you create or destroy an object of
222  * the given class. As long as you do not create or destroy any object, the rule
223  * is that <code>glk_<replaceable>CLASS</replaceable>_iterate(obj, r)</code> has
224  * a fixed result, and iterating through the results as above will list every
225  * object exactly once. 
226  * </para>
227  * </refsect2>
228  */
229
230 /**
231  * SECTION:glk-gestalt
232  * @short_description: Testing Glk's capabilities
233  * @include: glk.h
234  *
235  * The <quote>gestalt</quote> mechanism (cheerfully stolen from the Mac OS) is a
236  * system by which the Glk API can be upgraded without making your life
237  * impossible. New capabilities (graphics, sound, or so on) can be added without
238  * changing the basic specification. The system also allows for 
239  * <quote>optional</quote> capabilities &mdash; those which not all Glk library
240  * implementations will support &mdash; and allows you to check for their
241  * presence without trying to infer them from a version number.
242  * 
243  * The basic idea is that you can request information about the capabilities of
244  * the API, by calling the gestalt functions.
245  */
246
247 /**
248  * SECTION:glk-character-input
249  * @short_description: Waiting for a single keystroke
250  * @include: glk.h
251  *
252  * You can request that the player hit a single key. See <link 
253  * linkend="chimara-Character-Input-Events">Character Input Events</link>.
254  * 
255  * If you use the basic text API, the character code which is returned can be
256  * any value from 0 to 255. The printable character codes have already been
257  * described. The remaining codes are typically control codes: <keycombo  
258  * action="simul"><keycap function="control">control</keycap>
259  * <keycap>A</keycap></keycombo> to <keycombo action="simul"><keycap 
260  * function="control">control</keycap><keycap>Z</keycap></keycombo> and a few
261  * others.
262  * 
263  * There are also a number of special codes, representing special keyboard
264  * keys, which can be returned from a char-input event. These are represented
265  * as 32-bit integers, starting with 4294967295 (0xFFFFFFFF) and working down.
266  * The special key codes are defined in the <filename 
267  * class="headerfile">glk.h</filename> file. They include one code for <keycap
268  * function="enter">return</keycap> or <keycap function="enter">enter</keycap>,
269  * one for <keycap function="delete">delete</keycap> or <keycap
270  * function="backspace">backspace</keycap>, twelve function keys, and one code
271  * for any key which has no Latin-1 or special code. The full list of key codes
272  * is included below.
273  * 
274  * Various implementations of Glk will vary widely in which characters the
275  * player can enter. The most obvious limitation is that some characters are
276  * mapped to others. For example, most keyboards return a <keycombo
277  * action="simul"><keycap function="control">control</keycap><keycap>I</keycap>
278  * </keycombo> code when the <keycap function="tab">tab</keycap> key is
279  * pressed. The Glk library, if it can recognize this at all, will generate a
280  * <keysym>#keycode_Tab</keysym> event (value 0xFFFFFFF7) when this occurs.
281  * Therefore, for these keyboards, no keyboard key will generate a <keycombo
282  * action="simul"><keycap function="control">control</keycap><keycap>I</keycap>
283  * </keycombo> event (value 9.) The Glk library will probably map many of the
284  * control codes to the other special keycodes.
285  * 
286  * <note><para>
287  *   On the other hand, the library may be very clever and discriminate between
288  *   <keycap>tab</keycap> and <keycombo action="simul"><keycap
289  *   function="control">control</keycap><keycap>I</keycap></keycombo>. This is
290  *   legal. The idea is, however, that if your program asks the player to
291  *   <quote><computeroutput>press the <keycap function="tab">tab</keycap>
292  *   key</computeroutput></quote>, you should check for a 
293  *   <keysym>#keycode_Tab</keysym> event as opposed to a <keycombo 
294  *   action="simul"><keycap function="control">control</keycap>
295  *   <keycap>I</keycap></keycombo> event.
296  * </para></note>
297  * 
298  * Some characters may not be enterable simply because they do not exist.
299  * 
300  * <note><para>
301  *   Not all keyboards have a <keycap function="home">home</keycap> or <keycap
302  *   function="end">end</keycap> key. A pen-based platform may not recognize
303  *   any control characters at all.
304  * </para></note>
305  * 
306  * Some characters may not be enterable because they are reserved for the
307  * purposes of the interface. For example, the Mac Glk library reserves the 
308  * <keycap function="tab">tab</keycap> key for switching between different Glk
309  * windows. Therefore, on the Mac, the library will never generate a
310  * <keysym>#keycode_Tab</keysym> event or a <keycombo action="simul">
311  * <keycap function="control">control</keycap><keycap>I</keycap></keycombo>
312  * event.
313  * 
314  * <note><para>
315  *   Note that the linefeed or <keycombo action="simul"><keycap  
316  *   function="control">control</keycap><keycap>J</keycap></keycombo> 
317  *   character, which is the only printable control character, is probably not
318  *   typable. This is because, in most libraries, it will be converted to
319  *   <keysym>#keycode_Return</keysym>. Again, you should check for
320  *   <keysym>#keycode_Return</keysym> if your program asks the player to 
321  *   <quote><computeroutput>press the <keycap function="enter">return</keycap>
322  *   key</computeroutput></quote>.
323  * </para></note>
324  * 
325  * <note><para>
326  *   The <keycap function="delete">delete</keycap> and <keycap
327  *   function="backspace">backspace</keycap> keys are merged into a single
328  *   keycode because they have such an astonishing history of being confused in
329  *   the first place... this spec formally waives any desire to define the
330  *   difference. Of course, a library is free to distinguish <keycap
331  *   function="delete">delete</keycap> and <keycap
332  *   function="backspace">backspace</keycap> during line input. This is when it
333  *   matters most; conflating the two during character input should not be a
334  *   large problem.
335  * </para></note>
336  *
337  * You can test for this by using the #gestalt_CharInput selector.
338  * 
339  * <note><para>
340  *   Glk porters take note: it is not a goal to be able to generate every
341  *   single possible key event. If the library says that it can generate a
342  *   particular keycode, then game programmers will assume that it is
343  *   available, and ask players to use it. If a <keysym>#keycode_Home</keysym>
344  *   event can only be generated by typing <keycombo action="seq"><keycap
345  *   function="escape">escape</keycap><keycombo action="simul"><keycap
346  *   function="control">control</keycap><keycap>A</keycap></keycombo>
347  *   </keycombo>, and the player does not know this, the player will be lost
348  *   when the game says <quote><computeroutput>Press the <keycap
349  *   function="home">home</keycap> key to see the next 
350  *   hint.</computeroutput></quote> It is better for the library to say that it
351  *   cannot generate a <keysym>#keycode_Home</keysym> event; that way the game
352  *   can detect the situation and ask the user to type <keycap>H</keycap>
353  *   instead.
354  * </para>
355  * <para>
356  *   Of course, it is better not to rely on obscure keys in any case. The arrow
357  *   keys and <keycap function="enter">return</keycap> are nearly certain to be
358  *   available; the others are of gradually decreasing reliability, and you
359  *   (the game programmer) should not depend on them. You must be certain to
360  *   check for the ones you want to use, including the arrow keys and <keycap
361  *   function="enter">return</keycap>, and be prepared to use different keys in
362  *   your interface if #gestalt_CharInput says they are not available.
363  * </para></note>
364  */
365
366 /**
367  * SECTION:glk-case
368  * @short_description: Changing the case of strings
369  * @include: glk.h
370  *
371  * Glk has functions to manipulate the case of both Latin-1 and Unicode strings.
372  * One Latin-1 lowercase character corresponds to one uppercase character, and
373  * vice versa, so the Latin-1 functions act on single characters. The Unicode
374  * functions act on whole strings, since the length of the string may change.
375  */
376
377 /**
378  * SECTION:glk-window-opening
379  * @short_description: Creating new windows and closing them
380  * @include: glk.h
381  *
382  * You can open a new window using glk_window_open() and close it again using
383  * glk_window_close().
384  */
385
386 /**
387  * SECTION:glk-window-constraints
388  * @short_description: Manipulating the size of a window
389  * @include: glk.h
390  *
391  * There are library functions to change and to measure the size of a window.
392  */
393
394 /**
395  * SECTION:glk-window-types
396  * @short_description: Blank, pair, text grid, text buffer, and graphics windows
397  * @include: glk.h
398  * 
399  * A technical description of all the window types, and exactly how they behave.
400  */
401
402 /**
403  * SECTION:glk-echo-streams
404  * @short_description: Creating a copy of a window's output
405  * @include: glk.h
406  *
407  * Every window has an associated window stream; you print to the window by
408  * printing to this stream. However, it is possible to attach a second stream to
409  * a window. Any text printed to the window is also echoed to this second
410  * stream, which is called the window's <quote>echo stream.</quote>
411  * 
412  * Effectively, any call to glk_put_char() (or the other output commands) which
413  * is directed to the window's window stream, is replicated to the window's echo
414  * stream. This also goes for the style commands such as glk_set_style().
415  * 
416  * Note that the echoing is one-way. You can still print text directly to the
417  * echo stream, and it will go wherever the stream is bound, but it does not
418  * back up and appear in the window. 
419  *
420  * An echo stream can be of any type, even another window's window stream.
421  * 
422  * <note><para>
423  *   This would be somewhat silly, since it would mean that any text printed to
424  *   the window would be duplicated in another window. More commonly, you would
425  *   set a window's echo stream to be a file stream, in order to create a
426  *   transcript file from that window.
427  * </para></note>
428  *
429  * A window can only have one echo stream. But a single stream can be the echo
430  * stream of any number of windows, sequentially or simultaneously.
431  *
432  * If a window is closed, its echo stream remains open; it is not automatically
433  * closed. 
434  *
435  * <note><para>
436  *   Do not confuse the window's window stream with its echo stream. The window
437  *   stream is <quote>owned</quote> by the window, and dies with it. The echo
438  *   stream is merely temporarily associated with the window.
439  * </para></note>
440  * 
441  * If a stream is closed, and it is the echo stream of one or more windows,
442  * those windows are reset to not echo anymore. (So then calling
443  * glk_window_get_echo_stream() on them will return %NULL.) 
444  */
445
446 /**
447  * SECTION:glk-window-other
448  * @short_description: Miscellaneous functions for windows
449  * @include: glk.h
450  *
451  * This section contains functions for windows that don't fit anywhere else.
452  */
453
454 /**
455  * SECTION:glk-events
456  * @short_description: Waiting for events
457  * @include: glk.h
458  *
459  * As described in <link linkend="chimara-Your-Programs-Main-Function">Your
460  * Program's Main Function</link>, all player input is handed to your program by
461  * the glk_select() call, in the form of events. You should write at least one
462  * event loop to retrieve these events.
463  */
464
465 /**
466  * SECTION:glk-character-input-events
467  * @short_description: Events representing a single keystroke
468  * @include: glk.h
469  *
470  * You can request character input from text buffer and text grid windows. See 
471  * #evtype_CharInput. There are separate functions for requesting Latin-1 input
472  * and Unicode input; see #gestalt_Unicode.
473  */
474
475 /**
476  * SECTION:glk-line-input-events
477  * @short_description: Events representing a line of user input
478  * @include: glk.h
479  *
480  * You can request line input from text buffer and text grid windows. See
481  * #evtype_LineInput. There are separate functions for requesting Latin-1 input
482  * and Unicode input; see #gestalt_Unicode.
483  */
484
485 /**
486  * SECTION:glk-streams
487  * @short_description: Input and output abstractions
488  * @include: glk.h
489  *
490  * All character output in Glk is done through streams. Every window has an
491  * output stream associated with it. You can also write to files on disk; every
492  * open file is represented by an output stream as well.
493  *
494  * There are also input streams; these are used for reading from files on disk.
495  * It is possible for a stream to be both an input and an output stream. 
496  *
497  * <note><para>
498  *   Player input is done through line and character input events, not streams.
499  *   This is a small inelegance in theory. In practice, player input is slow and
500  *   things can interrupt it, whereas file input is immediate. If a network
501  *   extension to Glk were proposed, it would probably use events and not
502  *   streams, since network communication is not immediate.
503  * </para></note>
504  *
505  * It is also possible to create a stream that reads or writes to a buffer in
506  * memory.
507  * 
508  * Finally, there may be platform-specific types of streams, which are created
509  * before your program starts running. 
510  *
511  * <note><para>
512  *   For example, a program running under Unix may have access to standard input
513  *   as a stream, even though there is no Glk call to explicitly open standard
514  *   input. On the Mac, data in a Mac resource may be available through a
515  *   resource-reading stream.
516  * </para></note>
517  *
518  * You do not need to worry about the origin of such streams; just read or write
519  * them as usual. For information about how platform-specific streams come to
520  * be, see <link linkend="chimara-Startup-Options">Startup Options</link>.
521  * 
522  * A stream is opened with a particular file mode, see the 
523  * <code>filemode_</code> constants below.
524  *
525  * For information on opening streams, see the discussion of each specific type
526  * of stream in <link linkend="chimara-The-Types-of-Streams">The Types of
527  * Streams</link>. Remember that it is always possible that opening a stream
528  * will fail, in which case the creation function will return %NULL.
529  * 
530  * Each stream remembers two character counts, the number of characters printed
531  * to and read from that stream. The write-count is exactly one per 
532  * glk_put_char() call; it is figured before any platform-dependent character
533  * cookery. 
534  *
535  * <note><para>
536  *   For example, if a newline character is converted to 
537  *   linefeed-plus-carriage-return, the stream's count still only goes up by
538  *   one; similarly if an accented character is displayed as two characters.
539  * </para></note>
540  * 
541  * The read-count is exactly one per glk_get_char_stream() call, as long as the
542  * call returns an actual character (as opposed to an end-of-file token.) 
543  *
544  * Glk has a notion of the <quote>current (output) stream</quote>. If you print
545  * text without specifying a stream, it goes to the current output stream. The
546  * current output stream may be %NULL, meaning that there isn't one. It is
547  * illegal to print text to stream %NULL, or to print to the current stream when
548  * there isn't one.
549  *
550  * If the stream which is the current stream is closed, the current stream
551  * becomes %NULL. 
552  */
553  
554 /**
555  * SECTION:glk-print
556  * @short_description: Printing to streams
557  * @include: glk.h
558  *
559  * You can print Latin-1 and Unicode characters, null-terminated strings, or
560  * buffers to any stream. The characters will be converted into the appropriate
561  * format for that stream.
562  */
563  
564 /**
565  * SECTION:glk-read
566  * @short_description: Reading from streams
567  * @include: glk.h
568  *
569  * You can read Latin-1 or Unicode characters, buffers, or whole lines from any
570  * stream. The characters will be converted into the form in which you request
571  * them.
572  */
573  
574 /**
575  * SECTION:glk-closing-streams
576  * @short_description: Closing streams and retrieving their character counts
577  * @include: glk.h
578  *
579  * When you close a Glk stream, you have the opportunity to examine the
580  * character counts &mdash; the number of characters written to or read from the
581  * stream.
582  */
583
584 /**
585  * SECTION:glk-stream-positions
586  * @short_description: Moving the read/write mark
587  * @include: glk.h
588  *
589  * You can set the position of the read/write mark in a stream.
590  *
591  * <note><para>
592  *   Which makes one wonder why they're called <quote>streams</quote> in the
593  *   first place. Oh well.
594  * </para></note>
595  */
596
597 /**
598  * SECTION:glk-stream-types
599  * @short_description: Window, memory, and file streams
600  * @include: glk.h
601  *
602  * <refsect2 id="chimara-Window-Streams"><title>Window Streams</title>
603  * <para>
604  * Every window has an output stream associated with it. This is created
605  * automatically, with #filemode_Write, when you open the window. You get it
606  * with glk_window_get_stream().
607  * 
608  * A window stream cannot be closed with glk_stream_close(). It is closed
609  * automatically when you close its window with glk_window_close().
610  * 
611  * Only printable characters (including newline) may be printed to a window
612  * stream. See <link linkend="chimara-Character-Encoding">Character 
613  * Encoding</link>.
614  * </para>
615  * </refsect2>
616  * <refsect2 id="chimara-Memory-Streams"><title>Memory Streams</title>
617  * <para>
618  * You can open a stream which reads from or writes to a space in memory. See
619  * glk_stream_open_memory() and glk_stream_open_memory_uni(). When opening a
620  * memory stream, you specify a buffer to which the stream's output will be
621  * written, and its length @buflen.
622  *
623  * When outputting, if more than @buflen characters are written to the stream,
624  * all of them beyond the buffer length will be thrown away, so as not to
625  * overwrite the buffer. (The character count of the stream will still be
626  * maintained correctly. That is, it will count the number of characters written
627  * into the stream, not the number that fit into the buffer.)
628  *
629  * If the buffer is %NULL, or for that matter if @buflen is zero, then 
630  * <emphasis>everything</emphasis> written to the stream is thrown away. This
631  * may be useful if you are interested in the character count.
632  *
633  * When inputting, if more than @buflen characters are read from the stream, the
634  * stream will start returning -1 (signalling end-of-file.) If the buffer is 
635  * %NULL, the stream will always return end-of-file.
636  *
637  * The data is written to the buffer exactly as it was passed to the printing
638  * functions (glk_put_char(), etc.); input functions will read the data exactly
639  * as it exists in memory. No platform-dependent cookery will be done on it.
640  *
641  * <note><para>
642  *   You can write a disk file in text mode, but a memory stream is effectively
643  *   always in binary mode.
644  * </para></note>
645  * 
646  * Whether reading or writing, the contents of the buffer are undefined until
647  * the stream is closed. The library may store the data there as it is written,
648  * or deposit it all in a lump when the stream is closed. It is illegal to
649  * change the contents of the buffer while the stream is open.
650  * </para>
651  * </refsect2>
652  * <refsect2 id="chimara-File-Streams"><title>File Streams</title>
653  * <para>
654  * You can open a stream which reads from or writes to a disk file. See 
655  * glk_stream_open_file() and glk_stream_open_file_uni().
656  *
657  * The file may be written in text or binary mode; this is determined by the
658  * file reference you open the stream with. Similarly, platform-dependent
659  * attributes such as file type are determined by the file reference. See <link
660  * linkend="chimara-File-References">File References</link>.
661  * </para>
662  * </refsect2>
663  */
664  
665 /**
666  * SECTION:glk-stream-other
667  * @short_description: Miscellaneous functions for streams
668  * @include: glk.h
669  *
670  * This section includes functions for streams that don't fit anywhere else.
671  */
672
673 /**
674  * SECTION:glk-fileref
675  * @short_description: A platform-independent way to refer to disk files
676  * @include: glk.h
677  *
678  * You deal with disk files using file references. Each fileref is an opaque C
679  * structure pointer; see <link linkend="chimara-Opaque-Objects">Opaque 
680  * Objects</link>.
681  * 
682  * A file reference contains platform-specific information about the name and
683  * location of the file, and possibly its type, if the platform has a notion of
684  * file type. It also includes a flag indication whether the file is a text file
685  * or binary file. 
686  *
687  * <note><para>
688  *   Note that this is different from the standard C I/O library, in which you
689  *   specify text or binary mode when the file is opened.
690  * </para></note>
691  * 
692  * A fileref does not have to refer to a file which actually exists. You can
693  * create a fileref for a nonexistent file, and then open it in write mode to
694  * create a new file.
695  * 
696  * You always provide a usage argument when you create a fileref. The usage is a
697  * mask of constants (see below) to indicate the file type and the mode (text or
698  * binary.) These values are used when you create a new file, and also to filter
699  * file lists when the player is selecting a file to load. 
700  * 
701  * In general, you should use text mode if the player expects to read the file
702  * with a platform-native text editor; you should use binary mode if the file is
703  * to be read back by your program, or if the data must be stored exactly. Text
704  * mode is appropriate for #fileusage_Transcript; binary mode is appropriate for
705  * #fileusage_SavedGame and probably for #fileusage_InputRecord. #fileusage_Data
706  * files may be text or binary, depending on what you use them for. 
707  */
708  
709 /**
710  * SECTION:glk-fileref-types
711  * @short_description: Four different ways to create a file reference
712  * @include: glk.h
713  *
714  * There are four different functions for creating a fileref, depending on how
715  * you wish to specify it. Remember that it is always possible that a fileref
716  * creation will fail and return %NULL.
717  */
718  
719 /**
720  * SECTION:glk-fileref-other
721  * @short_description: Miscellaneous functions for file references
722  * @include: glk.h
723  *
724  * This section includes functions for file references that don't fit anywhere
725  * else.
726  */
727
728 /*---------------- TYPES AND CONSTANTS FROM GLK.H ----------------------------*/
729
730 /**
731  * glui32:
732  *
733  * A 32-bit unsigned integer type, used wherever possible in Glk.
734  */
735  
736 /**
737  * glsi32:
738  *
739  * A 32-bit signed integer type, rarely used.
740  */
741
742 /**
743  * GLK_MODULE_UNICODE:
744  *
745  * If this preprocessor symbol is defined, so are all the Unicode functions and
746  * constants (see #gestalt_Unicode). If not, not.
747  */
748
749 /**
750  * winid_t:
751  *
752  * Opaque structure representing a Glk window. It has no user-accessible 
753  * members.
754  */
755  
756 /**
757  * strid_t:
758  *
759  * Opaque structure representing an input or output stream. It has no
760  * user-accessible members.
761  */
762  
763 /**
764  * frefid_t:
765  * 
766  * Opaque structure representing a file reference. It has no user-accessible
767  * members.
768  */
769
770 /**
771  * gestalt_Version:
772  *
773  * For an example of the gestalt mechanism, consider the selector
774  * #gestalt_Version. If you do
775  * |[
776  * #glui32 res;
777  * res = #glk_gestalt(#gestalt_Version, 0);
778  * ]|
779  * <code>res</code> will be set to a 32-bit number which encodes the version of
780  * the Glk spec which the library implements. The upper 16 bits stores the major
781  * version number; the next 8 bits stores the minor version number; the low 8 
782  * bits stores an even more minor version number, if any.
783  *
784  * <note><para>
785  *   So the version number 78.2.11 would be encoded as 0x004E020B.
786  * </para></note>
787  *
788  * The current Glk specification version is 0.7.0, so this selector will return
789  * 0x00000700.
790  *
791  * |[
792  * #glui32 res;
793  * res = #glk_gestalt_ext(#gestalt_Version, 0, NULL, 0);
794  * ]|
795  * does exactly the same thing. Note that, in either case, the second argument 
796  * is not used; so you should always pass 0 to avoid future surprises.
797  */
798
799 /**
800  * gestalt_CharInput:
801  *
802  * If you set <code>ch</code> to a character code, or a special code (from
803  * 0xFFFFFFFF down), and call
804  * |[
805  * #glui32 res;
806  * res = #glk_gestalt(#gestalt_CharInput, ch);
807  * ]|
808  * then <code>res</code> will be %TRUE (1) if that character can be typed by
809  * the player in character input, and %FALSE (0) if not. See <link
810  * linkend="chimara-Character-Input">Character Input</link>.
811  */
812
813 /**
814  * gestalt_LineInput:
815  *
816  * If you set <code>ch</code> to a character code, and call
817  * |[
818  * #glui32 res;
819  * res = #glk_gestalt(#gestalt_LineInput, ch);
820  * ]|
821  * then <code>res</code> will be %TRUE (1) if that character can be typed by the
822  * player in line input, and %FALSE (0) if not. Note that if <code>ch</code> is 
823  * a nonprintable Latin-1 character (0 to 31, 127 to 159), then this is 
824  * guaranteed to return %FALSE. See <link linkend="chimara-Line-Input">Line
825  * Input</link>.
826  */
827
828 /**
829  * gestalt_CharOutput:
830  *
831  * If you set <code>ch</code> to a character code (Latin-1 or higher), and call
832  * |[
833  * #glui32 res, len;
834  * res = #glk_gestalt_ext(#gestalt_CharOutput, ch, &amp;len, 1);
835  * ]|
836  * then <code>res</code> will be one of #gestalt_CharOutput_CannotPrint,
837  * #gestalt_CharOutput_ExactPrint, or #gestalt_CharOutput_ApproxPrint (see 
838  * below.)
839  * 
840  * In all cases, <code>len</code> (the #glui32 value pointed at by the third
841  * argument) will be the number of actual glyphs which will be used to represent
842  * the character. In the case of #gestalt_CharOutput_ExactPrint, this will 
843  * always be 1; for #gestalt_CharOutput_CannotPrint, it may be 0 (nothing 
844  * printed) or higher; for #gestalt_CharOutput_ApproxPrint, it may be 1 or 
845  * higher. This information may be useful when printing text in a fixed-width 
846  * font.
847  *
848  * <note><para>
849  *   As described in <link linkend="chimara-Other-API-Conventions">Other API
850  *   Conventions</link>, you may skip this information by passing %NULL as the
851  *   third argument in glk_gestalt_ext(), or by calling glk_gestalt() instead.
852  * </para></note>
853  *
854  * This selector will always return #gestalt_CharOutput_CannotPrint if 
855  * <code>ch</code> is an unprintable eight-bit character (0 to 9, 11 to 31, 127 
856  * to 159.)
857  *
858  * <note><para>
859  *   Make sure you do not get confused by signed byte values. If you set a
860  *   <quote><type>char</type></quote> variable <code>ch</code> to 0xFE, the 
861  *   small-thorn character (&thorn;), and then call
862  *   |[ res = #glk_gestalt(#gestalt_CharOutput, ch); ]|
863  *   then (by the definition of C/C++) <code>ch</code> will be sign-extended to
864  *   0xFFFFFFFE, which is not a legitimate character, even in Unicode. You 
865  *   should write
866  *   |[ res = #glk_gestalt(#gestalt_CharOutput, (unsigned char)ch); ]|
867  *   instead.
868  * </para></note>
869  * <note><para>
870  *   Unicode includes the concept of non-spacing or combining characters, which 
871  *   do not represent glyphs; and double-width characters, whose glyphs take up
872  *   two spaces in a fixed-width font. Future versions of this spec may 
873  *   recognize these concepts by returning a <code>len</code> of 0 or 2 when
874  *   #gestalt_CharOutput_ExactPrint is used. For the moment, we are adhering to 
875  *   a policy of <quote>simple stuff first</quote>.
876  * </para></note>
877  */
878  
879 /**
880  * gestalt_CharOutput_CannotPrint:
881  *
882  * When the #gestalt_CharOutput selector returns this for a character, the
883  * character cannot be meaningfully printed. If you try, the player may see
884  * nothing, or may see a placeholder.
885  */
886
887 /**
888  * gestalt_CharOutput_ApproxPrint:
889  *
890  * When the #gestalt_CharOutput selector returns this for a character, the 
891  * library will print some approximation of the character. It will be more or 
892  * less right, but it may not be precise, and it may not be distinguishable from
893  * other, similar characters. (Examples: 
894  * <quote><computeroutput>ae</computeroutput></quote> for the one-character
895  * <quote>&aelig;</quote> ligature, 
896  * <quote><computeroutput>e</computeroutput></quote> for 
897  * <quote>&egrave;</quote>, <quote><computeroutput>|</computeroutput></quote> 
898  * for a broken vertical bar (&brvbar;).)
899  */
900  
901 /**
902  * gestalt_CharOutput_ExactPrint:
903  *
904  * When the #gestalt_CharOutput selector returns this for a character, the
905  * character will be printed exactly as defined.
906  */
907
908 /**
909  * gestalt_Unicode:
910  *
911  * The basic text functions will be available in every Glk library. The Unicode
912  * functions may or may not be available. Before calling them, you should use
913  * the following gestalt selector:
914  * |[
915  * glui32 res;
916  * res = #glk_gestalt(#gestalt_Unicode, 0);
917  * ]|
918  * 
919  * This returns 1 if the Unicode functions are available. If it returns 0, you
920  * should not try to call them. They may print nothing, print gibberish, or
921  * cause a run-time error. The Unicode functions include
922  * glk_buffer_to_lower_case_uni(), glk_buffer_to_upper_case_uni(),  
923  * glk_buffer_to_title_case_uni(), glk_put_char_uni(), glk_put_string_uni(),
924  * glk_put_buffer_uni(), glk_put_char_stream_uni(), glk_put_string_stream_uni(),
925  * glk_put_buffer_stream_uni(), glk_get_char_stream_uni(),
926  * glk_get_buffer_stream_uni(), glk_get_line_stream_uni(),
927  * glk_request_char_event_uni(), glk_request_line_event_uni(),
928  * glk_stream_open_file_uni(), glk_stream_open_memory_uni().
929  * 
930  * If you are writing a C program, there is an additional complication. A
931  * library which does not support Unicode may not implement the Unicode
932  * functions at all. Even if you put gestalt tests around your Unicode calls,
933  * you may get link-time errors. If the 
934  * <filename class="headerfile">glk.h</filename> file is so old that it does not
935  * declare the Unicode functions and constants, you may even get compile-time
936  * errors.
937  * 
938  * To avoid this, you can perform a preprocessor test for the existence of
939  * #GLK_MODULE_UNICODE. 
940  */
941
942 /**
943  * evtype_None:
944  *
945  * No event. This is a placeholder, and glk_select() never returns it.
946  */
947
948 /**
949  * evtype_Timer:
950  *
951  * An event that repeats at fixed intervals. See <link 
952  * linkend="chimara-Timer-Events">Timer Events</link>.
953  */
954  
955 /**
956  * evtype_CharInput:
957  *
958  * A keystroke event in a window. See <link 
959  * linkend="chimara-Character-Input-Events">Character Input Events</link>.
960  *
961  * If a window has a pending request for character input, and the player hits a
962  * key in that window, glk_select() will return an event whose type is
963  * #evtype_CharInput. Once this happens, the request is complete; it is no 
964  * longer pending. You must call glk_request_char_event() or
965  * glk_request_char_event_uni() if you want another character from that window.
966  * 
967  * In the event structure, @win tells what window the event came from. @val1 
968  * tells what character was entered; this will be a character code, or a special
969  * keycode. (See <link linkend="chimara-Character-Input">Character 
970  * Input</link>.) If you called glk_request_char_event(), @val1 will be in 
971  * 0..255, or else a special keycode. In any case, @val2 will be 0.
972  */
973
974 /**
975  * evtype_LineInput:
976  *
977  * A full line of input completed in a window. See <link 
978  * linkend="chimara-Line-Input-Events">Line Input Events</link>.
979  *
980  * If a window has a pending request for line input, and the player hits
981  * <keycap>enter</keycap> in that window (or whatever action is appropriate to
982  * enter his input), glk_select() will return an event whose type is
983  * #evtype_LineInput. Once this happens, the request is complete; it is no 
984  * longer pending. You must call glk_request_line_event() if you want another 
985  * line of text from that window.
986  * 
987  * In the event structure, @win tells what window the event came from. @val1 
988  * tells how many characters were entered. @val2 will be 0. The characters
989  * themselves are stored in the buffer specified in the original
990  * glk_request_line_event() or glk_request_line_event_uni() call. 
991  *
992  * <note><para>There is no null terminator stored in the buffer.</para></note>
993  * 
994  * It is illegal to print anything to a window which has line input pending. 
995  *
996  * <note><para>
997  *   This is because the window may be displaying and editing the player's 
998  *   input, and printing anything would make life unnecessarily complicated for
999  *   the library.
1000  * </para></note>
1001  */
1002
1003 /**
1004  * evtype_MouseInput:
1005  *
1006  * A mouse click in a window. See <link 
1007  * linkend="chimara-Mouse-Input-Events">Mouse Input Events</link>.
1008  */
1009  
1010 /**
1011  * evtype_Arrange:
1012  *
1013  * An event signalling that the sizes of some windows have changed. 
1014  * 
1015  * Some platforms allow the player to resize the Glk window during play. This 
1016  * will naturally change the sizes of your windows. If this occurs, then
1017  * immediately after all the rearrangement, glk_select() will return an event
1018  * whose type is #evtype_Arrange. You can use this notification to redisplay the
1019  * contents of a graphics or text grid window whose size has changed.
1020  *
1021  * <note><para>
1022  *   The display of a text buffer window is entirely up to the library, so you
1023  *   don't need to worry about those.
1024  * </para></note>
1025  * 
1026  * In the event structure, @win will be %NULL if all windows are affected. If 
1027  * only some windows are affected, @win will refer to a window which contains 
1028  * all the affected windows. @val1 and @val2 will be 0.
1029  *
1030  * <note><para>
1031  *   You can always play it safe, ignore @win, and redraw every graphics and 
1032  *   text grid window.
1033  * </para></note>
1034  *
1035  * An arrangement event is guaranteed to occur whenever the player causes any
1036  * window to change size, as measured by its own metric. 
1037  *
1038  * <note><para>
1039  *   Size changes caused by you &mdash; for example, if you open, close, or 
1040  *   resize a window &mdash; do not trigger arrangement events. You must be 
1041  *   aware of the effects of your window management, and redraw the windows that
1042  *   you affect.
1043  * </para></note>
1044  * 
1045  * <note><para>
1046  *   It is possible that several different player actions can cause windows to
1047  *   change size. For example, if the player changes the screen resolution, an
1048  *   arrangement event might be triggered. This might also happen if the player
1049  *   changes his display font to a different size; the windows would then be
1050  *   different <quote>sizes</quote> in the metric of rows and columns, which is
1051  *   the important metric and the only one you have access to.
1052  * </para></note>
1053  * 
1054  * Arrangement events, like timer events, can be returned by glk_select_poll().
1055  * But this will not occur on all platforms. You must be ready to receive an
1056  * arrangement event when you call glk_select_poll(), but it is possible that it
1057  * will not arrive until the next time you call glk_select(). 
1058  *
1059  * <note><para>
1060  *   This is because on some platforms, window resizing is handled as part of
1061  *   player input; on others, it can be triggered by an external process such as 
1062  *   a window manager.
1063  * </para></note>
1064  */
1065
1066 /**
1067  * evtype_Redraw:
1068  *
1069  * An event signalling that graphics windows must be redrawn.
1070  *
1071  * On platforms that support graphics, it is possible that the contents of a
1072  * graphics window will be lost, and have to be redrawn from scratch. If this
1073  * occurs, then glk_select() will return an event whose type is #evtype_Redraw.
1074  *
1075  * In the event structure, @win will be %NULL if all windows are affected. If 
1076  * only some windows are affected, @win will refer to a window which contains 
1077  * all the affected windows. @val1 and @val2 will be 0.
1078  *
1079  * <note><para>
1080  *   You can always play it safe, ignore @win, and redraw every graphics window.
1081  * </para></note>
1082  *
1083  * Affected windows are already cleared to their background color when you 
1084  * receive the redraw event.
1085  * 
1086  * Redraw events can be returned by glk_select_poll(). But, like arrangement
1087  * events, this is platform-dependent. See #evtype_Arrange.
1088  *
1089  * For more about redraw events and how they affect graphics windows, see <link
1090  * linkend="chimara-Graphics-Windows">Graphics Windows</link>.
1091  */
1092
1093 /**
1094  * evtype_SoundNotify:
1095  *
1096  * On platforms that support sound, you can request to receive an 
1097  * #evtype_SoundNotify event when a sound finishes playing. See <link
1098  * linkend="chimara-Playing-Sounds">Playing Sounds</link>.
1099  */
1100  
1101 /**
1102  * evtype_Hyperlink:
1103  * 
1104  * On platforms that support hyperlinks, you can request to receive an
1105  * #evtype_Hyperlink event when the player selects a link. See <link
1106  * linkend="chimara-Accepting-Hyperlink-Events">Accepting Hyperlink 
1107  * Events</link>.
1108  */
1109
1110 /**
1111  * event_t:
1112  * @type: the event type
1113  * @win: the window that spawned the event, or %NULL
1114  * @val1: information, the meaning of which depends on the type of event
1115  * @val2: more information, the meaning of which depends on the type of event
1116  *
1117  * The event structure is self-explanatory. @type is the event type. The window
1118  * that spawned the event, if relevant, is in @win. The remaining fields contain
1119  * more information specific to the event.
1120  *
1121  * The event types are described below. Note that #evtype_None is zero, and the
1122  * other values are positive. Negative event types (0x80000000 to 0xFFFFFFFF) 
1123  * are reserved for implementation-defined events. 
1124  */
1125
1126 /**
1127  * keycode_Unknown:
1128  *
1129  * Represents any key that has no Latin-1 or special code.
1130  */
1131
1132 /**
1133  * keycode_Left:
1134  *
1135  * Represents the <keycap function="left">left arrow</keycap> key.
1136  */
1137  
1138 /**
1139  * keycode_Right:
1140  *
1141  * Represents the <keycap function="right">right arrow</keycap> key.
1142  */
1143  
1144 /**
1145  * keycode_Up:
1146  *
1147  * Represents the <keycap function="up">up arrow</keycap> key.
1148  */
1149  
1150 /**
1151  * keycode_Down:
1152  *
1153  * Represents the <keycap function="down">down arrow</keycap> key.
1154  */
1155  
1156 /**
1157  * keycode_Return:
1158  *
1159  * Represents the <keycap function="enter">return</keycap> or <keycap 
1160  * function="enter">enter</keycap> keys.
1161  */
1162
1163 /**
1164  * keycode_Delete:
1165  *
1166  * Represents the <keycap function="delete">delete</keycap> or <keycap
1167  * function="backspace">backspace</keycap> keys.
1168  */
1169  
1170 /**
1171  * keycode_Escape:
1172  *
1173  * Represents the <keycap function="escape">escape</keycap> key.
1174  */
1175  
1176 /**
1177  * keycode_Tab:
1178  *
1179  * Represents the <keycap function="tab">tab</keycap> key.
1180  */
1181
1182 /**
1183  * keycode_PageUp:
1184  *
1185  * Represents the <keycap function="pageup">page up</keycap> key.
1186  */
1187
1188 /**
1189  * keycode_PageDown:
1190  *
1191  * Represents the <keycap function="pagedown">page down</keycap> key.
1192  */
1193
1194 /**
1195  * keycode_Home:
1196  *
1197  * Represents the <keycap function="home">home</keycap> key.
1198  */
1199  
1200 /**
1201  * keycode_End:
1202  *
1203  * Represents the <keycap function="end">end</keycap> key.
1204  */
1205
1206 /**
1207  * keycode_Func1:
1208  *
1209  * Represents the <keycap>F1</keycap> key.
1210  */
1211  
1212 /**
1213  * keycode_Func2:
1214  *
1215  * Represents the <keycap>F2</keycap> key.
1216  */
1217
1218 /**
1219  * keycode_Func3:
1220  *
1221  * Represents the <keycap>F3</keycap> key.
1222  */
1223
1224 /**
1225  * keycode_Func4:
1226  *
1227  * Represents the <keycap>F4</keycap> key.
1228  */
1229
1230 /**
1231  * keycode_Func5:
1232  *
1233  * Represents the <keycap>F5</keycap> key.
1234  */
1235  
1236 /**
1237  * keycode_Func6:
1238  *
1239  * Represents the <keycap>F6</keycap> key.
1240  */
1241
1242 /**
1243  * keycode_Func7:
1244  *
1245  * Represents the <keycap>F7</keycap> key.
1246  */
1247
1248 /**
1249  * keycode_Func8:
1250  *
1251  * Represents the <keycap>F8</keycap> key.
1252  */
1253
1254 /**
1255  * keycode_Func9:
1256  *
1257  * Represents the <keycap>F9</keycap> key.
1258  */
1259
1260 /**
1261  * keycode_Func10:
1262  *
1263  * Represents the <keycap>F10</keycap> key.
1264  */
1265
1266 /**
1267  * keycode_Func11:
1268  *
1269  * Represents the <keycap>F11</keycap> key.
1270  */
1271
1272 /**
1273  * keycode_Func12:
1274  *
1275  * Represents the <keycap>F12</keycap> key.
1276  */
1277
1278 /**
1279  * keycode_MAXVAL:
1280  *
1281  * This value is equal to the number of special keycodes. The last keycode is
1282  * The last keycode is always 
1283  * <informalequation>
1284  *   <alt>(0x100000000 - <keysym>keycode_MAXVAL</keysym>)</alt>
1285  *   <mathphrase>(0x100000000 - <keysym>keycode_MAXVAL</keysym>)</mathphrase>
1286  * </informalequation>
1287  * .
1288  */
1289
1290 /**
1291  * stream_result_t:
1292  * @readcount: Number of characters read from the stream.
1293  * @writecount: Number of characters printed to the stream, including ones that
1294  * were thrown away.
1295  *
1296  * If you are interested in the character counts of a stream (see <link
1297  * linkend="chimara-Streams">Streams</link>), then you can pass a pointer to
1298  * #stream_result_t as an argument of glk_stream_close() or glk_window_close().
1299  * The structure will be filled with the stream's final character counts.
1300  */
1301
1302 /**
1303  * wintype_AllTypes:
1304  *
1305  * A constant representing all window types, which may be used as the @wintype
1306  * argument in glk_stylehint_set().
1307  */
1308
1309 /** 
1310  * wintype_Pair:
1311  * 
1312  * A pair window is completely filled by the two windows it contains. It
1313  * supports no input and no output, and it has no size.
1314  * 
1315  * You cannot directly create a pair window; one is automatically created
1316  * every time you split a window with glk_window_open(). Pair windows are
1317  * always created with a rock value of 0.
1318  * 
1319  * You can close a pair window with glk_window_close(); this also closes every
1320  * window contained within the pair window.
1321  * 
1322  * It is legal to split a pair window when you call glk_window_open().
1323  */
1324  
1325 /**
1326  * wintype_Blank:
1327  * 
1328  * A blank window is always blank. It supports no input and no output. (You
1329  * can call glk_window_get_stream() on it, as you can with any window, but
1330  * printing to the resulting stream has no effect.) A blank window has no
1331  * size; glk_window_get_size() will return (0,0), and it is illegal to set a
1332  * window split with a fixed size in the measurement system of a blank window.
1333  * 
1334  * <note><para>
1335  *   A blank window is not the same as there being no windows. When Glk starts
1336  *   up, there are no windows at all, not even a window of the blank type.
1337  * </para></note>
1338  */
1339  
1340 /**
1341  * wintype_TextBuffer: 
1342  *
1343  * A text buffer window contains a linear stream of text. It supports output;
1344  * when you print to it, the new text is added to the end. There is no way for
1345  * you to affect text which has already been printed. There are no guarantees
1346  * about how much text the window keeps; old text may be stored forever, so
1347  * that the user can scroll back to it, or it may be thrown away as soon as it
1348  * scrolls out of the window. 
1349  * 
1350  * <note><para>
1351  *   Therefore, there may or may not be a player-controllable scroll bar or
1352  *   other scrolling widget.
1353  * </para></note>
1354  * 
1355  * The display of the text in a text buffer is up to the library. Lines will
1356  * probably not be broken in the middles of words &mdash; but if they are, the
1357  * library is not doing anything illegal, only ugly. Text selection and copying
1358  * to a clipboard, if available, are handled however is best on the player's
1359  * machine. Paragraphs (as defined by newline characters in the output) may be
1360  * indented. 
1361  * 
1362  * <note><para>
1363  *   You should not, in general, fake this by printing spaces before each
1364  *   paragraph of prose text. Let the library and player preferences handle
1365  *   that. Special cases (like indented lists) are of course up to you.
1366  * </para></note>
1367  * 
1368  * When a text buffer is cleared (with glk_window_clear()), the library will do
1369  * something appropriate; the details may vary. It may clear the window, with
1370  * later text appearing at the top &mdash; or the bottom. It may simply print
1371  * enough blank lines to scroll the current text out of the window. It may
1372  * display a distinctive page-break symbol or divider.
1373  * 
1374  * The size of a text buffer window is necessarily imprecise. Calling
1375  * glk_window_get_size() will return the number of rows and columns that would
1376  * be available <emphasis>if</emphasis> the window was filled with 
1377  * <quote>0</quote> (zero) characters in the <quote>normal</quote> font.
1378  * However, the window may use a non-fixed-width font, so that number of
1379  * characters in a line could vary. The window might even support 
1380  * variable-height text (say, if the player is using large text for emphasis);
1381  * that would make the number of lines in the window vary as well.
1382  * 
1383  * Similarly, when you set a fixed-size split in the measurement system of a
1384  * text buffer, you are setting a window which can handle a fixed number of rows
1385  * (or columns) of <quote>0</quote> characters. The number of rows (or
1386  * characters) that will actually be displayed depends on font variances.
1387  * 
1388  * A text buffer window supports both character and line input, but not mouse
1389  * input.
1390  * 
1391  * In character input, there will be some visible signal that the window is
1392  * waiting for a keystroke. (Typically, a cursor at the end of the text.) When
1393  * the player hits a key in that window, an event is generated, but the key is
1394  * <emphasis>not</emphasis> printed in the window.
1395  * 
1396  * In line input, again, there will be some visible signal. It is most common
1397  * for the player to compose input in the window itself, at the end of the text.
1398  * (This is how IF story input usually looks.) But it's not strictly required.
1399  * An alternative approach is the way MUD clients usually work: there is a
1400  * dedicated one-line input window, outside of Glk's window space, and the user
1401  * composes input there.
1402  * 
1403  * <note><para>
1404  *   If this approach is used, there will still be some way to handle input from
1405  *   two windows at once. It is the library's responsibility to make this
1406  *   available to the player. You only need request line input and  wait for the
1407  *   result.
1408  * </para></note>
1409  * 
1410  * When the player finishes his line of input, the library will display the
1411  * input text at the end of the buffer text (if it wasn't there already.) It
1412  * will be followed by a newline, so that the next text you print will start a
1413  * new line (paragraph) after the input.
1414  * 
1415  * If you call glk_cancel_line_event(), the same thing happens; whatever text
1416  * the user was composing is visible at the end of the buffer text, followed by
1417  * a newline.
1418  */
1419  
1420 /**
1421  * wintype_TextGrid: 
1422  * 
1423  * A text grid contains a rectangular array of characters, in a fixed-width
1424  * font. Its size is the number of columns and rows of the array.
1425  * 
1426  * A text grid window supports output. It maintains knowledge of an output
1427  * cursor position. When the window is opened, it is filled with blanks (space
1428  * characters), and the output cursor starts in the top left corner &mdash;
1429  * character (0,0). If the window is cleared with glk_window_clear(), the window
1430  * is filled with blanks again, and the cursor returns to the top left corner.
1431  * 
1432  * When you print, the characters of the output are laid into the array in
1433  * order, left to right and top to bottom. When the cursor reaches the end of a
1434  * line, it goes to the beginning of the next line. The library makes no attempt
1435  * to wrap lines at word breaks.
1436  * 
1437  * <note><para>
1438  *   Note that printing fancy characters may cause the cursor to advance more
1439  *   than one position per character. (For example, the <quote>&aelig;</quote>
1440  *   ligature may print as two characters.) See <link 
1441  *   linkend="chimara-Output">Output</link>, for how to test this situation.
1442  * </para></note>
1443  * 
1444  * You can set the cursor position with glk_window_move_cursor().
1445  * 
1446  * When a text grid window is resized smaller, the bottom or right area is
1447  * thrown away, but the remaining area stays unchanged. When it is resized
1448  * larger, the new bottom or right area is filled with blanks.
1449  * 
1450  * <note><para>
1451  *   You may wish to watch for #evtype_Arrange events, and clear-and-redraw your
1452  *   text grid windows when you see them change size.
1453  * </para></note>
1454  * 
1455  * Text grid window support character and line input, as well as mouse input (if
1456  * a mouse is available.)
1457  * 
1458  * Mouse input returns the position of the character that was touched, from
1459  * (0,0) to 
1460  * <inlineequation>
1461  *   <alt>(width-1,height-1)</alt>
1462  *   <mathphrase>(width - 1, height - 1)</mathphrase>
1463  * </inlineequation>
1464  * .
1465  * 
1466  * Character input is as described in the previous section.
1467  * 
1468  * Line input is slightly different; it is guaranteed to take place in the
1469  * window, at the output cursor position. The player can compose input only to
1470  * the right edge of the window; therefore, the maximum input length is
1471  * <inlineequation>
1472  *   <alt>(windowwidth - 1 - cursorposition)</alt>
1473  *   <mathphrase>(windowwidth - 1 - cursorposition)</mathphrase>
1474  * </inlineequation>
1475  * . If the maxlen argument of glk_request_line_event() is smaller than this,
1476  * the library will not allow the input cursor to go more than maxlen characters
1477  * past its start point. 
1478  * 
1479  * <note><para>
1480  *   This allows you to enter text in a fixed-width field, without the player
1481  *   being able to overwrite other parts of the window.
1482  * </para></note>
1483  * 
1484  * When the player finishes his line of input, it will remain visible in the
1485  * window, and the output cursor will be positioned at the beginning of the 
1486  * <emphasis>next</emphasis> row. Again, if you glk_cancel_line_event(), the
1487  * same thing happens.
1488  */
1489  
1490 /**
1491  * wintype_Graphics: 
1492  * 
1493  * A graphics window contains a rectangular array of pixels. Its size is the
1494  * number of columns and rows of the array.
1495  * 
1496  * Each graphics window has a background color, which is initially white. You
1497  * can change this; see <link 
1498  * linkend="chimara-Graphics-in-Graphics-Windows">Graphics in Graphics 
1499  * Windows</link>.
1500  * 
1501  * When a text grid window is resized smaller, the bottom or right area is
1502  * thrown away, but the remaining area stays unchanged. When it is resized
1503  * larger, the new bottom or right area is filled with the background color.
1504  * 
1505  * <note><para>
1506  *   You may wish to watch for #evtype_Arrange events, and clear-and-redraw your
1507  *   graphics windows when you see them change size.
1508  * </para></note>
1509  * 
1510  * In some libraries, you can receive a graphics-redraw event (#evtype_Redraw)
1511  * at any time. This signifies that the window in question has been cleared to
1512  * its background color, and must be redrawn. If you create any graphics
1513  * windows, you <emphasis>must</emphasis> handle these events.
1514  * 
1515  * <note><para>
1516  *   Redraw events can be triggered when a Glk window is uncovered or made
1517  *   visible by the platform's window manager. On the other hand, some Glk
1518  *   libraries handle these problem automatically &mdash; for example, with a
1519  *   backing store &mdash; and do not send you redraw events. On the third hand,
1520  *   the backing store may be discarded if memory is low, or for other reasons
1521  *   &mdash; perhaps the screen's color depth has changed. So redraw events are
1522  *   always a possibility, even in clever libraries. This is why you must be
1523  *   prepared to handle them.
1524  * 
1525  *   However, you will not receive a redraw event when you create a graphics
1526  *   window. It is assumed that you will do the initial drawing of your own
1527  *   accord. You also do not get redraw events when a graphics window is
1528  *   enlarged. If you ordered the enlargement, you already know about it; if the
1529  *   player is responsible, you receive a window-arrangement event, which covers
1530  *   the situation.
1531  * </para></note>
1532  * 
1533  * For a description of the drawing functions that apply to graphics windows,
1534  * see <link linkend="chimara-Graphics-in-Graphics-Windows">Graphics in Graphics
1535  * Windows</link>.
1536  * 
1537  * Graphics windows support no text input or output.
1538  * 
1539  * Not all libraries support graphics windows. You can test whether Glk graphics
1540  * are available using the gestalt system. In a C program, you can also test
1541  * whether the graphics functions are defined at compile-time. See <link 
1542  * linkend="chimara-Testing-for-Graphics-Capabilities">Testing for Graphics
1543  * Capabilities</link>. 
1544  *
1545  * <note><para>
1546  *   As with all windows, you should also test for %NULL when you create a
1547  *   graphics window.
1548  * </para></note>
1549  */
1550  
1551 /**
1552  * winmethod_Left:
1553  *
1554  * When calling glk_window_open() with this @method, the new window will be 
1555  * to the left of the old one which was split.
1556  */
1557
1558 /**
1559  * winmethod_Right:
1560  *
1561  * When calling glk_window_open() with this @method, the new window will be 
1562  * to the right of the old one which was split.
1563  */
1564
1565 /**
1566  * winmethod_Above:
1567  *
1568  * When calling glk_window_open() with this @method, the new window will be 
1569  * above the old one which was split.
1570  */
1571  
1572 /**
1573  * winmethod_Below:
1574  *
1575  * When calling glk_window_open() with this @method, the new window will be 
1576  * below the old one which was split.
1577  */
1578
1579 /**
1580  * winmethod_DirMask:
1581  *
1582  * Bitwise AND this value with a window splitting method argument to find
1583  * whether the split is #winmethod_Left, #winmethod_Right, #winmethod_Above, or
1584  * #winmethod_Below.
1585  */
1586  
1587 /**
1588  * winmethod_Fixed:
1589  *
1590  * When calling glk_window_open() with this @method, the new window will be 
1591  * a fixed size. (See glk_window_open()).
1592  */
1593
1594 /**
1595  * winmethod_Proportional:
1596  *
1597  * When calling glk_window_open() with this @method, the new window will be 
1598  * a given proportion of the old window's size. (See glk_window_open()).
1599  */
1600  
1601 /**
1602  * winmethod_DivisionMask:
1603  *
1604  * Bitwise AND this value with a window splitting method argument to find
1605  * whether the new window has #winmethod_Fixed or #winmethod_Proportional.
1606  */
1607  
1608 /** 
1609  * fileusage_Data: 
1610  *
1611  * Any other kind of file (preferences, statistics, arbitrary data.) 
1612  */
1613
1614 /**
1615  * fileusage_SavedGame: 
1616  * 
1617  * A file which stores game state.
1618  */
1619
1620 /**
1621  * fileusage_Transcript: 
1622  * 
1623  * A file which contains a stream of text from the game (often an echo stream
1624  * from a window.)
1625  */
1626  
1627 /** 
1628  * fileusage_InputRecord: 
1629  * 
1630  * A file which records player input.
1631  */
1632
1633 /** 
1634  * fileusage_TextMode: 
1635  *
1636  * The file contents will be transformed to a platform-native text file as they
1637  * are written out. Newlines may be converted to linefeeds or 
1638  * linefeed-plus-carriage-return combinations; Latin-1 characters may be
1639  * converted to native character codes. When reading a file in text mode, native
1640  * line breaks will be converted back to newline (0x0A) characters, and native
1641  * character codes may be converted to Latin-1. 
1642  *
1643  * <note><para>
1644  *   Line breaks will always be converted; other conversions are more
1645  *   questionable. If you write out a file in text mode, and then read it back
1646  *   in text mode, high-bit characters (128 to 255) may be transformed or lost.
1647  * </para></note>
1648  * <note><title>Chimara</title>
1649  * <para>
1650  * Text mode files in Chimara are in UTF-8, which is GTK+'s native file
1651  * encoding.
1652  * </para></note>
1653  */
1654
1655 /**
1656  * fileusage_BinaryMode: 
1657  *
1658  * The file contents will be stored exactly as they are written, and read back
1659  * in the same way. The resulting file may not be viewable on platform-native
1660  * text file viewers.
1661  */
1662
1663 /**
1664  * fileusage_TypeMask:
1665  *
1666  * Bitwise AND this value with a file usage argument to find whether the file
1667  * type is #fileusage_SavedGame, #fileusage_Transcript, #fileusage_InputRecord,
1668  * or #fileusage_Data.
1669  */
1670
1671 /**
1672  * filemode_Write: 
1673  *
1674  * An output stream.
1675  *
1676  * <note><para>
1677  *   Corresponds to mode <code>"w"</code> in the stdio library, using fopen().
1678  * </para></note>
1679  */
1680
1681 /** 
1682  * filemode_Read: 
1683  *
1684  * An input stream.
1685  *
1686  * <note><para>
1687  *   Corresponds to mode <code>"r"</code> in the stdio library, using fopen().
1688  * </para></note>
1689  */
1690
1691 /**
1692  * filemode_ReadWrite: 
1693  *
1694  * Both an input and an output stream.
1695  *
1696  * <note><para>
1697  *   Corresponds to mode <code>"r+"</code> in the stdio library, using fopen().
1698  * </para></note>
1699  */
1700
1701 /**
1702  * filemode_WriteAppend: 
1703  *
1704  * An output stream, but the data will added to the end of whatever already
1705  * existed in the destination, instead of replacing it. 
1706  *
1707  * <note><para>
1708  *   Corresponds to mode <code>"a"</code> in the stdio library, using fopen().
1709  * </para></note>
1710  */
1711  
1712 /**
1713  * seekmode_Start:
1714  *
1715  * In glk_stream_set_position(), signifies that @pos is counted in characters
1716  * after the beginning of the file.
1717  */
1718  
1719 /**
1720  * seekmode_Current: 
1721  *
1722  * In glk_stream_set_position(), signifies that @pos is counted in characters
1723  * after the current position (moving backwards if @pos is negative.)
1724  */
1725
1726 /** 
1727  * seekmode_End: 
1728  *
1729  * In glk_stream_set_position(), signifies that @pos is counted in characters
1730  * after the end of the file. (@pos should always be zero or negative, so that
1731  * this will move backwards to a  position within the file.
1732  */
1733