class BBS::FrameBuffer

An off-screen grid of character cells, each holding one character and the SGR escape sequence that styles it. Widgets and windows draw into a frame buffer with 1-based coordinates; diff then turns the changes since the previous frame into the ANSI bytes to send to the terminal.

Its class methods are rubbs’ one set of tools for ANSI text: ::plain, ::visible_width, ::clip_ansi and ::wrap_ansi (the one word-wrap).

buf = BBS::FrameBuffer.new(80, 24)
buf.box(x: 1, y: 1, width: 20, height: 5, title: 'Hello')
session.write(buf.diff(BBS::FrameBuffer.new(80, 24)))

Anything drawn outside the grid is clipped.