package notty-community
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=b8cb51edb37d28d9d53e98ac52848677
sha512=8922a190a412790285603ba7ab37f9f58202d9406ebc9e6d3329189eac7fda5c25316264c27b6f7decb8f25f0d78801873b9f16c40e90f020e2c06ab9d058686
doc/notty-community.unix/Notty_unix/Term/index.html
Module Notty_unix.TermSource
Terminal IO abstraction for fullscreen, interactive applications.
This module provides both input and output. It assumes exclusive ownership of the IO streams between initialization and shutdown.
Representation of the terminal, giving structured access to IO.
Construction and destruction
val create :
?dispose:bool ->
?nosig:bool ->
?mouse:bool ->
?bpaste:bool ->
?input:Unix.file_descr ->
?output:Unix.file_descr ->
unit ->
tcreate ~dispose ~nosig ~mouse ~input ~output () creates a fresh terminal. It has the following side effects:
Unix.tcsetattris applied toinputto disable echo and canonical mode.outputis set to alternate screen mode, and the cursor is hidden. Mouse and bracketed paste reporting are (optionally) enabled.SIGWINCHsignal, normally ignored, is handled.
~dispose arranges for automatic cleanup of the terminal before the process terminates. The downside is that a reference to this terminal is retained until the program exits. Defaults to true.
~nosig additionally turns off signal delivery and flow control (isig and ixon) on input. Inhibits automatic handling of CTRL-{C,Z,\,S,Q}. Defaults to true.
~mouse activates mouse reporting. Defaults to true.
~bpaste activates bracketed paste reporting. Defaults to true.
~input is the input file descriptor. Defaults to stdin.
~output is the output file descriptor. Defaults to stdout.
Dispose of this terminal. Original behavior of input fd is reinstated, cursor is restored, mouse reporting disabled, and alternate mode is terminated.
It is an error to use the commands on a released terminal, and will raise Invalid_argument, while release itself is idempotent.
Commands
image t i sets i as t's current image and redraws the terminal.
refresh t redraws the terminal using the current image.
Useful if the output might have become garbled.
cursor t pos sets and redraws the cursor.
None hides it. Some (x, y) places it at column x and row y, with the origin at (0, 0), mapping to the upper-left corner.
Events
Wait for a new event. event t can be:
#Unescape.event, aneventfrom the input fd;`Endif the input fd is closed, or the terminal was released; or`Resize (cols, rows)giving the current size of the output tty, if aSIGWINCHwas delivered before or during this call toevent.
Note event is buffered. Calls can either block or immediately return. Use pending to detect when the next call would not block.
pending t is true if the next call to event would not block and the terminal has not yet been released.
Properties
fds t are t's input and output file descriptors.