I want the terminal widget to support printer spooling from terminal output streams. The public API should include type Printer interface { Print([]byte) }, type PrinterFunc func([]byte), and func (t *Terminal) SetPrinterFunc(printerFunc PrinterFunc) so an application can register a callback on a Terminal instance.
When a running terminal receives CSI print mode start ESC[5i, all following bytes should be collected as print data instead of being drawn into the terminal buffer. When CSI print mode end ESC[4i arrives, the terminal should stop collecting and call the registered printer exactly once with the collected bytes, excluding both control sequences. For example, if the stream contains abc ESC[5i def ESC[4i ghi, the visible terminal text should become abcghi and the printer callback should receive def.
The spooled payload must preserve bytes exactly, including UTF-8 text such as Hello, 世界!, single-byte data such as H\xe9llo, embedded ESC bytes that are not the terminating ESC[4i, and large binary payloads such as PDF data split across multiple reads. If print mode ends and no printer callback has been registered, the print payload should still be consumed and should not appear on screen.