[comp.lang.perl] Curses and Perl

jukoff@imram.net.com (Steve Jukoff) (05/02/91)

I need to create an ASCII window-oriented set of programs.
The design is to be as simple and intuitive as possible,
allowing new and novice users to use it with little intruction.

Is there a method for accessing curses(3) and/or termcap/terminfo
databases from Perl.

Is there an (ASCII) screen-oriented menu program in PD-land?

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Steven Jukoff                 DDN:   jukoff@net.com       
Phone: 415-780-5819           uucp:  ames!unet!jukoff     
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

henkp@cs.ruu.nl (Henk P. Penning) (05/03/91)

In <1352@unet.UUCP> jukoff@imram.net.com (Steve Jukoff) writes:

>I need to create an ASCII window-oriented set of programs.
>The design is to be as simple and intuitive as possible,
>allowing new and novice users to use it with little intruction.
>
>Is there a method for accessing curses(3) and/or termcap/terminfo
>databases from Perl.

  There are two ways.
  1. Create a perl with curses built in to it.  I have never used this.
  2. Use my "cterm" package. It allows you to use (almost) full curses
     with a 'standard' perl. It consists of a curses-emulator running
     in a separate process, and an interface library.
     See below on how to get it.

>Is there an (ASCII) screen-oriented menu program in PD-land?

  I wrote a flat-file handler called "jinx" which uses "cterm".
  Jinx is menu driven, so it could serve as an example.

  Below is a message I posted earlier.

				===  HenkP  ===

Henk P. Penning, Dept of Computer Science, Utrecht University.
Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands.
Telephone: +31-30-534106
e-mail   : henkp@cs.ruu.nl (uucp to hp4nl!ruuinf!henkp)

-----------------------------------------------------------------

I have put together a system for manipulating simple databases.
It is called 'jinx'. I wrote it for the secretaries at our department.
Jinx is easy to use but has powerful relational facilities as well.

Jinx is an interactive, menu-driven program which handles databases
consisting of lists of records, each a list of fields.
In a given database, every record contains the same number of fields.
In short, a database is structured like the /etc/passwd file.
For each field a regexp may be specified which is used as a constraint on the
data which may be entered in the field. Users may override this constraint.

There is no limit on the number of records in a database,
or the number of fields in a record, or the length of a field.
A field may contain arbitrary ascii-printable data.
Jinx uses curses so it runs on any terminal or window of any size.
Jinx doesn't require a 'special' perl, plain PL.18+ will do.

With Jinx you can perform operations on a database like:
-- update, add, copy and delete records
-- test if all fields in all records match their associated regexp
-- select/delete a subset of the records by various means
-- put back some of the deleted records
-- sort the database on one or more key-fields
-- project on one or more columns
-- join with another database
-- add a column to the database (that is: add a field to every record)
-- insert some records from another database
-- test if some given combination of fields is uniq for all records
-- compute fields as a function of other fields in the record

A database is represented by two files, both of them ordinary, editable files.
A simple report generator is provided. Some of the main functions are available
as shell-callable perl scripts.

Jinx requires the 'cterm' package I posted earlier. Jinx and cterm are
available from our archive server archive.cs.ruu.nl (131.211.80.5).
If you have ftp, get 'cterm.shar.Z' and 'jinx.shar.Z' from directory 'pub/UNIX'.
If not, send a message to 'mail-server@cs.ruu.nl' containing the next 4 lines:
begin
send UNIX/cterm.shar
send UNIX/jinx.shar
end
The mail-server will send you the compressed, uuencoded stuff.
Jinx+tools+man+doc is about 4500 lines, (compressed 60 KB).
A jinx tutorial (in LaTeX) is included in the package.
A PostScript version is available in 'UNIX/jinx.ps' in our archive.

Please, try out Jinx and let me know what you think.

				===  HenkP  ===

PS. Jinx is distributed under the terms of the Gnu General Public Licence.

-- 
Henk P. Penning, Dept of Computer Science, Utrecht University.
Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands.
Telephone: +31-30-534106
e-mail   : henkp@cs.ruu.nl (uucp to hp4nl!ruuinf!henkp)

martelli@cadlab.sublink.ORG (Alex Martelli) (05/05/91)

jukoff@imram.net.com (Steve Jukoff) writes:
	...
:Is there an (ASCII) screen-oriented menu program in PD-land?

"shellforms", by Paul Lew, contributed in 1988 to comp.sources.misc (or was
it .unix?); simple to use, and functional; it can be embedded in a sh, csh,
or perl script.  Need a small patch to use with strict terminfo-based-curses:
a call to put_string must be exchanged to whatever-it-is-you-use-in-terminfo
for proper implementation of milliseconds delays, if you have them in your
terminfo description for the terminal you're using, or you end up with a 
screen full of '$<5>' etc; the only machine with this problem among the many
we use was the IBM RS6000, and the fix was easy to find, although I'm no
expert on SysV-curses; I can ferret it out if you need it.

May well not be the best solution for perl, but in our case we wanted to
enable people knowing only sh to quickly modify menu-based scripts, so sf
(shellforms) stood out a mile!