Text Width (Unicode Width) Calculator

widget_text_width

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…

Read the source code β†’