Library
Module
Module type
Parameter
Class
Class type
.
Notty
IO for pure Unix
.
This is an IO module for Notty
.
module Term : sig ... end
Terminal IO abstraction for fullscreen, interactive applications.
These operations do not change the terminal state and do not assume exclusive access to the output. They can be combined with other means of producing output.
val winsize : Unix.file_descr -> (int * int) option
winsize fd
is Some (columns, rows)
, the current dimensions of fd
's backing tty, or None
, when fd
is not backed by a tty.
val output_image :
?cap:Notty.Cap.t ->
?chan:Pervasives.out_channel ->
Notty.image ->
unit
output_image ~cap ~chan i
writes the image i
to chan
.
The image is displayed in its full height. If the output is a tty, image width is clipped to the output width, otherwise, full width is used.
~chan
defaults to stdout
.
~cap
is the optional terminal capability set.
Note No leading or trailing characters are produced, so:
val output_image_size :
?cap:Notty.Cap.t ->
?chan:Pervasives.out_channel ->
((int * int) -> Notty.image) ->
unit
output_image_size ~cap ~chan f
is output_image ~cap ~chan (f size)
where size
are chan
's current output dimensions.
If chan
is not backed by a tty, as a matter of convenience, f
is applied to (80, 24)
. Use Unix.isatty
or winsize
to detect whether the output has a well-defined size.
val output_image_endline :
?cap:Notty.Cap.t ->
?chan:Pervasives.out_channel ->
Notty.image ->
unit
print_image_endline ~cap ~chan i
is output_image ~cap ~chan i
followed by a newline.
All image
output requires terminal capabilities.
When not provided, capabilities are auto-detected, by checking that the output is a tty, that the environment variable $TERM
is set, and that it is not set to either ""
or "dumb"
. If these conditions hold, ANSI escapes are used. Otherwise, no escapes are used.