package terminal

  1. Overview
  2. Docs
Basic utilities for interacting with terminals

Install

Dune Dependency

Authors

Maintainers

Sources

terminal-0.2.1.tbz
sha256=7ae7f5c5a2db88107d0b3fd37d5344f066921270a3e74d56dd13457feb9e586e
sha512=3828ac568e447e5f1e59450ee48491c256d8bc77abe234190e14e2db5be7b81f379837083f0eb28ea9572fce2781fd0addd7adc1701947c0b2de9d8319ace042

doc/terminal/Terminal/index.html

Module TerminalSource

This library provides a small set of standard utility functions for interacting with terminals.

Sourcemodule Color : sig ... end
Sourcemodule Style : sig ... end
Sourcemodule Ansi : sig ... end
Sourcemodule Size : sig ... end
Sourceval guess_printed_width : string -> int

guess_printed_width s returns an estimate of the number of terminal columns that the UTF-8 encoded string s would occupy if displayed in a terminal, after stripping any ANSI escape codes in the string.

Note: this function uses a heuristic (Uucp.tty_width_hint) to guess the rendered length of supplied strings. This function is not guaranteed to be correct on all UTF-8 codepoints. See the Uucp documentation for details.

Sourceval truncate_to_width : int -> string -> string

truncate_to_width n s is the longest prefix of UTF-8 encoded string s that will fit within n columns when displayed in a terminal (without including unbalanced ANSI control sequences after the n-th column).

As with guess_printed_width, the implementation relies on heuristics and so may not be accurate for all inputs (or for all terminal implementations).

OCaml

Innovation. Community. Security.