package notty
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=00c77c02497cb8c9eeba338d75f4b11c471253467e8742ead1e7fc1afaabae71
md5=f85f6d0099483230b2b60335ab4496d1
Description
Notty is a declarative terminal library for OCaml structured around a notion of composable images. It tries to abstract away the basic terminal programming model, providing a simpler and a more expressive one.
Published: 06 Nov 2017
README
Notty — Declaring terminals
Notty is a declarative terminal library for OCaml structured around a notion of composable images. It tries to abstract away the basic terminal programming model, providing a simpler and a more expressive one.
The core layout engine and IO codecs are pure platform-independent OCaml. Distribution includes modules with input and output facilities for Unix, and Lwt on Unix.
As an attempt to redefine terminal programming, Notty has to be opinionated. It assumes Unicode throughout, does not have universal support for various terminals out there, and has a peculiar programming and rendering model.
Notty's core API was heavily influenced by Haskell's Vty.
Where to start
Check out the documentation, examples, or peek directly into the interface file.
Building with pkg/pkg.ml build --with-lwt true --examples true
will produce several little example programs that also double as tests.
(* Game of Life with ZX Spectrum kitsch. *)
let dot : image = I.uchar A.(fg lightred) (Uchar.of_int 0x25cf) 1 1
let background step (n, m) =
let k = 24. *. sin (float (step + m + n) /. 10.) |> truncate in
if k > 0 then I.char A.(fg (gray k)) '.' 1 1 else I.void 1 1
let render (w, h) step life : image =
I.tabulate w (h - 1) @@ fun x y ->
let pt = (x, y) in
if CSet.mem pt life then dot else background step pt
Why?
Notty?
Terminals are tedious to program for. Notty tries to abstract the tedium away, leaving you with a more pleasant programming surface that's quite unlike a TTY. Hence, No-TTY.
Why make yet another terminal library?
Because:
It allows one to describe what should be seen, as opposed to commanding a terminal.
It's pretty compact. Both bells and whistles can be implemented separately.
Core is easy to glue onto various IO backends.
Pure platform-independent OCaml.
Dependencies (9)
-
uutf
>= "1.0.0"
-
uuseg
>= "1.0.0"
-
uucp
>= "2.0.0"
- uchar
-
ocb-stubblr
build & >= "0.1.0"
-
topkg
build
-
ocamlfind
build
-
ocamlbuild
build
-
ocaml
>= "4.03.0" & < "4.14"
Dev Dependencies
None
Used by (13)
- bechamel-notty
- camels
- docfd
- git-split
- git_split
- hardcaml_waveterm
- nottui
- nottui-lwt
- nottui-pretty
- notty_async
-
ocal
>= "0.2.1"
- teash
-
xapi-stdext-encodings
>= "4.22.0"
Conflicts (3)
-
lwt
>= "5.0.0"
-
lwt
< "2.6.0"
-
ocb-stubblr
< "0.1.0"