Flexible Windows

version 13/130803 by Jon Ingold

  • Home page
  • Beginning
  • Previous
  • Next

  •     Section: Hyperlinked text

    Flexible Windows also offers the ability to place hyperlinks in text windows. The hyperlink functionality in Flexible Windows is based on that in Emily Short's Basic Hyperlinks extension. In fact, if you are moving an existing project to Flexible Windows, you may simply include Basic Hyperlinks to avoid making any changes to your existing hyperlink code. If you are starting a new project, though, it is recommended that you simply use the Flexible Windows commands (Though the functionality is similar, Flexible Windows uses a different namespace from Basic Hyperlinks.)

    By default, Flexible Windows's response to a clicked hyperlink is to enter a replacement command at the prompt on behalf of the player. To set a hyperlink, enclose the text to be linked between "set link <number>" and "end link" phrases:

        say "To the [set link 1]north[end link] a wide field opens, while to the [set link 2]south[end link] a narrow path winds into dark woods."

    Hyperlink replacement commands are defined by the Table of Glulx Hyperlink Replacement Commands. Hyperlinks are numbered, starting from 1:

        Table of Glulx Hyperlink Replacement Commands (continued)
      link ID  replacement  
      1  "GO NORTH"  
      2  "GO SOUTH"  

    If a link ID number has no corresponding text command in the table of replacement commands, nothing will happen when the link is clicked.

    To define custom behavior for a particular link, we write a new rule for the hyperlink processing rulebook. For example, to have a hyperlink simply clear the screen immediately, without pasting any text to the command line:

        Hyperlink processing rule when the current hyperlink ID is 1:
            clear the main-window;
            silently try looking;
            say "[command prompt][run paragraph on]";
            rule succeeds.

    When we use this type of rule, we need not put anything in the Table of Glulx Hyperlink Replacement Commands. This table is only consulted when the default hyperlink processing rule is run.

    Note that Flexible Windows will also register hyperlinks in the status line. We define these like we do any other hyperlink, e.g.:

        When play begins:
            now the right hand status line is "[set link 1]clear screen[end link]"