package matrix

Build not yet checked
  1. Overview
  2. Docs
Fast, modern terminal toolkit for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

mosaic-0.3.0.tbz
sha256=a92cbbcbe016fb19fb0a749222da0e459a9567aef3f4c7340d9bd6b71c53ed6f
sha512=6a7ab054605538bb31a2b73a1a6d093981a2704c9f0af5852221c05735290d74aca7c7282298c4d0f91e86a800e2ccd94b4918af883cd963449c758eb6b272b3

doc/matrix.input/Matrix_input/index.html

Module Matrix_inputSource

Terminal input, read into keystrokes, mouse reports and replies.

A terminal's input is one byte stream. It carries what the user does at the keyboard and the mouse, the reports the program enabled (focus, bracketed paste, resizes, color scheme changes), and the terminal's replies to the program's queries. Decoder reads it into one ordered stream of events. A decoder has no clock, and the caller says when the terminal has been silent.

A keystroke has one value whatever the terminal's encoding (Keystroke). A mouse report carries its own meaning, so nothing is kept between reports (Mouse_report). A reply answers one of the program's queries, and the decoder tells it from keys by its form and by the replies the program is owed (Reply, Owed replies).

This decodes the n bytes read into buf and prints each event:

let d = Matrix_input.Decoder.create () in
Matrix_input.Decoder.feed d buf ~off:0 ~len:n (fun event ->
    Format.printf "%a@." Matrix_input.Decoder.pp_event event)
Sourcemodule Keystroke : sig ... end

Keystrokes, each with one value whatever the terminal's encoding.

Sourcemodule Mouse_report : sig ... end

Mouse reports, which a terminal sends while mouse tracking is on.

Sourcemodule Reply : sig ... end

Terminal replies to the program's queries.

Sourcemodule Decoder : sig ... end

Decoders, which read the bytes a terminal sends into events.