package charInfo_width

All checked builds pass
  1. Overview
  2. Docs
Determine column width for a character

Install

dune-project
 Dependency

Authors

Maintainers

Sources

2.0.0.tar.gz
sha256=ea492b79329148415e66f0a968d9fec01714ea888dcc09e9b34a53a2c6bfa48b
md5=220645b99124d6871e503527ca363ce5

Description

This module is implemented purely in OCaml and the width function follows the prototype of POSIX's wcwidth.

Added to opam-repository:

README

CharInfo_width

Determine column width for a character.

How to use

CharInfo_width.width c returns the column width of c where c is of type Camomile.UChar.t and the value returned is of type int.

This module is implemented purely in OCaml and the width function follows the prototype of POSIX's wcwidth. i.e. If c is a printable character, the value is at least 0. If c is null character (L'\0'), the value is 0. Otherwise, -1 is returned. The width_exn function, when encounter an unprintable character, it raises Failure "unprintable character" instead of returning -1.

By default, the width and width_exn function is compatible with ncursesw, ncursesw based CLIs, terminals. The way they consider the width of a character is the same.

An optional parameter, cfg, can extend extra width info. The current width info table of ncursesw, xterm, xterm-compatible terminal is inadequate and limited, so is the default cfg of this module. When implement raw mode command-line interface, e.g. readline, a text editor, better extend extra width info by cfg. An on going sample repository of width table is here: charInfo_width_extra

This module also provides a functor, CharInfo_width.String. This functor accepts a Camomile.UnicodeString compatible module to calculate the width of a unicode string. The returned value is either Ok width or Error pos-of-unprintable-character.

Document

The document is available here.

Dependencies (4)

  1. dune >= "1.4"
  2. camomile >= "2.0.0" & < "3.0~"
  3. result
  4. ocaml >= "4.02.3"

Dev Dependencies (1)

  1. ppx_expect with-test

Used by

None

Conflicts

None

Build status

Results of building charInfo_width with each compiler on check.ci.ocaml.org, run of against opam-repository 7cdc698. All results for this package.

Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.

Version OCaml 4.11 OCaml 4.14 OCaml 5.2 OCaml 5.4 OCaml 5.5
2.0.0 (this version) n/a good good good good
1.1.0 good good n/a n/a n/a
  • good Package successfully built
  • partial One of the dependencies failed to build
  • bad Package failed to build
  • n/a Package is not available in this environment
  • internal Internal failure