render method
Renders the current game state to the current terminal, if one is
currently bound to this UI. If manually calling render, you can request
that the UI render regardless of the current dirty state by setting
ignoreDirty
to true.
Implementation
void render([bool ignoreDirty = false]) {
if (!ignoreDirty && !_dirty) return;
// grab a ref to the current terminal so we can use it for this entire
// render step even if it changes
var term = _terminal;
// nothing to render if there is no bound terminal
if (term == null) return;
term.clear();
// find the first opaque layer
var i = _layers.length - 1;
while (i >= 0) {
if (!_layers[i].isTransparent) break;
i--;
}
if (i < 0) i = 0;
// render the top opaque layer and all above it
for (; i < _layers.length; i++) {
_layers[i].render(term);
}
term.render();
_dirty = false;
}