bufferPushScissorRect method
Pushes a clip rectangle onto buffer's native scissor stack.
Clips subsequent draws until the matching bufferPopScissorRect, except
transparent-background drawBox borders, which bypass the scissor.
Four properties surprise callers, all of them upstream behaviour:
- The push intersects with the current rectangle rather than replacing it, so nesting narrows and never widens.
- The stack is state on the native buffer, not on a view. It outlives
render()andresize(), because OpenTUI allocates its buffers once per renderer and never swaps them. Noir clears both stacks as each frame borrows its buffer, so an unpopped push corrupts only the frame that leaked it — but within a frame the pairing is the caller's. - It also clips writes made through Buffer.clipped, whose Dart-side rectangle is then no longer the only thing deciding what lands.
drawBoxwith a transparent background escapes it entirely: upstream writes those borders through an unchecked index.
Implementation
void bufferPushScissorRect(
OptimizedBufferHandle buffer,
int x,
int y,
int width,
int height,
) {
_checkSigned32Abi(x, 'x');
_checkSigned32Abi(y, 'y');
_checkUnsignedAbi(width, 0xFFFFFFFF, 'width');
_checkUnsignedAbi(height, 0xFFFFFFFF, 'height');
_guard('Failed to push scissor rect', () {
_native.bufferPushScissorRect(buffer.value, x, y, width, height);
});
}