print

package
v0.24.5 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package print provides low level routines for styling output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AndSeparator

func AndSeparator(w writer.Output) writer.OutputCloser

AndSeparator creates a phrase: a, b, c, and d. Note: spacing between words is left to print.Spacing.

func Capitalize

func Capitalize(out writer.Output) writer.ChunkOutput

Capitalize filters writer.Output, capitalizing the first string.

func Lowercase

func Lowercase(out writer.Output) writer.ChunkOutput

Lowercase filters writer.Output, lowering every string.

func NewLineSentences

func NewLineSentences(w io.Writer) writer.ChunkOutput

func OrSeparator

func OrSeparator(w writer.Output) writer.OutputCloser

OrSeparator creates a phrase: a, b, c, or d. Note: spacing between words is left to print.Spacing.

func Slash

func Slash(out writer.Output) writer.ChunkOutput

Slash filters writer.Output, separating writes with a slash.

func Tag

func Tag(out writer.Output, tag string) writer.OutputCloser

Tag - surrounds a block of text with an html-like element.

func TitleCase

func TitleCase(out writer.Output) writer.ChunkOutput

TitleCase filters writer.Output, capitalizing every write.

Types

type BracketSpanner

type BracketSpanner struct {
	Spanner // inside the brackets: write with spaces
	// contains filtered or unexported fields
}

func Brackets

func Brackets(open, close string) BracketSpanner

func Parens

func Parens() BracketSpanner

Parens buffers writer.Output, grouping a stream of writes. Close adds the closing paren.

func (*BracketSpanner) ChunkOutput

func (p *BracketSpanner) ChunkOutput() writer.ChunkOutput

func (*BracketSpanner) WriteChunk

func (p *BracketSpanner) WriteChunk(c writer.Chunk) (ret int, err error)

type Filter

type Filter struct {
	First, Rest func(writer.Chunk) (int, error)
	Last        func(int) error
	// contains filtered or unexported fields
}

Filter - sends incoming chunks to one of three functions: first, rest, or last. a user of filter can alter those chunks before sending them onward somewhere else. this doesnt define that destination.

func (*Filter) WriteChunk

func (f *Filter) WriteChunk(c writer.Chunk) (ret int, err error)

type Lines

type Lines struct {
	writer.ChunkOutput
	// contains filtered or unexported fields
}

Lines implements io.Writer, buffering every Write as a new line. use MakeChunks to construct a valid line writer.

func NewLines

func NewLines() *Lines

func (*Lines) Lines

func (ls *Lines) Lines() []string

Lines returns all current lines. There is no flush. A new line writer can be constructed instead.

func (*Lines) WriteChunk

func (ls *Lines) WriteChunk(c writer.Chunk) (int, error)

Write implements writer.Output, spacing writes with separators.

type Sep

type Sep struct {
	// contains filtered or unexported fields
}

Sep implements writer.Output, treating every Write as a new word.

func (*Sep) ChunkOutput

func (l *Sep) ChunkOutput() writer.ChunkOutput

func (*Sep) WriteChunk

func (l *Sep) WriteChunk(c writer.Chunk) (ret int, err error)

Write implements writer.Output, spacing writes with separators.

type Spanner

type Spanner struct {
	// contains filtered or unexported fields
}

Spanner implements ChunkWriter, buffering output with spaces. It treats each new Write as a word adding spaces to separate words as necessary. FIX: this uses a buffer internally, but does it really need to do so?

func NewSpanner

func NewSpanner() *Spanner

func (*Spanner) Bytes

func (p *Spanner) Bytes() []byte

func (*Spanner) ChunkOutput

func (p *Spanner) ChunkOutput() writer.ChunkOutput

ChunkOutput - returns an object capable of writing to the spanner.

func (*Spanner) Len

func (p *Spanner) Len() int

func (*Spanner) String

func (p *Spanner) String() string

func (*Spanner) WriteChunk

func (p *Spanner) WriteChunk(c writer.Chunk) (ret int, err error)

func (*Spanner) WriteTo

func (p *Spanner) WriteTo(w writer.Output) (int, error)

WriteTo - move the contents of the spanner to the passed output.

Jump to

Keyboard shortcuts

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