NAME

Game::Terminal::Kit::Line - a line of text typed a key at a time

VERSION

Version 0.05

SYNOPSIS

use Game::Terminal::Kit::Line;

my $line = Game::Terminal::Kit::Line->new(prompt => 'seed: ', head => \@board);
my ($event, $text) = $line->run($keys, $screen);
use_seed($text) if $event eq 'chosen';

DESCRIPTION

A game that reads a key at a time cannot read a line the usual way: nothing is echoed and backspace is just another key. This is the line done by hand. A printable key is added to the text, backspace takes the last one off, enter is the answer and escape gives up.

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

ATTRIBUTES

prompt

What is drawn before the text.

text

What has been typed so far. Give it a value to start with one.

limit

The most characters taken; 0, the default, is no limit.

Lines drawn above the prompt, an array reference: the board, or the form the line belongs to.

screen

Not used by a line; there so every widget has one.

METHODS

lines

The head, then the prompt and the text on one line.

step

my ($event, $value) = $line->step($key);

chosen and the text on enter, back on escape, quit when the input ends, changed when the text changed, and none for a key that does nothing: a backspace with nothing to take, a key past the limit, a key with a name.

run

my ($event, $text) = $line->run($keys, $screen);

Draws and reads until the line is entered or given up.

SEE ALSO

Game::Terminal::Kit::Widget, "read_line" in Game::Terminal::Kit::Keys for a line read the usual way.

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)