| 1 |
The Command-Line User Interface Term::Clui |
| 2 |
|
| 3 |
NEW ! Now with mouse ! |
| 4 |
NEW ! Now with speech ! |
| 5 |
|
| 6 |
Term::Clui offers a high-level user interface, with subroutines &choose |
| 7 |
&ask &edit &view &confirm and &sorry. It works at a higher level than |
| 8 |
widgets; it gives command-line applications a consistent "look and feel". |
| 9 |
Its metaphor for the computer is a human-like conversation-partner, |
| 10 |
and as each answer/response is completed it is summarised onto one line, |
| 11 |
and remains on screen, so that the history of the dialogue gradually |
| 12 |
accumulates on the screen and is available for review, or for cut/paste. |
| 13 |
Also included is the file-selector module Term::Clui::FileSelect, |
| 14 |
with its main subroutine &select_file. Term::Clui doesn't yet work |
| 15 |
under Windows. |
| 16 |
|
| 17 |
To install just: |
| 18 |
perl Makefile.PL ; make ; make install |
| 19 |
|
| 20 |
For up-to-date source, see http://search.cpan.org/~pjb |
| 21 |
|
| 22 |
|
| 23 |
&edit and &view use the default EDITOR and PAGER from the user's |
| 24 |
environment, except that if &view is called with a very short text |
| 25 |
a builtin viewer is used, allowing the user to choose whether the |
| 26 |
text remains on-screen or is cleared. |
| 27 |
|
| 28 |
&confirm expects Y,y,N or n. &ask respects left and right arrows |
| 29 |
and backspace, ctrl-B moves to the beginning, ctrl-E to the end, |
| 30 |
and ctrl-D or ctrl-X clear the current string. |
| 31 |
|
| 32 |
&choose maintains a DBM database of what the user chose last time in |
| 33 |
response to the same question, and if it's still in the list this |
| 34 |
time then &choose highlights it as the default. Thus &choose manages |
| 35 |
its own defaults, and menus using Term::Clui autoconfigure themselves |
| 36 |
to the user's preferences. When &choose is called in an array context, |
| 37 |
it offers the user a multiple choice; mouse-button3 or the Spacebar |
| 38 |
mark items in a multiple choice. If the choices won't fit on the |
| 39 |
screen the user is asked for a substring clue. |
| 40 |
|
| 41 |
The programmer can pass &ask a default string, as an optional second |
| 42 |
argument. &select_file obeys options modelled after those of |
| 43 |
Tk::FileDialog.pm and Tk::SimpleFileSelect.pm |
| 44 |
|
| 45 |
Term::Clui is fast, very easy for both programmer and user, and has |
| 46 |
few external dependencies. It doesn't use curses which is a whole-of |
| 47 |
-screen interface; it uses a portable subset of vt100 sequences (up |
| 48 |
left right normal reverse clrtoeol and mouse-reporting). It handles |
| 49 |
window size changes, using Term::ReadKey or Term::Size if available; |
| 50 |
if not, it tries `tput`. |
| 51 |
|
| 52 |
For the user, Version 1.50 introduced a significant upgrade: mouse- |
| 53 |
-handling. The user can now select an item in &choose using the mouse |
| 54 |
and left-click, as well as by using the arrowkeys and return as before |
| 55 |
(or q or ctrl-X to quit); button3 or the spacebar mark items in a |
| 56 |
multiple choice. Since version 1.62, mouse-handling can be disabled |
| 57 |
by setting CLUI_MOUSE=OFF; by default, it is on. |
| 58 |
|
| 59 |
Since version 1.60, a speaking interface is provided for the visually |
| 60 |
impaired user. It employs either eflite or espeak. Speech is turned |
| 61 |
on if the CLUI_SPEAK environment variable is set to a non-empty string; |
| 62 |
by default, it is off. If speakup is running, then it is silenced |
| 63 |
while Term::Clui runs, and then restored. Because Term::Clui's |
| 64 |
metaphor for the computer is a human-like conversation-partner, this |
| 65 |
works very naturally, and the application needs no modification. |
| 66 |
|
| 67 |
A calling-interface-compatible Python3-module is included. |
| 68 |
|
| 69 |
Peter Billam http://www.pjb.com.au/comp/contact.html |