It’s not that bad, I think. Erik Temple’s Inline Hyperlinks extension already creates one list of indexed texts as it gathers the hyperlinks, so it knows what to put in the command line when a link is clicked. You can just create another list of indexed texts as you go, and if the player types a command instead of clicking a link, go through the second list checking to see if that’s been typed. If so, change the text of the player’s command to what they’d get if they clicked on the link.
This is only tested on the simplest example from the Inline Hyperlinks documentation (I don’t seem to be able to run Glulx projects in the IDE right now) and there are almost certainly some edge cases it doesn’t deal with – for instance, if two hyperlinks go to the same command – but it’s a start. Replace “Section - Placing links” in Chapter 1 of Inline Hyperlinks with the following, which just adds a couple of things:
[code]Section - Placing links
The hyperlink list is a list of indexed texts variable.
The hyperlink text list is a list of indexed texts variable. [NEW – this is the list of texts that actually appear on the screen]
The hyperlinked text is an indexed text variable. The hyperlinked text is “”.
The hyperlinked command is an indexed text variable. The hyperlinked command is “”.
To say link:
now the hyperlinked text is “”;
now the hyperlinked command is “”;
start capturing text.
To say as:
stop capturing text;
now the hyperlinked text is “[captured text]”;
start capturing text;
To say end link:
let hyperlink index be a number;
stop capturing text;
if the hyperlinked text is “”:
now the hyperlinked text is “[captured text]”;
now the hyperlinked command is “[captured text]”;
if the hyperlinked command is listed in the hyperlink list: [this I think is the part that would cause trouble if two links translate to the same command – but I think it might be possible to solve this just by deleting this block]
repeat with count running from 1 to the number of entries in the hyperlink list:
if entry (count) of the hyperlink list is hyperlinked command:
let hyperlink index be count;
otherwise unless the hyperlinked command is “”:
add hyperlinked command to hyperlink list;
add hyperlinked text to hyperlink text list; [NEW: this adds the link text that appears on the screen to the list that we’ll check against when we read a command]
let hyperlink index be the number of entries of hyperlink list;
say “[set link (hyperlink index)][hyperlinked text][terminate link]”;
After reading a command: [NEW: this is the rule that looks through the hyperlink text list and, if the player typed something that appears in it, replaces the command with the appropriate corresponding command]
let T be indexed text;
now T is the player’s command;
repeat with N running from 1 to the number of entries in hyperlink list:
if T exactly matches the text entry N in the hyperlink text list:
change the text of the player’s command to entry N in the hyperlink list;
break.
To say set link (N - a number):
(- if (glk_gestalt(gestalt_Hyperlinks, 0)) glk_set_hyperlink({N}); -)
To say terminate link:
(- if (glk_gestalt(gestalt_Hyperlinks, 0)) glk_set_hyperlink(0); -)[/code]
You’d have to make similar changes to the chapter for use with Flexible Windows, and I don’t know if it eats up a lot of CPU time anyway. But hopefully it shows that it can be done without too much blood, sweat, and tears.