package terminal

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

Install

Dune Dependency

Authors

Maintainers

Sources

terminal-0.2.0.tbz
sha256=7a92f6aede3d5010a30e6e47ccbc8380cc5bece8ac95c508323eb25272e6ddd3
sha512=a2ccea467e2d0e419b569992102bd2c43ff97b47f7f8413ee8fbe775ce369a80ff11e0a8fd450ebf1776f7c65baf2482076a120318c9d818488ceba0b9196639

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.