Top |
#define | style_Normal |
#define | style_Emphasized |
#define | style_Preformatted |
#define | style_Header |
#define | style_Subheader |
#define | style_Alert |
#define | style_Note |
#define | style_BlockQuote |
#define | style_Input |
#define | style_User1 |
#define | style_User2 |
You can send style-changing commands to an output stream. After a style change, new text which is printed to that stream will be given the new style, whatever that means for the stream in question. For a window stream, the text will appear in that style. For a memory stream, style changes have no effect. For a file stream, if the machine supports styled text files, the styles may be written to the file; more likely the style changes will have no effect.
Styles are exclusive. A character is shown with exactly one style, not a subset of the possible styles.
Note that every stream and window has its own idea of the “current style.” Sending a style command to one window or stream does not affect any others.
Except for a window's echo stream; see Echo Streams.
The styles are intended to distinguish meaning and use, not formatting. There is no standard definition of what each style will look like. That is left up to the Glk library, which will choose an appearance appropriate for the platform's interface and the player's preferences.
There are currently eleven styles defined. More may be defined in the future.
Styles may be distinguished on screen by font, size, color, indentation,
justification, and other attributes. Note that some attributes (notably
justification and indentation) apply to entire paragraphs. If possible and
relevant, you should apply a style to an entire paragraph — call
glk_set_style()
immediately after printing the newline at the beginning of
the text, and do the same at the end.
For example, style_Header
may well be centered text. If you print
“Welcome to Victim (a short interactive mystery)”, and only the word
“Victim” is in the style_Header
, the center-justification attribute will be
lost.
Similarly, a block quote is usually indented on both sides, but indentation
is only meaningful when applied to an entire line or paragraph, so block
quotes should take up an entire paragraph.
Contrariwise, style_Emphasized
need not be used on an entire paragraph.
It is often used for single emphasized words in normal text, so you can
expect that it will appear properly that way; it will be displayed in
italics or underlining, not center-justified or indented.
Yes, this is all a matter of mutual agreement between game authors and game players. It's not fixed by this specification. That's natural language for you.
void
glk_set_style (glui32 styl
);
Changes the style of the current output stream. styl
should be one of the
style_
constants.
However, any value is actually legal; if the interpreter does not recognize
the style value, it will treat it as style_Normal
.
This policy allows for the future definition of styles without breaking old Glk libraries.
void glk_set_style_stream (strid_t str
,glui32 styl
);
This changes the style of the stream str
. See glk_set_style()
.
#define style_Normal (0)
The style of normal or body text. A new window or stream always starts with
style_Normal
as the current style.
#define style_Preformatted (2)
Text which has a particular arrangement of characters.
This style, unlike the others, does have a standard appearance; it will always be a fixed-width font. This is a concession to practicality. Games often want to display maps or diagrams using character graphics, and this is the style for that.
#define style_Header (3)
Text which introduces a large section. This is suitable for the title of an entire game, or a major division such as a chapter.
#define style_Subheader (4)
Text which introduces a smaller section within a large section.
In a Colossal-Cave-style game, this is suitable for the name of a room (when the player looks around.)
#define style_Alert (5)
Text which warns of a dangerous condition, or one which the player should pay attention to.
#define style_Note (6)
Text which notifies of an interesting condition.
This is suitable for noting that the player's score has changed.
#define style_BlockQuote (7)
Text which forms a quotation or otherwise abstracted text.
#define style_Input (8)
Text which the player has entered. You should generally not use this style at
all; the library uses it for text which is typed during a line-input request.
One case when it is appropriate for you to use style_Input
is when you are
simulating player input by reading commands from a text file.
#define style_User1 (9)
This style has no particular semantic meaning. You may define a meaning relevant to your own work, and use it as you see fit.