Did you know ... | Search Documentation: |
tty.pl -- Terminal operations |
This library package defines some common operations on terminals. It is based on the Unix termcap facility to perform terminal independant I/O on video displays. The package consists of three sections:
-------------------------------------------- | | | Title | | | | 1) Option One | | 2) Option Two | | 3) Quit | | | | Your Choice? * | | |
The user selects an item by pressing the number of the item, or the first letter of the option. If more then one option match, the common prefix of the matching options is given and the user is expected to type the next character. On illegal input the screen is flashed (or a beep is given if the terminal can't flash the screen).
Text fields (the title and option texts) are either plain atoms or terms Fmt/Args. In the latter case the argument is transformed into an atom using format/3.
The specification of an option is a term PrologName:UserName. PrologName is an atom, which is returned as choice if the user selects this menu item. UserName is processed as a text field (see above) and displayed. The entries are numbered automatically.
The example above could be defined as:
get_action(Choice) :- menu('Title', [ option_1 : 'Option One' , option_2 : 'Option Two' , quit : 'Quit' ], Choice).