Term::Form - Read lines from STDIN.
Version 0.554
my $aoa = [ [ 'name' ], [ 'year' ], [ 'color', 'green' ], [ 'city' ] ]; # Object-oriented interface: use Term::Form; my $new = Term::Form->new(); my $modified_list = $new->fill_form( $aoa ); # Functional interface: use Term::Form qw( fill_form ); my $modified_list = fill_form( $aoa );
fill_form reads a list of lines from STDIN.
fill_form
The output is removed after leaving the method, so the user can decide what remains on the screen.
readline has been moved to Term::Form::ReadLine.
readline
BackSpace or Ctrl-H: Delete the character behind the cursor.
BackSpace
Ctrl-H
Delete or Ctrl-D: Delete the character at point.
Delete
Ctrl-D
Ctrl-U: Delete the text backward from the cursor to the beginning of the line.
Ctrl-U
Ctrl-K: Delete the text from the cursor to the end of the line.
Ctrl-K
Right-Arrow or Ctrl-F: Move forward a character.
Right-Arrow
Ctrl-F
Left-Arrow or Ctrl-B: Move back a character.
Left-Arrow
Ctrl-B
Home or Ctrl-A: Move to the start of the line.
Home
Ctrl-A
End or Ctrl-E: Move to the end of the line.
End
Ctrl-E
Up-Arrow or Ctrl-S: Move up one row.
Up-Arrow
Ctrl-S
Down-Arrow or Ctrl-T: Move down one row.
Down-Arrow
Ctrl-T
Ctrl-X: Delete the text of the line.
Ctrl-X
Page-Up or Ctrl-P: Move to the previous page.
Page-Up
Ctrl-P
Page-Down or Ctrl-N: Move to the next page.
Page-Down
Ctrl-N
The new method returns a Term::Form object.
new
Term::Form
my $new = Term::Form->new();
To set the different options it can be passed a reference to a hash as an optional argument.
$new_list = $new->fill_form( $aoa, { prompt => 'Required:' } );
The first argument is a reference to an array of arrays. The arrays have 1 or 2 elements: the first element is the key and the optional second element is the value. The key is used as the prompt string for the "readline", the value is used as the default value for the "readline" (initial value of input).
When $aoa is return values of rows where nothing has been entered are set to the empty string.
$aoa
The optional second argument is a hash-reference. The hash-keys/options are:
0 - if the cursor is on a data row (that means not on the "back" or "confirm" menu entry), pressing ENTER moves the cursor to the next row. If ENTER is pressed when the cursor is on the last data row, the cursor jumps to the first data row. The initially cursor position is on the first data row.
ENTER
1 - if the cursor is on a data row, pressing ENTER moves the cursor to the next row unless the cursor is on the last data row. Then pressing ENTER moves the cursor to the "back" menu entry (the menu entry on the top of the menu). The initially cursor position is on the "back" menu entry.
2 - if the cursor is on a data row, pressing ENTER moves the cursor to the "back" menu entry. The initially cursor position is on the "back" menu entry.
default: 1
1
Set the name of the "back" menu entry.
The "back" menu entry can be disabled by setting back to an empty string.
default: Back
Back
If enabled, the screen is cleared before the output.
0 - off
1 - on
default: 0
0
This option has only meaning if the operating system is MSWin32.
If the OS is MSWin32, Win32::Console::ANSI is used. By default Win32::Console::ANSI converts the characters from Windows code page to DOS code page (the so-called ANSI to OEM conversion). This conversation is disabled by default in Term::Choose but one can enable it by setting this option.
Win32::Console::ANSI
Term::Choose
Setting this option to 1 enables the codepage mapping offered by Win32::Console::ANSI.
0 - disable automatic codepage mapping (default)
1 - keep automatic codepage mapping
Enables the support for color and text formatting escape sequences for the form-keys, the "back"-string, the "confirm"-string, the info text and the prompt text.
Set the name of the "confirm" menu entry.
default: Confirm
Confirm
0 - disabled
1 - enabled
Expects as is value a string. If set, the string is printed on top of the output of fill_form.
If prompt is set, a main prompt string is shown on top of the output.
default: undefined
Set a form-row to read only.
Expected value: a reference to an array with the indexes of the rows which should be read only.
default: empty array
To close the form and get the modified list (reference to an array or arrays) as the return value select the "confirm" menu entry. If the "back" menu entry is chosen to close the form, fill_form returns nothing.
Requires Perl version 5.10.0 or greater.
It is required a terminal which uses a monospaced font.
Unless the OS is MSWin32 the terminal has to understand ANSI escape sequences.
It is required to use appropriate I/O encoding layers. If the encoding layer for STDIN doesn't match the terminal's character set, fill_from will break if a non ascii character is entered.
fill_from
You can find documentation for this module with the perldoc command.
perldoc Term::Form
Matthäus Kiem <cuer2s@gmail.com>
Thanks to the Perl-Community.de and the people form stackoverflow for the help.
Copyright 2014-2023 Matthäus Kiem.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. For details, see the full text of the licenses in the file LICENSE.
To install Term::Form, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Term::Form
CPAN shell
perl -MCPAN -e shell install Term::Form
For more information on module installation, please visit the detailed CPAN module installation guide.