NAME
Term::Graille::IO
Allows user interaction in Graille Applications (or perhaps on any pterminal application). Depends on Term::ReadKey and Time::HiRes; When integrated with Term::Graille::Menu allows a modal drop down menu that
SYNOPSIS
my $io=Term::Graille::IO->new();
$io->addAction( # add action for key press
"Am", # Am is returned for up arrow
{note=>"up arrow:cursor up ", # For drawing a menu
proc=>sub{my $self.@args)=@_ ...} # the action
} );
$io->run($io,@args); # start trapping keypresses
...
$io->stop(); # stop
FUNCTIONS
my $io=Term::Graille::IO->new(%params)
Creates a new IO object for user interaction. Three modes are available; free
, means the key presses are captured and not echoed, menu
requires the setting of $io->{menu}
, using $io->addMenu($menu), and
normal
when the key presses are read normally
my $io->addMenu($menu,$trigger)
Uses a topbar dropdown menu of class Term::Graille::Menu. If $trigger
is specified that activates or deactivates the menu; if not specified the 'm' key activates the menu.
my $io->addAction($menu,$key,$actionData)
Determines what happens when a key is pressed in free
mode. Functions in the users scripts have to be "fully qualified" e.g. &main::function()
$io->addAction("s",{note=>"s key saves sprite",proc=>sub{
my ($self,$canvas,$sprite,$cursor)=@_; # these are the objects passed as parameters
&main::saveSprite($sprite);
&main::flashCursor($sprite,$cursor);
&main::restoreIO();},} );
my $io->run($io,@objects)
Iniiating the capture of the key presses may trigger actions. These actions may need parameters including the $io object itself, it is useful to select all possible objects that may need to be passed to the anonymous subroutines added by addAction
above.
my $io->startMenu()
Starts a menu as described in Term::Graille::Menu. The $io object enters a "menu" mode when Arrow, Enter and the Trigger key (see above) are passed to the Menu object
my $io->stopMenu()
Stops menu and returns to free
mode
my $io->stop()
stops capturing key presses and enters normal mode. Useful for exeample, when the user needs to enter data
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 41:
Unterminated C<...> sequence