package colwriter

import "github.com/kr/text/colwriter"

Package colwriter provides a write filter that formats input lines in multiple columns.

The package is a straightforward translation from /src/cmd/draw/mc.c in Plan 9 from User Space.

Index

Constants

const (
	// Print each input line ending in a colon ':' separately.
	BreakOnColon uint = 1 << iota
)

Types

type Writer

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

A Writer is a filter that arranges input lines in as many columns as will fit in its width. Tab '\t' chars in the input are translated to sequences of spaces ending at multiples of 4 positions.

If BreakOnColon is set, each input line ending in a colon ':' is written separately.

The Writer assumes that all Unicode code points have the same width; this may not be true in some fonts.

func NewWriter

func NewWriter(w io.Writer, width int, flag uint) *Writer

NewWriter allocates and initializes a new Writer writing to w. Parameter width controls the total number of characters on each line across all columns.

func (*Writer) Flush

func (w *Writer) Flush() error

Flush should be called after the last call to Write to ensure that any data buffered in the Writer is written to output.

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Write writes p to the writer w. The only errors returned are ones encountered while writing to the underlying output stream.

Source Files

column.go

Version
v0.2.0 (latest)
Published
Feb 14, 2020
Platform
linux/amd64
Imports
3 packages
Last checked
9 minutes ago

Tools for package owners.