Specifying Gargoyle's Glk extensions

I have started specifying Gargoyle’s Glk extensions so that they can be exposed directly to the VMs for all of you to use, and perhaps for them to be implemented in other interpreters in the future. For now I’m specifying the text formatting functions, which is what has been most under demand!

Have a look at the specification, and let me know if you think it needs any clarifications.

I’ll be posting example code soon.

Edit: example code at github.com/curiousdannii/if/blo … e-text.inf

1 Like

This seems like a good idea! It all looks pretty straightforward, except for “zcolor_Transparent (-4)”. Is that actually useful or even useable at all? “Transparent” was only supported by Z-code V6 and used for overlaying text onto images, but with Glk as it currently is, I don’t see how you could usefully use “transparent” at the moment.

garglk itself just completely ignores both zcolor_Transparent and zcolor_Cursor. Maybe it would be better to leave them out of what I’m specifying here? If, in some distant future, they ever become useful it would be easy to add them back because it would be a backwards-compatible change.

Leaving them out makes sense - I’d forgotten that zcolor_Cursor is only really of use in the same way as zcolor_Transparent. If we’re not going to have any use for them yet, and no-one implements it, let;s leave it out.

Okay, I’ve removed zcolor_Cursor and zcolor_Transparent.

A further suggestion for clarification: what happens after glk_set_style() is called after a garglk_set_zcolors() call? Does the over-ride of the style colours remain, or do we reset back to what’s in the Glk style hints? I would favour the latter, but the most important thing is to specify one way or another…

From reading Gargoyle’s cgstream.c the garglk_set_zcolors colours (as well as reverse) stay in place even after calling glk_set_style. Perhaps not ideal, but at least it’s fairly self contained.

I’m having trouble building Gargoyle currently, but I’ll try to test it soon, and then update the spec and test file.

I’ve implemented these text formatting opcodes in Windows Glk, so that they can be used with the latest builds of Windows Glulxe and Windows Git, which are available from here:

Windows Glulxe: http://ifarchive.org/indexes/if-archiveXprogrammingXglulxXinterpretersXglulxe.html
Windows Git: http://ifarchive.org/indexes/if-archiveXprogrammingXglulxXinterpretersXgit.html

This would perhaps have been more use about 15 years ago, but better late than never …

Excellent!

Sorry I haven’t updated the unit test yet. I’m still planning to. I also want to make an Inform 7 extension.

Hi David, sorry it took so long, but I’ve checked how Garglk handles conflicting instructions from stylehints and these text functions. Unfortunately it’s a bit messy. Here’s what I added to the spec:

I’ve updated the test file to test all the combinations I could think of: github.com/curiousdannii/if/blo … e-text.ulx

I was concerned that you might have made Windows-Glk make garglk_set_reversevideo(0) overwrite a stylehint, but you followed what Garglk does, and the testcase runs correctly! :slight_smile:

And I’ve written an I7 extension: github.com/i7/extensions/blob/m … atting.i7x

Unfortunately it doesn’t look like it will be possible to make an inline colour change (like [colour #ff0000] or [colour “#ff0000”]). It would be possible to have say phrases for the colour functions, but they’d need to use text variables/constants rather than inline texts. I thought that would be too confusing so didn’t add the phrases.

If no one has any trouble with it, I’ll submit it to the PL soon.

Thanks for specifying this. The ability to change foreground and background colors on the fly is great, and something I dearly miss in plain glk.