module BBS::Selector::Cells
What a Selector shows, as segments: [text, colour, reversed], the colour a role of Selector::COLORS or an itemβs own. The layout (Columns or Row) asks for the cells; the painter (the Selector on an ANSI line, a BBS::Petscii::CanvasMenu on a canvas) draws them.
Public Instance Methods
Source
# File lib/bbs/selector/cells.rb, line 23 def across_cells fitting = fitting_items pad = @width - fitting.sum { |item, _| word(item).length + 2 } fitting.flat_map { |item, i| across_cell(item, i) } << [' ' * pad, :text] end
The items on one row as segments, each a key letter and its label, the lit one a bar; the items that do not fit are left off.
Source
# File lib/bbs/selector/cells.rb, line 13 def cell(index, width) item = @items[index] return [[' ' * width, :text]] unless item return [[label(" #{item.label}", width), :heading]] if item.heading item_cell(item, index, width) end
Item index as a cell width wide, a list of segments (see #paint): blank past the last item, a heading in its colour, the lit one as a bar of plain text, the others as a key and a label.