package lambda-term

  1. Overview
  2. Docs
Terminal manipulation library for OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

lambda-term-3.3.0.tbz
sha256=589f7e1fd3584a174ddf1cb96d5c5dee45a1be2e6ea5ca5a44c41222d74a27ce
sha512=e8f302ce669ae161454584ddee21c57d58f9539ab94e4e31b15d821f277fd8be980cf0a47e9c6949f16d14823d511b31d2048d9315547cb97dffdb617507de5a

Description

Lambda-term is a cross-platform library for manipulating the terminal. It provides an abstraction for keys, mouse events, colors, as well as a set of widgets to write curses-like applications. The main objective of lambda-term is to provide a higher level functional interface to terminal manipulation than, for example, ncurses, by providing a native OCaml interface instead of bindings to a C library. Lambda-term integrates with zed to provide text edition facilities in console applications.

Published: 05 Jul 2022

README

Lambda-Term

Lambda-Term is a cross-platform library for manipulating the terminal. It provides an abstraction for keys, mouse events, colors, as well as a set of widgets to write curses-like applications.

The main objective of Lambda-Term is to provide a higher level functional interface to terminal manipulation than, for example, ncurses, by providing a native OCaml interface instead of bindings to a C library.

Lambda-Term integrates with zed to provide text edition facilities in console applications.

API Documentation

Installation

To build and install Lambda-Term:

$ dune build
$ dune install

Note that this will build Lambda-Term using the development build profile which has strict compilation flags. If the build fails, try passing --profile=release to dune or alternatively create a dune-workspace file with the following contents:

(lang dune 1.1)
(profile release)

HTML API Documentation (optional)

To build the documentation:

$ dune build @doc

You can then consult it by openning _build/default/_doc/_html/index.html.

Tests (optional)

To build and execute tests:

$ dune runtest

Examples (optional)

To build the examples:

$ dune build @examples

Binaries for the examples will be in _build/default/examples.

The asciiart example is not built by default as it as an additional dependency on the camlimages library. To build it run:

$ dune build examples/asciiart/asciiart.exe

Terminal emulators compatibility

All terminal emulators behave differently, especially regarding how keystrokes are reported to the application on its standard input. Lambda-Term tries to handle all of them, but it may happen that a particular key of combination of keys is not recognized by Lambda-Term, and thus does not produce the expected effect (for example: arrow keys or backspace not working).

To check what is reported by your terminal you can run the script print_sequences.ml which at the root of the repository:

$ ocaml print_sequences.ml
press 'q' to quit
\027[A
\027[D
\027[C
\027[A
\027[D
a
z
e
q

You can then send the result to jeremie@dimino.org, including:

  • the application you are using as terminal emulator,

  • the contents of the TERM environment variable inside the terminal (echo $TERM),

  • the output of print_sequences.ml with, for each line, the keystroke.

Key bindings

Key bindings can be set in ~/.config/lambda-term-inputrc. See lambda-term-inputrc. Useful mappings:

# This allows zsh-like searching the history by pressing up/down
[read-line]
up: history-search-prev
down: history-search-next

Main modules

  • LTerm: basic interface to the terminal, it allows to put the terminal in raw mode, hide the cursor, render an offscreen array of points, ...

  • LTerm_draw: drawing functions, for rendering in an offscreen array.

  • LTerm_read_line: line edition.

  • LTerm_inputrc: parsing of configurations files for key bindings.

  • LTerm_history: history and history file management.

  • LTerm_ui: helpers for writing full-screen applications.

  • LTerm_widget: widget system (not stable).

  • LTerm_resources: resources loading for widgets.

Dependencies (8)

  1. zed >= "3.2.0" & < "4.0"
  2. react
  3. mew_vi >= "0.5.0" & < "0.6.0"
  4. lwt_react
  5. lwt_log
  6. lwt >= "4.2.0"
  7. ocaml >= "4.08.0" & < "5.0"
  8. dune >= "3.0"

Dev Dependencies (1)

  1. odoc with-doc

Used by (7)

  1. anthill
  2. cairn
  3. github-unix >= "4.1.0" & < "4.3.2"
  4. ocp-browser >= "1.3.5"
  5. prof_spacetime >= "0.3.0"
  6. protocol-9p-tool >= "2.0.2"
  7. utop >= "2.10.0"

Conflicts

None

OCaml

Innovation. Community. Security.