Got Gtk-Doc working. Now all the fancy /** comments before the functions
[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  * <informalexample><programlisting>
180  * <replaceable>CLASS</replaceable>id_t glk_<replaceable>CLASS</replaceable>_iterate(<replaceable>CLASS</replaceable>id_t <parameter>obj</parameter>, #glui32 *<parameter>rockptr</parameter>);
181  * </programlisting></informalexample>
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  * <informalexample><programlisting>
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  * </programlisting></informalexample>
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  * <informalexample><programlisting>
776  * #glui32 res;
777  * res = #glk_gestalt(#gestalt_Version, 0);
778  * </programlisting></informalexample>
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  * <informalexample><programlisting>
792  * #glui32 res;
793  * res = #glk_gestalt_ext(#gestalt_Version, 0, NULL, 0);
794  * </programlisting></informalexample>
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  * <informalexample><programlisting>
805  * #glui32 res;
806  * res = #glk_gestalt(#gestalt_CharInput, ch);
807  * </programlisting></informalexample>
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  * <informalexample><programlisting>
818  * #glui32 res;
819  * res = #glk_gestalt(#gestalt_LineInput, ch);
820  * </programlisting></informalexample>
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  * <informalexample><programlisting>
833  * #glui32 res, len;
834  * res = #glk_gestalt_ext(#gestalt_CharOutput, ch, &amp;len, 1);
835  * </programlisting></informalexample>
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  *   <informalexample><programlisting>
863  *   res = #glk_gestalt(#gestalt_CharOutput, ch);
864  *   </programlisting></informalexample>
865  *   then (by the definition of C/C++) <code>ch</code> will be sign-extended to
866  *   0xFFFFFFFE, which is not a legitimate character, even in Unicode. You 
867  *   should write
868  *   <informalexample><programlisting>
869  *   res = #glk_gestalt(#gestalt_CharOutput, (unsigned char)ch);
870  *   </programlisting></informalexample>
871  *   instead.
872  * </para></note>
873  * <note><para>
874  *   Unicode includes the concept of non-spacing or combining characters, which 
875  *   do not represent glyphs; and double-width characters, whose glyphs take up
876  *   two spaces in a fixed-width font. Future versions of this spec may 
877  *   recognize these concepts by returning a <code>len</code> of 0 or 2 when
878  *   #gestalt_CharOutput_ExactPrint is used. For the moment, we are adhering to 
879  *   a policy of <quote>simple stuff first</quote>.
880  * </para></note>
881  */
882  
883 /**
884  * gestalt_CharOutput_CannotPrint:
885  *
886  * When the #gestalt_CharOutput selector returns this for a character, the
887  * character cannot be meaningfully printed. If you try, the player may see
888  * nothing, or may see a placeholder.
889  */
890
891 /**
892  * gestalt_CharOutput_ApproxPrint:
893  *
894  * When the #gestalt_CharOutput selector returns this for a character, the 
895  * library will print some approximation of the character. It will be more or 
896  * less right, but it may not be precise, and it may not be distinguishable from
897  * other, similar characters. (Examples: 
898  * <quote><computeroutput>ae</computeroutput></quote> for the one-character
899  * <quote>&aelig;</quote> ligature, 
900  * <quote><computeroutput>e</computeroutput></quote> for 
901  * <quote>&egrave;</quote>, <quote><computeroutput>|</computeroutput></quote> 
902  * for a broken vertical bar (&brvbar;).)
903  */
904  
905 /**
906  * gestalt_CharOutput_ExactPrint:
907  *
908  * When the #gestalt_CharOutput selector returns this for a character, the
909  * character will be printed exactly as defined.
910  */
911
912 /**
913  * gestalt_Unicode:
914  *
915  * The basic text functions will be available in every Glk library. The Unicode
916  * functions may or may not be available. Before calling them, you should use
917  * the following gestalt selector:
918  * <informalexample><programlisting>
919  * glui32 res;
920  * res = #glk_gestalt(#gestalt_Unicode, 0);
921  * </programlisting></informalexample>
922  * 
923  * This returns 1 if the Unicode functions are available. If it returns 0, you
924  * should not try to call them. They may print nothing, print gibberish, or
925  * cause a run-time error. The Unicode functions include
926  * glk_buffer_to_lower_case_uni(), glk_buffer_to_upper_case_uni(),  
927  * glk_buffer_to_title_case_uni(), glk_put_char_uni(), glk_put_string_uni(),
928  * glk_put_buffer_uni(), glk_put_char_stream_uni(), glk_put_string_stream_uni(),
929  * glk_put_buffer_stream_uni(), glk_get_char_stream_uni(),
930  * glk_get_buffer_stream_uni(), glk_get_line_stream_uni(),
931  * glk_request_char_event_uni(), glk_request_line_event_uni(),
932  * glk_stream_open_file_uni(), glk_stream_open_memory_uni().
933  * 
934  * If you are writing a C program, there is an additional complication. A
935  * library which does not support Unicode may not implement the Unicode
936  * functions at all. Even if you put gestalt tests around your Unicode calls,
937  * you may get link-time errors. If the 
938  * <filename class="headerfile">glk.h</filename> file is so old that it does not
939  * declare the Unicode functions and constants, you may even get compile-time
940  * errors.
941  * 
942  * To avoid this, you can perform a preprocessor test for the existence of
943  * #GLK_MODULE_UNICODE. 
944  */
945
946 /**
947  * evtype_None:
948  *
949  * No event. This is a placeholder, and glk_select() never returns it.
950  */
951
952 /**
953  * evtype_Timer:
954  *
955  * An event that repeats at fixed intervals. See <link 
956  * linkend="chimara-Timer-Events">Timer Events</link>.
957  */
958  
959 /**
960  * evtype_CharInput:
961  *
962  * A keystroke event in a window. See <link 
963  * linkend="chimara-Character-Input-Events">Character Input Events</link>.
964  *
965  * If a window has a pending request for character input, and the player hits a
966  * key in that window, glk_select() will return an event whose type is
967  * #evtype_CharInput. Once this happens, the request is complete; it is no 
968  * longer pending. You must call glk_request_char_event() or
969  * glk_request_char_event_uni() if you want another character from that window.
970  * 
971  * In the event structure, @win tells what window the event came from. @val1 
972  * tells what character was entered; this will be a character code, or a special
973  * keycode. (See <link linkend="chimara-Character-Input">Character 
974  * Input</link>.) If you called glk_request_char_event(), @val1 will be in 
975  * 0..255, or else a special keycode. In any case, @val2 will be 0.
976  */
977
978 /**
979  * evtype_LineInput:
980  *
981  * A full line of input completed in a window. See <link 
982  * linkend="chimara-Line-Input-Events">Line Input Events</link>.
983  *
984  * If a window has a pending request for line input, and the player hits
985  * <keycap>enter</keycap> in that window (or whatever action is appropriate to
986  * enter his input), glk_select() will return an event whose type is
987  * #evtype_LineInput. Once this happens, the request is complete; it is no 
988  * longer pending. You must call glk_request_line_event() if you want another 
989  * line of text from that window.
990  * 
991  * In the event structure, @win tells what window the event came from. @val1 
992  * tells how many characters were entered. @val2 will be 0. The characters
993  * themselves are stored in the buffer specified in the original
994  * glk_request_line_event() or glk_request_line_event_uni() call. 
995  *
996  * <note><para>There is no null terminator stored in the buffer.</para></note>
997  * 
998  * It is illegal to print anything to a window which has line input pending. 
999  *
1000  * <note><para>
1001  *   This is because the window may be displaying and editing the player's 
1002  *   input, and printing anything would make life unnecessarily complicated for
1003  *   the library.
1004  * </para></note>
1005  */
1006
1007 /**
1008  * evtype_MouseInput:
1009  *
1010  * A mouse click in a window. See <link 
1011  * linkend="chimara-Mouse-Input-Events">Mouse Input Events</link>.
1012  */
1013  
1014 /**
1015  * evtype_Arrange:
1016  *
1017  * An event signalling that the sizes of some windows have changed. 
1018  * 
1019  * Some platforms allow the player to resize the Glk window during play. This 
1020  * will naturally change the sizes of your windows. If this occurs, then
1021  * immediately after all the rearrangement, glk_select() will return an event
1022  * whose type is #evtype_Arrange. You can use this notification to redisplay the
1023  * contents of a graphics or text grid window whose size has changed.
1024  *
1025  * <note><para>
1026  *   The display of a text buffer window is entirely up to the library, so you
1027  *   don't need to worry about those.
1028  * </para></note>
1029  * 
1030  * In the event structure, @win will be %NULL if all windows are affected. If 
1031  * only some windows are affected, @win will refer to a window which contains 
1032  * all the affected windows. @val1 and @val2 will be 0.
1033  *
1034  * <note><para>
1035  *   You can always play it safe, ignore @win, and redraw every graphics and 
1036  *   text grid window.
1037  * </para></note>
1038  *
1039  * An arrangement event is guaranteed to occur whenever the player causes any
1040  * window to change size, as measured by its own metric. 
1041  *
1042  * <note><para>
1043  *   Size changes caused by you &mdash; for example, if you open, close, or 
1044  *   resize a window &mdash; do not trigger arrangement events. You must be 
1045  *   aware of the effects of your window management, and redraw the windows that
1046  *   you affect.
1047  * </para></note>
1048  * 
1049  * <note><para>
1050  *   It is possible that several different player actions can cause windows to
1051  *   change size. For example, if the player changes the screen resolution, an
1052  *   arrangement event might be triggered. This might also happen if the player
1053  *   changes his display font to a different size; the windows would then be
1054  *   different <quote>sizes</quote> in the metric of rows and columns, which is
1055  *   the important metric and the only one you have access to.
1056  * </para></note>
1057  * 
1058  * Arrangement events, like timer events, can be returned by glk_select_poll().
1059  * But this will not occur on all platforms. You must be ready to receive an
1060  * arrangement event when you call glk_select_poll(), but it is possible that it
1061  * will not arrive until the next time you call glk_select(). 
1062  *
1063  * <note><para>
1064  *   This is because on some platforms, window resizing is handled as part of
1065  *   player input; on others, it can be triggered by an external process such as 
1066  *   a window manager.
1067  * </para></note>
1068  */
1069
1070 /**
1071  * evtype_Redraw:
1072  *
1073  * An event signalling that graphics windows must be redrawn.
1074  *
1075  * On platforms that support graphics, it is possible that the contents of a
1076  * graphics window will be lost, and have to be redrawn from scratch. If this
1077  * occurs, then glk_select() will return an event whose type is #evtype_Redraw.
1078  *
1079  * In the event structure, @win will be %NULL if all windows are affected. If 
1080  * only some windows are affected, @win will refer to a window which contains 
1081  * all the affected windows. @val1 and @val2 will be 0.
1082  *
1083  * <note><para>
1084  *   You can always play it safe, ignore @win, and redraw every graphics window.
1085  * </para></note>
1086  *
1087  * Affected windows are already cleared to their background color when you 
1088  * receive the redraw event.
1089  * 
1090  * Redraw events can be returned by glk_select_poll(). But, like arrangement
1091  * events, this is platform-dependent. See #evtype_Arrange.
1092  *
1093  * For more about redraw events and how they affect graphics windows, see <link
1094  * linkend="chimara-Graphics-Windows">Graphics Windows</link>.
1095  */
1096
1097 /**
1098  * evtype_SoundNotify:
1099  *
1100  * On platforms that support sound, you can request to receive an 
1101  * #evtype_SoundNotify event when a sound finishes playing. See <link
1102  * linkend="chimara-Playing-Sounds">Playing Sounds</link>.
1103  */
1104  
1105 /**
1106  * evtype_Hyperlink:
1107  * 
1108  * On platforms that support hyperlinks, you can request to receive an
1109  * #evtype_Hyperlink event when the player selects a link. See <link
1110  * linkend="chimara-Accepting-Hyperlink-Events">Accepting Hyperlink 
1111  * Events</link>.
1112  */
1113
1114 /**
1115  * event_t:
1116  * @type: the event type
1117  * @win: the window that spawned the event, or %NULL
1118  * @val1: information, the meaning of which depends on the type of event
1119  * @val2: more information, the meaning of which depends on the type of event
1120  *
1121  * The event structure is self-explanatory. @type is the event type. The window
1122  * that spawned the event, if relevant, is in @win. The remaining fields contain
1123  * more information specific to the event.
1124  *
1125  * The event types are described below. Note that #evtype_None is zero, and the
1126  * other values are positive. Negative event types (0x80000000 to 0xFFFFFFFF) 
1127  * are reserved for implementation-defined events. 
1128  */
1129
1130 /**
1131  * keycode_Unknown:
1132  *
1133  * Represents any key that has no Latin-1 or special code.
1134  */
1135
1136 /**
1137  * keycode_Left:
1138  *
1139  * Represents the <keycap function="left">left arrow</keycap> key.
1140  */
1141  
1142 /**
1143  * keycode_Right:
1144  *
1145  * Represents the <keycap function="right">right arrow</keycap> key.
1146  */
1147  
1148 /**
1149  * keycode_Up:
1150  *
1151  * Represents the <keycap function="up">up arrow</keycap> key.
1152  */
1153  
1154 /**
1155  * keycode_Down:
1156  *
1157  * Represents the <keycap function="down">down arrow</keycap> key.
1158  */
1159  
1160 /**
1161  * keycode_Return:
1162  *
1163  * Represents the <keycap function="enter">return</keycap> or <keycap 
1164  * function="enter">enter</keycap> keys.
1165  */
1166
1167 /**
1168  * keycode_Delete:
1169  *
1170  * Represents the <keycap function="delete">delete</keycap> or <keycap
1171  * function="backspace">backspace</keycap> keys.
1172  */
1173  
1174 /**
1175  * keycode_Escape:
1176  *
1177  * Represents the <keycap function="escape">escape</keycap> key.
1178  */
1179  
1180 /**
1181  * keycode_Tab:
1182  *
1183  * Represents the <keycap function="tab">tab</keycap> key.
1184  */
1185
1186 /**
1187  * keycode_PageUp:
1188  *
1189  * Represents the <keycap function="pageup">page up</keycap> key.
1190  */
1191
1192 /**
1193  * keycode_PageDown:
1194  *
1195  * Represents the <keycap function="pagedown">page down</keycap> key.
1196  */
1197
1198 /**
1199  * keycode_Home:
1200  *
1201  * Represents the <keycap function="home">home</keycap> key.
1202  */
1203  
1204 /**
1205  * keycode_End:
1206  *
1207  * Represents the <keycap function="end">end</keycap> key.
1208  */
1209
1210 /**
1211  * keycode_Func1:
1212  *
1213  * Represents the <keycap>F1</keycap> key.
1214  */
1215  
1216 /**
1217  * keycode_Func2:
1218  *
1219  * Represents the <keycap>F2</keycap> key.
1220  */
1221
1222 /**
1223  * keycode_Func3:
1224  *
1225  * Represents the <keycap>F3</keycap> key.
1226  */
1227
1228 /**
1229  * keycode_Func4:
1230  *
1231  * Represents the <keycap>F4</keycap> key.
1232  */
1233
1234 /**
1235  * keycode_Func5:
1236  *
1237  * Represents the <keycap>F5</keycap> key.
1238  */
1239  
1240 /**
1241  * keycode_Func6:
1242  *
1243  * Represents the <keycap>F6</keycap> key.
1244  */
1245
1246 /**
1247  * keycode_Func7:
1248  *
1249  * Represents the <keycap>F7</keycap> key.
1250  */
1251
1252 /**
1253  * keycode_Func8:
1254  *
1255  * Represents the <keycap>F8</keycap> key.
1256  */
1257
1258 /**
1259  * keycode_Func9:
1260  *
1261  * Represents the <keycap>F9</keycap> key.
1262  */
1263
1264 /**
1265  * keycode_Func10:
1266  *
1267  * Represents the <keycap>F10</keycap> key.
1268  */
1269
1270 /**
1271  * keycode_Func11:
1272  *
1273  * Represents the <keycap>F11</keycap> key.
1274  */
1275
1276 /**
1277  * keycode_Func12:
1278  *
1279  * Represents the <keycap>F12</keycap> key.
1280  */
1281
1282 /**
1283  * keycode_MAXVAL:
1284  *
1285  * This value is equal to the number of special keycodes. The last keycode is
1286  * The last keycode is always 
1287  * <informalequation>
1288  *   <alt>(0x100000000 - <keysym>keycode_MAXVAL</keysym>)</alt>
1289  *   <mathphrase>(0x100000000 - <keysym>keycode_MAXVAL</keysym>)</mathphrase>
1290  * </informalequation>
1291  * .
1292  */
1293
1294 /**
1295  * stream_result_t:
1296  * @readcount: Number of characters read from the stream.
1297  * @writecount: Number of characters printed to the stream, including ones that
1298  * were thrown away.
1299  *
1300  * If you are interested in the character counts of a stream (see <link
1301  * linkend="chimara-Streams">Streams</link>), then you can pass a pointer to
1302  * #stream_result_t as an argument of glk_stream_close() or glk_window_close().
1303  * The structure will be filled with the stream's final character counts.
1304  */
1305
1306 /**
1307  * wintype_AllTypes:
1308  *
1309  * A constant representing all window types, which may be used as the @wintype
1310  * argument in glk_stylehint_set().
1311  */
1312
1313 /** 
1314  * wintype_Pair:
1315  * 
1316  * A pair window is completely filled by the two windows it contains. It
1317  * supports no input and no output, and it has no size.
1318  * 
1319  * You cannot directly create a pair window; one is automatically created
1320  * every time you split a window with glk_window_open(). Pair windows are
1321  * always created with a rock value of 0.
1322  * 
1323  * You can close a pair window with glk_window_close(); this also closes every
1324  * window contained within the pair window.
1325  * 
1326  * It is legal to split a pair window when you call glk_window_open().
1327  */
1328  
1329 /**
1330  * wintype_Blank:
1331  * 
1332  * A blank window is always blank. It supports no input and no output. (You
1333  * can call glk_window_get_stream() on it, as you can with any window, but
1334  * printing to the resulting stream has no effect.) A blank window has no
1335  * size; glk_window_get_size() will return (0,0), and it is illegal to set a
1336  * window split with a fixed size in the measurement system of a blank window.
1337  * 
1338  * <note><para>
1339  *   A blank window is not the same as there being no windows. When Glk starts
1340  *   up, there are no windows at all, not even a window of the blank type.
1341  * </para></note>
1342  */
1343  
1344 /**
1345  * wintype_TextBuffer: 
1346  *
1347  * A text buffer window contains a linear stream of text. It supports output;
1348  * when you print to it, the new text is added to the end. There is no way for
1349  * you to affect text which has already been printed. There are no guarantees
1350  * about how much text the window keeps; old text may be stored forever, so
1351  * that the user can scroll back to it, or it may be thrown away as soon as it
1352  * scrolls out of the window. 
1353  * 
1354  * <note><para>
1355  *   Therefore, there may or may not be a player-controllable scroll bar or
1356  *   other scrolling widget.
1357  * </para></note>
1358  * 
1359  * The display of the text in a text buffer is up to the library. Lines will
1360  * probably not be broken in the middles of words &mdash; but if they are, the
1361  * library is not doing anything illegal, only ugly. Text selection and copying
1362  * to a clipboard, if available, are handled however is best on the player's
1363  * machine. Paragraphs (as defined by newline characters in the output) may be
1364  * indented. 
1365  * 
1366  * <note><para>
1367  *   You should not, in general, fake this by printing spaces before each
1368  *   paragraph of prose text. Let the library and player preferences handle
1369  *   that. Special cases (like indented lists) are of course up to you.
1370  * </para></note>
1371  * 
1372  * When a text buffer is cleared (with glk_window_clear()), the library will do
1373  * something appropriate; the details may vary. It may clear the window, with
1374  * later text appearing at the top &mdash; or the bottom. It may simply print
1375  * enough blank lines to scroll the current text out of the window. It may
1376  * display a distinctive page-break symbol or divider.
1377  * 
1378  * The size of a text buffer window is necessarily imprecise. Calling
1379  * glk_window_get_size() will return the number of rows and columns that would
1380  * be available <emphasis>if</emphasis> the window was filled with 
1381  * <quote>0</quote> (zero) characters in the <quote>normal</quote> font.
1382  * However, the window may use a non-fixed-width font, so that number of
1383  * characters in a line could vary. The window might even support 
1384  * variable-height text (say, if the player is using large text for emphasis);
1385  * that would make the number of lines in the window vary as well.
1386  * 
1387  * Similarly, when you set a fixed-size split in the measurement system of a
1388  * text buffer, you are setting a window which can handle a fixed number of rows
1389  * (or columns) of <quote>0</quote> characters. The number of rows (or
1390  * characters) that will actually be displayed depends on font variances.
1391  * 
1392  * A text buffer window supports both character and line input, but not mouse
1393  * input.
1394  * 
1395  * In character input, there will be some visible signal that the window is
1396  * waiting for a keystroke. (Typically, a cursor at the end of the text.) When
1397  * the player hits a key in that window, an event is generated, but the key is
1398  * <emphasis>not</emphasis> printed in the window.
1399  * 
1400  * In line input, again, there will be some visible signal. It is most common
1401  * for the player to compose input in the window itself, at the end of the text.
1402  * (This is how IF story input usually looks.) But it's not strictly required.
1403  * An alternative approach is the way MUD clients usually work: there is a
1404  * dedicated one-line input window, outside of Glk's window space, and the user
1405  * composes input there.
1406  * 
1407  * <note><para>
1408  *   If this approach is used, there will still be some way to handle input from
1409  *   two windows at once. It is the library's responsibility to make this
1410  *   available to the player. You only need request line input and  wait for the
1411  *   result.
1412  * </para></note>
1413  * 
1414  * When the player finishes his line of input, the library will display the
1415  * input text at the end of the buffer text (if it wasn't there already.) It
1416  * will be followed by a newline, so that the next text you print will start a
1417  * new line (paragraph) after the input.
1418  * 
1419  * If you call glk_cancel_line_event(), the same thing happens; whatever text
1420  * the user was composing is visible at the end of the buffer text, followed by
1421  * a newline.
1422  */
1423  
1424 /**
1425  * wintype_TextGrid: 
1426  * 
1427  * A text grid contains a rectangular array of characters, in a fixed-width
1428  * font. Its size is the number of columns and rows of the array.
1429  * 
1430  * A text grid window supports output. It maintains knowledge of an output
1431  * cursor position. When the window is opened, it is filled with blanks (space
1432  * characters), and the output cursor starts in the top left corner &mdash;
1433  * character (0,0). If the window is cleared with glk_window_clear(), the window
1434  * is filled with blanks again, and the cursor returns to the top left corner.
1435  * 
1436  * When you print, the characters of the output are laid into the array in
1437  * order, left to right and top to bottom. When the cursor reaches the end of a
1438  * line, it goes to the beginning of the next line. The library makes no attempt
1439  * to wrap lines at word breaks.
1440  * 
1441  * <note><para>
1442  *   Note that printing fancy characters may cause the cursor to advance more
1443  *   than one position per character. (For example, the <quote>&aelig;</quote>
1444  *   ligature may print as two characters.) See <link 
1445  *   linkend="chimara-Output">Output</link>, for how to test this situation.
1446  * </para></note>
1447  * 
1448  * You can set the cursor position with glk_window_move_cursor().
1449  * 
1450  * When a text grid window is resized smaller, the bottom or right area is
1451  * thrown away, but the remaining area stays unchanged. When it is resized
1452  * larger, the new bottom or right area is filled with blanks.
1453  * 
1454  * <note><para>
1455  *   You may wish to watch for #evtype_Arrange events, and clear-and-redraw your
1456  *   text grid windows when you see them change size.
1457  * </para></note>
1458  * 
1459  * Text grid window support character and line input, as well as mouse input (if
1460  * a mouse is available.)
1461  * 
1462  * Mouse input returns the position of the character that was touched, from
1463  * (0,0) to 
1464  * <inlineequation>
1465  *   <alt>(width-1,height-1)</alt>
1466  *   <mathphrase>(width - 1, height - 1)</mathphrase>
1467  * </inlineequation>
1468  * .
1469  * 
1470  * Character input is as described in the previous section.
1471  * 
1472  * Line input is slightly different; it is guaranteed to take place in the
1473  * window, at the output cursor position. The player can compose input only to
1474  * the right edge of the window; therefore, the maximum input length is
1475  * <inlineequation>
1476  *   <alt>(windowwidth - 1 - cursorposition)</alt>
1477  *   <mathphrase>(windowwidth - 1 - cursorposition)</mathphrase>
1478  * </inlineequation>
1479  * . If the maxlen argument of glk_request_line_event() is smaller than this,
1480  * the library will not allow the input cursor to go more than maxlen characters
1481  * past its start point. 
1482  * 
1483  * <note><para>
1484  *   This allows you to enter text in a fixed-width field, without the player
1485  *   being able to overwrite other parts of the window.
1486  * </para></note>
1487  * 
1488  * When the player finishes his line of input, it will remain visible in the
1489  * window, and the output cursor will be positioned at the beginning of the 
1490  * <emphasis>next</emphasis> row. Again, if you glk_cancel_line_event(), the
1491  * same thing happens.
1492  */
1493  
1494 /**
1495  * wintype_Graphics: 
1496  * 
1497  * A graphics window contains a rectangular array of pixels. Its size is the
1498  * number of columns and rows of the array.
1499  * 
1500  * Each graphics window has a background color, which is initially white. You
1501  * can change this; see <link 
1502  * linkend="chimara-Graphics-in-Graphics-Windows">Graphics in Graphics 
1503  * Windows</link>.
1504  * 
1505  * When a text grid window is resized smaller, the bottom or right area is
1506  * thrown away, but the remaining area stays unchanged. When it is resized
1507  * larger, the new bottom or right area is filled with the background color.
1508  * 
1509  * <note><para>
1510  *   You may wish to watch for #evtype_Arrange events, and clear-and-redraw your
1511  *   graphics windows when you see them change size.
1512  * </para></note>
1513  * 
1514  * In some libraries, you can receive a graphics-redraw event (#evtype_Redraw)
1515  * at any time. This signifies that the window in question has been cleared to
1516  * its background color, and must be redrawn. If you create any graphics
1517  * windows, you <emphasis>must</emphasis> handle these events.
1518  * 
1519  * <note><para>
1520  *   Redraw events can be triggered when a Glk window is uncovered or made
1521  *   visible by the platform's window manager. On the other hand, some Glk
1522  *   libraries handle these problem automatically &mdash; for example, with a
1523  *   backing store &mdash; and do not send you redraw events. On the third hand,
1524  *   the backing store may be discarded if memory is low, or for other reasons
1525  *   &mdash; perhaps the screen's color depth has changed. So redraw events are
1526  *   always a possibility, even in clever libraries. This is why you must be
1527  *   prepared to handle them.
1528  * 
1529  *   However, you will not receive a redraw event when you create a graphics
1530  *   window. It is assumed that you will do the initial drawing of your own
1531  *   accord. You also do not get redraw events when a graphics window is
1532  *   enlarged. If you ordered the enlargement, you already know about it; if the
1533  *   player is responsible, you receive a window-arrangement event, which covers
1534  *   the situation.
1535  * </para></note>
1536  * 
1537  * For a description of the drawing functions that apply to graphics windows,
1538  * see <link linkend="chimara-Graphics-in-Graphics-Windows">Graphics in Graphics
1539  * Windows</link>.
1540  * 
1541  * Graphics windows support no text input or output.
1542  * 
1543  * Not all libraries support graphics windows. You can test whether Glk graphics
1544  * are available using the gestalt system. In a C program, you can also test
1545  * whether the graphics functions are defined at compile-time. See <link 
1546  * linkend="chimara-Testing-for-Graphics-Capabilities">Testing for Graphics
1547  * Capabilities</link>. 
1548  *
1549  * <note><para>
1550  *   As with all windows, you should also test for %NULL when you create a
1551  *   graphics window.
1552  * </para></note>
1553  */
1554  
1555 /**
1556  * winmethod_Left:
1557  *
1558  * When calling glk_window_open() with this @method, the new window will be 
1559  * to the left of the old one which was split.
1560  */
1561
1562 /**
1563  * winmethod_Right:
1564  *
1565  * When calling glk_window_open() with this @method, the new window will be 
1566  * to the right of the old one which was split.
1567  */
1568
1569 /**
1570  * winmethod_Above:
1571  *
1572  * When calling glk_window_open() with this @method, the new window will be 
1573  * above the old one which was split.
1574  */
1575  
1576 /**
1577  * winmethod_Below:
1578  *
1579  * When calling glk_window_open() with this @method, the new window will be 
1580  * below the old one which was split.
1581  */
1582
1583 /**
1584  * winmethod_DirMask:
1585  *
1586  * Bitwise AND this value with a window splitting method argument to find
1587  * whether the split is #winmethod_Left, #winmethod_Right, #winmethod_Above, or
1588  * #winmethod_Below.
1589  */
1590  
1591 /**
1592  * winmethod_Fixed:
1593  *
1594  * When calling glk_window_open() with this @method, the new window will be 
1595  * a fixed size. (See glk_window_open()).
1596  */
1597
1598 /**
1599  * winmethod_Proportional:
1600  *
1601  * When calling glk_window_open() with this @method, the new window will be 
1602  * a given proportion of the old window's size. (See glk_window_open()).
1603  */
1604  
1605 /**
1606  * winmethod_DivisionMask:
1607  *
1608  * Bitwise AND this value with a window splitting method argument to find
1609  * whether the new window has #winmethod_Fixed or #winmethod_Proportional.
1610  */
1611  
1612 /** 
1613  * fileusage_Data: 
1614  *
1615  * Any other kind of file (preferences, statistics, arbitrary data.) 
1616  */
1617
1618 /**
1619  * fileusage_SavedGame: 
1620  * 
1621  * A file which stores game state.
1622  */
1623
1624 /**
1625  * fileusage_Transcript: 
1626  * 
1627  * A file which contains a stream of text from the game (often an echo stream
1628  * from a window.)
1629  */
1630  
1631 /** 
1632  * fileusage_InputRecord: 
1633  * 
1634  * A file which records player input.
1635  */
1636
1637 /** 
1638  * fileusage_TextMode: 
1639  *
1640  * The file contents will be transformed to a platform-native text file as they
1641  * are written out. Newlines may be converted to linefeeds or 
1642  * linefeed-plus-carriage-return combinations; Latin-1 characters may be
1643  * converted to native character codes. When reading a file in text mode, native
1644  * line breaks will be converted back to newline (0x0A) characters, and native
1645  * character codes may be converted to Latin-1. 
1646  *
1647  * <note><para>
1648  *   Line breaks will always be converted; other conversions are more
1649  *   questionable. If you write out a file in text mode, and then read it back
1650  *   in text mode, high-bit characters (128 to 255) may be transformed or lost.
1651  * </para></note>
1652  * <note><title>Chimara</title>
1653  * <para>
1654  * Text mode files in Chimara are in UTF-8, which is GTK+'s native file
1655  * encoding.
1656  * </para></note>
1657  */
1658
1659 /**
1660  * fileusage_BinaryMode: 
1661  *
1662  * The file contents will be stored exactly as they are written, and read back
1663  * in the same way. The resulting file may not be viewable on platform-native
1664  * text file viewers.
1665  */
1666
1667 /**
1668  * fileusage_TypeMask:
1669  *
1670  * Bitwise AND this value with a file usage argument to find whether the file
1671  * type is #fileusage_SavedGame, #fileusage_Transcript, #fileusage_InputRecord,
1672  * or #fileusage_Data.
1673  */
1674
1675 /**
1676  * filemode_Write: 
1677  *
1678  * An output stream.
1679  *
1680  * <note><para>
1681  *   Corresponds to mode <code>"w"</code> in the stdio library, using fopen().
1682  * </para></note>
1683  */
1684
1685 /** 
1686  * filemode_Read: 
1687  *
1688  * An input stream.
1689  *
1690  * <note><para>
1691  *   Corresponds to mode <code>"r"</code> in the stdio library, using fopen().
1692  * </para></note>
1693  */
1694
1695 /**
1696  * filemode_ReadWrite: 
1697  *
1698  * Both an input and an output stream.
1699  *
1700  * <note><para>
1701  *   Corresponds to mode <code>"r+"</code> in the stdio library, using fopen().
1702  * </para></note>
1703  */
1704
1705 /**
1706  * filemode_WriteAppend: 
1707  *
1708  * An output stream, but the data will added to the end of whatever already
1709  * existed in the destination, instead of replacing it. 
1710  *
1711  * <note><para>
1712  *   Corresponds to mode <code>"a"</code> in the stdio library, using fopen().
1713  * </para></note>
1714  */
1715  
1716 /**
1717  * seekmode_Start:
1718  *
1719  * In glk_stream_set_position(), signifies that @pos is counted in characters
1720  * after the beginning of the file.
1721  */
1722  
1723 /**
1724  * seekmode_Current: 
1725  *
1726  * In glk_stream_set_position(), signifies that @pos is counted in characters
1727  * after the current position (moving backwards if @pos is negative.)
1728  */
1729
1730 /** 
1731  * seekmode_End: 
1732  *
1733  * In glk_stream_set_position(), signifies that @pos is counted in characters
1734  * after the end of the file. (@pos should always be zero or negative, so that
1735  * this will move backwards to a  position within the file.
1736  */
1737