Text Width Calculator

Demonstrates string width calculation in a terminal environment.

Not all characters are created equal. In a TUI, β€œWidth” means cell count, not string length. Emoji (πŸ‘) take 2 cells. Chinese characters (δ½ ) take 2 cells. The tui.text_width helper tells you the visual width of a string.

Features Demonstrated

Hotkeys

Usage

ruby examples/widget_text_width/app.rb

Learning Outcomes

Use this example if you need to… - Align text correctly in columns. - Truncate strings that are too long for a widget. - Build your own custom layout engine.

Demo