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
10 * @include: libchimara/glk.h
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
20 * @include: libchimara/glk.h
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
37 * @include: libchimara/glk.h
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
51 * @include: libchimara/glk.h
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
99 * @include: libchimara/glk.h
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
233 * @include: libchimara/glk.h
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
250 * @include: libchimara/glk.h
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
369 * @include: libchimara/glk.h
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
380 * @include: libchimara/glk.h
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
389 * @include: libchimara/glk.h
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
397 * @include: libchimara/glk.h
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
405 * @include: libchimara/glk.h
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
449 * @include: libchimara/glk.h
451 * This section contains functions for windows that don't fit anywhere else.
456 * @short_description: Waiting for events
457 * @include: libchimara/glk.h
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
468 * @include: libchimara/glk.h
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
478 * @include: libchimara/glk.h
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-mouse-events
487 * @short_description: Events representing a mouse click
488 * @include: libchimara/glk.h
490 * On some platforms, Glk can recognize when the mouse (or other pointer) is
491 * used to select a spot in a window. You can request mouse input only in text
492 * grid windows and graphics windows.
494 * A window can have mouse input and character/line input pending at the same
497 * If the player clicks in a window which has a mouse input event pending,
498 * glk_select() will return an event whose type is %evtype_MouseInput. Again,
499 * once this happens, the request is complete, and you must request another if
500 * you want further mouse input.
502 * In the event structure, @win tells what window the event came from.
504 * In a text grid window, the @val1 and @val2 fields are the x and y coordinates
505 * of the character that was clicked on.
506 * <note><para>So @val1 is the column, and @val2 is the row.</para></note>
507 * The top leftmost character is considered to be (0,0).
509 * In a graphics window, they are the x and y coordinates of the pixel that was
510 * clicked on. Again, the top left corner of the window is (0,0).
513 * Most mouse-based idioms define standard functions for mouse hits in text
514 * windows — typically selecting or copying text. It is up to the
515 * library to separate this from Glk mouse input. The library may choose to
516 * select text when it is clicked normally, and cause Glk mouse events when
517 * text is control-clicked. Or the other way around. Or it may be the
518 * difference between clicking and double-clicking. Or the library may
519 * reserve a particular mouse button, on a multi-button mouse. It may even
520 * specify a keyboard key to be the "mouse button", referring to wherever the
521 * mouse cursor is when the key is hit. Or some even more esoteric positioning
522 * system. You need only know that the user can do it, or not.
525 * However, since different platforms will handle this issue differently, you
526 * should be careful how you instruct the player in your program. Do not tell
527 * the player to <quote>double-click</quote>, <quote>right-click</quote>, or
528 * <quote>control-click</quote> in a window. The preferred term is <quote>to
529 * touch the window</quote>, or a spot in the window.
532 * Goofy, but preferred.
537 * SECTION:glk-timer-events
538 * @short_description: Events sent at fixed intervals
539 * @include: libchimara/glk.h
541 * You can request that an event be sent at fixed intervals, regardless of what
542 * the player does. Unlike input events, timer events can be tested for with
543 * glk_select_poll() as well as glk_select().
545 * It is possible that the library does not support timer events. You can check
546 * this with the %gestalt_Timer selector.
550 * SECTION:glk-streams
551 * @short_description: Input and output abstractions
552 * @include: libchimara/glk.h
554 * All character output in Glk is done through streams. Every window has an
555 * output stream associated with it. You can also write to files on disk; every
556 * open file is represented by an output stream as well.
558 * There are also input streams; these are used for reading from files on disk.
559 * It is possible for a stream to be both an input and an output stream.
562 * Player input is done through line and character input events, not streams.
563 * This is a small inelegance in theory. In practice, player input is slow and
564 * things can interrupt it, whereas file input is immediate. If a network
565 * extension to Glk were proposed, it would probably use events and not
566 * streams, since network communication is not immediate.
569 * It is also possible to create a stream that reads or writes to a buffer in
572 * Finally, there may be platform-specific types of streams, which are created
573 * before your program starts running.
576 * For example, a program running under Unix may have access to standard input
577 * as a stream, even though there is no Glk call to explicitly open standard
578 * input. On the Mac, data in a Mac resource may be available through a
579 * resource-reading stream.
582 * You do not need to worry about the origin of such streams; just read or write
583 * them as usual. For information about how platform-specific streams come to
584 * be, see <link linkend="chimara-Startup-Options">Startup Options</link>.
586 * A stream is opened with a particular file mode, see the
587 * <code>filemode_</code> constants below.
589 * For information on opening streams, see the discussion of each specific type
590 * of stream in <link linkend="chimara-The-Types-of-Streams">The Types of
591 * Streams</link>. Remember that it is always possible that opening a stream
592 * will fail, in which case the creation function will return %NULL.
594 * Each stream remembers two character counts, the number of characters printed
595 * to and read from that stream. The write-count is exactly one per
596 * glk_put_char() call; it is figured before any platform-dependent character
600 * For example, if a newline character is converted to
601 * linefeed-plus-carriage-return, the stream's count still only goes up by
602 * one; similarly if an accented character is displayed as two characters.
605 * The read-count is exactly one per glk_get_char_stream() call, as long as the
606 * call returns an actual character (as opposed to an end-of-file token.)
608 * Glk has a notion of the <quote>current (output) stream</quote>. If you print
609 * text without specifying a stream, it goes to the current output stream. The
610 * current output stream may be %NULL, meaning that there isn't one. It is
611 * illegal to print text to stream %NULL, or to print to the current stream when
614 * If the stream which is the current stream is closed, the current stream
620 * @short_description: Printing to streams
621 * @include: libchimara/glk.h
623 * You can print Latin-1 and Unicode characters, null-terminated strings, or
624 * buffers to any stream. The characters will be converted into the appropriate
625 * format for that stream.
630 * @short_description: Reading from streams
631 * @include: libchimara/glk.h
633 * You can read Latin-1 or Unicode characters, buffers, or whole lines from any
634 * stream. The characters will be converted into the form in which you request
639 * SECTION:glk-closing-streams
640 * @short_description: Closing streams and retrieving their character counts
641 * @include: libchimara/glk.h
643 * When you close a Glk stream, you have the opportunity to examine the
644 * character counts — the number of characters written to or read from the
649 * SECTION:glk-stream-positions
650 * @short_description: Moving the read/write mark
651 * @include: libchimara/glk.h
653 * You can set the position of the read/write mark in a stream.
656 * Which makes one wonder why they're called <quote>streams</quote> in the
657 * first place. Oh well.
663 * @short_description: Changing the appearance of printed text
664 * @include: libchimara/glk.h
666 * You can send style-changing commands to an output stream. After a style
667 * change, new text which is printed to that stream will be given the new style,
668 * whatever that means for the stream in question. For a window stream, the text
669 * will appear in that style. For a memory stream, style changes have no effect.
670 * For a file stream, if the machine supports styled text files, the styles may
671 * be written to the file; more likely the style changes will have no effect.
673 * Styles are exclusive. A character is shown with exactly one style, not a
674 * subset of the possible styles.
677 * Note that every stream and window has its own idea of the <quote>current
678 * style.</quote> Sending a style command to one window or stream does not
682 * Except for a window's echo stream; see <link
683 * linkend="chimara-Echo-Streams">Echo Streams</link>.
686 * The styles are intended to distinguish meaning and use, not formatting. There
687 * is no standard definition of what each style will look like. That is left up
688 * to the Glk library, which will choose an appearance appropriate for the
689 * platform's interface and the player's preferences.
691 * There are currently eleven styles defined. More may be defined in the future.
693 * Styles may be distinguished on screen by font, size, color, indentation,
694 * justification, and other attributes. Note that some attributes (notably
695 * justification and indentation) apply to entire paragraphs. If possible and
696 * relevant, you should apply a style to an entire paragraph — call
697 * glk_set_style() immediately after printing the newline at the beginning of
698 * the text, and do the same at the end.
701 * For example, %style_Header may well be centered text. If you print
702 * <quote>Welcome to Victim (a short interactive mystery)</quote>, and only the
703 * word <quote>Victim</quote> is in the %style_Header, the center-justification
704 * attribute will be lost. Similarly, a block quote is usually indented on both
705 * sides, but indentation is only meaningful when applied to an entire line or
706 * paragraph, so block quotes should take up an entire paragraph. Contrariwise,
707 * %style_Emphasized need not be used on an entire paragraph. It is often used
708 * for single emphasized words in normal text, so you can expect that it will
709 * appear properly that way; it will be displayed in italics or underlining,
710 * not center-justified or indented.
714 * Yes, this is all a matter of mutual agreement between game authors and game
715 * players. It's not fixed by this specification. That's natural language for
721 * SECTION:glk-stylehints
722 * @short_description: Setting style hints
723 * @include: libchimara/glk.h
725 * There are no guarantees of how styles will look, but you can make
728 * Initially, no hints are set for any window type or style. Note that having no
729 * hint set is not the same as setting a hint with value 0.
731 * These functions do <emphasis>not</emphasis> affect
732 * <emphasis>existing</emphasis> windows. They affect the windows which you
733 * create subsequently. If you want to set hints for all your game windows, call
734 * glk_stylehint_set() before you start creating windows. If you want different
735 * hints for different windows, change the hints before creating each window.
738 * This policy makes life easier for the interpreter. It knows everything about
739 * a particular window's appearance when the window is created, and it doesn't
740 * have to change it while the window exists.
743 * Hints are hints. The interpreter may ignore them, or give the player a choice
744 * about whether to accept them. Also, it is never necessary to set hints. You
745 * don't have to suggest that %style_Preformatted be fixed-width, or
746 * %style_Emphasized be boldface or italic; they will have appropriate defaults.
747 * Hints are for situations when you want to <emphasis>change</emphasis> the
748 * appearance of a style from what it would ordinarily be. The most common case
749 * when this is appropriate is for the styles %style_User1 and %style_User2.
751 * There are currently ten style hints defined. More may be defined in the
754 * Again, when passing a style hint to a Glk function, any value is actually
755 * legal. If the interpreter does not recognize the stylehint value, it will
758 * This policy allows for the future definition of style hints without breaking
764 * SECTION:glk-stream-types
765 * @short_description: Window, memory, and file streams
766 * @include: libchimara/glk.h
768 * <refsect2 id="chimara-Window-Streams"><title>Window Streams</title>
770 * Every window has an output stream associated with it. This is created
771 * automatically, with %filemode_Write, when you open the window. You get it
772 * with glk_window_get_stream().
774 * A window stream cannot be closed with glk_stream_close(). It is closed
775 * automatically when you close its window with glk_window_close().
777 * Only printable characters (including newline) may be printed to a window
778 * stream. See <link linkend="chimara-Character-Encoding">Character
782 * <refsect2 id="chimara-Memory-Streams"><title>Memory Streams</title>
784 * You can open a stream which reads from or writes to a space in memory. See
785 * glk_stream_open_memory() and glk_stream_open_memory_uni(). When opening a
786 * memory stream, you specify a buffer to which the stream's output will be
787 * written, and its length @buflen.
789 * When outputting, if more than @buflen characters are written to the stream,
790 * all of them beyond the buffer length will be thrown away, so as not to
791 * overwrite the buffer. (The character count of the stream will still be
792 * maintained correctly. That is, it will count the number of characters written
793 * into the stream, not the number that fit into the buffer.)
795 * If the buffer is %NULL, or for that matter if @buflen is zero, then
796 * <emphasis>everything</emphasis> written to the stream is thrown away. This
797 * may be useful if you are interested in the character count.
799 * When inputting, if more than @buflen characters are read from the stream, the
800 * stream will start returning -1 (signalling end-of-file.) If the buffer is
801 * %NULL, the stream will always return end-of-file.
803 * The data is written to the buffer exactly as it was passed to the printing
804 * functions (glk_put_char(), etc.); input functions will read the data exactly
805 * as it exists in memory. No platform-dependent cookery will be done on it.
808 * You can write a disk file in text mode, but a memory stream is effectively
809 * always in binary mode.
812 * Whether reading or writing, the contents of the buffer are undefined until
813 * the stream is closed. The library may store the data there as it is written,
814 * or deposit it all in a lump when the stream is closed. It is illegal to
815 * change the contents of the buffer while the stream is open.
818 * <refsect2 id="chimara-File-Streams"><title>File Streams</title>
820 * You can open a stream which reads from or writes to a disk file. See
821 * glk_stream_open_file() and glk_stream_open_file_uni().
823 * The file may be written in text or binary mode; this is determined by the
824 * file reference you open the stream with. Similarly, platform-dependent
825 * attributes such as file type are determined by the file reference. See <link
826 * linkend="chimara-File-References">File References</link>.
832 * SECTION:glk-stream-other
833 * @short_description: Miscellaneous functions for streams
834 * @include: libchimara/glk.h
836 * This section includes functions for streams that don't fit anywhere else.
840 * SECTION:glk-fileref
841 * @short_description: A platform-independent way to refer to disk files
842 * @include: libchimara/glk.h
844 * You deal with disk files using file references. Each fileref is an opaque C
845 * structure pointer; see <link linkend="chimara-Opaque-Objects">Opaque
848 * A file reference contains platform-specific information about the name and
849 * location of the file, and possibly its type, if the platform has a notion of
850 * file type. It also includes a flag indication whether the file is a text file
854 * Note that this is different from the standard C I/O library, in which you
855 * specify text or binary mode when the file is opened.
858 * A fileref does not have to refer to a file which actually exists. You can
859 * create a fileref for a nonexistent file, and then open it in write mode to
862 * You always provide a usage argument when you create a fileref. The usage is a
863 * mask of constants (see below) to indicate the file type and the mode (text or
864 * binary.) These values are used when you create a new file, and also to filter
865 * file lists when the player is selecting a file to load.
867 * In general, you should use text mode if the player expects to read the file
868 * with a platform-native text editor; you should use binary mode if the file is
869 * to be read back by your program, or if the data must be stored exactly. Text
870 * mode is appropriate for %fileusage_Transcript; binary mode is appropriate for
871 * %fileusage_SavedGame and probably for %fileusage_InputRecord. %fileusage_Data
872 * files may be text or binary, depending on what you use them for.
876 * SECTION:glk-fileref-types
877 * @short_description: Four different ways to create a file reference
878 * @include: libchimara/glk.h
880 * There are four different functions for creating a fileref, depending on how
881 * you wish to specify it. Remember that it is always possible that a fileref
882 * creation will fail and return %NULL.
886 * SECTION:glk-fileref-other
887 * @short_description: Miscellaneous functions for file references
888 * @include: libchimara/glk.h
890 * This section includes functions for file references that don't fit anywhere
895 * SECTION:glk-image-resources
896 * @short_description: Graphics in Glk
897 * @include: libchimara/glk.h
899 * In accordance with this modern age, Glk provides for a modicum of graphical
900 * flair. It does not attempt to be a complete graphical toolkit. Those already
901 * exist. Glk strikes the usual uncomfortable balance between power,
902 * portability, and ease of implementation: commands for arranging pre-supplied
903 * images on the screen and intermixed with text.
905 * Graphics is an optional capability in Glk; not all libraries support
906 * graphics. This should not be a surprise.
908 * Most of the graphics commands in Glk deal with image resources. Your program
909 * does not have to worry about how images are stored. Everything is a resource,
910 * and a resource is referred to by an integer identifier. You may, for example,
911 * call a function to display image number 17. The format, loading, and
912 * displaying of that image is entirely up to the Glk library for the platform
915 * Of course, it is also desirable to have a platform-independent way to store
916 * sounds and images. Blorb is the official resource-storage format of Glk. A
917 * Glk library does not have to understand Blorb, but it is more likely to
918 * understand Blorb than any other format.
921 * Glk does not specify the exact format of images, but Blorb does. Images in
922 * a Blorb archive must be PNG or JPEG files. More formats may be added if
923 * real-world experience shows it to be desirable. However, that is in the
924 * domain of the Blorb specification. The Glk spec, and Glk programming, will
928 * At present, images can only be drawn in graphics windows and text buffer
929 * windows. In fact, a library may not implement both of these possibilities.
930 * You should test each with the %gestalt_DrawImage selector if you plan to use
931 * it. See <link linkend="chimara-Testing-for-Graphics-Capabilities">Testing for
932 * Graphics Capabilities</link>.
936 * SECTION:glk-graphics-windows
937 * @short_description: Drawing graphics in graphics windows
938 * @include: libchimara/glk.h
940 * A graphics window is a rectangular canvas of pixels, upon which you can draw
941 * images. The contents are entirely under your control. You can draw as many
942 * images as you like, at any positions — overlapping if you like. If the
943 * window is resized, you are responsible for redrawing everything. See <link
944 * linkend="wintype-Graphics">Graphics Windows</link>.
947 * Note that graphics windows do not support a full set of object-drawing
948 * commands, nor can you draw text in them. That may be available in a future
949 * Glk extension. For now, it seems reasonable to limit the task to a single
950 * primitive, the drawing of a raster image. And then there's the ability to
951 * fill a rectangle with a solid color — a small extension, and
952 * hopefully no additional work for the library, since it can already clear
953 * with arbitrary background colors. In fact, if glk_window_fill_rect() did
954 * not exist, an author could invent it — by briefly setting the
955 * background color, erasing a rectangle, and restoring.
958 * If you call glk_image_draw() or glk_image_draw_scaled() in a graphics window,
959 * @val1 and @val2 are interpreted as X and Y coordinates. The image will be
960 * drawn with its upper left corner at this position.
962 * It is legitimate for part of the image to fall outside the window; the excess
963 * is not drawn. Note that these are signed arguments, so you can draw an image
964 * which falls outside the left or top edge of the window, as well as the right
967 * There are a few other commands which apply to graphics windows.
971 * SECTION:glk-graphics-testing
972 * @short_description: Checking whether the library supports graphics
973 * @include: libchimara/glk.h
975 * Before calling Glk graphics functions, you should use the gestalt selector
976 * %gestalt_Graphics. To test for additional capabilities, you can also use the
977 * %gestalt_DrawImage and %gestalt_GraphicsTransparency selectors.
981 * SECTION:glk-creating-hyperlinks
982 * @short_description: Printing text as a hyperlink
983 * @include: libchimara/glk.h
985 * Some games may wish to mark up text in their windows with hyperlinks, which
986 * can be selected by the player — most likely by mouse click. Glk allows
987 * this in a manner similar to the way text styles are set.
989 * Hyperlinks are an optional capability in Glk.
993 * SECTION:glk-accepting-hyperlinks
994 * @short_description: Generating and catching hyperlink navigation events
995 * @include: libchimara/glk.h
999 * SECTION:glk-hyperlinks-testing
1000 * @short_description: Checking whether the library supports hyperlinks
1001 * @include: libchimara/glk.h
1003 * Before calling Glk hyperlink functions, you should use the gestalt selectors
1004 * %gestalt_Hyperlinks and %gestalt_HyperlinkInput.
1008 * SECTION:dispatch-interrogating
1009 * @short_description: Finding out what functions the Glk library exports
1010 * @include: libchimara/glk.h, libchimara/gi_dispa.h
1012 * These are the ancilliary functions that let you enumerate.
1016 * SECTION:dispatch-dispatching
1017 * @short_description: Dispatching the call to the Glk library
1018 * @include: libchimara/glk.h, libchimara/gi_dispa.h
1022 * SECTION:dispatch-prototypes
1023 * @short_description: Querying Glk function prototypes
1024 * @include: libchimara/glk.h, libchimara/gi_dispa.h
1026 * There are many possible ways to set up a #gluniversal_t array, and it's
1027 * illegal to call gidispatch_call() with an array which doesn't match the
1028 * function. Furthermore, some references are passed in, some passed out, and
1029 * some both. How do you know how to handle the argument list?
1031 * One possibility is to recognize each function selector, and set up the
1032 * arguments appropriately. However, this entails writing special code for each
1033 * Glk function; which is exactly what we don't want to do.
1035 * Instead, you can call gidispatch_prototype().
1039 * SECTION:dispatch-library-functions
1040 * @short_description: Platform-dependent dispatch layer functions
1041 * @include: libchimara/glk.h, libchimara/gi_dispa.h
1043 * Ideally, the three layers — program, dispatch layer, Glk library
1044 * — would be completely modular; each would refer only to the layers
1045 * beneath it. Sadly, there are a few places where the library must notify the
1046 * program that something has happened. Worse, these situations are only
1047 * relevant to programs which use the dispatch layer, and then only some of
1050 * Since C is uncomfortable with the concept of calling functions which may not
1051 * exist, Glk handles this with call-back function pointers. The program can
1052 * pass callbacks in to the library; if it does, the library will call them, and
1053 * if not, the library doesn't try.
1055 * These callbacks are optional, in the sense that the program may or may not
1056 * set them. However, any library which wants to interoperate with the dispatch
1057 * layer must <emphasis>allow</emphasis> the program to set them; it is the
1058 * program's choice. The library does this by implementing
1059 * <code>set_registry functions</code> — the functions to which the
1060 * program passes its callbacks.
1063 * Even though these callbacks and the functions to set them are declared in
1064 * <filename class="headerfile">gi_dispa.h</filename>, they are not defined in
1065 * <filename>gi_dispa.c</filename>. The dispatch layer merely coordinates
1066 * them. The program defines the callback functions; the library calls them.
1071 * SECTION:blorb-program
1072 * @short_description: How to use the Blorb layer in your program
1073 * @include: libchimara/glk.h, libchimara/gi_blorb.h
1075 * If you wish your program to load its resources from a Blorb file, you need to
1076 * find and open that file in your startup code. (See <link
1077 * linkend="chimara-Startup-Options">Startup Options</link>.) Each platform will
1078 * have appropriate functions available for finding startup data. Be sure to
1079 * open the file in binary mode, not text mode. Once you have opened the file as
1080 * a Glk stream, pass it to giblorb_set_resource_map().
1082 * If you do not call giblorb_set_resource_map() in your startup code, or if it
1083 * fails, the library is left to its own devices for finding resources. Some
1084 * libraries may try to load resources from individual files —
1085 * <filename>PIC1</filename>, <filename>PIC2</filename>,
1086 * <filename>PIC3</filename>, and so on. (See the Blorb specification for more
1087 * on this approach.) Other libraries will not have any other loading mechanism
1088 * at all; no resources will be available.
1092 * SECTION:blorb-layer
1093 * @short_description: The platform-independent functions in the Blorb layer
1094 * @include: libchimara/glk.h, libchimara/gi_blorb.h
1096 * These are the functions which are implemented in
1097 * <filename>gi_blorb.c</filename>. They will be compiled into the library, but
1098 * they are the same on every platform. In general, only the library needs to
1099 * call these functions. The Glk program should allow the library to do all the
1100 * resource handling.
1104 * SECTION:blorb-errors
1105 * @short_description: Error codes returned by the Blorb layer functions
1106 * @include: libchimara/glk.h, libchimara/gi_blorb.h
1108 * All Blorb layer functions, including giblorb_set_resource_map(), return the
1109 * following error codes.
1113 * SECTION:glkext-startup
1114 * @short_description: Parsing startup options
1115 * @include: libchimara/glk.h, libchimara/glkstart.h
1117 * This section describes an extension to Glk for parsing command-line startup
1118 * options. It was written by Andrew Plotkin for the Glk libraries CheapGlk and
1121 * When you compile a Glk program, you may define a function called
1122 * glkunix_startup_code(), and an array <code>glkunix_arguments[]</code>. These
1123 * set up various Unix-specific options used by the Glk library. There is a
1124 * sample <quote><filename>glkstart.c</filename></quote> file included in this
1125 * package; you should modify it to your needs.
1127 * |[ extern #glkunix_argumentlist_t glkunix_arguments[]; ]|
1129 * The <code>glkunix_arguments[]</code> array is a list of command-line
1130 * arguments that your program can accept. The library will sort these out of
1131 * the command line and pass them on to your code.
1135 * SECTION:glkext-unix
1136 * @short_description: Unix-specific functions
1137 * @include: libchimara/glk.h, libchimara/glkstart.h
1139 * This section describes an extension to Glk for various Unix functions. It was
1140 * written by Andrew Plotkin for the Glk libraries CheapGlk and GlkTerm.
1142 * You can put other startup code in glkunix_startup_code(). This should
1143 * generally be limited to finding and opening data files. There are a few Unix
1144 * Glk library functions which are convenient for this purpose.
1147 /*---------------- TYPES AND CONSTANTS FROM GLK.H ----------------------------*/
1152 * A 32-bit unsigned integer type, used wherever possible in Glk.
1158 * A 32-bit signed integer type, rarely used.
1162 * GLK_MODULE_UNICODE:
1164 * If this preprocessor symbol is defined, so are all the Unicode functions and
1165 * constants (see %gestalt_Unicode). If not, not.
1171 * If you are writing a C program, there is an additional complication. A
1172 * library which does not support graphics may not implement the graphics
1173 * functions at all. Even if you put gestalt tests around your graphics calls,
1174 * you may get link-time errors. If the <filename
1175 * class="headerfile">glk.h</filename> file is so old that it does not declare
1176 * the graphics functions and constants, you may even get compile-time errors.
1178 * To avoid this, you can perform a preprocessor test for the existence of
1179 * %GLK_MODULE_IMAGE. If this is defined, so are all the functions and constants
1180 * described in this section. If not, not.
1183 * To be extremely specific, there are two ways this can happen. If the
1184 * <filename class="headerfile">glk.h</filename> file that comes with the
1185 * library is too old to have the graphics declarations in it, it will of
1186 * course lack %GLK_MODULE_IMAGE as well. If the <filename
1187 * class="headerfile">glk.h</filename> file is recent, but the library is old,
1188 * the definition of %GLK_MODULE_IMAGE should be removed from <filename
1189 * class="headerfile">glk.h</filename>, to avoid link errors. This is not a
1190 * great solution. A better one is for the library to implement the graphics
1191 * functions as stubs that do nothing (or cause run-time errors). Since no
1192 * program will call the stubs without testing %gestalt_Graphics, this is
1198 * GLK_MODULE_HYPERLINKS:
1200 * If you are writing a C program, you can perform a preprocessor test for the
1201 * existence of %GLK_MODULE_HYPERLINKS. If this is defined, so are all the
1202 * functions and constants described in this section. If not, not.
1208 * Opaque structure representing a Glk window. It has no user-accessible
1215 * Opaque structure representing an input or output stream. It has no
1216 * user-accessible members.
1222 * Opaque structure representing a file reference. It has no user-accessible
1229 * For an example of the gestalt mechanism, consider the selector
1230 * %gestalt_Version. If you do
1233 * res = #glk_gestalt(#gestalt_Version, 0);
1235 * <code>res</code> will be set to a 32-bit number which encodes the version of
1236 * the Glk spec which the library implements. The upper 16 bits stores the major
1237 * version number; the next 8 bits stores the minor version number; the low 8
1238 * bits stores an even more minor version number, if any.
1241 * So the version number 78.2.11 would be encoded as 0x004E020B.
1244 * The current Glk specification version is 0.7.0, so this selector will return
1249 * res = #glk_gestalt_ext(#gestalt_Version, 0, NULL, 0);
1251 * does exactly the same thing. Note that, in either case, the second argument
1252 * is not used; so you should always pass 0 to avoid future surprises.
1256 * gestalt_CharInput:
1258 * If you set <code>ch</code> to a character code, or a special code (from
1259 * 0xFFFFFFFF down), and call
1262 * res = #glk_gestalt(#gestalt_CharInput, ch);
1264 * then <code>res</code> will be %TRUE (1) if that character can be typed by
1265 * the player in character input, and %FALSE (0) if not. See <link
1266 * linkend="chimara-Character-Input">Character Input</link>.
1270 * gestalt_LineInput:
1272 * If you set <code>ch</code> to a character code, and call
1275 * res = #glk_gestalt(#gestalt_LineInput, ch);
1277 * then <code>res</code> will be %TRUE (1) if that character can be typed by the
1278 * player in line input, and %FALSE (0) if not. Note that if <code>ch</code> is
1279 * a nonprintable Latin-1 character (0 to 31, 127 to 159), then this is
1280 * guaranteed to return %FALSE. See <link linkend="chimara-Line-Input">Line
1285 * gestalt_CharOutput:
1287 * If you set <code>ch</code> to a character code (Latin-1 or higher), and call
1290 * res = #glk_gestalt_ext(#gestalt_CharOutput, ch, &len, 1);
1292 * then <code>res</code> will be one of %gestalt_CharOutput_CannotPrint,
1293 * %gestalt_CharOutput_ExactPrint, or %gestalt_CharOutput_ApproxPrint (see
1296 * In all cases, <code>len</code> (the #glui32 value pointed at by the third
1297 * argument) will be the number of actual glyphs which will be used to represent
1298 * the character. In the case of %gestalt_CharOutput_ExactPrint, this will
1299 * always be 1; for %gestalt_CharOutput_CannotPrint, it may be 0 (nothing
1300 * printed) or higher; for %gestalt_CharOutput_ApproxPrint, it may be 1 or
1301 * higher. This information may be useful when printing text in a fixed-width
1305 * As described in <link linkend="chimara-Other-API-Conventions">Other API
1306 * Conventions</link>, you may skip this information by passing %NULL as the
1307 * third argument in glk_gestalt_ext(), or by calling glk_gestalt() instead.
1310 * This selector will always return %gestalt_CharOutput_CannotPrint if
1311 * <code>ch</code> is an unprintable eight-bit character (0 to 9, 11 to 31, 127
1315 * Make sure you do not get confused by signed byte values. If you set a
1316 * <quote><type>char</type></quote> variable <code>ch</code> to 0xFE, the
1317 * small-thorn character (þ), and then call
1318 * |[ res = #glk_gestalt(#gestalt_CharOutput, ch); ]|
1319 * then (by the definition of C/C++) <code>ch</code> will be sign-extended to
1320 * 0xFFFFFFFE, which is not a legitimate character, even in Unicode. You
1322 * |[ res = #glk_gestalt(#gestalt_CharOutput, (unsigned char)ch); ]|
1326 * Unicode includes the concept of non-spacing or combining characters, which
1327 * do not represent glyphs; and double-width characters, whose glyphs take up
1328 * two spaces in a fixed-width font. Future versions of this spec may
1329 * recognize these concepts by returning a <code>len</code> of 0 or 2 when
1330 * %gestalt_CharOutput_ExactPrint is used. For the moment, we are adhering to
1331 * a policy of <quote>simple stuff first</quote>.
1336 * gestalt_CharOutput_CannotPrint:
1338 * When the %gestalt_CharOutput selector returns this for a character, the
1339 * character cannot be meaningfully printed. If you try, the player may see
1340 * nothing, or may see a placeholder.
1344 * gestalt_CharOutput_ApproxPrint:
1346 * When the %gestalt_CharOutput selector returns this for a character, the
1347 * library will print some approximation of the character. It will be more or
1348 * less right, but it may not be precise, and it may not be distinguishable from
1349 * other, similar characters. (Examples:
1350 * <quote><computeroutput>ae</computeroutput></quote> for the one-character
1351 * <quote>æ</quote> ligature,
1352 * <quote><computeroutput>e</computeroutput></quote> for
1353 * <quote>è</quote>, <quote><computeroutput>|</computeroutput></quote>
1354 * for a broken vertical bar (¦).)
1358 * gestalt_CharOutput_ExactPrint:
1360 * When the %gestalt_CharOutput selector returns this for a character, the
1361 * character will be printed exactly as defined.
1365 * gestalt_MouseInput:
1367 * You can test whether mouse input is supported with the %gestalt_MouseInput
1369 * |[ res = glk_gestalt(gestalt_MouseInput, windowtype); ]|
1370 * This will return %TRUE (1) if windows of the given type support mouse input.
1371 * If this returns %FALSE (0), it is still legal to call
1372 * glk_request_mouse_event(), but it will have no effect, and you will never get
1379 * You can test whether the library supports timer events:
1380 * |[ res = #glk_gestalt(#gestalt_Timer, 0); ]|
1381 * This returns 1 if timer events are supported, and 0 if they are not.
1387 * Before calling Glk graphics functions, you should use the following gestalt
1391 * res = glk_gestalt(gestalt_Graphics, 0);
1393 * This returns 1 if the overall suite of graphics functions is available. This
1394 * includes glk_image_draw(), glk_image_draw_scaled(), glk_image_get_info(),
1395 * glk_window_erase_rect(), glk_window_fill_rect(),
1396 * glk_window_set_background_color(), and glk_window_flow_break(). It also
1397 * includes the capability to create graphics windows.
1399 * If this selector returns 0, you should not try to call these functions. They
1400 * may have no effect, or they may cause a run-time error. If you try to create
1401 * a graphics window, you will get %NULL.
1405 * gestalt_DrawImage:
1407 * This selector returns 1 if images can be drawn in windows of the given type.
1408 * If it returns 0, glk_image_draw() will fail and return %FALSE. You should
1409 * test %wintype_Graphics and %wintype_TextBuffer separately, since libraries
1410 * may implement both, neither, or only one.
1414 * gestalt_Hyperlinks:
1416 * You can test whether the library supports hyperlinks:
1419 * res = #glk_gestalt(#gestalt_Hyperlinks, 0);
1421 * This returns 1 if the overall suite of hyperlinks functions is available.
1422 * This includes glk_set_hyperlink(), glk_set_hyperlink_stream(),
1423 * glk_request_hyperlink_event(), glk_cancel_hyperlink_event().
1425 * If this selector returns 0, you should not try to call these functions. They
1426 * may have no effect, or they may cause a run-time error.
1430 * gestalt_HyperlinkInput:
1432 * You can test whether hyperlinks are supported with the
1433 * %gestalt_HyperlinkInput selector:
1434 * |[ res = #glk_gestalt(#gestalt_HyperlinkInput, windowtype); ]|
1435 * This will return %TRUE (1) if windows of the given type support hyperlinks.
1436 * If this returns %FALSE (0), it is still legal to call glk_set_hyperlink() and
1437 * glk_request_hyperlink_event(), but they will have no effect, and you will
1438 * never get hyperlink events.
1442 * gestalt_GraphicsTransparency:
1444 * This returns 1 if images with alpha channels can actually be drawn with the
1445 * appropriate degree of transparency. If it returns 0, the alpha channel is
1446 * ignored; fully transparent areas will be drawn in an implementation-defined
1449 * The JPEG format does not support transparency or alpha channels; the PNG
1457 * The basic text functions will be available in every Glk library. The Unicode
1458 * functions may or may not be available. Before calling them, you should use
1459 * the following gestalt selector:
1462 * res = #glk_gestalt(#gestalt_Unicode, 0);
1465 * This returns 1 if the Unicode functions are available. If it returns 0, you
1466 * should not try to call them. They may print nothing, print gibberish, or
1467 * cause a run-time error. The Unicode functions include
1468 * glk_buffer_to_lower_case_uni(), glk_buffer_to_upper_case_uni(),
1469 * glk_buffer_to_title_case_uni(), glk_put_char_uni(), glk_put_string_uni(),
1470 * glk_put_buffer_uni(), glk_put_char_stream_uni(), glk_put_string_stream_uni(),
1471 * glk_put_buffer_stream_uni(), glk_get_char_stream_uni(),
1472 * glk_get_buffer_stream_uni(), glk_get_line_stream_uni(),
1473 * glk_request_char_event_uni(), glk_request_line_event_uni(),
1474 * glk_stream_open_file_uni(), glk_stream_open_memory_uni().
1476 * If you are writing a C program, there is an additional complication. A
1477 * library which does not support Unicode may not implement the Unicode
1478 * functions at all. Even if you put gestalt tests around your Unicode calls,
1479 * you may get link-time errors. If the
1480 * <filename class="headerfile">glk.h</filename> file is so old that it does not
1481 * declare the Unicode functions and constants, you may even get compile-time
1484 * To avoid this, you can perform a preprocessor test for the existence of
1485 * #GLK_MODULE_UNICODE.
1491 * No event. This is a placeholder, and glk_select() never returns it.
1497 * An event that repeats at fixed intervals. See <link
1498 * linkend="chimara-Timer-Events">Timer Events</link>.
1504 * A keystroke event in a window. See <link
1505 * linkend="chimara-Character-Input-Events">Character Input Events</link>.
1507 * If a window has a pending request for character input, and the player hits a
1508 * key in that window, glk_select() will return an event whose type is
1509 * %evtype_CharInput. Once this happens, the request is complete; it is no
1510 * longer pending. You must call glk_request_char_event() or
1511 * glk_request_char_event_uni() if you want another character from that window.
1513 * In the event structure, @win tells what window the event came from. @val1
1514 * tells what character was entered; this will be a character code, or a special
1515 * keycode. (See <link linkend="chimara-Character-Input">Character
1516 * Input</link>.) If you called glk_request_char_event(), @val1 will be in
1517 * 0..255, or else a special keycode. In any case, @val2 will be 0.
1523 * A full line of input completed in a window. See <link
1524 * linkend="chimara-Line-Input-Events">Line Input Events</link>.
1526 * If a window has a pending request for line input, and the player hits
1527 * <keycap>enter</keycap> in that window (or whatever action is appropriate to
1528 * enter his input), glk_select() will return an event whose type is
1529 * %evtype_LineInput. Once this happens, the request is complete; it is no
1530 * longer pending. You must call glk_request_line_event() if you want another
1531 * line of text from that window.
1533 * In the event structure, @win tells what window the event came from. @val1
1534 * tells how many characters were entered. @val2 will be 0. The characters
1535 * themselves are stored in the buffer specified in the original
1536 * glk_request_line_event() or glk_request_line_event_uni() call.
1538 * <note><para>There is no null terminator stored in the buffer.</para></note>
1540 * It is illegal to print anything to a window which has line input pending.
1543 * This is because the window may be displaying and editing the player's
1544 * input, and printing anything would make life unnecessarily complicated for
1550 * evtype_MouseInput:
1552 * A mouse click in a window. See <link
1553 * linkend="chimara-Mouse-Input-Events">Mouse Input Events</link>.
1559 * An event signalling that the sizes of some windows have changed.
1561 * Some platforms allow the player to resize the Glk window during play. This
1562 * will naturally change the sizes of your windows. If this occurs, then
1563 * immediately after all the rearrangement, glk_select() will return an event
1564 * whose type is %evtype_Arrange. You can use this notification to redisplay the
1565 * contents of a graphics or text grid window whose size has changed.
1568 * The display of a text buffer window is entirely up to the library, so you
1569 * don't need to worry about those.
1572 * In the event structure, @win will be %NULL if all windows are affected. If
1573 * only some windows are affected, @win will refer to a window which contains
1574 * all the affected windows. @val1 and @val2 will be 0.
1577 * You can always play it safe, ignore @win, and redraw every graphics and
1581 * An arrangement event is guaranteed to occur whenever the player causes any
1582 * window to change size, as measured by its own metric.
1585 * Size changes caused by you — for example, if you open, close, or
1586 * resize a window — do not trigger arrangement events. You must be
1587 * aware of the effects of your window management, and redraw the windows that
1592 * It is possible that several different player actions can cause windows to
1593 * change size. For example, if the player changes the screen resolution, an
1594 * arrangement event might be triggered. This might also happen if the player
1595 * changes his display font to a different size; the windows would then be
1596 * different <quote>sizes</quote> in the metric of rows and columns, which is
1597 * the important metric and the only one you have access to.
1600 * Arrangement events, like timer events, can be returned by glk_select_poll().
1601 * But this will not occur on all platforms. You must be ready to receive an
1602 * arrangement event when you call glk_select_poll(), but it is possible that it
1603 * will not arrive until the next time you call glk_select().
1606 * This is because on some platforms, window resizing is handled as part of
1607 * player input; on others, it can be triggered by an external process such as
1615 * An event signalling that graphics windows must be redrawn.
1617 * On platforms that support graphics, it is possible that the contents of a
1618 * graphics window will be lost, and have to be redrawn from scratch. If this
1619 * occurs, then glk_select() will return an event whose type is %evtype_Redraw.
1621 * In the event structure, @win will be %NULL if all windows are affected. If
1622 * only some windows are affected, @win will refer to a window which contains
1623 * all the affected windows. @val1 and @val2 will be 0.
1626 * You can always play it safe, ignore @win, and redraw every graphics window.
1629 * Affected windows are already cleared to their background color when you
1630 * receive the redraw event.
1632 * Redraw events can be returned by glk_select_poll(). But, like arrangement
1633 * events, this is platform-dependent. See %evtype_Arrange.
1635 * For more about redraw events and how they affect graphics windows, see <link
1636 * linkend="chimara-Graphics-Windows">Graphics Windows</link>.
1640 * evtype_SoundNotify:
1642 * On platforms that support sound, you can request to receive an
1643 * %evtype_SoundNotify event when a sound finishes playing. See <link
1644 * linkend="chimara-Playing-Sounds">Playing Sounds</link>.
1650 * On platforms that support hyperlinks, you can request to receive an
1651 * %evtype_Hyperlink event when the player selects a link. See <link
1652 * linkend="chimara-Accepting-Hyperlink-Events">Accepting Hyperlink
1658 * @type: the event type
1659 * @win: the window that spawned the event, or %NULL
1660 * @val1: information, the meaning of which depends on the type of event
1661 * @val2: more information, the meaning of which depends on the type of event
1663 * The event structure is self-explanatory. @type is the event type. The window
1664 * that spawned the event, if relevant, is in @win. The remaining fields contain
1665 * more information specific to the event.
1667 * The event types are described below. Note that %evtype_None is zero, and the
1668 * other values are positive. Negative event types (0x80000000 to 0xFFFFFFFF)
1669 * are reserved for implementation-defined events.
1675 * Represents any key that has no Latin-1 or special code.
1681 * Represents the <keycap function="left">left arrow</keycap> key.
1687 * Represents the <keycap function="right">right arrow</keycap> key.
1693 * Represents the <keycap function="up">up arrow</keycap> key.
1699 * Represents the <keycap function="down">down arrow</keycap> key.
1705 * Represents the <keycap function="enter">return</keycap> or <keycap
1706 * function="enter">enter</keycap> keys.
1712 * Represents the <keycap function="delete">delete</keycap> or <keycap
1713 * function="backspace">backspace</keycap> keys.
1719 * Represents the <keycap function="escape">escape</keycap> key.
1725 * Represents the <keycap function="tab">tab</keycap> key.
1731 * Represents the <keycap function="pageup">page up</keycap> key.
1737 * Represents the <keycap function="pagedown">page down</keycap> key.
1743 * Represents the <keycap function="home">home</keycap> key.
1749 * Represents the <keycap function="end">end</keycap> key.
1755 * Represents the <keycap>F1</keycap> key.
1761 * Represents the <keycap>F2</keycap> key.
1767 * Represents the <keycap>F3</keycap> key.
1773 * Represents the <keycap>F4</keycap> key.
1779 * Represents the <keycap>F5</keycap> key.
1785 * Represents the <keycap>F6</keycap> key.
1791 * Represents the <keycap>F7</keycap> key.
1797 * Represents the <keycap>F8</keycap> key.
1803 * Represents the <keycap>F9</keycap> key.
1809 * Represents the <keycap>F10</keycap> key.
1815 * Represents the <keycap>F11</keycap> key.
1821 * Represents the <keycap>F12</keycap> key.
1827 * This value is equal to the number of special keycodes. The last keycode is
1830 * <alt>(0x100000000 - <keysym>keycode_MAXVAL</keysym>)</alt>
1831 * <mathphrase>(0x100000000 - <keysym>keycode_MAXVAL</keysym>)</mathphrase>
1839 * The style of normal or body text. A new window or stream always starts with
1840 * %style_Normal as the current style.
1846 * Text which is emphasized.
1850 * style_Preformatted:
1852 * Text which has a particular arrangement of characters.
1854 * This style, unlike the others, does have a standard appearance; it will
1855 * always be a fixed-width font. This is a concession to practicality. Games
1856 * often want to display maps or diagrams using character graphics, and this is
1857 * the style for that.
1864 * Text which introduces a large section. This is suitable for the title of an
1865 * entire game, or a major division such as a chapter.
1871 * Text which introduces a smaller section within a large section.
1873 * In a Colossal-Cave-style game, this is suitable for the name of a room (when
1874 * the player looks around.)
1881 * Text which warns of a dangerous condition, or one which the player should pay
1888 * Text which notifies of an interesting condition.
1890 * This is suitable for noting that the player's score has changed.
1897 * Text which forms a quotation or otherwise abstracted text.
1903 * Text which the player has entered. You should generally not use this style at
1904 * all; the library uses it for text which is typed during a line-input request.
1905 * One case when it is appropriate for you to use %style_Input is when you are
1906 * simulating player input by reading commands from a text file.
1912 * This style has no particular semantic meaning. You may define a meaning
1913 * relevant to your own work, and use it as you see fit.
1919 * Another style available for your use.
1925 * The number of styles defined in this library.
1930 * @readcount: Number of characters read from the stream.
1931 * @writecount: Number of characters printed to the stream, including ones that
1934 * If you are interested in the character counts of a stream (see <link
1935 * linkend="chimara-Streams">Streams</link>), then you can pass a pointer to
1936 * #stream_result_t as an argument of glk_stream_close() or glk_window_close().
1937 * The structure will be filled with the stream's final character counts.
1943 * A constant representing all window types, which may be used as the @wintype
1944 * argument in glk_stylehint_set().
1950 * A pair window is completely filled by the two windows it contains. It
1951 * supports no input and no output, and it has no size.
1953 * You cannot directly create a pair window; one is automatically created
1954 * every time you split a window with glk_window_open(). Pair windows are
1955 * always created with a rock value of 0.
1957 * You can close a pair window with glk_window_close(); this also closes every
1958 * window contained within the pair window.
1960 * It is legal to split a pair window when you call glk_window_open().
1966 * A blank window is always blank. It supports no input and no output. (You
1967 * can call glk_window_get_stream() on it, as you can with any window, but
1968 * printing to the resulting stream has no effect.) A blank window has no
1969 * size; glk_window_get_size() will return (0,0), and it is illegal to set a
1970 * window split with a fixed size in the measurement system of a blank window.
1973 * A blank window is not the same as there being no windows. When Glk starts
1974 * up, there are no windows at all, not even a window of the blank type.
1979 * wintype_TextBuffer:
1981 * A text buffer window contains a linear stream of text. It supports output;
1982 * when you print to it, the new text is added to the end. There is no way for
1983 * you to affect text which has already been printed. There are no guarantees
1984 * about how much text the window keeps; old text may be stored forever, so
1985 * that the user can scroll back to it, or it may be thrown away as soon as it
1986 * scrolls out of the window.
1989 * Therefore, there may or may not be a player-controllable scroll bar or
1990 * other scrolling widget.
1993 * The display of the text in a text buffer is up to the library. Lines will
1994 * probably not be broken in the middles of words — but if they are, the
1995 * library is not doing anything illegal, only ugly. Text selection and copying
1996 * to a clipboard, if available, are handled however is best on the player's
1997 * machine. Paragraphs (as defined by newline characters in the output) may be
2001 * You should not, in general, fake this by printing spaces before each
2002 * paragraph of prose text. Let the library and player preferences handle
2003 * that. Special cases (like indented lists) are of course up to you.
2006 * When a text buffer is cleared (with glk_window_clear()), the library will do
2007 * something appropriate; the details may vary. It may clear the window, with
2008 * later text appearing at the top — or the bottom. It may simply print
2009 * enough blank lines to scroll the current text out of the window. It may
2010 * display a distinctive page-break symbol or divider.
2012 * The size of a text buffer window is necessarily imprecise. Calling
2013 * glk_window_get_size() will return the number of rows and columns that would
2014 * be available <emphasis>if</emphasis> the window was filled with
2015 * <quote>0</quote> (zero) characters in the <quote>normal</quote> font.
2016 * However, the window may use a non-fixed-width font, so that number of
2017 * characters in a line could vary. The window might even support
2018 * variable-height text (say, if the player is using large text for emphasis);
2019 * that would make the number of lines in the window vary as well.
2021 * Similarly, when you set a fixed-size split in the measurement system of a
2022 * text buffer, you are setting a window which can handle a fixed number of rows
2023 * (or columns) of <quote>0</quote> characters. The number of rows (or
2024 * characters) that will actually be displayed depends on font variances.
2026 * A text buffer window supports both character and line input, but not mouse
2029 * In character input, there will be some visible signal that the window is
2030 * waiting for a keystroke. (Typically, a cursor at the end of the text.) When
2031 * the player hits a key in that window, an event is generated, but the key is
2032 * <emphasis>not</emphasis> printed in the window.
2034 * In line input, again, there will be some visible signal. It is most common
2035 * for the player to compose input in the window itself, at the end of the text.
2036 * (This is how IF story input usually looks.) But it's not strictly required.
2037 * An alternative approach is the way MUD clients usually work: there is a
2038 * dedicated one-line input window, outside of Glk's window space, and the user
2039 * composes input there.
2042 * If this approach is used, there will still be some way to handle input from
2043 * two windows at once. It is the library's responsibility to make this
2044 * available to the player. You only need request line input and wait for the
2048 * When the player finishes his line of input, the library will display the
2049 * input text at the end of the buffer text (if it wasn't there already.) It
2050 * will be followed by a newline, so that the next text you print will start a
2051 * new line (paragraph) after the input.
2053 * If you call glk_cancel_line_event(), the same thing happens; whatever text
2054 * the user was composing is visible at the end of the buffer text, followed by
2061 * A text grid contains a rectangular array of characters, in a fixed-width
2062 * font. Its size is the number of columns and rows of the array.
2064 * A text grid window supports output. It maintains knowledge of an output
2065 * cursor position. When the window is opened, it is filled with blanks (space
2066 * characters), and the output cursor starts in the top left corner —
2067 * character (0,0). If the window is cleared with glk_window_clear(), the window
2068 * is filled with blanks again, and the cursor returns to the top left corner.
2070 * When you print, the characters of the output are laid into the array in
2071 * order, left to right and top to bottom. When the cursor reaches the end of a
2072 * line, it goes to the beginning of the next line. The library makes no attempt
2073 * to wrap lines at word breaks.
2076 * Note that printing fancy characters may cause the cursor to advance more
2077 * than one position per character. (For example, the <quote>æ</quote>
2078 * ligature may print as two characters.) See <link
2079 * linkend="chimara-Output">Output</link>, for how to test this situation.
2082 * You can set the cursor position with glk_window_move_cursor().
2084 * When a text grid window is resized smaller, the bottom or right area is
2085 * thrown away, but the remaining area stays unchanged. When it is resized
2086 * larger, the new bottom or right area is filled with blanks.
2089 * You may wish to watch for %evtype_Arrange events, and clear-and-redraw your
2090 * text grid windows when you see them change size.
2093 * Text grid window support character and line input, as well as mouse input (if
2094 * a mouse is available.)
2096 * Mouse input returns the position of the character that was touched, from
2099 * <alt>(width-1,height-1)</alt>
2100 * <mathphrase>(width - 1, height - 1)</mathphrase>
2104 * Character input is as described in the previous section.
2106 * Line input is slightly different; it is guaranteed to take place in the
2107 * window, at the output cursor position. The player can compose input only to
2108 * the right edge of the window; therefore, the maximum input length is
2110 * <alt>(windowwidth - 1 - cursorposition)</alt>
2111 * <mathphrase>(windowwidth - 1 - cursorposition)</mathphrase>
2113 * . If the maxlen argument of glk_request_line_event() is smaller than this,
2114 * the library will not allow the input cursor to go more than maxlen characters
2115 * past its start point.
2118 * This allows you to enter text in a fixed-width field, without the player
2119 * being able to overwrite other parts of the window.
2122 * When the player finishes his line of input, it will remain visible in the
2123 * window, and the output cursor will be positioned at the beginning of the
2124 * <emphasis>next</emphasis> row. Again, if you glk_cancel_line_event(), the
2125 * same thing happens.
2131 * A graphics window contains a rectangular array of pixels. Its size is the
2132 * number of columns and rows of the array.
2134 * Each graphics window has a background color, which is initially white. You
2135 * can change this; see <link
2136 * linkend="chimara-Graphics-in-Graphics-Windows">Graphics in Graphics
2139 * When a text grid window is resized smaller, the bottom or right area is
2140 * thrown away, but the remaining area stays unchanged. When it is resized
2141 * larger, the new bottom or right area is filled with the background color.
2144 * You may wish to watch for %evtype_Arrange events, and clear-and-redraw your
2145 * graphics windows when you see them change size.
2148 * In some libraries, you can receive a graphics-redraw event (%evtype_Redraw)
2149 * at any time. This signifies that the window in question has been cleared to
2150 * its background color, and must be redrawn. If you create any graphics
2151 * windows, you <emphasis>must</emphasis> handle these events.
2154 * Redraw events can be triggered when a Glk window is uncovered or made
2155 * visible by the platform's window manager. On the other hand, some Glk
2156 * libraries handle these problem automatically — for example, with a
2157 * backing store — and do not send you redraw events. On the third hand,
2158 * the backing store may be discarded if memory is low, or for other reasons
2159 * — perhaps the screen's color depth has changed. So redraw events are
2160 * always a possibility, even in clever libraries. This is why you must be
2161 * prepared to handle them.
2163 * However, you will not receive a redraw event when you create a graphics
2164 * window. It is assumed that you will do the initial drawing of your own
2165 * accord. You also do not get redraw events when a graphics window is
2166 * enlarged. If you ordered the enlargement, you already know about it; if the
2167 * player is responsible, you receive a window-arrangement event, which covers
2171 * For a description of the drawing functions that apply to graphics windows,
2172 * see <link linkend="chimara-Graphics-in-Graphics-Windows">Graphics in Graphics
2175 * Graphics windows support no text input or output.
2177 * Not all libraries support graphics windows. You can test whether Glk graphics
2178 * are available using the gestalt system. In a C program, you can also test
2179 * whether the graphics functions are defined at compile-time. See <link
2180 * linkend="chimara-Testing-for-Graphics-Capabilities">Testing for Graphics
2181 * Capabilities</link>.
2184 * As with all windows, you should also test for %NULL when you create a
2192 * When calling glk_window_open() with this @method, the new window will be
2193 * to the left of the old one which was split.
2199 * When calling glk_window_open() with this @method, the new window will be
2200 * to the right of the old one which was split.
2206 * When calling glk_window_open() with this @method, the new window will be
2207 * above the old one which was split.
2213 * When calling glk_window_open() with this @method, the new window will be
2214 * below the old one which was split.
2218 * winmethod_DirMask:
2220 * Bitwise AND this value with a window splitting method argument to find
2221 * whether the split is %winmethod_Left, %winmethod_Right, %winmethod_Above, or
2228 * When calling glk_window_open() with this @method, the new window will be
2229 * a fixed size. (See glk_window_open()).
2233 * winmethod_Proportional:
2235 * When calling glk_window_open() with this @method, the new window will be
2236 * a given proportion of the old window's size. (See glk_window_open()).
2240 * winmethod_DivisionMask:
2242 * Bitwise AND this value with a window splitting method argument to find
2243 * whether the new window has %winmethod_Fixed or %winmethod_Proportional.
2249 * Any other kind of file (preferences, statistics, arbitrary data.)
2253 * fileusage_SavedGame:
2255 * A file which stores game state.
2259 * fileusage_Transcript:
2261 * A file which contains a stream of text from the game (often an echo stream
2266 * fileusage_InputRecord:
2268 * A file which records player input.
2272 * fileusage_TextMode:
2274 * The file contents will be transformed to a platform-native text file as they
2275 * are written out. Newlines may be converted to linefeeds or
2276 * linefeed-plus-carriage-return combinations; Latin-1 characters may be
2277 * converted to native character codes. When reading a file in text mode, native
2278 * line breaks will be converted back to newline (0x0A) characters, and native
2279 * character codes may be converted to Latin-1.
2282 * Line breaks will always be converted; other conversions are more
2283 * questionable. If you write out a file in text mode, and then read it back
2284 * in text mode, high-bit characters (128 to 255) may be transformed or lost.
2286 * <note><title>Chimara</title>
2288 * Text mode files in Chimara are in UTF-8, which is GTK+'s native file
2294 * fileusage_BinaryMode:
2296 * The file contents will be stored exactly as they are written, and read back
2297 * in the same way. The resulting file may not be viewable on platform-native
2298 * text file viewers.
2302 * fileusage_TypeMask:
2304 * Bitwise AND this value with a file usage argument to find whether the file
2305 * type is %fileusage_SavedGame, %fileusage_Transcript, %fileusage_InputRecord,
2306 * or %fileusage_Data.
2315 * Corresponds to mode <code>"w"</code> in the stdio library, using fopen().
2325 * Corresponds to mode <code>"r"</code> in the stdio library, using fopen().
2330 * filemode_ReadWrite:
2332 * Both an input and an output stream.
2335 * Corresponds to mode <code>"r+"</code> in the stdio library, using fopen().
2340 * filemode_WriteAppend:
2342 * An output stream, but the data will added to the end of whatever already
2343 * existed in the destination, instead of replacing it.
2346 * Corresponds to mode <code>"a"</code> in the stdio library, using fopen().
2353 * In glk_stream_set_position(), signifies that @pos is counted in characters
2354 * after the beginning of the file.
2360 * In glk_stream_set_position(), signifies that @pos is counted in characters
2361 * after the current position (moving backwards if @pos is negative.)
2367 * In glk_stream_set_position(), signifies that @pos is counted in characters
2368 * after the end of the file. (@pos should always be zero or negative, so that
2369 * this will move backwards to a position within the file.
2373 * stylehint_Indentation:
2375 * How much to indent lines of text in the given style. May be a negative
2376 * number, to shift the text out (left) instead of in (right). The exact metric
2377 * isn't precisely specified; you can assume that +1 is the smallest indentation
2378 * possible which is clearly visible to the player.
2382 * stylehint_ParaIndentation:
2384 * How much to indent the first line of each paragraph. This is in addition to
2385 * the indentation specified by %stylehint_Indentation. This too may be
2386 * negative, and is measured in the same units as %stylehint_Indentation.
2390 * stylehint_Justification:
2392 * The value of this hint must be one of the constants
2393 * %stylehint_just_LeftFlush, %stylehint_just_LeftRight (full justification),
2394 * %stylehint_just_Centered, or %stylehint_just_RightFlush.
2400 * How much to increase or decrease the font size. This is relative; 0 means the
2401 * interpreter's default font size will be used, positive numbers increase it,
2402 * and negative numbers decrease it. Again, +1 is the smallest size increase
2403 * which is easily visible.
2405 * The amount of this increase may not be constant. +1 might increase an
2406 * 8-point font to 9-point, but a 16-point font to 18-point.
2413 * The value of this hint must be 1 for heavy-weight fonts (boldface), 0 for
2414 * normal weight, and -1 for light-weight fonts.
2418 * stylehint_Oblique:
2420 * The value of this hint must be 1 for oblique fonts (italic), or 0 for normal
2425 * stylehint_Proportional:
2427 * The value of this hint must be 1 for proportional-width fonts, or 0 for
2432 * stylehint_TextColor:
2434 * The foreground color of the text. This is encoded in the 32-bit hint value:
2435 * the top 8 bits must be zero, the next 8 bits are the red value, the next 8
2436 * bits are the green value, and the bottom 8 bits are the blue value. Color
2437 * values range from 0 to 255.
2439 * So 0x00000000 is black, 0x00FFFFFF is white, and 0x00FF0000 is bright red.
2444 * stylehint_BackColor:
2446 * The background color behind the text. This is encoded the same way as
2447 * %stylehint_TextColor.
2451 * stylehint_ReverseColor:
2453 * The value of this hint must be 0 for normal printing (%stylehint_TextColor on
2454 * %stylehint_BackColor), or 1 for reverse printing (%stylehint_BackColor on
2455 * %stylehint_TextColor).
2457 * Some libraries may support this hint but not the %stylehint_TextColor and
2458 * %stylehint_BackColor hints. Other libraries may take the opposite tack;
2459 * others may support both, or neither.
2464 * stylehint_NUMHINTS:
2466 * The number of style hints defined in this library.
2470 * stylehint_just_LeftFlush:
2472 * A value for %stylehint_Justification representing left-justified text.
2476 * stylehint_just_LeftRight:
2478 * A value for %stylehint_Justification representing fully justified text.
2482 * stylehint_just_Centered:
2484 * A value for %stylehint_Justification representing centered text.
2488 * stylehint_just_RightFlush:
2490 * A value for %stylehint_Justification representing right-justified text.
2493 /*---------- TYPES, FUNCTIONS AND CONSTANTS FROM GI_DISPA.H ------------------*/
2496 * gidispatch_count_classes:
2498 * Returns the number of opaque object classes used by the library. You will
2499 * need to know this if you want to keep track of opaque objects as they are
2500 * created; see <link linkend="gidispatch-set-object-registry">Opaque Object
2503 * As of Glk API 0.7.0, there are four classes: windows, streams, filerefs, and
2504 * sound channels (numbered 0, 1, 2, and 3 respectively.)
2506 * Returns: Number of opaque object classes used by the library.
2510 * gidispatch_count_intconst:
2512 * Returns the number of integer constants exported by the library.
2514 * Returns: Number of integer constants exported by the library.
2518 * gidispatch_get_intconst:
2519 * @index: Unique integer index of the integer constant.
2521 * Returns a structure describing an integer constant which the library exports.
2522 * These are, roughly, all the constants defined in the <filename
2523 * class="headerfile">glk.h</filename> file. @index can range from 0 to
2524 * <inlineequation><mathphrase>N - 1</mathphrase><alt>N -
2525 * 1</alt></inlineequation>, where N is the value returned by
2526 * gidispatch_count_intconst().
2528 * Returns: A #gidispatch_intconst_t structure describing the integer constant.
2532 * gidispatch_intconst_t:
2533 * @name: Symbolic name of the integer constant.
2534 * @val: Value of the integer constant.
2536 * This structure simply contains a string and a value. The string is a
2537 * symbolic name of the value, and can be re-exported to anyone interested in
2538 * using Glk constants.
2542 * gidispatch_count_functions:
2544 * Returns the number of functions exported by the library.
2546 * Returns: Number of functions exported by the library.
2550 * gidispatch_get_function:
2551 * @index: Unique integer index of the function.
2553 * Returns a structure describing a Glk function. @index can range from 0 to
2554 * <inlineequation><mathphrase>N - 1</mathphrase><alt>N -
2555 * 1</alt></inlineequation>, where N is the value returned by
2556 * gidispatch_count_functions().
2558 * Returns: A #gidispatch_function_t structure describing the function.
2562 * gidispatch_function_t:
2563 * @id: Dispatch selector of the function.
2564 * @fnptr: Pointer to the function.
2565 * @name: Name of the function, without the <code>glk_</code> prefix.
2567 * The @id field is a selector — a numeric constant used to refer to the
2568 * function in question. @name is the function name, as it is given in the
2569 * <filename class="headerfile">glk.h</filename> file, but without the
2570 * <quote><code>glk_</code></quote> prefix. And @fnptr is the address of the
2574 * This is included because it might be useful, but it is not recommended. To
2575 * call an arbitrary Glk function, you should use gidispatch_call().
2578 * See <link linkend="chimara-Table-of-Selectors">Table of Selectors</link> for
2579 * the selector definitions. See <link
2580 * linkend="chimara-Dispatching">Dispatching</link> for more about calling Glk
2581 * functions by selector.
2585 * gidispatch_get_function_by_id:
2588 * Returns a structure describing the Glk function with selector @id. If there
2589 * is no such function in the library, this returns %NULL.
2591 * Returns: a #gidispatch_function_t structure, or %NULL.
2596 * @funcnum: Selector of the function to call.
2597 * @numargs: Length of @arglist.
2598 * @arglist: List of arguments to pass to the function.
2600 * @funcnum is the function number to invoke; see <link
2601 * linkend="chimara-Table-of-Selectors">Table of Selectors</link>. @arglist is
2602 * the list of arguments, and @numargs is the length of the list.
2604 * The arguments are all stored as #gluniversal_t objects.
2605 * </para><refsect3 id="chimara-Basic-Types"><title>Basic Types</title><para>
2606 * Numeric arguments are passed in the obvious way — one argument per
2607 * #gluniversal_t, with the @uint or @sint field set to the numeric value.
2608 * Characters and strings are also passed in this way — #char<!---->s in
2609 * the @uch, @sch, or @ch fields (depending on whether the #char is signed) and
2610 * strings in the @charstr field. Opaque objects (windows, streams, etc) are
2611 * passed in the @opaqueref field (which is <code>void*</code>, in order to
2612 * handle all opaque pointer types.)
2614 * However, pointers (other than C strings), arrays, and structures complicate
2615 * life. So do return values.
2616 * </para></refsect3>
2617 * <refsect3 id="chimara-References"><title>References</title><para>
2618 * A reference to a numeric type or object reference — that is,
2619 * <code>#glui32*</code>, <code>#winid_t*</code>, and so on — takes
2620 * <emphasis>one or two</emphasis> #gluniversal_t objects. The first is a flag
2621 * indicating whether the reference argument is %NULL or not. The @ptrflag field
2622 * of this #gluniversal_t should be %FALSE if the reference is %NULL, and %TRUE
2623 * otherwise. If %FALSE, that is the end of the argument; you should not use a
2624 * #gluniversal_t to explicitly store the %NULL reference. If the flag is %TRUE,
2625 * you must then put a #gluniversal_t storing the base type of the reference.
2627 * For example, consider a hypothetical function, with selector
2628 * <code>0xABCD</code>:
2630 * void glk_glomp(#glui32 num, #winid_t win, #glui32 *numref, #strid_t *strref);
2636 * #strid_t gamefile;
2637 * glk_glomp(5, mainwin, &value, &gamefile);
2640 * To perform this through gidispatch_call(), you would do the following:
2642 * #gluniversal_t arglist[6];
2643 * arglist[0].uint = 5;
2644 * arglist[1].opaqueref = mainwin;
2645 * arglist[2].ptrflag = TRUE;
2646 * arglist[3].uint = value;
2647 * arglist[4].ptrflag = TRUE;
2648 * arglist[5].opaqueref = gamefile;
2649 * #gidispatch_call(0xABCD, 6, arglist);
2650 * value = arglist[3].uint;
2651 * gamefile = arglist[5].opaqueref;
2654 * Note that you copy the value of the reference arguments into and out of
2655 * @arglist. Of course, it may be that glk_glomp() only uses these as pass-out
2656 * references or pass-in references; if so, you could skip copying in or out.
2658 * For further examples:
2660 * glk_glomp(7, mainwin, NULL, NULL);
2662 * #gluniversal_t arglist[4];
2663 * arglist[0].uint = 7;
2664 * arglist[1].opaqueref = mainwin;
2665 * arglist[2].ptrflag = FALSE;
2666 * arglist[3].ptrflag = FALSE;
2667 * #gidispatch_call(0xABCD, 4, arglist);
2671 * glk_glomp(13, NULL, NULL, &gamefile);
2673 * #gluniversal_t arglist[5];
2674 * arglist[0].uint = 13;
2675 * arglist[1].opaqueref = NULL;
2676 * arglist[2].ptrflag = FALSE;
2677 * arglist[3].ptrflag = TRUE;
2678 * arglist[4].opaqueref = gamefile;
2679 * #gidispatch_call(0xABCD, 5, arglist);
2680 * gamefile = arglist[4].opaqueref;
2684 * glk_glomp(17, NULL, &value, NULL);
2686 * #gluniversal_t arglist[5];
2687 * arglist[0].uint = 17;
2688 * arglist[1].opaqueref = NULL;
2689 * arglist[2].ptrflag = TRUE;
2690 * arglist[3].uint = value;
2691 * arglist[4].ptrflag = FALSE;
2692 * #gidispatch_call(0xABCD, 5, arglist);
2693 * value = arglist[3].uint;
2696 * As you see, the length of @arglist depends on how many of the reference
2697 * arguments are %NULL.
2698 * </para></refsect3>
2699 * <refsect3 id="chimara-Structures"><title>Structures</title><para>
2700 * A structure pointer is represented by a single @ptrflag, possibly followed by
2701 * a sequence of #gluniversal_t objects (one for each field of the structure.)
2702 * Again, if the structure pointer is non-%NULL, the @ptrflag should be %TRUE
2703 * and be followed by values; if not, the @ptrflag should be %NULL and stands
2706 * For example, the function glk_select() can be invoked as follows:
2709 * #gluniversal_t arglist[5];
2710 * arglist[0].ptrflag = TRUE;
2711 * #gidispatch_call(0x00C0, 5, arglist);
2712 * ev.type = arglist[1].uint;
2713 * ev.win = arglist[2].opaqueref;
2714 * ev.val1 = arglist[3].uint;
2715 * ev.val2 = arglist[4].uint;
2718 * Since the structure passed to glk_select() is a pass-out reference (the entry
2719 * values are ignored), you don't need to fill in <code>arglist[1..4]</code>
2720 * before calling gidispatch_call().
2723 * Theoretically, you would invoke <code>#glk_select(%NULL)</code> by setting'
2724 * <code>arglist[0].ptrflag</code> to %FALSE, and using a one-element @arglist
2725 * instead of five-element. But it's illegal to pass %NULL to glk_select(). So
2726 * you cannot actually do this.
2727 * </para></note></para></refsect3>
2728 * <refsect3 id="chimara-Arrays"><title>Arrays</title><para>
2729 * In the Glk API, an array argument is always followed by a numeric argument
2730 * giving the array's length. These two C arguments are a single logical
2731 * argument, which is represented by <emphasis>one or three</emphasis>
2732 * #gluniversal_t objects. The first is a @ptrflag, indicating whether the
2733 * argument is %NULL or not. The second is a pointer, stored in the @array
2734 * field. The third is the array length, stored in the @uint field. And again,
2735 * if the @ptrflag is %NULL, the following two are omitted.
2737 * For example, the function glk_put_buffer() can be invoked as follows:
2741 * #glk_put_buffer(buf, len);
2743 * #gluniversal_t arglist[3];
2744 * arglist[0].ptrflag = TRUE;
2745 * arglist[1].array = buf;
2746 * arglist[2].uint = len;
2747 * #gidispatch_call(0x0084, 3, arglist);
2750 * Since you are passing a C char array to gidispatch_call(), the contents will
2751 * be read directly from that. There is no need to copy data into @arglist, as
2752 * you would for a basic type.
2754 * If you are implementing a VM whose native representation of char arrays is
2755 * more complex, you will have to do more work. You should allocate a C char
2756 * array, copy your characters into it, make the call, and then free the array.
2759 * glk_put_buffer() does not modify the array passed to it, so there is no
2760 * need to copy the characters out.
2761 * </para></note></para></refsect3>
2762 * <refsect3 id="chimara-Return-Values"><title>Return Values</title><para>
2763 * The return value of a function is not treated specially. It is simply
2764 * considered to be a pass-out reference argument which may not be %NULL. It
2765 * comes after all the other arguments of the function.
2767 * For example, the function glk_window_get_rock() can be invoked as follows:
2771 * rock = #glk_window_get_rock(win);
2773 * #gluniversal_t arglist[3];
2774 * arglist[0].opaqueref = win;
2775 * arglist[1].ptrflag = TRUE;
2776 * #gidispatch_call(0x0021, 3, arglist);
2777 * rock = arglist[2].uint;
2779 * </para></refsect3><para>
2784 * @uint: Stores a #glui32.
2785 * @sint: Stores a #glsi32.
2786 * @opaqueref: Stores a #winid_t, #strid_t, #frefid_t, or #schanid_t.
2787 * @uch: Stores an #unsigned #char.
2788 * @sch: Stores a #signed #char.
2789 * @ch: Stores a #char with the default signedness.
2790 * @charstr: Stores a %NULL-terminated string.
2791 * @array: Stores a pointer to an array, and should be followed by another
2792 * #gluniversal_t with the array length stored in the @uint member.
2793 * @ptrflag: If %FALSE, represents an opaque reference or array that is %NULL,
2794 * in which case it represents the entire argument. If %TRUE, should be followed
2795 * by another #gluniversal_t with the pointer in its @opaqueref or @array field.
2797 * This is a union, encompassing all the types that can be passed to Glk
2802 * gidispatch_prototype:
2803 * @funcnum: A selector for the function to be queried.
2805 * This returns a string which encodes the proper argument list for the given
2806 * function. If there is no such function in the library, this returns %NULL.
2808 * The prototype string for the glk_glomp() function described above would be:
2809 * <code>"4IuQa&Iu&Qb:"</code>. The <code>"4"</code> is the number of
2810 * arguments (including the return value, if there is one, which in this case
2811 * there isn't.) <code>"Iu"</code> denotes an unsigned integer;
2812 * <code>"Qa"</code> is an opaque object of class 0 (window).
2813 * <code>"&Iu"</code> is a <emphasis>reference</emphasis> to an unsigned
2814 * integer, and <code>"&Qb"</code> is a reference to a stream. The colon at
2815 * the end terminates the argument list; the return value would follow it, if
2818 * Note that the initial number (<code>"4"</code> in this case) is the number of
2819 * logical arguments, not the number of #gluniversal_t objects which will be
2820 * passed to gidispatch_call(). The glk_glomp() call uses anywhere from four to
2821 * six #gluniversal_t objects, as demonstrated above.
2823 * The basic type codes:
2826 * <term><code>Iu, Is</code></term>
2827 * <listitem><para>Unsigned and signed 32-bit integer.</para></listitem>
2830 * <term><code>Cn, Cu, Cs</code></term>
2831 * <listitem><para>Character, #unsigned #char, and #signed #char.</para>
2832 * <note><para>Of course <code>Cn</code> will be the same as either
2833 * <code>Cu</code> or <code>Cs</code>, depending on the platform. For this
2834 * reason, Glk avoids using it, but it is included here for completeness.
2839 * <term><code>S</code></term>
2840 * <listitem><para>A C-style string (null-terminated array of #char). In Glk,
2841 * strings are always treated as read-only and used immediately; the library
2842 * does not retain a reference to a string between Glk calls. A Glk call that
2843 * wants to use writable char arrays will use an array type
2844 * (<code>"#C"</code>), not string (<code>"S"</code>).</para></listitem>
2847 * <term><code>U</code></term>
2848 * <listitem><para>A zero-terminated array of 32-bit integers. This is
2849 * primarily intended as a Unicode equivalent of <code>"S"</code>. Like
2850 * <code>"S"</code> strings, <code>"U"</code> strings are read-only and used
2851 * immediately. A Glk call that wants to use writable Unicode arrays will use
2852 * an array type (<code>"#Iu"</code>) instead of <code>"U"</code>.</para>
2856 * <term><code>F</code></term>
2857 * <listitem><para>A floating-point value. Glk does not currently use
2858 * floating-point values, but we might as well define a code for them.</para>
2862 * <term><code>Qa, Qb, Qc...</code></term>
2863 * <listitem><para>A reference to an opaque object. The second letter
2864 * determines which class is involved. (The number of classes can be gleaned
2865 * from gidispatch_count_classes(); see <link
2866 * linkend="chimara-Interrogating-the-Interface">Interrogating the
2867 * Interface</link>).</para>
2869 * If Glk expands to have more than 26 classes, we'll think of something.
2870 * </para></note></listitem>
2873 * Any type code can be prefixed with one or more of the following characters
2874 * (order does not matter):
2877 * <term><code>&</code></term>
2878 * <listitem><para>A reference to the type; or, if you like, a variable passed
2879 * by reference. The reference is passed both in and out, so you must copy the
2880 * value in before calling gidispatch_call() and copy it out afterward.</para>
2884 * <term><code><</code></term>
2885 * <listitem><para>A reference which is pass-out only. The initial value is
2886 * ignored, so you only need copy out the value after the call.</para>
2890 * <term><code>></code></term>
2891 * <listitem><para>A reference which is pass-in only.</para>
2893 * This is not generally used for simple types, but is useful for structures
2895 * </para></note></listitem>
2898 * <term><code>+</code></term>
2899 * <listitem><para>Combined with <code>"&"</code>, <code>"<"</code>, or
2900 * <code>">"</code>, indicates that a valid reference is mandatory; %NULL
2901 * cannot be passed.</para>
2903 * Note that even though the @ptrflag #gluniversal_t for a <code>"+"</code>
2904 * reference is always %TRUE, it cannot be omitted.
2905 * </para></note></listitem>
2908 * <term><code>:</code></term>
2909 * <listitem><para>The colon separates the arguments from the return value, or
2910 * terminates the string if there is no return value. Since return values are
2911 * always non-%NULL pass-out references, you may treat <code>":"</code> as
2912 * equivalent to <code>"<+"</code>. The colon is never combined with any
2913 * other prefix character.</para></listitem>
2916 * <term><code>[...]</code></term>
2917 * <listitem><para>Combined with <code>"&"</code>, <code>"<"</code>, or
2918 * <code>">"</code>, indicates a structure reference. Between the brackets
2919 * is a complete argument list encoding string, including the number of
2922 * For example, the prototype string for glk_select() is
2923 * <code>"1<+[4IuQaIuIu]:"</code> — one argument, which is a
2924 * pass-out non-%NULL reference to a structure, which contains four
2927 * <para>Currently, structures in Glk contain only basic types.</para>
2931 * <term><code>#</code></term>
2932 * <listitem><para>Combined with <code>"&"</code>, <code>"<"</code>, or
2933 * <code>">"</code>, indicates an array reference. As described above, this
2934 * encompasses up to three #gluniversal_t objects — @ptrflag, pointer,
2935 * and integer length.</para>
2937 * Depending on the design of your program, you may wish to pass a pointer
2938 * directly to your program's memory, or allocate an array and copy the
2939 * contents in and out. See <link linkend="chimara-Arrays">Arrays</link>.
2940 * </para></note></listitem>
2943 * <term><code>!</code></term>
2944 * <listitem><para>Combined with <code>"#"</code>, indicates that the
2945 * array is retained by the library. The library will keep a reference to the
2946 * array; the contents are undefined until further notice. You should not use
2947 * or copy the contents of the array out after the call, even for
2948 * <code>"&#!"</code> or <code>"<#!"</code> arrays. Instead, do
2949 * it when the library releases the array.</para>
2951 * For example, glk_stream_open_memory() retains the array that you pass it,
2952 * and releases it when the stream is closed. The library can notify you
2953 * automatically when arrays are retained and released; see <link
2954 * linkend="gidispatch-set-retained-registry">Retained Array
2956 * </para></note></listitem>
2960 * Returns: A string which encodes the prototype of the specified Glk function.
2964 * gidisp_Class_Window:
2966 * Represents a #winid_t opaque object.
2970 * gidisp_Class_Stream:
2972 * Represents a #strid_t opaque object.
2976 * gidisp_Class_Fileref:
2978 * Represents a #frefid_t opaque object.
2982 * gidisp_Class_Schannel:
2984 * Represents a #schanid_t opaque object.
2988 * gidispatch_rock_t:
2989 * @num: Space for storing an integer.
2990 * @ptr: Space for storing a pointer.
2992 * You can store any value you want in this object; return it from your object
2993 * registry and retained array registry callbacks, and the library will stash it
2994 * away. You can retrieve it with gidispatch_get_objrock().
2997 /*---------- TYPES, FUNCTIONS AND CONSTANTS FROM GI_BLORB.H ------------------*/
3002 * An integer type that can hold the Blorb error codes.
3012 * giblorb_err_CompileTime:
3014 * Something is compiled wrong in the Blorb layer.
3018 * giblorb_err_Alloc:
3020 * Memory could not be allocated.
3021 * <note><title>Chimara</title>
3023 * The Blorb layer in the Chimara library should not return this error code;
3024 * instead, the program aborts if memory allocation fails, in keeping with
3032 * Data could not be read from the file.
3036 * giblorb_err_NotAMap:
3038 * The map parameter is invalid.
3042 * giblorb_err_Format:
3044 * The Blorb file is corrupted or invalid.
3048 * giblorb_err_NotFound:
3050 * The requested data could not be found.
3054 * giblorb_method_DontLoad:
3056 * Pass this to giblorb_load_chunk_by_type(), giblorb_load_chunk_by_number(), or
3057 * giblorb_load_resource() to obtain information about a chunk without actually
3062 * giblorb_method_Memory:
3064 * Pass this to giblorb_load_chunk_by_type(), giblorb_load_chunk_by_number(), or
3065 * giblorb_load_resource() to load a chunk into memory.
3069 * giblorb_method_DontLoad:
3071 * Pass this to giblorb_load_chunk_by_type(), giblorb_load_chunk_by_number(), or
3072 * giblorb_load_resource() to get the position in the Blorb file at which the
3073 * chunk data starts.
3079 * Resource usage constant representing a sound file.
3085 * Resource usage constant representing an executable program.
3091 * Resource usage constant representing an image file.
3095 * giblorb_ID_Copyright:
3097 * Resource usage constant representing the copyright message (date and holder,
3098 * without the actual copyright symbol). There should only be one such chunk per
3105 * Resource usage constant representing the name of the author or creator of the
3106 * file. This could be a login name on multi-user systems, for example. There
3107 * should only be one such chunk per file.
3113 * Resource usage constant representing any textual annotation that the user or
3114 * writing program sees fit to include.
3120 * Holds the complete description of an open Blorb file. This type is opaque for
3121 * normal interpreter use.
3127 * Holds information about a chunk loaded from a Blorb file, and the method of
3128 * accessing the chunk data. See giblorb_load_chunk_by_type() and
3129 * giblorb_load_chunk_by_number().
3133 * giblorb_create_map:
3134 * @file: An input stream pointing to a Blorb file.
3135 * @newmap: Return location for a Blorb resource map.
3137 * Reads Blorb data out of a Glk stream. It does not load every resource at
3138 * once; instead, it creates a map in memory which makes it easy to find
3139 * resources. A pointer to the map is stored in @newmap. This is an opaque
3140 * object; you pass it to the other Blorb-layer functions.
3142 * Returns: a Blorb error code.
3146 * giblorb_destroy_map:
3147 * @map: A Blorb resource map to deallocate.
3149 * Deallocates @map and all associated memory. This does
3150 * <emphasis>not</emphasis> close the original stream.
3152 * Returns: a Blorb error code.
3156 * giblorb_load_chunk_by_type:
3157 * @map: The Blorb resource map to load a chunk from.
3158 * @method: The loading method to use, one of %giblorb_method_DontLoad,
3159 * %giblorb_method_Memory, or %giblorb_method_FilePos.
3160 * @res: Return location for the result.
3161 * @chunktype: The type of chunk to load.
3162 * @count: The chunk number of type @chunktype to load.
3164 * Loads a chunk of a given type. The @count parameter distinguishes between
3165 * chunks of the same type. If @count is zero, the first chunk of that type is
3166 * loaded, and so on.
3168 * To load a chunk of an IFF FORM type (such as AIFF), you should pass in the
3169 * form type, rather than FORM.
3171 * This introduces a slight ambiguity — you cannot distiguish between a
3172 * FORM AIFF chunk and a non-FORM chunk of type AIFF. However, the latter is
3173 * almost certainly a mistake.
3176 * The returned data is written into @res, according to @method.
3178 * The <structfield>chunknum</structfield> field is filled in with the number of
3179 * the chunk. (This value can then be passed to giblorb_load_chunk_by_number()
3180 * or giblorb_unload_chunk().) The <structfield>length</structfield> field is
3181 * filled in with the length of the chunk in bytes. The
3182 * <structfield>chunktype</structfield> field is the chunk's type, which of
3183 * course will be the type you asked for.
3185 * If you specify %giblorb_method_DontLoad, no data is actually loaded in. You
3186 * can use this if you are only interested in whether a chunk exists, or in the
3187 * <structfield>chunknum</structfield> and <structfield>length</structfield>
3190 * If you specify %giblorb_method_FilePos,
3191 * <structfield>data.startpos</structfield> is filled in with the file position
3192 * of the chunk data. You can use glk_stream_set_position() to read the data
3195 * If you specify %giblorb_method_Memory, <structfield>data.ptr</structfield> is
3196 * filled with a pointer to allocated memory containing the chunk data. This
3197 * memory is owned by the map, not you. If you load the chunk more than once
3198 * with %giblorb_method_Memory, the Blorb layer is smart enough to keep just one
3199 * copy in memory. You should not deallocate this memory yourself; call
3200 * giblorb_unload_chunk() instead.
3202 * Returns: a Blorb error code.
3206 * giblorb_load_chunk_by_number:
3207 * @map: The Blorb resource map to load a chunk from.
3208 * @method: The loading method to use, one of %giblorb_method_DontLoad,
3209 * %giblorb_method_Memory, or %giblorb_method_FilePos.
3210 * @res: Return location for the result.
3211 * @chunknum: The chunk number to load.
3213 * This is similar to giblorb_load_chunk_by_type(), but it loads a chunk with a
3214 * given chunk number. The type of the chunk can be found in the
3215 * <structfield>chunktype</structfield> field of #giblorb_result_t. You can get
3216 * the chunk number from the <structfield>chunknum</structfield> field, after
3217 * calling one of the other load functions.
3219 * Returns: a Blorb error code.
3223 * giblorb_unload_chunk:
3224 * @map: The Blorb resource map to unload a chunk from.
3225 * @chunknum: The chunk number to unload.
3227 * Frees the chunk data allocated by %giblorb_method_Memory. If the given chunk
3228 * has never been loaded into memory, this has no effect.
3230 * Returns: a Blorb error code.
3234 * giblorb_load_resource:
3235 * @map: The Blorb resource map to load a resource from.
3236 * @method: The loading method to use, one of %giblorb_method_DontLoad,
3237 * %giblorb_method_Memory, or %giblorb_method_FilePos.
3238 * @res: Return location for the result.
3239 * @usage: The type of data resource to load.
3240 * @resnum: The resource number to load.
3242 * Loads a resource, given its usage and resource number. Currently, the three
3243 * usage values are %giblorb_ID_Pict (images), %giblorb_ID_Snd (sounds), and
3244 * %giblorb_ID_Exec (executable program). See the Blorb specification for more
3245 * information about the types of data that can be stored for these usages.
3247 * Note that a resource number is not the same as a chunk number. The resource
3248 * number is the sound or image number specified by a Glk program. Chunk number
3249 * is arbitrary, since chunks in a Blorb file can be in any order. To find the
3250 * chunk number of a given resource, call giblorb_load_resource() and look in
3251 * <structfield>res.chunknum</structfield>.
3253 * Returns: a Blorb error code.
3257 * giblorb_count_resources:
3258 * @map: The Blorb resource map in which to count the resources.
3259 * @usage: The type of data resource to count.
3260 * @num: Return location for the number of chunks of @usage.
3261 * @min: Return location for the lowest resource number of @usage.
3262 * @max: Return location for the highest resource number of @usage.
3264 * Counts the number of chunks with a given usage (image, sound, or executable.)
3265 * The total number of chunks of that usage is stored in @num. The lowest and
3266 * highest resource number of that usage are stored in @min and @max. You can
3267 * leave any of the three pointers %NULL if you don't care about that
3270 * Returns: a Blorb error code.
3273 /*--------------------TYPES AND CONSTANTS FROM GLKSTART.H---------------------*/
3276 * glkunix_argumentlist_t:
3278 * In each entry, name is the option as it would appear on the command line
3279 * (including the leading dash, if any.) The desc is a description of the
3280 * argument; this is used when the library is printing a list of options. And
3281 * argtype is one of the following constants:
3285 * <term>%glkunix_arg_NoValue</term>
3286 * <listitem><para>The argument appears by itself.</para></listitem>
3289 * <term>%glkunix_arg_ValueFollows</term>
3290 * <listitem><para>The argument must be followed by another argument (the
3291 * value).</para></listitem>
3294 * <term>%glkunix_arg_ValueCanFollow</term>
3295 * <listitem><para>The argument may be followed by a value, optionally. (If the
3296 * next argument starts with a dash, it is taken to be a new argument, not the
3297 * value of this one.)</para></listitem>
3300 * <term>%glkunix_arg_NumberValue</term>
3301 * <listitem><para>The argument must be followed by a number, which may be the
3302 * next argument or part of this one. (That is, either <quote><code>-width
3303 * 20</code></quote> or <quote><code>-width20</code></quote> will be accepted.)
3304 * </para></listitem>
3307 * <term>%glkunix_arg_End</term>
3308 * <listitem><para>The <code>glkunix_arguments[]</code> array must be
3309 * terminated with an entry containing this value.</para></listitem>
3313 * To accept arbitrary arguments which lack dashes, specify a name of
3314 * <code>""</code> and an argtype of %glkunix_arg_ValueFollows.
3316 * If you don't care about command-line arguments, you must still define an
3317 * empty arguments list, as follows:
3319 * #glkunix_argumentlist_t glkunix_arguments[] = {
3320 * { NULL, #glkunix_arg_End, NULL }
3324 * Here is a more complete sample list:
3326 * #glkunix_argumentlist_t glkunix_arguments[] = {
3327 * { "", #glkunix_arg_ValueFollows, "filename: The game file to load." },
3328 * { "-hum", #glkunix_arg_ValueFollows, "-hum NUM: Hum some NUM." },
3329 * { "-bom", #glkunix_arg_ValueCanFollow, "-bom [ NUM ]: Do a bom (on
3330 * the NUM, if given)." },
3331 * { "-goo", #glkunix_arg_NoValue, "-goo: Find goo." },
3332 * { "-wob", #glkunix_arg_NumberValue, "-wob NUM: Wob NUM times." },
3333 * { NULL, #glkunix_arg_End, NULL }
3336 * This would match the arguments <quote><code>thingfile -goo -wob8 -bom -hum
3337 * song</code></quote>.
3339 * After the library parses the command line, it does various occult rituals of
3340 * initialization, and then calls glkunix_startup_code().
3342 * |[ int glkunix_startup_code(#glkunix_startup_t *data); ]|
3344 * This should return %TRUE if everything initializes properly. If it returns
3345 * %FALSE, the library will shut down without ever calling your glk_main()
3350 * glkunix_startup_t:
3352 * The fields are a standard Unix <code>(argc, argv)</code> list, which contain
3353 * the arguments you requested from the command line. In deference to custom,
3354 * <code>argv[0]</code> is always the program name.
3360 * Terminates a list of #glkunix_argumentlist_t.
3364 * glkunix_arg_ValueFollows:
3366 * Indicates an argument which must be followed by a value, as the next
3371 * glkunix_arg_NoValue:
3373 * Indicates an argument which occurs by itself, without a value.
3377 * glkunix_arg_ValueCanFollow:
3379 * Indicates an argument which may be followed by a value, or may occur by
3384 * glkunix_arg_NumberValue:
3386 * Indicates an argument which must be followed by a numerical value, either as
3387 * the next argument or tacked onto the end of this argument.