package matrix

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

Install

dune-project
 Dependency

Authors

Maintainers

Sources

mosaic-0.2.0.tbz
sha256=ab48bc02082f9c1deea0769a13c2935df529536630745ec3a3d718f59656109b
sha512=c0f3c490e13ca60217d9d59c9bfdf3ada12e1565f04fe2a623e7c94298d519393eabe404e2317726712bf5e7fa860780a07494e77994ac05032e71f535c56910

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.