Skip to content

Modern Tui TuiWrap

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Terminal TUI Library › Unicode Width › TuiWrap

TuiWrap

Breaks text into lines that fit a number of columns, keeping its line breaks.

Syntax

TuiWrap( byref s as ustring, byval cols as int32 ) as TuiStringArray

Description

Word-wraps to a column width, returning the lines. Embedded chr(10) starts a new line. This is what TuiParagraph uses, which is why paragraph wrapping is correct for CJK.

Example

#import "std/tui"
using tui

dim as TuiStringArray lines_ = TuiWrap( "the quick brown fox jumps", 10 )
for i as int32 = 0 to lines_.Count( ) - 1
    print "["; lines_[i]; "]"
next
'' [the quick ]
'' [brown fox ]
'' [jumps]
''
'' NOTE THE TRAILING SPACE: the break space stays on the line it broke after,
'' so a wrapped line can measure one column wider than you expect. Right-align
'' or box wrapped text and you will see it.

'' a newline is honoured, not swallowed
print TuiWrap( "a" & chr( 10 ) & "b", 40 ).Count( )     '' 2

See also

TuiCharWidth · TuiStringWidth · TuiTruncate · TuiSetAmbiguousWide · TuiAmbiguousWide


Library: Terminal TUI Library
Category: Terminal TUI Library
Documented under: Unicode Width
Working examples: hello.tiko · form.tiko · dashboard.tiko


Home · Keyword Index

Clone this wiki locally