Creating Hyperlinks

Creating Hyperlinks — Printing text as a hyperlink

Functions

Includes

#include <libchimara/glk.h>

Description

Some games may wish to mark up text in their windows with hyperlinks, which can be selected by the player — most likely by mouse click. Glk allows this in a manner similar to the way text styles are set.

Hyperlinks are an optional capability in Glk.

Functions

glk_set_hyperlink ()

void
glk_set_hyperlink (glui32 linkval);

This call sets the current link value in the current output stream. See glk_set_hyperlink_stream().

Parameters

linkval

Set to nonzero to initiate hyperlink mode. Set to zero to disengage.

 

glk_set_hyperlink_stream ()

void
glk_set_hyperlink_stream (strid_t str,
                          glui32 linkval);

This call sets the current link value on the specified output stream. A link value is any non-zero integer; zero indicates no link. Subsequent text output is considered to make up the body of the link, which continues until the link value is changed (or set to zero).

Note that it is almost certainly useless to change the link value of a stream twice with no intervening text. The result will be a zero-length link, which the player probably cannot see or select; the library may optimize it out entirely.

Setting the link value of a stream to the value it already has, has no effect.

If the library supports images, they take on the current link value as they are output, just as text does. The player can select an image in a link just as he does text. (This includes margin-aligned images, which can lead to some peculiar situations, since a right-margin image may not appear directly adjacent to the text it was output with.)

The library will attempt to display links in some distinctive way (and it will do this whether or not hyperlink input has actually been requested for the window). Naturally, blue underlined text is most likely. Link images may not be distinguished from non-link images, so it is best not to use a particular image both ways.

Parameters

str

The stream to set the hyperlink mode on.

 

linkval

Set to non-zero to initiate hyperlink mode. Set to zero to disengage.