tgrid

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package tgrid represents tables as simple ASCII art. Example:

┌──╥──╥──╥───┐
│12║12║12║123│
╞══╬══╬══╬═══╡
│12║12║12║123│
╞══╬══╬══╬═══╡
│12║12║12║123│
└──╨──╨──╨───┘

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WordWrap

func WordWrap(text []byte, lineWidth int) []byte

Types

type Cell

type Cell struct {
	Next   int
	Width  int
	Height int
	Lines  []Line
}

func NewCell

func NewCell(fromLines ...Line) *Cell

func NewCellFromBytes

func NewCellFromBytes(b []byte, lineWidth int) *Cell

func (*Cell) WriteFiller

func (c *Cell) WriteFiller(w io.Writer, n int) (err error)

func (*Cell) WriteLine

func (c *Cell) WriteLine(w io.Writer) (err error)

type CellGenerator

type CellGenerator func() (*Cell, error)

type Grid

type Grid []Row

Grid is an ASCII rendering of table data.

func NewGrid

func NewGrid(columns, rows int, from CellGenerator) (Grid, error)

func (Grid) MiddleBorder

func (g Grid) MiddleBorder() []byte

func (Grid) Normalize

func (g Grid) Normalize()

func (Grid) Write

func (g Grid) Write(w io.Writer) (n int, err error)

func (Grid) WriteBottomBorder

func (g Grid) WriteBottomBorder(w io.Writer) (n int, err error)

func (Grid) WriteTopBorder

func (g Grid) WriteTopBorder(w io.Writer) (n int, err error)

type Line

type Line []byte

type Row

type Row []*Cell

func (Row) Height

func (r Row) Height() (height int)

func (Row) Write

func (r Row) Write(w io.Writer) (n int, err error)

Jump to

Keyboard shortcuts

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