5 #include "chimara-glk.h"
6 #include "chimara-glk-private.h"
9 G_GNUC_INTERNAL GPrivate *glk_data_key = NULL;
14 * If you want to shut down your program in the middle of your <function>
15 * glk_main()</function> function, you can call glk_exit().
17 * This function does not return.
19 * If you print some text to a window and then shut down your program, you can
20 * assume that the player will be able to read it. Most likely the Glk library
21 * will give a <quote><computeroutput>Hit any key to
22 * exit</computeroutput></quote> prompt. (There are other possiblities, however.
23 * A terminal-window version of Glk might simply exit and leave the last screen
24 * state visible in the terminal window.)
27 * You should only shut down your program with glk_exit() or by returning from
28 * your <function>glk_main()</function> function. If you call the ANSI
29 * <function>exit()</function> function, bad things may happen. Some versions of
30 * the Glk library may be designed for multiple sessions, for example, and you
31 * would be cutting off all the sessions instead of just yours. You would
32 * probably also prevent final text from being visible to the player.
34 * <note><title>Chimara</title>
36 * If there are any windows open at the time glk_exit() is called, then Chimara
37 * will leave them open. This way, the final text remains visible. Note that bad
38 * things most definitely <emphasis>will</emphasis> happen if you use the ANSI
39 * <function>exit()</function>.
52 * Carries out platform-dependent actions such as yielding time to the operating
53 * system and checking for interrupts. glk_tick() should be called every so
54 * often when there is a long interval between calls of glk_select() or
55 * glk_select_poll(). This call is fast; in fact, on average, it does nothing at
56 * all. So you can call it often.
59 * In a virtual machine interpreter, once per opcode is appropriate. In a
60 * program with lots of computation, pick a comparable rate.
63 * glk_tick() does not try to update the screen, or check for player input, or
64 * any other interface task. For that, you should call glk_select() or
65 * glk_select_poll(). See <link linkend="chimara-Events">Events</link>.
68 * <para>Captious critics have pointed out that in the sample program
69 * <filename>model.c</filename>, I do not call glk_tick() at all. This is
70 * because <filename>model.c</filename> has no heavy loops. It does a bit of
71 * work for each command, and then cycles back to the top of the event loop.
72 * The glk_select() call, of course, blocks waiting for input, so it does all
73 * the yielding and interrupt-checking one could imagine.
75 * <para>Basically, you must ensure there's some fixed upper bound on the
76 * amount of computation that can occur before a glk_tick() (or glk_select())
77 * occurs. In a VM interpreter, where the VM code might contain an infinite
78 * loop, this is critical. In a C program, you can often eyeball it.
80 * <para>But the next version of <filename>model.c</filename> will have a
81 * glk_tick() in the ornate printing loop of <function>verb_yada()</function>.
82 * Just to make the point.
91 /* Do one iteration of the main loop if there are any events */
93 if(gtk_events_pending())