Skip to content
Reflow lets you word-wrap strings or entire blocks of text. It follows the io.Writer interface and supports ANSI escape sequences.
Go
Branch: master
Clone or download
Latest commit 363f169 Dec 5, 2019

README.md

reflow GoDoc Build Status Coverage Status Go ReportCard

Reflow lets you word-wrap strings or entire blocks of text. It conveniently follows the io.Writer / io.WriteCloser interface and supports ANSI escape sequences. This means you can style your terminal output without it affecting the word-wrapping algorithm.

Usage

s := reflow.String("Hello World!", 5)
fmt.Println(s)

Result:

Hello
World!

Reflow is compatible with the io.Writer / io.WriteCloser interfaces:

f := reflow.NewReflow(limit)
f.Write(b)
f.Close()

fmt.Println(f.String())

Customize reflow's behavior:

f := reflow.NewReflow(limit)
f.Breakpoints = []rune{':', ','}
f.Newline = []rune{'\r'}

ANSI Example

s := reflow.String("I really \x1B[38;2;249;38;114mlove\x1B[0m Go!", 8)
fmt.Println(s)

Result:

ANSI Example Output

You can’t perform that action at this time.