package terminal

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

Install

Dune Dependency

Authors

Maintainers

Sources

progress-0.3.0.tbz
sha256=3dfd00bd4def773239159b17781d02fdbfd8ea191801681a94aa0a5be1d06b7c
sha512=fd64ff8a819b2db2460c06b7fbd5663e2a1941f9e2d4e9b921a3d5f24509fe3be543521fbe1bb6baedad9f62b579aae933efac3903db03a27385233f5461f09c

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
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.