Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
Term::Form(3)	      User Contributed Perl Documentation	 Term::Form(3)

NAME
       Term::Form - Read lines from STDIN.

VERSION
       Version 0.528

SYNOPSIS
	   my $aoa = [
	       [ 'name'		  ],
	       [ 'year'		  ],
	       [ 'color', 'green' ],
	       [ 'city'		  ]
	   ];

	   # Object-oriented interface:

	   use Term::Form;

	   my $new = Term::Form->new();

	   my $line = $new->readline( 'Prompt: ', { default => 'abc' } );

	   my $modified_list = $new->fill_form(	$aoa );

	   # Functional	interface:

	   use Term::Form qw( read_line	fill_form );

	   my $line = read_line( 'Prompt: ', { default => 'abc'	} );

	   my $modified_list = fill_form( $aoa );

DESCRIPTION
       "readline" reads	a line from STDIN. As soon as "Return" is pressed
       "readline" returns the read string without the newline character	- so
       no "chomp" is required.

       "fill_form" reads a list	of lines from STDIN.

       This module is intended to cope with Unicode (multibyte
       character/grapheme cluster).

       The output is removed after leaving the method, so the user can decide
       what remains on the screen.

   Keys
       "BackSpace" or "Ctrl-H":	Delete the character behind the	cursor.

       "Delete"	or "Ctrl-D": Delete  the  character at point.

       "Ctrl-U": Delete	the text backward from the cursor to the beginning of
       the line.

       "Ctrl-K": Delete	the text from the cursor to the	end of the line.

       "Right-Arrow": Move forward a character.

       "Left-Arrow": Move back a character.

       "Home" or "Ctrl-A": Move	to the start of	the line.

       "End" or	"Ctrl-E": Move to the end of the line.

       "Up-Arrow": in "fill_form" move up one row, in "readline" move back 10
       characters.

       "Down-Arrow": in	"fill_form" move down one row, in "readline" move
       forward 10 characters.

       "Ctrl-X": If the	input puffer is	not empty, the input puffer is
       cleared,	else "Ctrl-X" returns nothing (undef).

       Only in "fill_form":

       "Page-Up" or "Ctrl-B": Move back	one page.

       "Page-Down" or "Ctrl-F":	Move forward one page.

METHODS
   new
       The "new" method	returns	a "Term::Form" object.

	   my $new = Term::Form->new();

       To set the different options it can be passed a reference to a hash as
       an optional argument.

   readline
       "readline" reads	a line from STDIN.

	   $line = $new->readline( $prompt, [ \%options	] );

       The fist	argument is the	prompt string.

       The optional second argument is the default string (see option default)
       if it is	not a reference. If the	second argument	is a hash-reference,
       the hash	is used	to set the different options. The keys/options are

       o   clear_screen

	   If enabled, the screen is cleared before the	output.

	   0 - off

	   1 - on

	   default: 0

       o   color

	   Enables the support for color and text formatting escape sequences
	   for the prompt string and the info text.

	   0 - off

	   1 - on

	   default: 0

       o   info

	   Expects as is value a string. If set, the string is printed on top
	   of the output of "readline".

       o   default

	   Set a initial value of input.

       o   no_echo

	   - if	set to 0, the input is echoed on the screen.

	   - if	set to 1, ""*""	are displayed instead of the characters.

	   - if	set to 2, no output is shown apart from	the prompt string.

	   default: 0

       o   show_context

	   Display the input that does not fit into the	"readline" before or
	   after the "readline".

	   0 - disable show_context

	   1 - enable show_context

	   default: 0

       o   codepage_mapping

	   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.

	   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

	   default: 0

       o   hide_cursor

	   0 - disabled

	   1 - enabled

	   default: 1

   fill_form
       "fill_form" reads a list	of lines from STDIN.

	   $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).

       The optional second argument is a hash-reference. The keys/options are

       o   clear_screen

	   If enabled, the screen is cleared before the	output.

	   0 - off

	   1 - on

	   default: 0

       o   color

	   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.

	   0 - off

	   1 - on

	   default: 0

       o   info

	   Expects as is value a string. If set, the string is printed on top
	   of the output of "fill_form".

       o   prompt

	   If prompt is	set, a main prompt string is shown on top of the
	   output.

	   default: undefined

       o   auto_up

	   With	auto_up	set to 0 or 1 pressing "ENTER" moves the cursor	to the
	   next	line (if the cursor is not on the "back" or "confirm" row). If
	   the last row	is reached, the	cursor jumps to	the first data row if
	   "ENTER" is pressed.	While with  auto_up set	to 0 the cursor	loops
	   through the rows until a key	other than "ENTER" is pressed with
	   auto_up set to 1 after one loop an "ENTER" moves the	cursor to the
	   top menu entry ("back") if no other key than	"ENTER"	was pressed.

	   With	auto_up	set to 2 an "ENTER" moves the cursor to	the top	menu
	   entry (except the cursor is on the "confirm"	row).

	   If auto_up is set to	0 or 1 the initially cursor position is	on the
	   first data row while	when set to 2 the initially cursor position is
	   on the first	menu entry ("back").

	   default: 1

       o   clear_screen

	   If enabled, the screen is cleared before the	output.

	   default: disabled

       o   read_only

	   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

       o   confirm

	   Set the name	of the "confirm" menu entry.

	   default: "Confirm"

       o   back

	   Set the name	of the "back" menu entry.

	   The "back" menu entry can be	disabled by setting back to an empty
	   string.

	   default: "Back"

       o   codepage_mapping

	   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.

	   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

	   default: 0

       o   hide_cursor

	   0 - disabled

	   1 - enabled

	   default: 1

       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.

REQUIREMENTS
   Perl	version
       Requires	Perl version 5.8.3 or greater.

   Terminal
       It is required a	terminal which uses a monospaced font.

       Unless the OS is	MSWin32	the terminal has to understand ANSI escape
       sequences.

   Encoding layer
       It is required to use appropriate I/O encoding layers. If the encoding
       layer for STDIN doesn't match the terminal's character set, "readline"
       will break if a non ascii character is entered.

SUPPORT
       You can find documentation for this module with the perldoc command.

	   perldoc Term::Form

AUTHOR
       MatthAxus Kiem <cuer2s@gmail.com>

CREDITS
       Thanks to the Perl-Community.de <http://www.perl-community.de> and the
       people form stackoverflow <http://stackoverflow.com> for	the help.

LICENSE	AND COPYRIGHT
       Copyright 2014-2020 MatthAxus 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.

perl v5.32.0			  2020-04-21			 Term::Form(3)

NAME | VERSION | SYNOPSIS | DESCRIPTION | METHODS | REQUIREMENTS | SUPPORT | AUTHOR | CREDITS | LICENSE AND COPYRIGHT

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=Term::Form&sektion=3&manpath=FreeBSD+12.2-RELEASE+and+Ports>

home | help