Color in Glulx again

Back in 2016 (Text colour effects for the glulx target) someone brought up the troubles involved in getting text color changes to work with some sense of consistency and usability. When I fiddled with the I6 Library and color for Glulx, I was able to get the whole screen text color to change, but not “from this point on, it’s now green.”. I haven’t touched that code in the Library, but now the code does nothing. It seems that sometime between then and now, something about Glk changed because until a few minutes ago, trying to change colors caused Glulxe to crash.

I’d really like to get this functionality fixed for the 6.12.4 Library release.

Which bit of that thread were you referring to?

The final comment (talking about the story-hints window not showing text) is due to a bug in the source, rather than anywhere else. The problem is that it declares a text-buffer window with a height of 1 line, and then proceeds to print three lines (two lines of text and an automatic paragraph break) so it scrolls out of view. It can be fixed by changing to a text grid window and then replacing this rule:

Rule for refreshing the story-hints window:
	say "Stuck in the story? [red reverse]Do not dial 911[default letters] in the [highlighted]USA![no line break][default letters] - Try west.[no line break]".

Note explicit suppression of line breaks after the exclamation point – that’s otherwise a location that I7 will helpfully inject one for you because it sees an ending punctuation character followed by a “separate rule”. (I’d be happier if it didn’t do that, but such is life.)

Although actually with this change it will work without using a text grid window, as long as the screen width is wide enough to not trigger word wrapping. Which is good because you need more changes to change the style of a text grid window, since that defaults to reverse.

(The existing glk styles do feel quite restrictive sometimes, though.)

FWIW, the extra change to make the background colour work for the text grid window is to add the “reversed” column to the Table of User Styles, with this extra row:

story-hints	all-styles	--	--	false

Is the goal here to change the look of one of the existing Glk styles? Or to imitate what the Z-machine does in terms of immediate color changes?

I want to imitate how the Z-machine does it.

“Core” Glulx is unable to do that; it relies on Glk for all its fancy IO manipulation, and Glk isn’t capable of coloring individual characters. (Even if you repurposed all the existing styles, you wouldn’t have enough to do what the Z-machine does.)

How do you feel about using the Garglk extensions? They specifically give you what you need to implement a Z-machine on Glk. I don’t know of any implementation using them except Gargoyle, but they’re the best you can get. (And like Glk styles, but unlike the core Z-machine color opcodes, they support full 24-bit color for both foreground and background. Which is neat.)

1 Like

Actually support is getting quite good now: Gargoyle, Windows Glulxe/Git, Spatterlight, and they should be supported in this year’s IF Comp online templates. And hopefully Lectrote if I can convince Zarf to include them :wink:.

2 Likes