class BBS::Selector

A menu at the cursor for a line-by-line board, on a Commodore 64 and a modern terminal alike: the items one under the other (in one column or several, or side by side on one row), the chosen one lit as a reversed bar that the cursor keys move. RETURN takes the lit item; an item’s own key (a letter or a digit) takes it at once, so a caller who knows the menu types as before. With numbers the items are numbered instead, and the digits typed light the item of that number. More items than a page holds turn into pages.

Like BBS::Field it draws from where the cursor is (at the start of a line) downwards and moves with a BBS::Cursor, so a C64 never gets HOME; after the choice the cursor is on the line under the menu.

Under the items it can show two more rows: the lit item’s about, when an item has one, and a status row with the hint, the number being typed and the page.

Keys:

cursor up, down

the item before, after (down a column, then on to the next one and across the pages)

cursor left, right

on one row the item before, after; in columns the item beside it; otherwise the page before, after

+, -, PgUp, PgDn

the page before, after

HOME, END

the first, the last item

RETURN

takes the lit item

an item’s key

takes that item

digits

with numbers: lights the item of that number

RUN/STOP, ←, Esc

returns back

items = [BBS::Selector.item('latest posts', key: 'l', value: :latest),
         BBS::Selector.item('log off', key: 'q', value: :quit)]
case BBS::Selector.new(session, items, width: 38).run
when :latest then latest
when :quit, nil then return
end