package notty-community
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=b8cb51edb37d28d9d53e98ac52848677
sha512=8922a190a412790285603ba7ab37f9f58202d9406ebc9e6d3329189eac7fda5c25316264c27b6f7decb8f25f0d78801873b9f16c40e90f020e2c06ab9d058686
doc/notty-community.unix/Notty_unix/index.html
Module Notty_unix
Source
Notty
IO for pure Unix
.
This is an IO module for Notty
.
%%VERSION%% — homepage
Fullscreen input and output
Inline output
These operations do not assume exclusive access to the output. This means that they can be combined with other means of producing output. At the same time, it means that they are affected by the current terminal state, and that this state is not tracked.
winsize fd
is Some (columns, rows)
, the current dimensions of fd
's backing tty, or None
, when fd
is not backed by a tty.
eol image
is image
, producing an extra newline when printed.
output_image ?cap ?fd image
writes image
to fd
.
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.
~cap
is the optional terminal capability set.
~fd
defaults to stdout
.
val output_image_size :
?cap:Notty.Cap.t ->
?fd:out_channel ->
((int * int) -> Notty.image) ->
unit
output_image_size ?cap ?fd f
is output_image ?cap ?fd (f size)
where size
are fd
's current output dimensions.
If fd
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.
show_cursor ?cap ?fd visible
toggles the cursor visibility on fd
.
val move_cursor :
?cap:Notty.Cap.t ->
?fd:out_channel ->
[ `Home | `By of int * int | `To of int * int ] ->
unit
move_cursor ?cap ?fd motion
moves the cursor on fd
.
motion
is one of:
`To (column, line)
, positioning the cursor to(column, line)
. Origin is(0, 0)
, the upper-left corner of the screen.`Home
, moving the cursor the beginning of line.`By (columns, lines)
, moving the cursorcolumns
to the right (left if negative) andlines
down (up if negative).Note Behavior is terminal dependent if the movement overshoots the output size.
Capability detection
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.