box

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2023 License: MIT Imports: 3 Imported by: 1

README

box

Go Reference

Renders messages inside boxes in the terminal.

Install

go get github.com/altipla-consulting/box
Usage
package main

import (
	"github.com/altipla-consulting/box"
	"github.com/logrusorgru/aurora"
)

func main() {
	var o box.Box
	o.AddLine("foo", "bar")
	o.AddLine("before", aurora.Red("colored"), "after")
	o.Render()
}

Contributing

You can make pull requests or create issues in GitHub. Any code you send should be formatted using make gofmt.

License

MIT License

Documentation

Overview

Package box renders messages inside boxes in the terminal.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Box

type Box struct {
	// Horizontal padding in spaces between the border of the box and the content.
	//
	// By default it's 3 spaces.
	Px int

	// Vertical padding in lines between the border of the box and the content.
	//
	// By default it's 1 line.
	Py int

	// Color of the border of the box.
	//
	// By default it's bright yellow: aurora.YellowFg | aurora.BrightFg
	BorderColor aurora.Color
	// contains filtered or unexported fields
}
Example
package main

import (
	"github.com/logrusorgru/aurora"

	"github.com/altipla-consulting/box"
)

func main() {
	var o box.Box
	o.AddLine("foo", "bar")
	o.AddLine("before", aurora.Red("colored"), "after")
	o.Render()
}
Output:

func (*Box) AddLine

func (box *Box) AddLine(parts ...interface{})

AddLine adds a new line to the output content. It accepts multiple strings or aurora.Value for colored output.

o.AddLine("part1", "part2", "joined without spaces")

If you need colored output split the string, this function should be able to read every part individually to calculate the length correctly:

o.AddLine("before", aurora.Red("colored"), "after", aurora.Blue("another colored"))

func (*Box) Render

func (box *Box) Render()

Render emits the full box to stdout.

Jump to

Keyboard shortcuts

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