As I poke at a (global style $) predicate for Dialog, my tests have produced some weird results in terms of overall screen background color (that is, the background of the parts of the screen beyond the text being printed).
The Standard doesn’t seem to say anything about this. Is there an informal/de facto standard for what causes the entire screen to change color, rather than just one line of it?
I’m currently testing in Gargoyle and ncurses Frotz.
Hmm, so Gargoyle is not following the spec, and Frotz…I honestly don’t know what’s going on there. I’ll tinker with that a bit more before showing my results and make sure it’s not a bug in my code.
This makes sense with the knowledge that it updates the screen color on each @get_key, though it’s notable that updating the screen to a non-default color applies to previous default-colored text, but updating it to a default color does not apply to previous non-default-colored text.
(In other words, when I make the screen red-on-blue, the previous white-on-black text changes, but when I make the screen white-on-black, the previous red-on-blue text doesn’t change.)
The third of these is the one I don’t understand. Clearing the screen filled the whole terminal with blue, which I expected. But it seems like further printing is in default white-on-black, as if clearing the screen also reset the colors.
If this is expected behavior, I can work around it in the compiler (make it output another @set_color opcode after each reset; the current colors are stored in registers). But I’m confused as to why it’s happening. I don’t think my Z-code is resetting the colors, because it doesn’t happen in Gargoyle.
Note that back when these opcodes were invented, far from all platforms could select the background colour freely per character. Typical 8-bit platforms would have the same background colour for the entire screen. This is what you get in Ozmoo as well.
I want to call this a straight-up bug in Frotz, since the spec doesn’t say that clearing the screen should reset the colors. But I guess it also doesn’t say that clearing the screen shouldn’t reset the colors…
Anyway, whether it’s a bug or not, I can work around it easily enough. Dialog’s Z-machine backend now runs another @set_color or @set_true_color after clearing the screen, and this produces the expected behavior on both Gargoyle and Frotz.
Somewhat recently, we discovered that one of the popular modern interpreters (Bocfel maybe?) reset the foreground colour but not the background colour, or the other way around, when performing a restart.