- Documentation
- Reference manual
- Built-in Predicates
- Notation of Predicate Descriptions
- Character representation
- Loading Prolog source files
- Editor Interface
- List the program, predicates or clauses
- Verify Type of a Term
- Comparison and Unification of Terms
- Control Predicates
- Meta-Call Predicates
- Delimited continuations
- Exception handling
- Handling signals
- DCG Grammar rules
- Database
- Declaring predicate properties
- Examining the program
- Input and output
- Status of streams
- Primitive character I/O
- Term reading and writing
- Analysing and Constructing Terms
- Analysing and Constructing Atoms
- Localization (locale) support
- Character properties
- Operators
- Character Conversion
- Arithmetic
- Misc arithmetic support predicates
- Built-in list operations
- Finding all Solutions to a Goal
- Forall
- Formatted Write
- Global variables
- Terminal Control
- Operating System Interaction
- File System Interaction
- User Top-level Manipulation
- Creating a Protocol of the User Interaction
- Debugging and Tracing Programs
- Obtaining Runtime Statistics
- Execution profiling
- Memory Management
- Windows DDE interface
- Miscellaneous
- Built-in Predicates
- Packages
- Reference manual
4.34 Terminal Control
The following predicates form a simple access mechanism to the Unix termcap library to provide terminal-independent I/O for screen terminals. These predicates are only available on Unix machines. The SWI-Prolog Windows console accepts the ANSI escape sequences.
- tty_get_capability(+Name, +Type, -Result)
- Get the capability named Name from the termcap library. See
termcap(5) for the capability names. Type specifies the type
of the expected result, and is one of
string
,number
orbool
. String results are returned as an atom, number results as an integer, and bool results as the atomon
oroff
. If an option cannot be found, this predicate fails silently. The results are only computed once. Successive queries on the same capability are fast. - tty_goto(+X, +Y)
- Goto position (X, Y) on the screen. Note that the predicates line_count/2 and line_position/2 will not have a well-defined behaviour while using this predicate.
- tty_put(+Atom, +Lines)
- Put an atom via the termcap library function tputs(). This function decodes padding information in the strings returned by tty_get_capability/3 and should be used to output these strings. Lines is the number of lines affected by the operation, or 1 if not applicable (as in almost all cases).
- tty_size(-Rows, -Columns)
- Determine the size of the terminal. Platforms:
- Unix
- If the system provides ioctl calls for this, these are used and tty_size/2
properly reflects the actual size after a user resize of the window. The ioctl
is issued on teh file descriptor associated with the
user_input
stream. As a fallback, the system uses tty_get_capability/3 usingli
andco
capabilities. In this case the reported size reflects the size at the first call and is not updated after a user-initiated resize of the terminal. - Windows
- Getting the size of the terminal is provided for swipl-win.exe.
The requested value reflects the current size. For the multithreaded
version the console that is associated with the
user_input
stream is used.