package notty
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=74659fb14073db4438989891ab24f24bef81aa497dac16d9a67f9a1c9c200824
sha512=6e21d44fe39f3d80884b87635bebae55cb2b931ef74f9184ba4d74cc3e51cb0b3e976c3b6dc61d377288504e8bfabe21acdc1069eacb30df1fbf6686b80f7c6b
doc/notty.unix/Notty_unix/index.html
Module Notty_unix
Source
Notty
IO for pure Unix
.
This is an IO module for Notty
.
v0.2.2-19-ge035d06 — 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.