box

package
v1.88.2 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2021 License: MIT Imports: 3 Imported by: 0

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"

	"libs.altipla.consulting/box"
)

func main() {
	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