module

Term2::Text

Text utilities for measuring and manipulating styled text

Class methods

char_width(c : Char) : Int32

Get width of a single character (handles wide chars)

Source
height(text : String) : Int32

Calculate text height based on newline count.

Source
strip_ansi(text : String) : String

Strip ANSI escape codes from text.

Handles common CSI/OSC sequences and Bubblezone markers (CSI ... z).

Source
truncate(text : String, width : Int32) : String

Truncate text to width, respecting ANSI codes.

Source
width(text : String) : Int32

Calculate the display width of text (ignoring ANSI codes)

Source