Color in I7?

Ummm. Shouldn’t it be easy for me to change the color of the text in I7?

I’ve tried a bunch of different things, but there doesn’t seem to be a simple way of doing it when compiling to glulx.

The best way I could think of to get it to work was to use Glulx Text Effects by Emily Short.

But that method sucks because all I want is a color change and it only gives you two extra custom styles.

I am aware that there might be a table of color values built into the extension, but there doesn’t seem to be a way to add it to any string you want just using the value.

This is, unfortunately, a limitation of the Glulx virtual machine itself. There’s been talk of changing it for some time but nothing has materialized yet.

You can repurpose the other styles if you want: for example, block-quote could be used for “green text”, and note for “blue text”. But it’s not optimal and not all interpreters support it.

Looks like you may be new to IF programming. If text color is important to you, you might want to take a look at TADS 3 (with the adv3Lite library, which I recommend because it’s simpler and has some extra features). In T3, you have a good amount of access to HTML text effects, including font size and color.

I7 is somewhat easier for new authors than T3, and T3 has no IDE on the Mac (unless you run Workbench in a Windows emulator). But if you’re up to the challenge, you won’t be disappointed.

Fair enough. Thanks everyone.

Sounds like I need to install TADS3 then instead.

What has to happen for this work on Glulx to happen? For me, it has been a big frustration for getting any sort of color working in any consistent way.

Don’t know about glulx or glk, but this sounds like another reason to separate UI from game development. Changing colors in FyreVM would be trivial although you’d have to define some kind of markup to relay the information. You’d end up with text like this:

say “<#F8F8F8>Now is the time for the text to change colors<#FFFFFF>”;

OR use HTML/CSS

say “Now is the time for the text to change colors”;

Whatever extension is devised to offer colorization would have to match up with the client, which I assume is the same problem in Glk. I’m guess Glk would look for 4-byte integers in the stream to identify color changes, but that’s not my area.

Speaking as someone who routinely uses more than one interpreter and is therefore dependant on games setting what they want instead of having to rely on every interpreter being updated… I’d rather see this on the game development side rather than the UI/terp side. That way the game displays properly everywhere.

It’s like CSS. Yeah, neat trick, but it only works on web browsers.

There is no solution that would not require updating every interpreter. At the moment Glulx supports only two custom styles; no matter how that will be changed, the interpreters will have to be updated to support the new system.

Well, there’s nothing that would prevent it from being used anywhere else. If the interpreters must be updated, it doesn’t really make a difference if the solution is to use CSS(-like syntax) or something else.

Nah. You can parse markup and implement it in any client. It’s just a contract that both the game and the UI need to agree upon.

Well the usage would still be in story development, but the implementation would be on the UI side. As the author, you’d just markup your text the same way you do now.

say “Now is the time for all [blue]men[black] to come to the aid of their country.”;

This would get compiled as something else, possibly CSS, but could be any type of markup or VM encoding.

I guess my separation argument is more about layout and user experience, less about text colors.

Not as it stands now, no. But if something were to change I’d rather see a change where the interpreters take the cues from the game rather than rely on an interpreter’s configuration, or an interpreter’s configuration file that may not necessarily work with another interpreter.

Of course, if I’m misunderstanding something - and DavidC’s later posts lead me to believe I am - I’ll just quietly withdraw while the grown ups talk. :slight_smile:

It seems that this is an itch that a lot of people have. Let’s go forward with scratching it.

I would suggest we agree on the I7 usage and then develop the appropriate extension to implement it for Glk. Given a standard, I can follow the same usage pattern for fyrevm.

In I7, would we have run-on color changes or encapsulated color changes? So [blue]word[black]word OR [blue]word[end blue] OR [blue]word[/blue] OR _____?

I assume we’d have to support RBG codes, (#000000 - #FFFFFF), so the I7 usage will need some help. I’d suggest a low-level I6 library of constants that defines color names that are usable in I7. If the author wants to add more color-names, they would need to define I6 constants and the I7 translation, but we’d implement the “standard colors” in:

w3schools.com/html/html_colornames.asp

I think we’d need glk_set_color(color) added to the glk specification.

Then we have to do something similar to Glulx Text Effects:

Table of color phrases
    hex           color
"#0000FF"	"[blue]"
"#000000"	"[black]"
    ...add all of the standard color codes...

I think that’s what’s needed…the glk_set_color() function may be more complicated than this…

Now I’m looking at the Glk source and slamming on the brakes…

It’s not that glk_set_color isn’t workable, it’s just incomplete. What is needed is almost a full blown font management library. I know the pattern is to hand off the actual font to the client, but maybe the author can set default or preferred fonts. Outside of the actual font, the author could recommend size, style, fore color, back color, decoration, etc.

A slightly less trivial implementation. (:

I think that we should just work on the CSS/JS Glk system. Improving the typographic options available would then become the responsibility of the game file (provided through extensions for the most part of course.) And much of what Glk currently provides could also be shifted to that, simplifying what needs to be implemented at the interpreter level.

Most Inform 7 effects are run on changes currently. It’s simpler for independent composition.

A small set of preconfigured named colours isn’t flexible enough. It should be possible to specify a decimal RGB (or HSB) colour value in I7.