pen

package
v0.0.0-...-aefa52a Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoopPen = NewPen(noopWriter{})

NoopPen is a pen that does nothing.

Functions

This section is empty.

Types

type Block

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

Block writes a scoped Go block.

func NewBlock

func NewBlock() *Block

NewBlock creates a new preallocated block.

func (*Block) EmptyLine

func (b *Block) EmptyLine()

func (*Block) Line

func (b *Block) Line(line string)

Line writes a line.

func (*Block) Linef

func (b *Block) Linef(f string, v ...interface{})

Linef writes a line using Printf. If v is none, then f is taken literally.

func (*Block) String

func (b *Block) String() string

String returns the block.

type BlockSection

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

BlockSection is a section writer that writes into a single section from BlockSections.

func (*BlockSection) EmptyLine

func (sect *BlockSection) EmptyLine()

EmptyLine write an empty line into the section.

func (*BlockSection) Line

func (sect *BlockSection) Line(line string)

Line writes a single line into the section.

func (*BlockSection) Linef

func (sect *BlockSection) Linef(f string, v ...interface{})

Linef writes a Sprintf'd line.

type BlockSections

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

BlockSections is a section writer for writing multiple sections of a block at once. It can write 10 sections maximum.

func NewBlockSections

func NewBlockSections(preallocs ...int) *BlockSections

NewBlockSections preallocates backing arrays for BlockSections for a maximum of 8.

func (*BlockSections) EmptyLine

func (sects *BlockSections) EmptyLine(sect int)

EmptyLine writes an empty line into the given section.

func (*BlockSections) Line

func (sects *BlockSections) Line(sect int, line string)

Line writes a single line into the given section.

func (*BlockSections) Linef

func (sects *BlockSections) Linef(sect int, f string, v ...interface{})

Linef writes a Sprintf'd line.

func (*BlockSections) Reset

func (sects *BlockSections) Reset()

func (*BlockSections) Section

func (sects *BlockSections) Section(sect int) *BlockSection

Section returns a single section within the block sections.

func (*BlockSections) String

func (sects *BlockSections) String() string

String joins the sections together.

type Joints

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

Joints is a string builder that joins using a separator.

func NewJoints

func NewJoints(sep string, cap int) Joints

NewJoints creates a new Joints instance.

func (*Joints) Add

func (j *Joints) Add(str string)

Add adds a new joint.

func (*Joints) Addf

func (j *Joints) Addf(f string, v ...interface{})

Addf adds a new joint with Sprintf.

func (*Joints) Join

func (j *Joints) Join() string

Join joins the joints.

func (*Joints) Joints

func (j *Joints) Joints() []string

Joints returns the list of joints.

func (*Joints) Len

func (j *Joints) Len() int

Len returns the length of joints

func (*Joints) Reset

func (j *Joints) Reset(sep string)

Reset reuses the internal string slice but resets the state to zero.

func (*Joints) SetJoints

func (j *Joints) SetJoints(new []string)

SetJoints overrides the internal joints list.

type PaperBuffer

type PaperBuffer struct {
	Pen
}

PaperBuffer wraps a Pen and its own buffer.

func NewPaperBuffer

func NewPaperBuffer() *PaperBuffer

NewPaperBuffer creates a new Paper that preallocates 1KB.

func NewPaperBufferSize

func NewPaperBufferSize(size int) *PaperBuffer

NewPaperBufferSize creates a new Paper with the given size to preallocate.

func (*PaperBuffer) Bytes

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

Bytes returns the internal byte slice.

func (*PaperBuffer) IsEmpty

func (p *PaperBuffer) IsEmpty() bool

IsEmpty returns true if the buffer is empty.

func (*PaperBuffer) Len

func (p *PaperBuffer) Len() int

Len returns the internal length of the buffer.

func (*PaperBuffer) Reset

func (p *PaperBuffer) Reset()

Reset clears the internal buffer.

func (*PaperBuffer) String

func (p *PaperBuffer) String() string

String returns the copied final string written from the Pen.

type PaperString

type PaperString struct {
	Pen
}

PaperString wraps a Pen and its own buffer.

func NewPaperString

func NewPaperString() *PaperString

NewPaperString creates a new Paper that preallocates 1KB.

func NewPaperStringSize

func NewPaperStringSize(size int) *PaperString

NewPaperStringSize creates a new Paper with the given size to preallocate.

func (*PaperString) IsEmpty

func (p *PaperString) IsEmpty() bool

IsEmpty returns true if the buffer is empty.

func (*PaperString) Len

func (p *PaperString) Len() int

Len returns the internal length of the buffer.

func (*PaperString) Reset

func (p *PaperString) Reset()

Reset clears the internal buffer.

func (*PaperString) String

func (p *PaperString) String() string

String returns the final string written from the Pen.

type Pen

type Pen struct {
	PenWriter
}

Pen wraps a Pen and its own buffer.

func NewPen

func NewPen(w PenWriter) *Pen

NewPen creates a new Pen that preallocates 1KB.

func (*Pen) Ascend

func (p *Pen) Ascend()

func (*Pen) Descend

func (p *Pen) Descend()

func (*Pen) EmptyLine

func (p *Pen) EmptyLine()

EmptyLine adds an empty line.

func (*Pen) Line

func (p *Pen) Line(line string)

Line writes a single line.

func (*Pen) LineTmpl

func (p *Pen) LineTmpl(v interface{}, tmpl string)

LineTmpl writes an inline template with the delimiter "{" and "}".

func (*Pen) Linef

func (p *Pen) Linef(f string, v ...interface{})

Linef writes a Sprintf-formatted line.

func (*Pen) Lines

func (p *Pen) Lines(lines []string)

Lines writes multiple lines.

func (*Pen) Printf

func (p *Pen) Printf(f string, v ...interface{})

Printf writes a Sprintf-formatted string.

func (*Pen) Words

func (p *Pen) Words(words ...interface{})

Words writes a list of words into a single line.

func (*Pen) WriteTmpl

func (p *Pen) WriteTmpl(tmpl *template.Template, args interface{})

WritTmpl writes a template into the pen.

type PenWriter

type PenWriter interface {
	io.Writer
	io.ByteWriter
	io.StringWriter
}

PenWriter describes an interface that a pen can write to.

type Piece

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

Piece is a simple string builder with easy chaining.

func NewPiece

func NewPiece() *Piece

NewPiece returns a new piece.

func (*Piece) Char

func (p *Piece) Char(b byte) *Piece

Char writes a single ASCII character.

func (*Piece) EmptyLine

func (p *Piece) EmptyLine() *Piece

EmptyLine writes a new line.

func (*Piece) Line

func (p *Piece) Line(line string) *Piece

Line writes a line.

func (*Piece) Linef

func (p *Piece) Linef(f string, v ...interface{}) *Piece

Linef writes a line using Sprintf.

func (*Piece) String

func (p *Piece) String() string

String returns the inner string block.

func (*Piece) Write

func (p *Piece) Write(v ...interface{}) *Piece

Write writes using Print.

func (*Piece) Writef

func (p *Piece) Writef(f string, v ...interface{}) *Piece

Writef writes using Printf.

Jump to

Keyboard shortcuts

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