class BBS::Petscii::CanvasMenu

A BBS::Selector drawn on a BBS::Petscii::Canvas: the cursor menu of a graphics screen of a C64 board, in the uppercase/graphics set. The keys and the items are the Selector’s (CRSR, RETURN, an item’s key, RUN/STOP or ← for back, numbers, columns, pages, the about and status rows); only the drawing differs: the lit item is a reversed bar in its own colour, and each change goes out as raw PETSCII, the spans of the rows that changed, through session.write_raw.

The menu takes the rectangle at row, col (0-based), width columns wide, of the canvas the board draws its screen on. Either the board draws the whole screen first (paint the menu onto the canvas, send the canvas’s frame, then run(drawn: true)), or run paints the menu and sends its rows itself.

The colours (colors and an Item’s color) are C64 colours: a BBS::Petscii::Canvas code, a name (:yellow) or a colour of the palette (BBS::Petscii::Colors, YE); the roles default to the Selector’s COLORS.

canvas = BBS::Petscii::Canvas.new
house.draw_canvas(canvas)                      # a BBS::Art
items = [BBS::Selector.item('CORK BOARD', key: 'm', value: :boards, color: :light_blue),
         BBS::Selector.item('GAMES ROOM', key: 'r', value: :doors, color: :orange),
         BBS::Selector.item('LEAVE', key: 'q', value: :quit)]
menu = BBS::Petscii::CanvasMenu.new(session, items, canvas: canvas, row: 12, col: 1,
                                    width: 36, columns: 2, hint: 'CRSR: CHOOSE  RETURN: OPEN')
menu.paint
session.write_raw(canvas.frame)
choice = menu.run(drawn: true)

With idle seconds and a block the menu animates while the caller thinks: the block is called each time idle seconds pass without a key and returns the bytes to send (or nil); a key stops waiting at once.