NAME

Game::Terminal::Kit::Choose - one question with a few answers

VERSION

Version 0.05

SYNOPSIS

use Game::Terminal::Kit::Choose;

my $ask = Game::Terminal::Kit::Choose->new(
    question => 'Promote to',
    choices  => [
        [ q => 'a queen',  'nearly always' ],
        [ n => 'a knight', 'for the fork' ],
        [ r => 'a rook' ],
        [ b => 'a bishop' ],
    ],
);

my ($event, $piece) = $ask->run($keys, $screen);
promote($piece) if $event eq 'chosen';

DESCRIPTION

A question the game has to ask before it can go on: which side to play, what to promote to, whether to pass the keyboard. It is a Game::Terminal::Kit::Picker with the question above it, every answer drawn, and the keys a picker has.

It is one of the kit's widgets; see Game::Terminal::Kit::Widget.

ATTRIBUTES

question

The line above the answers.

choices

The answers, an array reference of [$value, $label, $about]: what comes back, what is drawn, and a few words beside it that may be left out.

at

The index of the answer under the cursor; the first by default.

legend

Lines below the answers. By default a blank line and the keys.

log

screen

A Game::Terminal::Kit::Log to draw and a Game::Terminal::Kit::Screen for colour, as for a picker.

picker

The picker underneath, built from the above.

METHODS

lines

step

run

my ($event, $value) = $ask->run($keys, $screen);

As for Game::Terminal::Kit::Picker: chosen with the value of the answer, back on escape, quit on q.

SEE ALSO

Game::Terminal::Kit::Picker, Game::Terminal::Kit::Widget.

AUTHOR

LNATION, <email at lnation.org>

LICENSE AND COPYRIGHT

This software is Copyright (c) 2026 by LNATION.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)