box

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2020 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const SLOP = 25

Variables

View Source
var MaxBytes = 256 + 3

MaxBytes is the largest capacity of bytes in a box

Functions

func PrevLine

func PrevLine(bx B) bool

Types

type B

type B interface {
	Seek(bn int, whence int) int
	Next() bool
	Prev() bool
	Box() *Box
}

type Box

type Box struct {
	Nrune    int
	Ptr      []byte
	Width    int
	Minwidth int
}

func (*Box) Break

func (b *Box) Break() byte

func (*Box) Bytes

func (b *Box) Bytes() []byte

func (*Box) Len

func (b *Box) Len() int

type Run

type Run struct {
	Box    []Box
	Nalloc int
	Nbox   int
	Face   font.Face
	Nchars int64
	Nlines int
	// contains filtered or unexported fields
}

Run is a one-dimensional field of boxes. It can scan arbitrary text into boxes with Bxscan().

func NewRun

func NewRun(minDx, maxDx int, ft font.Face) Run

func (*Run) Add

func (f *Run) Add(bn, n int)

Add adds n boxes after box bn, the rest are shifted up

func (*Run) Boxscan

func (r *Run) Boxscan(s []byte, ymax int)

func (*Run) Chop

func (f *Run) Chop(b *Box, n int)

Chop drops the first n chars in box b

func (*Run) Close

func (f *Run) Close(n0, n1 int)

Close closess box n0-n1 inclusively. The rest are shifted down

func (*Run) Colof

func (f *Run) Colof(bn int) (coln, xmax int)

func (*Run) Combine

func (f *Run) Combine(g *Run, n int)

func (*Run) Count

func (f *Run) Count(nb int) int64

Count recomputes and returns the number of bytes stored between box nb and the last box

func (*Run) Delete

func (f *Run) Delete(n0, n1 int)

Delete closes and deallocates n0-n1 inclusively

func (*Run) DumpBoxes

func (f *Run) DumpBoxes()

func (*Run) Dup

func (f *Run) Dup(bn int)

Dup copies the contents of box bn to box bn+1

func (*Run) EndCell

func (f *Run) EndCell(bn int) int

EndCell returns the first box beyond the end of the current cell under bn

func (*Run) EndLine

func (f *Run) EndLine(bn int) int

func (*Run) Find

func (f *Run) Find(bn int, p, q int64) int

Find finds the box containing q starting from box bn index p and puts q at the start of the next box

func (*Run) Findcol

func (f *Run) Findcol(bn int, coln int) (cbn int, xmax int)

func (*Run) Free

func (f *Run) Free(n0, n1 int)

Free deallocates memory for boxes n0-n1 inclusively

func (*Run) Grow

func (f *Run) Grow(delta int)

Grow allocates memory for delta more boxes

func (*Run) Merge

func (f *Run) Merge(bn int)

Merge merges box bn and bn+1

func (*Run) NextCell

func (f *Run) NextCell(bn int) int

NextCell is like EndCell, except it doesn't assume bn is part of a cell. It skips past the current cell under bn and any non-cellular boxes afterward, returning the starting box of the next cell or f.Nbox

func (*Run) NextLine

func (f *Run) NextLine(bn int) int

func (*Run) PrevLine

func (f *Run) PrevLine(bn int) int

func (*Run) Reset

func (f *Run) Reset(ft font.Face)

Reset resets all boxes in the run without deallocating their data on the heap. If widthfn is not nill, it becomes the new measuring function for the run. Boxes in the run are not remeasured upon reset.

func (*Run) Runescan

func (r *Run) Runescan(s []byte, ymax int)

func (*Run) Split

func (f *Run) Split(bn, n int)

Split splits box bn into two boxes; bn and bn+1, at index n

func (*Run) StartCell

func (f *Run) StartCell(bn int) int

StartCell returns the first box in the cell

func (*Run) StartLine

func (f *Run) StartLine(bn int) int

func (*Run) Stretch

func (f *Run) Stretch(nb int) (pb int)

Elastic tabstop experiment section. Not ready for general use by any means the text/tabwriter package implements elastic tabstops, but that package assumes that all chars are the same width and that text needs to be rescanned.

The frame already distinguishes between tabs, newlines, and plain text characters by encapsulating them in measured boxes. A direct copy of the tabwriter code would ignore the datastructures in the frame and their sublinear runtime cost.

The current elastic algorithm has suboptimal runtime performance

func (*Run) Stretch2

func (f *Run) Stretch2(nb int, bx []Box) (pb int)

func (Run) String

func (b Run) String() string

func (*Run) Truncate

func (f *Run) Truncate(b *Box, n int)

Jump to

Keyboard shortcuts

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