Copyright © 2002, Chris Gonnerman
All Rights Reserved
This package includes the package anycons, which implements a
very simple screen I/O API for both Win32 and Unix. You need either
a working curses installation or a working WConio installation
for anycons to be useful. Other backends are certainly possible.
Updates
Version 1.1 supports the following special keys: ins (insert),
del (delete), home, end, pgup, pgdn, up, down, left, right, and numbered
function keys. Other special keys may be handled, but this set works on
all supported platforms (well, both of them anyway). The short key names
listed will be returned from Read() as strings; for instance Page Down
is returned as "pgdn". This update also fixes a bug in the curses backend.
Installation
After unpacking the source distribution, run the following from the
command line:
python Setup.py install
Usage
First you must import anycons. Even though this is distributed as
a package, anycons is used as a module. The following module-level
functions are provided:
anycons.Init() should be called to set up the display. This
includes initializing the backend, setting terminal modes, etc.
The screen should be cleared by this function, but this function
should not be called just to clear the screen (see below).
anycons.Close() performs any needed display cleanup. It is
not required to clear the screen but should leave the terminal usable.
Programs must call this function! In particular, the curses backend
will leave the terminal input munged if you don't.
anycons.Clear() clears the screen and homes the cursor.
anycons.Read() reads one character from the keyboard.
The return from this function will always be a string; special keys
will be returned as strings of multiple characters.
The character/key pressed is not echoed to the display.
anycons.Write(stringvalue) writes the given string to the display.
Handling of '\n' will be as for '\r\n'; '\r' alone may not be handled
correctly, but '\b' should be. Other special character handling is
undefined (i.e. don't do it).
anycons.Goto(x, y) moves the cursor to column x, row y of the
display. All displays have (0, 0) origin and are assumed to have at
least 80 columns and 24 rows; anything beyond that is undefined.
|