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.
9 * @short_description: How to terminate a Glk program cleanly
12 * A Glk program usually ends when the end of the glk_main() function is
13 * reached. You can also terminate it earlier.
17 * SECTION:glk-interrupt
18 * @short_description: Specifying an interrupt handler for cleaning up critical
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.
30 * If you need to clean up critical resources, you can specify an interrupt
36 * @short_description: Yielding time to the operating system
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.
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
50 * @short_description: Basic types used in Glk
53 * For simplicity, all the arguments used in Glk calls are of a very few types.
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>
61 * <term>32-bit signed integer</term>
62 * <listitem><para>This type is called #glsi32. Rarely used.</para>
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>
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>
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>.
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>
90 * <term>Pointer to <type>void</type></term>
91 * <listitem><para>When nothing else will do.</para></listitem>
97 * SECTION:glk-opaque-objects
98 * @short_description: Complex objects in Glk
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.
104 * Currently, these classes are:
107 * <term>Windows</term>
108 * <listitem><para>Screen panels, used to input or output information.
112 * <term>Streams</term>
113 * <listitem><para>Data streams, to which you can input or output text.
115 * <note><para>There are file streams and window streams, since you can
116 * output data to windows or files.</para></note>
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>
128 * <term>Sound channels</term>
129 * <listitem><para>Audio output channels.</para>
130 * <note><para>Not all Glk libraries support sound.</para></note>
136 * Note that there may be more object classes in future versions of the Glk API.
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.
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.
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.
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.
161 * <refsect2 id="chimara-Rocks"><!-- Indeed it does. -->
162 * <title>Rocks</title>
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.
168 * <note><para>The library — so to speak — stuffs this value under a
169 * rock for safe-keeping, and gives it back to you when you ask for it.
171 * <note><para>If you don't know what to use the rocks for, provide 0 and forget
172 * about it.</para></note>
174 * <refsect2 id="chimara-Iterating-Through-Opaque-Objects">
175 * <title>Iteration Through Opaque Objects</title>
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
180 * <replaceable>CLASS</replaceable>id_t glk_<replaceable>CLASS</replaceable>_iterate(<replaceable>CLASS</replaceable>id_t <parameter>obj</parameter>, #glui32 *<parameter>rockptr</parameter>);
182 * ...where <code><replaceable>CLASS</replaceable></code> represents one of the
183 * opaque object classes.
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
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.
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.
204 * You usually use this as follows:
206 * obj = glk_<replaceable>CLASS</replaceable>_iterate(NULL, NULL);
208 * /* ...do something with obj... *<!-- -->/
209 * obj = glk_<replaceable>CLASS</replaceable>_iterate(obj, NULL);
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.
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.
231 * SECTION:glk-gestalt
232 * @short_description: Testing Glk's capabilities
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 — those which not all Glk library
240 * implementations will support — and allows you to check for their
241 * presence without trying to infer them from a version number.
243 * The basic idea is that you can request information about the capabilities of
244 * the API, by calling the gestalt functions.
248 * SECTION:glk-character-input
249 * @short_description: Waiting for a single keystroke
252 * You can request that the player hit a single key. See <link
253 * linkend="chimara-Character-Input-Events">Character Input Events</link>.
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
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
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.
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.
298 * Some characters may not be enterable simply because they do not exist.
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.
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>
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>.
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
337 * You can test for this by using the #gestalt_CharInput selector.
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>
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.
368 * @short_description: Changing the case of strings
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.
378 * SECTION:glk-window-opening
379 * @short_description: Creating new windows and closing them
382 * You can open a new window using glk_window_open() and close it again using
383 * glk_window_close().
387 * SECTION:glk-window-constraints
388 * @short_description: Manipulating the size of a window
391 * There are library functions to change and to measure the size of a window.
395 * SECTION:glk-window-types
396 * @short_description: Blank, pair, text grid, text buffer, and graphics windows
399 * A technical description of all the window types, and exactly how they behave.
403 * SECTION:glk-echo-streams
404 * @short_description: Creating a copy of a window's output
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>
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().
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.
420 * An echo stream can be of any type, even another window's window stream.
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.
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.
432 * If a window is closed, its echo stream remains open; it is not automatically
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.
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.)
447 * SECTION:glk-window-other
448 * @short_description: Miscellaneous functions for windows
451 * This section contains functions for windows that don't fit anywhere else.
456 * @short_description: Waiting for events
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.
466 * SECTION:glk-character-input-events
467 * @short_description: Events representing a single keystroke
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.
476 * SECTION:glk-line-input-events
477 * @short_description: Events representing a line of user input
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.
486 * SECTION:glk-streams
487 * @short_description: Input and output abstractions
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.
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.
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.
505 * It is also possible to create a stream that reads or writes to a buffer in
508 * Finally, there may be platform-specific types of streams, which are created
509 * before your program starts running.
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.
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>.
522 * A stream is opened with a particular file mode, see the
523 * <code>filemode_</code> constants below.
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.
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
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.
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.)
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
550 * If the stream which is the current stream is closed, the current stream
556 * @short_description: Printing to streams
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.
566 * @short_description: Reading from streams
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
575 * SECTION:glk-closing-streams
576 * @short_description: Closing streams and retrieving their character counts
579 * When you close a Glk stream, you have the opportunity to examine the
580 * character counts — the number of characters written to or read from the
585 * SECTION:glk-stream-positions
586 * @short_description: Moving the read/write mark
589 * You can set the position of the read/write mark in a stream.
592 * Which makes one wonder why they're called <quote>streams</quote> in the
593 * first place. Oh well.
598 * SECTION:glk-stream-types
599 * @short_description: Window, memory, and file streams
602 * <refsect2 id="chimara-Window-Streams"><title>Window Streams</title>
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().
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().
611 * Only printable characters (including newline) may be printed to a window
612 * stream. See <link linkend="chimara-Character-Encoding">Character
616 * <refsect2 id="chimara-Memory-Streams"><title>Memory Streams</title>
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.
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.)
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.
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.
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.
642 * You can write a disk file in text mode, but a memory stream is effectively
643 * always in binary mode.
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.
652 * <refsect2 id="chimara-File-Streams"><title>File Streams</title>
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().
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>.
666 * SECTION:glk-stream-other
667 * @short_description: Miscellaneous functions for streams
670 * This section includes functions for streams that don't fit anywhere else.
674 * SECTION:glk-fileref
675 * @short_description: A platform-independent way to refer to disk files
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
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
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.
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
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.
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.
710 * SECTION:glk-fileref-types
711 * @short_description: Four different ways to create a file reference
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.
720 * SECTION:glk-fileref-other
721 * @short_description: Miscellaneous functions for file references
724 * This section includes functions for file references that don't fit anywhere
728 /*---------------- TYPES AND CONSTANTS FROM GLK.H ----------------------------*/
733 * A 32-bit unsigned integer type, used wherever possible in Glk.
739 * A 32-bit signed integer type, rarely used.
743 * GLK_MODULE_UNICODE:
745 * If this preprocessor symbol is defined, so are all the Unicode functions and
746 * constants (see #gestalt_Unicode). If not, not.
752 * Opaque structure representing a Glk window. It has no user-accessible
759 * Opaque structure representing an input or output stream. It has no
760 * user-accessible members.
766 * Opaque structure representing a file reference. It has no user-accessible
773 * For an example of the gestalt mechanism, consider the selector
774 * #gestalt_Version. If you do
777 * res = #glk_gestalt(#gestalt_Version, 0);
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.
785 * So the version number 78.2.11 would be encoded as 0x004E020B.
788 * The current Glk specification version is 0.7.0, so this selector will return
793 * res = #glk_gestalt_ext(#gestalt_Version, 0, NULL, 0);
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.
802 * If you set <code>ch</code> to a character code, or a special code (from
803 * 0xFFFFFFFF down), and call
806 * res = #glk_gestalt(#gestalt_CharInput, ch);
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>.
816 * If you set <code>ch</code> to a character code, and call
819 * res = #glk_gestalt(#gestalt_LineInput, ch);
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
829 * gestalt_CharOutput:
831 * If you set <code>ch</code> to a character code (Latin-1 or higher), and call
834 * res = #glk_gestalt_ext(#gestalt_CharOutput, ch, &len, 1);
836 * then <code>res</code> will be one of #gestalt_CharOutput_CannotPrint,
837 * #gestalt_CharOutput_ExactPrint, or #gestalt_CharOutput_ApproxPrint (see
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
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.
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
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 (þ), 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
866 * |[ res = #glk_gestalt(#gestalt_CharOutput, (unsigned char)ch); ]|
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>.
880 * gestalt_CharOutput_CannotPrint:
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.
888 * gestalt_CharOutput_ApproxPrint:
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>æ</quote> ligature,
896 * <quote><computeroutput>e</computeroutput></quote> for
897 * <quote>è</quote>, <quote><computeroutput>|</computeroutput></quote>
898 * for a broken vertical bar (¦).)
902 * gestalt_CharOutput_ExactPrint:
904 * When the #gestalt_CharOutput selector returns this for a character, the
905 * character will be printed exactly as defined.
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:
916 * res = #glk_gestalt(#gestalt_Unicode, 0);
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().
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
938 * To avoid this, you can perform a preprocessor test for the existence of
939 * #GLK_MODULE_UNICODE.
945 * No event. This is a placeholder, and glk_select() never returns it.
951 * An event that repeats at fixed intervals. See <link
952 * linkend="chimara-Timer-Events">Timer Events</link>.
958 * A keystroke event in a window. See <link
959 * linkend="chimara-Character-Input-Events">Character Input Events</link>.
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.
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.
977 * A full line of input completed in a window. See <link
978 * linkend="chimara-Line-Input-Events">Line Input Events</link>.
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.
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.
992 * <note><para>There is no null terminator stored in the buffer.</para></note>
994 * It is illegal to print anything to a window which has line input pending.
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
1004 * evtype_MouseInput:
1006 * A mouse click in a window. See <link
1007 * linkend="chimara-Mouse-Input-Events">Mouse Input Events</link>.
1013 * An event signalling that the sizes of some windows have changed.
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.
1022 * The display of a text buffer window is entirely up to the library, so you
1023 * don't need to worry about those.
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.
1031 * You can always play it safe, ignore @win, and redraw every graphics and
1035 * An arrangement event is guaranteed to occur whenever the player causes any
1036 * window to change size, as measured by its own metric.
1039 * Size changes caused by you — for example, if you open, close, or
1040 * resize a window — do not trigger arrangement events. You must be
1041 * aware of the effects of your window management, and redraw the windows that
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.
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().
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
1069 * An event signalling that graphics windows must be redrawn.
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.
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.
1080 * You can always play it safe, ignore @win, and redraw every graphics window.
1083 * Affected windows are already cleared to their background color when you
1084 * receive the redraw event.
1086 * Redraw events can be returned by glk_select_poll(). But, like arrangement
1087 * events, this is platform-dependent. See #evtype_Arrange.
1089 * For more about redraw events and how they affect graphics windows, see <link
1090 * linkend="chimara-Graphics-Windows">Graphics Windows</link>.
1094 * evtype_SoundNotify:
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>.
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
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
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.
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.
1129 * Represents any key that has no Latin-1 or special code.
1135 * Represents the <keycap function="left">left arrow</keycap> key.
1141 * Represents the <keycap function="right">right arrow</keycap> key.
1147 * Represents the <keycap function="up">up arrow</keycap> key.
1153 * Represents the <keycap function="down">down arrow</keycap> key.
1159 * Represents the <keycap function="enter">return</keycap> or <keycap
1160 * function="enter">enter</keycap> keys.
1166 * Represents the <keycap function="delete">delete</keycap> or <keycap
1167 * function="backspace">backspace</keycap> keys.
1173 * Represents the <keycap function="escape">escape</keycap> key.
1179 * Represents the <keycap function="tab">tab</keycap> key.
1185 * Represents the <keycap function="pageup">page up</keycap> key.
1191 * Represents the <keycap function="pagedown">page down</keycap> key.
1197 * Represents the <keycap function="home">home</keycap> key.
1203 * Represents the <keycap function="end">end</keycap> key.
1209 * Represents the <keycap>F1</keycap> key.
1215 * Represents the <keycap>F2</keycap> key.
1221 * Represents the <keycap>F3</keycap> key.
1227 * Represents the <keycap>F4</keycap> key.
1233 * Represents the <keycap>F5</keycap> key.
1239 * Represents the <keycap>F6</keycap> key.
1245 * Represents the <keycap>F7</keycap> key.
1251 * Represents the <keycap>F8</keycap> key.
1257 * Represents the <keycap>F9</keycap> key.
1263 * Represents the <keycap>F10</keycap> key.
1269 * Represents the <keycap>F11</keycap> key.
1275 * Represents the <keycap>F12</keycap> key.
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>
1292 * @readcount: Number of characters read from the stream.
1293 * @writecount: Number of characters printed to the stream, including ones that
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.
1305 * A constant representing all window types, which may be used as the @wintype
1306 * argument in glk_stylehint_set().
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.
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.
1319 * You can close a pair window with glk_window_close(); this also closes every
1320 * window contained within the pair window.
1322 * It is legal to split a pair window when you call glk_window_open().
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.
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.
1341 * wintype_TextBuffer:
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.
1351 * Therefore, there may or may not be a player-controllable scroll bar or
1352 * other scrolling widget.
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 — 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
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.
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 — 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.
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.
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.
1388 * A text buffer window supports both character and line input, but not mouse
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.
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.
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
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.
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
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.
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 —
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.
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.
1438 * Note that printing fancy characters may cause the cursor to advance more
1439 * than one position per character. (For example, the <quote>æ</quote>
1440 * ligature may print as two characters.) See <link
1441 * linkend="chimara-Output">Output</link>, for how to test this situation.
1444 * You can set the cursor position with glk_window_move_cursor().
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.
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.
1455 * Text grid window support character and line input, as well as mouse input (if
1456 * a mouse is available.)
1458 * Mouse input returns the position of the character that was touched, from
1461 * <alt>(width-1,height-1)</alt>
1462 * <mathphrase>(width - 1, height - 1)</mathphrase>
1466 * Character input is as described in the previous section.
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
1472 * <alt>(windowwidth - 1 - cursorposition)</alt>
1473 * <mathphrase>(windowwidth - 1 - cursorposition)</mathphrase>
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.
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.
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.
1493 * A graphics window contains a rectangular array of pixels. Its size is the
1494 * number of columns and rows of the array.
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
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.
1506 * You may wish to watch for #evtype_Arrange events, and clear-and-redraw your
1507 * graphics windows when you see them change size.
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.
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 — for example, with a
1519 * backing store — 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 * — 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.
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
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
1537 * Graphics windows support no text input or output.
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>.
1546 * As with all windows, you should also test for %NULL when you create a
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.
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.
1568 * When calling glk_window_open() with this @method, the new window will be
1569 * above the old one which was split.
1575 * When calling glk_window_open() with this @method, the new window will be
1576 * below the old one which was split.
1580 * winmethod_DirMask:
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
1590 * When calling glk_window_open() with this @method, the new window will be
1591 * a fixed size. (See glk_window_open()).
1595 * winmethod_Proportional:
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()).
1602 * winmethod_DivisionMask:
1604 * Bitwise AND this value with a window splitting method argument to find
1605 * whether the new window has #winmethod_Fixed or #winmethod_Proportional.
1611 * Any other kind of file (preferences, statistics, arbitrary data.)
1615 * fileusage_SavedGame:
1617 * A file which stores game state.
1621 * fileusage_Transcript:
1623 * A file which contains a stream of text from the game (often an echo stream
1628 * fileusage_InputRecord:
1630 * A file which records player input.
1634 * fileusage_TextMode:
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.
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.
1648 * <note><title>Chimara</title>
1650 * Text mode files in Chimara are in UTF-8, which is GTK+'s native file
1656 * fileusage_BinaryMode:
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.
1664 * fileusage_TypeMask:
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.
1677 * Corresponds to mode <code>"w"</code> in the stdio library, using fopen().
1687 * Corresponds to mode <code>"r"</code> in the stdio library, using fopen().
1692 * filemode_ReadWrite:
1694 * Both an input and an output stream.
1697 * Corresponds to mode <code>"r+"</code> in the stdio library, using fopen().
1702 * filemode_WriteAppend:
1704 * An output stream, but the data will added to the end of whatever already
1705 * existed in the destination, instead of replacing it.
1708 * Corresponds to mode <code>"a"</code> in the stdio library, using fopen().
1715 * In glk_stream_set_position(), signifies that @pos is counted in characters
1716 * after the beginning of the file.
1722 * In glk_stream_set_position(), signifies that @pos is counted in characters
1723 * after the current position (moving backwards if @pos is negative.)
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.