Is it safe to enlarge the upper window while it has text in it?

Dialog tries to be a high-level language that hides Z-machine implementation details from authors. So when an author wants a status bar, they supply a block of (compile-time constant) CSS, and the compiler translates that into Z-machine instructions behind the scenes.

This gets messy, though, when the size of the status bar is not known at compile time. Right now, there’s a hacky way that authors can force the status bar to specific proportions. But it would be much more elegant if the compiler could accept height: auto; and make the status bar expand as needed to fit its contents.

The question is…is this legal on Z-machine? Can I reliably expand the upper window while it already has text in it without wrecking that existing text? (The spec “suggests that it should work as usual” to adjust the status bar height while currently printing to it, but a suggestion is not a rule.)

In particular, does this sample code work on all common interpreters? So far it seems to work fine in Gargoyle and Ncurses Frotz, the two that I have readily on hand.

Z-code file: statustest.z5 (1.5 KB)
Inform source:

[ Main;
	print "Main window one.^";
	@split_window 1; ! Make a one-line status bar
	@set_window 1;
	@set_cursor 1 1;
	print "First line.";
	@split_window 2; ! Two lines?
	@set_cursor 2 1;
	print "Second line.";
	@split_window 3; ! Three lines??
	@set_cursor 3 1;
	print "Third line.";
	@set_window 0;
	print "Main window two.^";
];

Ideally this should create a three-line status bar that says “First line. / Second line. / Third line.” What happens to the main-window text underneath varies by implementation and doesn’t really matter.

I believe it’s safe to do so. Re-splitting when there’s already a split should not erase any existing text.

Also note that the standard suggests that the interpreter should have the upper window auto-expand to make room for lines that the program prints which are too far down the screen to fit in the upper window. IIRC, the Nord & Bert statusline requires the interpreter to work like this, and many Inform 6 games print menus and box quotes that also rely on this mechanism.

1 Like

Spatterlight:

Parchment:

Lectrote:

(Lectrote has a purple overlay that shows up when the game ends.)

1 Like

It’s nice to see that they also preserve the main window text from before splitting! (Ncurses Frotz doesn’t.)

Windows Frotz:

iOS Frotz:

1 Like

The standard mentions that Sherlock miscalculates the upper window size and tries to place the cursor too low, and it is recommended to do an implicit split to contain the text. I think this probably implies not erasing the text aready printed. Also, nowhere in the description of a screen split is it mentioned that the contents of the screen change other than cursor locations. (Except v3 which explicitly clears the upper window when the split happens)

2 Likes

Fabularium (F-Droid)

1 Like