GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Term::Screen(3) User Contributed Perl Documentation Term::Screen(3)

Term::Screen - A Simple all perl Term::Cap based screen positioning module

   require Term::Screen;

   $scr = Term::Screen->new();
   unless ($scr) { die " Something's wrong \n"; }
   $scr->clrscr();
   $scr->at(5,3);
   $scr->puts("this is some stuff");
   $scr->at(10,10)->bold()->puts("hi!")->normal();
      # you can concatenate many calls (not getch)
   $c = $scr->getch();      # doesn't need Enter key 
   ...
   if ($scr->key_pressed()) { print "ha you hit a key!"; }

Term::Screen is a very simple screen positioning module that should work wherever "Term::Cap" does. It is set up for Unix using stty's but these dependences are isolated by evals in the "new" constructor. Thus you may create a child module implementing Screen with MS-DOS, ioctl, or other means to get raw and unblocked input. This is not a replacement for Curses -- it has no memory. This was written so that it could be easily changed to fit nasty systems, and to be available first thing.

The input functions getch, key_pressed, echo, and noecho are implemented so as to work under a fairly standard Unix system. They use 'stty' to set raw and no echo modes and turn on auto flush. All of these are 'eval'ed so that this class can be inherited for new definitions easily.

Term::Screen was designed to be "required", then used with object syntax as shown above. One quirk (which the author was used to so he didn't care) is that for function key translation, no delay is set. So for many terminals to get an esc character, you have to hit another char after it, generally another esc.

Term::Screen has a very minimal set of of fixed character terminal position and character reading commands:
new()
Initialize the screen. Does not clear the screen, but does home the cursor.
term(term)
Sets or Gets the Term::Cap object used by this object.
rows(rows)
Returns and/or sets the number of rows on the terminal.
cols(cols)
Returns and/or sets the number of cols on the terminal.
at(row,col)
Moves cursor to (row,col) where (0,0) is upper left corner, - if the spot is illegal does whatever 'cm' in termcap does, since that is what it uses.
resize(r,c)
Tell screen the new number of rows & cols physically you can skip the r & c and get new checked vals from stty or termcap. Term::Screen does not handle resize signals internally, but you can do it by checking and updating screen size using this function.
normal()
Turn off any highlightling (bold, reverse)
bold()
The md value from termcap - turn on bold usually
reverse()
The mr value from termcap - turn on reverse text often. these last two default to whatever is available.
curvis()
The vs value from termcap - make cursor very visible
curinvis()
The vi value from termcap - make cursor invisible
clrscr()
Clear the screen and home cursor
clreol()
Clear to the end of the line - cursor doesn't move
clreos()
Clear to end of screen - right and down, cursor doesn't move.
il()
Insert blank line before line cursor is on, moving lower lines down.
dl()
Delete line cursor is on, moving lower lines up.
ic_exists()
Insert character option is available.
ic()
Insert character at current position move rest to the right.
dc_exists()
Delete char option exists and is available.
dc()
Delete character at current position moving rest to the left.

The following are the I/O functions. They provide standard useful single character reading values. getch returns either a single char or the name of a function key when a key is pressed. The only exception is when you hit a character that is the start of a function key sequence. In this case getch keeps waiting for the next char to see if it is fn key. Generally this is the escape key, and why you need to hit esc twice. To get a stright char, just use the regular 'gets' perl function. You will need to echo it yourself if you want.

puts(str)
Prints $s and returns the screen object. Used to do things like "$scr-"at(10,0)->puts("Hi!")->at(0,0);>. You can just use print if you want.
getch()
Returns just a char in raw mode. Function keys are returned as their capability names, e.g. the up key would return "ku". See the "get_fn_keys" function for what a lot of the names are. This will wait for next char if in a possible fn key string, so you would need to type 'esc' 'esc' most likely to get out of getch, since 'esc' is usually the leading char for function keys. You can use perl's getc, to go 'underneath' getch if you want. See the table in Screen::get_fn_keys() for more information.
def_key('name','input string')
Lets you define your own function key sequence. 'name' is what will be returned by getch. 'input string' is what the fn key sends literally. This will override any prev definitions of the input. A whole bunch of defaults are defined for xterms rxvt's, etc. in the get_fn_keys function.
key_pressed([sec])
Returns true if there is a character waiting. You can pass an option time in seconds to wait.
echo()
Tells getch to echo the input to the screen. (the default.)
noecho()
Tells getch NOT to echo input to the screen.
flush_input()
Clears input buffer and removes any incoming chars.
stuff_input(str)
Lets you stuff chars into the input buffer to be read like keystrokes. This is only the "getch" method buffer, the underlying getc stuff is not touched.

<https://github.com/jonathanstowe/Term-Screen>

Term::Screen.pm by Mark Kaehny (kaehny@execpc.com) Currently maintained by Jonathan Stowe <jns@gellyfish.co.uk>

Please see the README file in the distribution kit for the license details for this module.

Term::Cap, termcap, curses, stty, select
2016-12-04 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.