boxes

package module
v0.0.0-...-1e70bbb Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2020 License: MIT Imports: 3 Imported by: 0

README

boxes

GoDoc Go Report Card

Boxes is a simple ascii box builder.

Example

package main

import "github.com/mvrilo/boxes"

func main() {
	box, _ := boxes.New().Padding(3).WriteString("hey there!")
	println(string(box.Render()))
}
$ go run examples/box/main.go
.----------------.
|                |
|   hey there!   |
|                |
'----------------'

$ go run examples/canvas/main.go
.-----------------. .-----------------------.
|                 | |                       |
|   hello world   | |   boxes is a simple   |
|                 | |   ascii box builder   |
'-----------------' |                       |
                    |   :)                  |
                    |                       |
                    '-----------------------'

License

MIT

Author

Murilo Santana <mvrilo@gmail.com>

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Box

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

Box is a container for a content

func New

func New() *Box

func (*Box) Bytes

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

func (*Box) Padding

func (b *Box) Padding(padding int) *Box

func (*Box) Render

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

func (*Box) Write

func (b *Box) Write(content []byte) (*Box, error)

func (*Box) WriteString

func (b *Box) WriteString(content string) (*Box, error)

type Canvas

type Canvas struct {
	Boxes []*Box
}

func NewCanvas

func NewCanvas() *Canvas

func (*Canvas) AddBox

func (c *Canvas) AddBox(box *Box)

func (*Canvas) HorizontalRender

func (c *Canvas) HorizontalRender() (final []byte)

func (*Canvas) Render

func (c *Canvas) Render() (data []byte)

Directories

Path Synopsis
examples
box

Jump to

Keyboard shortcuts

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