wordwrap

package
v0.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes

func Bytes(b []byte, limit int) []byte

Bytes is shorthand for declaring a new default WordWrap instance, used to immediately word-wrap a byte slice.

func String

func String(s string, limit int) string

String is shorthand for declaring a new default WordWrap instance, used to immediately word-wrap a string.

Types

type WordWrap

type WordWrap struct {
	Limit        int
	Breakpoints  []rune
	Newline      []rune
	KeepNewlines bool
	// contains filtered or unexported fields
}

WordWrap contains settings and state for customisable text reflowing with support for ANSI escape sequences. This means you can style your terminal output without affecting the word wrapping algorithm.

func NewWriter

func NewWriter(limit int) *WordWrap

NewWriter returns a new instance of a word-wrapping writer, initialized with default settings.

func (*WordWrap) Bytes

func (w *WordWrap) Bytes() []byte

Bytes returns the word-wrapped result as a byte slice.

func (*WordWrap) Close

func (w *WordWrap) Close() error

Close will finish the word-wrap operation. Always call it before trying to retrieve the final result.

func (*WordWrap) String

func (w *WordWrap) String() string

String returns the word-wrapped result as a string.

func (*WordWrap) Write

func (w *WordWrap) Write(b []byte) (int, error)

Write is used to write more content to the word-wrap buffer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL