pterm

package module
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2020 License: MIT Imports: 12 Imported by: 2,510

README ΒΆ

πŸ’» PTerm | Pretty Terminal Printer

A golang module to print pretty text

Latest Release Stars Forks Issues
Downloads
Downloads Forks Dops




Installation | Documentation | Examples | Q&A | Contributing


πŸ₯… Goal of PTerm

PTerm is designed to beautify the terminal output of your program.

β€’ πŸͺ€ Easy to use

Our first priority is to keep PTerm as easy to use as possible. With many examples for each individual component, getting started with PTerm is extremely easy. All components are similar in design and implement interfaces to simplify mixing individual components together.

β€’ πŸ€Ήβ€β™€οΈ Cross-Platform

We take special precautions to ensure that PTerm works on as many operating systems and terminals as possible. Whether it's Windows CMD, macOS iTerm2 or in the backend (for example inside a GitHub Action or other CI systems), PTerm guarantees beautiful output!

PTerm is actively tested on Windows, Linux (Debian & Ubuntu) and macOS.

β€’ πŸ§ͺ Well tested

PTerm has a 100% test coverage, which means that every line of code inside PTerm gets tested automatically

We test PTerm continuously. However, since a human cannot test everything all the time, we have our own test system with which we currently run 3469 automated tests to ensure that PTerm has no bugs.

β€’ ✨ Consistent Colors

PTerm uses the ANSI color scheme which is widely used by terminals to ensure consistent colors in different terminal themes. If that's not enough, PTerm can be used to access the full RGB color scheme (16 million colors) in terminals that support TrueColor.

ANSI Colors

β€’ πŸ“š Component system

PTerm consists of many components, called Printers, which can be used individually or together to generate pretty console output.

β€’ πŸ›  Configurable

PTerm can be used by without any configuration. However, you can easily configure each component with little code, so everyone has the freedom to design their own terminal output.

⚠ NOTICE

PTerm is currently under development. It is very likely that not all things will remain as they are at the moment. However, PTerm is still functional. The versioning of PTerm follows the SemVer guidelines. Breaking Changes are explicitly mentioned in the changelogs and the version will be increased accordingly. Everybody is welcome to improve PTerm, whether by making suggestions or pull requests. Thanks ❀

If you want to wait for a stable release, make sure to star the project and follow it, to get notified when we release v1.0.0 (stable) πŸš€

πŸ“¦ Installation

To make PTerm available in your project, you can run the following command.
Make sure to run this command inside your project, when you're using go modules πŸ˜‰

go get github.com/pterm/pterm

✏ Documentation

To view the official documentation of the latest release, you can go to the automatically generated page of pkg.go.dev This documentation is very technical and includes every method that can be used in PTerm.

For an easy start we recommend that you take a look at the examples section. Here you can see pretty much every feature of PTerm with its source code. The animations of the examples are automatically updated as soon as something changes in PTerm.

Have fun exploring this project πŸš€

πŸ’– Contributing

If you have found a bug or want to suggest a feature, you can do so here by opening a new issue.

If you want to contribute to the development of PTerm, you are very welcome to do so. Our contribution guidelines can be found here.

πŸ§ͺ Examples

bigtext

Animation

SHOW SOURCE
package main

import "github.com/pterm/pterm"

func main() {
	pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString("PTerm")).Render()

	pterm.DefaultBigText.WithLetters(
		pterm.NewLettersFromStringWithStyle("P", pterm.NewStyle(pterm.FgCyan)),
		pterm.NewLettersFromStringWithStyle("Term", pterm.NewStyle(pterm.FgLightMagenta))).
		Render()
}

bulletlist

Animation

SHOW SOURCE
package main

import "github.com/pterm/pterm"

func main() {
	pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{
		{Level: 0, Text: "Level 0"},
		{Level: 1, Text: "Level 1"},
		{Level: 2, Text: "Level 2"},
	}).Render()

	pterm.NewListFromString(`0
 1
  2
   3`, " ").Render()
}

bulletlist-custom

Animation

SHOW SOURCE
package main

import (
	"github.com/pterm/pterm"
)

func main() {
	pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{
		{Level: 0, Text: "Blue", TextStyle: pterm.NewStyle(pterm.FgBlue), BulletStyle: pterm.NewStyle(pterm.FgRed)},
		{Level: 1, Text: "Green", TextStyle: pterm.NewStyle(pterm.FgGreen), Bullet: "-", BulletStyle: pterm.NewStyle(pterm.FgLightWhite)},
		{Level: 2, Text: "Cyan", TextStyle: pterm.NewStyle(pterm.FgCyan), Bullet: ">", BulletStyle: pterm.NewStyle(pterm.FgYellow)},
	}).Render()
}

demo

Animation

SHOW SOURCE
package main

import (
	"strconv"
	"strings"
	"time"

	"github.com/pterm/pterm"
)

// Change this to time.Millisecond*200 to speed up the demo.
// Useful when debugging.
const second = time.Second

var pseudoProgramList = strings.Split("pseudo-excel pseudo-photoshop pseudo-chrome pseudo-outlook pseudo-explorer "+
	"pseudo-dops pseudo-git pseudo-vsc pseudo-intellij pseudo-minecraft pseudo-scoop pseudo-chocolatey", " ")

func main() {
	introScreen()
	clear()
	pseudoApplicationHeader()
	time.Sleep(second)
	fetchingPseudoInstallList()
	downloadingPseudoList()
	installingPseudoList()
}

func installingPseudoList() {
	pterm.DefaultSection.Println("Installing pseudo programs")

	p := pterm.DefaultProgressbar.WithTotal(len(pseudoProgramList)).WithTitle("Installing stuff").Start()
	for i := 0; i < p.Total; i++ {
		p.Title = "Installing " + pseudoProgramList[i]
		if pseudoProgramList[i] == "pseudo-minecraft" {
			pterm.Warning.Println("Could not install pseudo-minecraft\nThe company policy forbids games.")
		} else {
			pterm.Success.Println("Installing " + pseudoProgramList[i])
			p.Increment()
		}
		time.Sleep(second)
	}
	p.Stop()
}

func downloadingPseudoList() {
	p := pterm.DefaultProgressbar.WithTotal(len(pseudoProgramList)).WithTitle("Downloading stuff").Start()
	for i := 0; i < p.Total; i++ {
		p.Title = "Downloading " + pseudoProgramList[i]
		pterm.Success.Println("Downloading " + pseudoProgramList[i])
		p.Increment()
		time.Sleep(time.Millisecond * 500)
	}
}

func fetchingPseudoInstallList() {
	setupSpinner := pterm.DefaultSpinner.Start("Fetching pseudo install list...")
	time.Sleep(second * 4)
	setupSpinner.Success()
}

func pseudoApplicationHeader() *pterm.TextPrinter {
	return pterm.DefaultHeader.WithBackgroundStyle(pterm.NewStyle(pterm.BgLightBlue)).WithMargin(10).Println(
		"Pseudo Application created with PTerm")
}

func introScreen() {
	pterm.DefaultBigText.WithLetters(
		pterm.NewLettersFromStringWithStyle("P", pterm.NewStyle(pterm.FgCyan)),
		pterm.NewLettersFromStringWithStyle("Term", pterm.NewStyle(pterm.FgLightMagenta))).
		Render()

	pterm.DefaultHeader.WithBackgroundStyle(pterm.NewStyle(pterm.BgLightBlue)).WithMargin(10).Println(
		"PTDP - PTerm Demo Program")

	pterm.Info.Println("This animation was generated with the latest version of PTerm!" +
		"\nPTerm works on nearly every terminal and operating system." +
		"\nIt's super easy to use!" +
		"\nIf you want, you can customize everything :)" +
		"\nYou can see the code of this demo in the " + pterm.LightMagenta("./_examples/demo") + " directory." +
		"\n" +
		"\nThis demo was updated at: " + pterm.Green(time.Now().Format("02 Jan 2006 - 15:04:05 MST")))
	pterm.Println()
	introSpinner := pterm.DefaultSpinner.WithRemoveWhenDone(true).Start("Waiting for 15 seconds...")
	time.Sleep(second)
	for i := 14; i > 0; i-- {
		if i > 1 {
			introSpinner.UpdateText("Waiting for " + strconv.Itoa(i) + " seconds...")
		} else {
			introSpinner.UpdateText("Waiting for " + strconv.Itoa(i) + " second...")
		}
		time.Sleep(second)
	}
	introSpinner.Stop()
}

func clear() {
	print("\033[H\033[2J")
}

header

Animation

SHOW SOURCE
package main

import "github.com/pterm/pterm"

func main() {
	pterm.DefaultHeader.Println("This is the default header!")
}

header-custom

Animation

SHOW SOURCE
package main

import "github.com/pterm/pterm"

func main() {
	// All available options: https://pkg.go.dev/github.com/pterm/pterm#HeaderPrinter

	// Build on top of DefaultHeader
	pterm.DefaultHeader. // Use DefaultHeader as base
				WithMargin(15).                                    // Set Margin to 15
				WithBackgroundStyle(pterm.NewStyle(pterm.BgCyan)). // Set BackgroundStyle to Cyan
				WithTextStyle(pterm.NewStyle(pterm.FgBlack)).      // Set TextStyle to Black
				Println("This is a custom header!")                // Print header
	// Instead of printing the header you can set it to a variable.
	// You can then reuse your custom header.

	// Making a completely new HeaderPrinter
	newHeader := pterm.HeaderPrinter{
		TextStyle:       pterm.NewStyle(pterm.FgBlack),
		BackgroundStyle: pterm.NewStyle(pterm.BgRed),
		Margin:          20,
	}

	newHeader.Println("This is a custom header!")

}

override-default-printer

Animation

SHOW SOURCE
package main

import "github.com/pterm/pterm"

func main() {
	pterm.Error.Println("This is the default Error")

	pterm.Error.Prefix = pterm.Prefix{
		Text:  "OVERRIDE",
		Style: pterm.NewStyle(pterm.BgCyan, pterm.FgRed),
	}

	pterm.Error.Println("This is the default Error after the prefix was overridden")
}

paragraph

Animation

SHOW SOURCE
package main

import "github.com/pterm/pterm"

func main() {
	pterm.DefaultParagraph.Println("This is the default paragraph printer. As you can see, no words are separated, " +
		"but the text is split at the spaces. This is useful for continuous text of all kinds. You can manually change the line width if you want to." +
		"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam")

	pterm.Println()

	pterm.Println("This text is written with the default Println() function. No intelligent splitting here." +
		"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam")
}

paragraph-custom

Animation

SHOW SOURCE
package main

import "github.com/pterm/pterm"

func main() {

	// Custom MaxWidth
	pterm.DefaultParagraph.WithMaxWidth(60).Println("This is a custom paragraph printer. As you can see, no words are separated, " +
		"but the text is split at the spaces. This is useful for continuous text of all kinds. You can manually change the line width if you want to." +
		"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam")

	pterm.Println()

	pterm.Println("This text is written with the default Println() function. No intelligent splitting here." +
		"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam")
}

print-basic-text

Animation

SHOW SOURCE
package main

import "github.com/pterm/pterm"

func main() {
	pterm.DefaultBasicText.Println("Default basic text printer.")
	pterm.DefaultBasicText.Println("Can be used in any" + pterm.LightMagenta(" TextPrinter ") + "context.")
	pterm.DefaultBasicText.Println("For example to resolve progressbars and spinners.")
}

print-color-fade

Animation

SHOW SOURCE
package main

import (
	"github.com/pterm/pterm"
)

func main() {
	from := pterm.NewRGB(0, 255, 255)
	to := pterm.NewRGB(255, 0, 255)
	for i := 0; i < pterm.GetTerminalHeight(); i++ {
		from.Fade(0, float32(pterm.GetTerminalHeight()), float32(i), to).Println("Hello, World!")
	}
}

print-color-rgb

Animation

SHOW SOURCE
package main

import "github.com/pterm/pterm"

func main() {
	pterm.NewRGB(178, 44, 199).Println("This text is printed with a custom RGB!")
	pterm.NewRGB(15, 199, 209).Println("This text is printed with a custom RGB!")
	pterm.NewRGB(201, 144, 30).Println("This text is printed with a custom RGB!")
}

print-with-color

Animation

SHOW SOURCE
package main

import "github.com/pterm/pterm"

func main() {
	// Simple Println with different colored words.
	pterm.Println(pterm.Red("Hello, ") + pterm.Green("World") + pterm.Cyan("!"))
	pterm.Println(pterm.Red("Even " + pterm.Cyan("nested ") + pterm.Green("colors ") + "are supported!"))
	pterm.FgBlack.Println("FgBlack")
	pterm.FgRed.Println("FgRed")
	pterm.FgGreen.Println("FgGreen")
	pterm.FgYellow.Println("FgYellow")
	pterm.FgBlue.Println("FgBlue")
	pterm.FgMagenta.Println("FgMagenta")
	pterm.FgCyan.Println("FgCyan")
	pterm.FgWhite.Println("FgWhite")

	pterm.FgLightRed.Println("FgLightRed")
	pterm.FgLightGreen.Println("FgLightGreen")
	pterm.FgLightYellow.Println("FgLightYellow")
	pterm.FgLightBlue.Println("FgLightBlue")
	pterm.FgLightMagenta.Println("FgLightMagenta")
	pterm.FgLightCyan.Println("FgLightCyan")
	pterm.FgLightWhite.Println("FgLightWhite")
}

progressbar

Animation

SHOW SOURCE
package main

import (
	"strings"
	"time"

	"github.com/pterm/pterm"
)

var fakeInstallList = strings.Split("pseudo-excel pseudo-photoshop pseudo-chrome pseudo-outlook pseudo-explorer "+
	"pseudo-dops pseudo-git pseudo-vsc pseudo-intellij pseudo-minecraft pseudo-scoop pseudo-chocolatey", " ")

var vki int

func main() {
	p := pterm.DefaultProgressbar.WithTotal(len(fakeInstallList)).WithTitle("Downloading stuff").Start()

	for i := 0; i < p.Total; i++ {
		p.Title = "Downloading " + fakeInstallList[vki]
		pterm.Success.Println("Downloading " + fakeInstallList[vki])
		vki++
		p.Increment()
		time.Sleep(time.Millisecond * 350)
	}

	pterm.Success.Println("Finished downloading!")

	time.Sleep(time.Second * 5)
}

section

Animation

SHOW SOURCE
package main

import "github.com/pterm/pterm"

func main() {
	pterm.DefaultSection.Println("This is a section!")
	pterm.Info.Println("And here is some text.\nThis text could be anything.\nBasically it's just a placeholder")
	pterm.DefaultSection.Println("This is another section!")
	pterm.Info.Println("And this is\nmore placeholder text")
}

spinner

Animation

SHOW SOURCE
package main

import (
	"time"

	"github.com/pterm/pterm"
)

func main() {
	spinnerSuccess := pterm.DefaultSpinner.Start("Doing something important... (will succeed)")

	time.Sleep(time.Second * 3) // Simulate 3 seconds of processing something

	spinnerSuccess.Success()

	spinnerWarning := pterm.DefaultSpinner.Start("Doing something important... (will warn)")

	time.Sleep(time.Second * 3) // Simulate 3 seconds of processing something

	spinnerWarning.Warning()

	spinnerFail := pterm.DefaultSpinner.Start("Doing something important... (will fail)")

	time.Sleep(time.Second * 3) // Simulate 3 seconds of processing something

	spinnerFail.Fail()

	spinnerLiveText := pterm.DefaultSpinner.Start("Doing a lot of stuff...")

	time.Sleep(time.Second * 2)

	spinnerLiveText.UpdateText("It's really much")

	time.Sleep(time.Second * 2)

	spinnerLiveText.UpdateText("We're nearly done!")

	time.Sleep(time.Second * 2)

	spinnerLiveText.Success("Finally!")
}

table

Animation

SHOW SOURCE
package main

import "github.com/pterm/pterm"

func main() {
	pterm.DefaultTable.WithHasHeader().WithData(pterm.TableData{
		{"Firstname", "Lastname", "Email"},
		{"Paul", "Dean", "nisi.dictum.augue@velitAliquam.co.uk"},
		{"Callie", "Mckay", "egestas.nunc.sed@est.com"},
		{"Libby", "Camacho", "aliquet.lobortis@semper.com"},
	}).Render()
}

theme

Animation

SHOW SOURCE
package main

import (
	"github.com/pterm/pterm"
	"reflect"
	"time"
)

func main() {
	pterm.Info.Println("These are the default theme styles.\n" +
		"You can modify them easily to your personal preference,\n" +
		"or create new themes from scratch :)")
	pterm.Println()

	v := reflect.ValueOf(pterm.ThemeDefault)
	typeOfS := v.Type()

	if typeOfS == reflect.TypeOf(pterm.Theme{}) {
		for i := 0; i < v.NumField(); i++ {
			field, ok := v.Field(i).Interface().(pterm.Style)
			if ok {
				field.Println(typeOfS.Field(i).Name)
			}
			time.Sleep(time.Millisecond * 250)
		}
	}
}


GitHub @pterm Β Β·Β  Maintainer @MarvinJWendt | MarvinJWendt.com

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

View Source
var (
	// Red is an alias for FgRed.Sprint.
	Red = FgRed.Sprint
	// Cyan is an alias for FgCyan.Sprint.
	Cyan = FgCyan.Sprint
	// Gray is an alias for FgGray.Sprint.
	Gray = FgGray.Sprint
	// Blue is an alias for FgBlue.Sprint.
	Blue = FgBlue.Sprint
	// Black is an alias for FgBlack.Sprint.
	Black = FgBlack.Sprint
	// Green is an alias for FgGreen.Sprint.
	Green = FgGreen.Sprint
	// White is an alias for FgWhite.Sprint.
	White = FgWhite.Sprint
	// Yellow is an alias for FgYellow.Sprint.
	Yellow = FgYellow.Sprint
	// Magenta is an alias for FgMagenta.Sprint.
	Magenta = FgMagenta.Sprint

	// Normal is an alias for FgDefault.Sprint.
	Normal = FgDefault.Sprint

	// LightRed is a shortcut for FgLightRed.Sprint.
	LightRed = FgLightRed.Sprint
	// LightCyan is a shortcut for FgLightCyan.Sprint.
	LightCyan = FgLightCyan.Sprint
	// LightBlue is a shortcut for FgLightBlue.Sprint.
	LightBlue = FgLightBlue.Sprint
	// LightGreen is a shortcut for FgLightGreen.Sprint.
	LightGreen = FgLightGreen.Sprint
	// LightWhite is a shortcut for FgLightWhite.Sprint.
	LightWhite = FgLightWhite.Sprint
	// LightYellow is a shortcut for FgLightYellow.Sprint.
	LightYellow = FgLightYellow.Sprint
	// LightMagenta is a shortcut for FgLightMagenta.Sprint.
	LightMagenta = FgLightMagenta.Sprint
)
View Source
var (
	// ErrTerminalSizeNotDetectable - the terminal size can not be detected and the fallback values are used.
	ErrTerminalSizeNotDetectable = errors.New("terminal size could not be detected - using fallback value")

	// ErrHexCodeIsInvalid - the given HEX code is invalid.
	ErrHexCodeIsInvalid = errors.New("hex code is not valid")
)
View Source
var (
	// Info returns a PrefixPrinter, which can be used to print text with an "info" Prefix.
	Info = PrefixPrinter{
		MessageStyle: &ThemeDefault.InfoMessageStyle,
		Prefix: Prefix{
			Style: &ThemeDefault.InfoPrefixStyle,
			Text:  "INFO",
		},
	}

	// Warning returns a PrefixPrinter, which can be used to print text with a "warning" Prefix.
	Warning = PrefixPrinter{
		MessageStyle: &ThemeDefault.WarningMessageStyle,
		Prefix: Prefix{
			Style: &ThemeDefault.WarningPrefixStyle,
			Text:  "WARNING",
		},
	}

	// Success returns a PrefixPrinter, which can be used to print text with a "success" Prefix.
	Success = PrefixPrinter{
		MessageStyle: &ThemeDefault.SuccessMessageStyle,
		Prefix: Prefix{
			Style: &ThemeDefault.SuccessPrefixStyle,
			Text:  "SUCCESS",
		},
	}

	// Error returns a PrefixPrinter, which can be used to print text with an "error" Prefix.
	Error = PrefixPrinter{
		MessageStyle: &ThemeDefault.ErrorMessageStyle,
		Prefix: Prefix{
			Style: &ThemeDefault.ErrorPrefixStyle,
			Text:  "ERROR",
		},
	}

	// Fatal returns a PrefixPrinter, which can be used to print text with an "fatal" Prefix.
	// NOTICE: Fatal terminates the application immediately!
	Fatal = PrefixPrinter{
		MessageStyle: &ThemeDefault.FatalMessageStyle,
		Prefix: Prefix{
			Style: &ThemeDefault.FatalPrefixStyle,
			Text:  "FATAL",
		},
		Fatal: true,
	}

	// Description returns a PrefixPrinter, which can be used to print text with a "description" Prefix.
	Description = PrefixPrinter{
		MessageStyle: &ThemeDefault.DescriptionMessageStyle,
		Prefix: Prefix{
			Style: &ThemeDefault.DescriptionPrefixStyle,
			Text:  "Description",
		},
	}
)
View Source
var ActiveProgressBars []*Progressbar

ActiveProgressBars contains all running progressbars. Generally, there should only be one active Progressbar at a time.

View Source
var (
	// DefaultBasicText returns a default BasicTextPrinter, which can be used to print text as is.
	// No default style is present for BasicTextPrinter.
	DefaultBasicText = BasicTextPrinter{}
)
View Source
var DefaultBigText = BigTextPrinter{
	BigCharacters: map[string]string{
		"a": ` β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆ   β–ˆβ–ˆ `,
		"A": ` β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆ   β–ˆβ–ˆ `,
		"b": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ`,
		"B": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ`,
		"c": ` β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆ      
β–ˆβ–ˆ      
β–ˆβ–ˆ      
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ`,
		"C": ` β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆ      
β–ˆβ–ˆ      
β–ˆβ–ˆ      
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ`,
		"d": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ `,
		"D": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ `,
		"e": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆ      
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   
β–ˆβ–ˆ      
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ`,
		"E": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆ      
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   
β–ˆβ–ˆ      
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ`,
		"f": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆ      
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   
β–ˆβ–ˆ      
β–ˆβ–ˆ     `,
		"F": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆ      
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   
β–ˆβ–ˆ      
β–ˆβ–ˆ     `,
		"g": ` β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ       
β–ˆβ–ˆ   β–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆ    β–ˆβ–ˆ 
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  `,
		"G": ` β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ       
β–ˆβ–ˆ   β–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆ    β–ˆβ–ˆ 
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  `,
		"h": `β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆ   β–ˆβ–ˆ `,
		"H": `β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆ   β–ˆβ–ˆ `,
		"i": `β–ˆβ–ˆ 
β–ˆβ–ˆ 
β–ˆβ–ˆ 
β–ˆβ–ˆ 
β–ˆβ–ˆ`,
		"I": `β–ˆβ–ˆ 
β–ˆβ–ˆ 
β–ˆβ–ˆ 
β–ˆβ–ˆ 
β–ˆβ–ˆ`,
		"j": `     β–ˆβ–ˆ 
     β–ˆβ–ˆ 
     β–ˆβ–ˆ 
β–ˆβ–ˆ   β–ˆβ–ˆ 
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ `,
		"J": `     β–ˆβ–ˆ 
     β–ˆβ–ˆ 
     β–ˆβ–ˆ 
β–ˆβ–ˆ   β–ˆβ–ˆ 
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ `,
		"k": `β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆ  β–ˆβ–ˆ  
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   
β–ˆβ–ˆ  β–ˆβ–ˆ  
β–ˆβ–ˆ   β–ˆβ–ˆ`,
		"K": `β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆ  β–ˆβ–ˆ  
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   
β–ˆβ–ˆ  β–ˆβ–ˆ  
β–ˆβ–ˆ   β–ˆβ–ˆ`,
		"l": `β–ˆβ–ˆ      
β–ˆβ–ˆ      
β–ˆβ–ˆ      
β–ˆβ–ˆ      
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ `,
		"L": `β–ˆβ–ˆ      
β–ˆβ–ˆ      
β–ˆβ–ˆ      
β–ˆβ–ˆ      
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ `,
		"m": `β–ˆβ–ˆβ–ˆ    β–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ 
β–ˆβ–ˆ  β–ˆβ–ˆ  β–ˆβ–ˆ 
β–ˆβ–ˆ      β–ˆβ–ˆ`,
		"M": `β–ˆβ–ˆβ–ˆ    β–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ 
β–ˆβ–ˆ  β–ˆβ–ˆ  β–ˆβ–ˆ 
β–ˆβ–ˆ      β–ˆβ–ˆ`,
		"n": `β–ˆβ–ˆβ–ˆ    β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆ β–ˆβ–ˆ  β–ˆβ–ˆ 
β–ˆβ–ˆ  β–ˆβ–ˆ β–ˆβ–ˆ 
β–ˆβ–ˆ   β–ˆβ–ˆβ–ˆβ–ˆ`,
		"N": `β–ˆβ–ˆβ–ˆ    β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆ β–ˆβ–ˆ  β–ˆβ–ˆ 
β–ˆβ–ˆ  β–ˆβ–ˆ β–ˆβ–ˆ 
β–ˆβ–ˆ   β–ˆβ–ˆβ–ˆβ–ˆ`,
		"o": ` β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ    β–ˆβ–ˆ 
β–ˆβ–ˆ    β–ˆβ–ˆ 
β–ˆβ–ˆ    β–ˆβ–ˆ 
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  `,
		"O": ` β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ    β–ˆβ–ˆ 
β–ˆβ–ˆ    β–ˆβ–ˆ 
β–ˆβ–ˆ    β–ˆβ–ˆ 
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  `,
		"p": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ      
β–ˆβ–ˆ     `,
		"P": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ      
β–ˆβ–ˆ     `,
		"q": ` β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ    β–ˆβ–ˆ 
β–ˆβ–ˆ    β–ˆβ–ˆ 
β–ˆβ–ˆ β–„β–„ β–ˆβ–ˆ 
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
    β–€β–€   `,
		"Q": ` β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ    β–ˆβ–ˆ 
β–ˆβ–ˆ    β–ˆβ–ˆ 
β–ˆβ–ˆ β–„β–„ β–ˆβ–ˆ 
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
    β–€β–€   `,
		"r": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆ   β–ˆβ–ˆ`,
		"R": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆ   β–ˆβ–ˆ`,
		"s": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆ      
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
     β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ`,
		"S": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆ      
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
     β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ`,
		"t": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
   β–ˆβ–ˆ    
   β–ˆβ–ˆ    
   β–ˆβ–ˆ    
   β–ˆβ–ˆ    `,
		"T": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
   β–ˆβ–ˆ    
   β–ˆβ–ˆ    
   β–ˆβ–ˆ    
   β–ˆβ–ˆ    `,
		"u": `β–ˆβ–ˆ    β–ˆβ–ˆ 
β–ˆβ–ˆ    β–ˆβ–ˆ 
β–ˆβ–ˆ    β–ˆβ–ˆ 
β–ˆβ–ˆ    β–ˆβ–ˆ 
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ `,
		"U": `β–ˆβ–ˆ    β–ˆβ–ˆ 
β–ˆβ–ˆ    β–ˆβ–ˆ 
β–ˆβ–ˆ    β–ˆβ–ˆ 
β–ˆβ–ˆ    β–ˆβ–ˆ 
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ `,
		"v": `β–ˆβ–ˆ    β–ˆβ–ˆ 
β–ˆβ–ˆ    β–ˆβ–ˆ 
β–ˆβ–ˆ    β–ˆβ–ˆ 
 β–ˆβ–ˆ  β–ˆβ–ˆ  
  β–ˆβ–ˆβ–ˆβ–ˆ   `,
		"V": `β–ˆβ–ˆ    β–ˆβ–ˆ 
β–ˆβ–ˆ    β–ˆβ–ˆ 
β–ˆβ–ˆ    β–ˆβ–ˆ 
 β–ˆβ–ˆ  β–ˆβ–ˆ  
  β–ˆβ–ˆβ–ˆβ–ˆ   `,
		"w": `β–ˆβ–ˆ     β–ˆβ–ˆ 
β–ˆβ–ˆ     β–ˆβ–ˆ 
β–ˆβ–ˆ  β–ˆ  β–ˆβ–ˆ 
β–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆ 
 β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ `,
		"W": `β–ˆβ–ˆ     β–ˆβ–ˆ 
β–ˆβ–ˆ     β–ˆβ–ˆ 
β–ˆβ–ˆ  β–ˆ  β–ˆβ–ˆ 
β–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆ 
 β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ `,
		"x": `β–ˆβ–ˆ   β–ˆβ–ˆ 
 β–ˆβ–ˆ β–ˆβ–ˆ  
  β–ˆβ–ˆβ–ˆ   
 β–ˆβ–ˆ β–ˆβ–ˆ  
β–ˆβ–ˆ   β–ˆβ–ˆ `,
		"X": `β–ˆβ–ˆ   β–ˆβ–ˆ 
 β–ˆβ–ˆ β–ˆβ–ˆ  
  β–ˆβ–ˆβ–ˆ   
 β–ˆβ–ˆ β–ˆβ–ˆ  
β–ˆβ–ˆ   β–ˆβ–ˆ `,
		"y": `β–ˆβ–ˆ    β–ˆβ–ˆ 
 β–ˆβ–ˆ  β–ˆβ–ˆ  
  β–ˆβ–ˆβ–ˆβ–ˆ   
   β–ˆβ–ˆ    
   β–ˆβ–ˆ   `,
		"Y": `β–ˆβ–ˆ    β–ˆβ–ˆ 
 β–ˆβ–ˆ  β–ˆβ–ˆ  
  β–ˆβ–ˆβ–ˆβ–ˆ   
   β–ˆβ–ˆ    
   β–ˆβ–ˆ   `,
		"z": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
   β–ˆβ–ˆβ–ˆ  
  β–ˆβ–ˆβ–ˆ   
 β–ˆβ–ˆβ–ˆ    
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ`,
		"Z": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
   β–ˆβ–ˆβ–ˆ  
  β–ˆβ–ˆβ–ˆ   
 β–ˆβ–ˆβ–ˆ    
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ`,
		"0": ` β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ  β–ˆβ–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆ  β–ˆβ–ˆ 
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ `,
		"1": ` β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆ 
 β–ˆβ–ˆ 
 β–ˆβ–ˆ 
 β–ˆβ–ˆ `,
		"2": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
     β–ˆβ–ˆ 
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ      
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ `,
		"3": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
     β–ˆβ–ˆ 
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
     β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ `,
		"4": `β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆ   β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
     β–ˆβ–ˆ 
     β–ˆβ–ˆ `,
		"5": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆ      
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
     β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
       `,
		"6": ` β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ       
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ    β–ˆβ–ˆ 
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ `,
		"7": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
     β–ˆβ–ˆ 
    β–ˆβ–ˆ  
   β–ˆβ–ˆ   
   β–ˆβ–ˆ`,
		"8": ` β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ   β–ˆβ–ˆ 
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ   β–ˆβ–ˆ 
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ `,
		"9": ` β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
β–ˆβ–ˆ   β–ˆβ–ˆ 
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
     β–ˆβ–ˆ 
 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
        `,
		" ": "    ",
		"!": `β–ˆβ–ˆ 
β–ˆβ–ˆ 
β–ˆβ–ˆ 
   
β–ˆβ–ˆ `,
		"$": `β–„β–„β–ˆβ–ˆβ–ˆβ–„β–„Β·
β–ˆβ–ˆ      
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
     β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
  β–€β–€β–€  `,
		"%": `β–ˆβ–ˆ  β–ˆβ–ˆ 
   β–ˆβ–ˆ  
  β–ˆβ–ˆ   
 β–ˆβ–ˆ    
β–ˆβ–ˆ  β–ˆβ–ˆ`,
		"/": `    β–ˆβ–ˆ 
   β–ˆβ–ˆ  
  β–ˆβ–ˆ   
 β–ˆβ–ˆ    
β–ˆβ–ˆ     
       `,
		"(": ` β–ˆβ–ˆ 
β–ˆβ–ˆ  
β–ˆβ–ˆ  
β–ˆβ–ˆ  
 β–ˆβ–ˆ `,
		")": `β–ˆβ–ˆ  
 β–ˆβ–ˆ 
 β–ˆβ–ˆ 
 β–ˆβ–ˆ 
β–ˆβ–ˆ  `,
		"?": `β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  
     β–ˆβ–ˆ 
  β–„β–ˆβ–ˆβ–ˆ  
  β–€β–€    
  β–ˆβ–ˆ   `,
		"[": `β–ˆβ–ˆβ–ˆ 
β–ˆβ–ˆ  
β–ˆβ–ˆ  
β–ˆβ–ˆ  
β–ˆβ–ˆβ–ˆ`,
		"]": `β–ˆβ–ˆβ–ˆ 
 β–ˆβ–ˆ 
 β–ˆβ–ˆ 
 β–ˆβ–ˆ 
β–ˆβ–ˆβ–ˆ `,
		".": `   
   
   
   
β–ˆβ–ˆ`,
		",": `   
   
   
   
β–„β–ˆ`,
		"-": `      
      
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
      
      
      
     `,
		"<": `  β–ˆβ–ˆ 
 β–ˆβ–ˆ  
β–ˆβ–ˆ   
 β–ˆβ–ˆ  
  β–ˆβ–ˆ `,
		">": `β–ˆβ–ˆ   
 β–ˆβ–ˆ  
  β–ˆβ–ˆ 
 β–ˆβ–ˆ  
β–ˆβ–ˆ `,
		"*": `      
β–„ β–ˆβ–ˆ β–„
 β–ˆβ–ˆβ–ˆβ–ˆ 
β–€ β–ˆβ–ˆ β–€
     `,
		"#": ` β–ˆβ–ˆ  β–ˆβ–ˆ  
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
 β–ˆβ–ˆ  β–ˆβ–ˆ  
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 
 β–ˆβ–ˆ  β–ˆβ–ˆ `,
		"_": `        
        
        
        
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ `,
	},
}

DefaultBigText contains default values for BigTextPrinter.

View Source
var DefaultBulletList = BulletList{
	Bullet:      "β€’",
	TextStyle:   &ThemeDefault.ListTextStyle,
	BulletStyle: &ThemeDefault.ListBulletStyle,
}

DefaultBulletList contains standards, which can be used to print a BulletList.

View Source
var (
	// DefaultHeader returns the printer for a default header text.
	// Defaults to LightWhite, Bold Text and a Gray DefaultHeader background.
	DefaultHeader = HeaderPrinter{
		TextStyle:       &ThemeDefault.HeaderTextStyle,
		BackgroundStyle: &ThemeDefault.HeaderBackgroundStyle,
		Margin:          5,
	}
)
View Source
var DefaultListItem = BulletListItem{
	Bullet:      "β€’",
	TextStyle:   &ThemeDefault.ListTextStyle,
	BulletStyle: &ThemeDefault.ListBulletStyle,
}

DefaultListItem contains standards, which can be used to print a ListItem.

View Source
var DefaultParagraph = ParagraphPrinter{
	MaxWidth: GetTerminalWidth(),
}

DefaultParagraph contains the default values for a ParagraphPrinter.

View Source
var (
	// DefaultProgressbar is the default progressbar.
	DefaultProgressbar = Progressbar{
		Total:                     100,
		BarCharacter:              "β–ˆ",
		LastCharacter:             "β–ˆ",
		ElapsedTimeRoundingFactor: time.Second,
		BarStyle:                  &ThemeDefault.ProgressbarBarStyle,
		TitleStyle:                &ThemeDefault.ProgressbarTitleStyle,
		ShowTitle:                 true,
		ShowCount:                 true,
		ShowPercentage:            true,
		ShowElapsedTime:           true,
		BarFiller:                 " ",
	}
)
View Source
var DefaultSection = SectionPrinter{
	Style:           &ThemeDefault.SectionStyle,
	Level:           1,
	TopPadding:      1,
	BottomPadding:   1,
	IndentCharacter: "#",
}

DefaultSection is the default section printer.

View Source
var DefaultSpinner = Spinner{
	Sequence:       []string{"β–€ ", " β–€", " β–„", "β–„ "},
	Style:          &ThemeDefault.SpinnerStyle,
	Delay:          time.Millisecond * 200,
	MessageStyle:   &ThemeDefault.SpinnerTextStyle,
	SuccessPrinter: &Success,
	FailPrinter:    &Error,
	WarningPrinter: &Warning,
}

DefaultSpinner is the default spinner.

View Source
var DefaultTable = Table{
	Style:          &ThemeDefault.TableStyle,
	HeaderStyle:    &ThemeDefault.TableHeaderStyle,
	Separator:      " | ",
	SeparatorStyle: &ThemeDefault.TableSeparatorStyle,
}

DefaultTable contains standards, which can be used to print a Table.

View Source
var (
	// DisableOutput completely disables output from pterm. Can be used in CLI application quiet mode.
	DisableOutput = false
)
View Source
var FallbackTerminalHeight = 10

FallbackTerminalHeight is the value used for GetTerminalHeight, if the actual height can not be detected You can override that value if necessary.

View Source
var FallbackTerminalWidth = 80

FallbackTerminalWidth is the value used for GetTerminalWidth, if the actual width can not be detected You can override that value if necessary.

View Source
var (
	// GrayBoxStyle wraps text in a gray box.
	GrayBoxStyle = NewStyle(BgGray, FgLightWhite)
)
View Source
var (
	// ThemeDefault is the default theme used by PTerm.
	// If this variable is overwritten, the new value is used as default theme.
	ThemeDefault = Theme{
		PrimaryStyle:            Style{FgCyan},
		SecondaryStyle:          Style{FgLightMagenta},
		HighlightStyle:          Style{Bold, FgYellow},
		InfoMessageStyle:        Style{FgLightCyan},
		InfoPrefixStyle:         Style{FgBlack, BgCyan},
		SuccessMessageStyle:     Style{FgGreen},
		SuccessPrefixStyle:      Style{FgBlack, BgGreen},
		WarningMessageStyle:     Style{FgYellow},
		WarningPrefixStyle:      Style{FgBlack, BgYellow},
		ErrorMessageStyle:       Style{FgLightRed},
		ErrorPrefixStyle:        Style{FgBlack, BgLightRed},
		FatalMessageStyle:       Style{FgLightRed},
		FatalPrefixStyle:        Style{FgBlack, BgLightRed},
		DescriptionMessageStyle: Style{FgWhite},
		DescriptionPrefixStyle:  Style{FgLightWhite, BgDarkGray},
		ScopeStyle:              Style{FgGray},
		ProgressbarBarStyle:     Style{FgLightCyan},
		ProgressbarTitleStyle:   Style{FgLightCyan},
		HeaderTextStyle:         Style{FgLightWhite, Bold},
		HeaderBackgroundStyle:   Style{BgGray},
		SpinnerStyle:            Style{FgLightCyan},
		SpinnerTextStyle:        Style{FgLightWhite},
		TableStyle:              Style{FgWhite},
		TableHeaderStyle:        Style{FgLightCyan},
		TableSeparatorStyle:     Style{FgGray},
		SectionStyle:            Style{Bold, FgYellow},
		ListTextStyle:           Style{FgWhite},
		ListBulletStyle:         Style{FgGray},
		LetterStyle:             Style{FgDefault},
	}
)

Functions ΒΆ

func Fprint ΒΆ added in v0.1.0

func Fprint(writer io.Writer, a ...interface{})

Fprint formats using the default formats for its operands and writes to w. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.

func Fprintln ΒΆ added in v0.1.0

func Fprintln(writer io.Writer, a ...interface{})

Fprintln formats using the default formats for its operands and writes to w. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.

func Fprinto ΒΆ added in v0.1.0

func Fprinto(w io.Writer, a ...interface{})

Fprinto prints Printo to a custom writer.

func GetTerminalHeight ΒΆ added in v0.1.0

func GetTerminalHeight() int

GetTerminalHeight returns the terminal height of the active terminal.

func GetTerminalSize ΒΆ added in v0.1.0

func GetTerminalSize() (width, height int, err error)

GetTerminalSize returns the width and the height of the active terminal.

func GetTerminalWidth ΒΆ added in v0.1.0

func GetTerminalWidth() int

GetTerminalWidth returns the terminal width of the active terminal.

func Print ΒΆ

func Print(a ...interface{})

Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.

func Printf ΒΆ

func Printf(format string, a ...interface{})

Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.

func Println ΒΆ

func Println(a ...interface{})

Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.

func Printo ΒΆ added in v0.1.0

func Printo(a ...interface{})

Printo overrides the current line in a terminal. If the current line is empty, the text will be printed like with pterm.Print. To create a new line, which Example: pterm.Printo("Hello, World") time.Sleep(time.Second) pterm.Oprint("Hello, Earth!")

func RemoveColorFromString ΒΆ added in v0.4.0

func RemoveColorFromString(a ...interface{}) string

RemoveColorFromString removes color codes from a string.

func SetDefaultOutput ΒΆ added in v0.3.1

func SetDefaultOutput(w io.Writer)

SetDefaultOutput sets the default output of pterm.

func Sprint ΒΆ

func Sprint(a ...interface{}) string

Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.

func Sprintf ΒΆ

func Sprintf(format string, a ...interface{}) string

Sprintf formats according to a format specifier and returns the resulting string.

func Sprintln ΒΆ added in v0.2.0

func Sprintln(a ...interface{}) string

Sprintln returns what Println would print to the terminal.

func Sprinto ΒΆ added in v0.2.3

func Sprinto(a ...interface{}) string

Sprinto returns what Printo would print.

Types ΒΆ

type BasicTextPrinter ΒΆ added in v0.6.0

type BasicTextPrinter struct {
	Style *Style
}

BasicTextPrinter is the printer used to print the input as-is or as specified by user formatting.

func (*BasicTextPrinter) Print ΒΆ added in v0.6.0

func (p *BasicTextPrinter) Print(a ...interface{}) *TextPrinter

Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.

func (*BasicTextPrinter) Printf ΒΆ added in v0.6.0

func (p *BasicTextPrinter) Printf(format string, a ...interface{}) *TextPrinter

Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.

func (*BasicTextPrinter) Println ΒΆ added in v0.6.0

func (p *BasicTextPrinter) Println(a ...interface{}) *TextPrinter

Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.

func (BasicTextPrinter) Sprint ΒΆ added in v0.6.0

func (p BasicTextPrinter) Sprint(a ...interface{}) string

Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.

func (BasicTextPrinter) Sprintf ΒΆ added in v0.6.0

func (p BasicTextPrinter) Sprintf(format string, a ...interface{}) string

Sprintf formats according to a format specifier and returns the resulting string.

func (BasicTextPrinter) Sprintln ΒΆ added in v0.6.0

func (p BasicTextPrinter) Sprintln(a ...interface{}) string

Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.

func (BasicTextPrinter) WithStyle ΒΆ added in v0.6.0

func (p BasicTextPrinter) WithStyle(style *Style) *BasicTextPrinter

WithStyle adds a style to the printer. unlike prefix printer, there is a single style for the message.

type BigTextPrinter ΒΆ added in v0.8.0

type BigTextPrinter struct {
	// BigCharacters holds the map from a normal character to it's big version.
	BigCharacters map[string]string
	Letters       Letters
}

BigTextPrinter renders big text. You can use this as title screen for your application.

func (BigTextPrinter) Render ΒΆ added in v0.8.0

func (p BigTextPrinter) Render()

Render prints the BigText to the terminal.

func (BigTextPrinter) Srender ΒΆ added in v0.8.0

func (p BigTextPrinter) Srender() string

Srender renders the BigText as a string.

func (BigTextPrinter) WithBigCharacters ΒΆ added in v0.8.0

func (p BigTextPrinter) WithBigCharacters(chars map[string]string) *BigTextPrinter

WithBigCharacters returns a new BigTextPrinter with specific BigCharacters.

func (BigTextPrinter) WithLetters ΒΆ added in v0.8.0

func (p BigTextPrinter) WithLetters(letters ...Letters) *BigTextPrinter

WithLetters returns a new BigTextPrinter with specific Letters

type BulletList ΒΆ added in v0.8.0

type BulletList struct {
	Items       []BulletListItem
	TextStyle   *Style
	Bullet      string
	BulletStyle *Style
}

BulletList is able to render a list.

func NewListFromString ΒΆ added in v0.8.0

func NewListFromString(s string, padding string) BulletList

NewListFromString returns a BulletList with Text using the NewListItemFromString method, splitting after return (\n).

func NewListFromStrings ΒΆ added in v0.8.0

func NewListFromStrings(s []string, padding string) BulletList

NewListFromStrings returns a BulletList with Text using the NewListItemFromString method.

func (BulletList) Render ΒΆ added in v0.8.0

func (l BulletList) Render()

Render prints the list to the terminal.

func (BulletList) Srender ΒΆ added in v0.8.0

func (l BulletList) Srender() string

Srender renders the list as a string.

func (BulletList) WithBullet ΒΆ added in v0.8.0

func (l BulletList) WithBullet(bullet string) *BulletList

WithBullet returns a new list with a specific bullet.

func (BulletList) WithBulletStyle ΒΆ added in v0.8.0

func (l BulletList) WithBulletStyle(style *Style) *BulletList

WithBulletStyle returns a new list with a specific bullet style.

func (BulletList) WithItems ΒΆ added in v0.8.0

func (l BulletList) WithItems(items []BulletListItem) *BulletList

WithItems returns a new list with specific Items.

func (BulletList) WithTextStyle ΒΆ added in v0.8.0

func (l BulletList) WithTextStyle(style *Style) *BulletList

WithTextStyle returns a new list with a specific text style.

type BulletListItem ΒΆ added in v0.8.0

type BulletListItem struct {
	Level       int
	Text        string
	TextStyle   *Style
	Bullet      string
	BulletStyle *Style
}

BulletListItem is able to render a ListItem.

func NewListItemFromString ΒΆ added in v0.8.0

func NewListItemFromString(text string, padding string) BulletListItem

NewListItemFromString returns a ListItem with a Text. The padding is counted in the Text to define the Level of the ListItem.

func (BulletListItem) Render ΒΆ added in v0.8.0

func (p BulletListItem) Render()

Render renders the ListItem as a string.

func (BulletListItem) Srender ΒΆ added in v0.8.0

func (p BulletListItem) Srender() string

Srender renders the ListItem as a string.

func (BulletListItem) WithBullet ΒΆ added in v0.8.0

func (p BulletListItem) WithBullet(bullet string) BulletListItem

WithBullet returns a new ListItem with a specific Prefix.

func (BulletListItem) WithBulletStyle ΒΆ added in v0.8.0

func (p BulletListItem) WithBulletStyle(style *Style) BulletListItem

WithBulletStyle returns a new ListItem with a specific BulletStyle.

func (BulletListItem) WithLevel ΒΆ added in v0.8.0

func (p BulletListItem) WithLevel(level int) BulletListItem

WithLevel returns a new ListItem with a specific Level.

func (BulletListItem) WithText ΒΆ added in v0.8.0

func (p BulletListItem) WithText(text string) BulletListItem

WithText returns a new ListItem with a specific Text.

func (BulletListItem) WithTextStyle ΒΆ added in v0.8.0

func (p BulletListItem) WithTextStyle(style *Style) BulletListItem

WithTextStyle returns a new ListItem with a specific TextStyle.

type Color ΒΆ

type Color uint8

Color is a number which will be used to color strings in the terminal.

const (
	FgBlack Color = iota + 30
	FgRed
	FgGreen
	FgYellow
	FgBlue
	FgMagenta
	FgCyan
	FgWhite
	// FgDefault revert default FG.
	FgDefault Color = 39
)

Foreground colors. basic foreground colors 30 - 37.

const (
	FgDarkGray Color = iota + 90
	FgLightRed
	FgLightGreen
	FgLightYellow
	FgLightBlue
	FgLightMagenta
	FgLightCyan
	FgLightWhite
	// FgGray is an alias of FgDarkGray.
	FgGray Color = 90
)

Extra foreground color 90 - 97.

const (
	BgBlack Color = iota + 40
	BgRed
	BgGreen
	BgYellow // BgBrown like yellow
	BgBlue
	BgMagenta
	BgCyan
	BgWhite
	// BgDefault reverts to the default background.
	BgDefault Color = 49
)

Background colors. basic background colors 40 - 47.

const (
	BgDarkGray Color = iota + 100
	BgLightRed
	BgLightGreen
	BgLightYellow
	BgLightBlue
	BgLightMagenta
	BgLightCyan
	BgLightWhite
	// BgGray is an alias of BgDarkGray.
	BgGray Color = 100
)

Extra background color 100 - 107.

const (
	Reset Color = iota
	Bold
	Fuzzy
	Italic
	Underscore
	Blink
	FastBlink
	Reverse
	Concealed
	Strikethrough
)

Option settings.

func (Color) Print ΒΆ

func (c Color) Print(a ...interface{})

Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Color.

func (Color) Printf ΒΆ

func (c Color) Printf(format string, a ...interface{})

Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Color.

func (Color) Println ΒΆ

func (c Color) Println(a ...interface{})

Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Color.

func (Color) Sprint ΒΆ

func (c Color) Sprint(a ...interface{}) string

Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string. Input will be colored with the parent Color.

func (Color) Sprintf ΒΆ

func (c Color) Sprintf(format string, a ...interface{}) string

Sprintf formats according to a format specifier and returns the resulting string. Input will be colored with the parent Color.

func (Color) Sprintln ΒΆ

func (c Color) Sprintln(a ...interface{}) string

Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended. Input will be colored with the parent Color.

func (Color) String ΒΆ

func (c Color) String() string

String converts the color to a string. eg "35".

type HeaderPrinter ΒΆ added in v0.0.1

type HeaderPrinter struct {
	TextStyle       *Style
	BackgroundStyle *Style
	Margin          int
	FullWidth       bool
}

HeaderPrinter contains the data used to craft a header. A header is printed as a big box with text in it. Can be used as title screens or section separator.

func (*HeaderPrinter) Print ΒΆ added in v0.0.1

func (p *HeaderPrinter) Print(a ...interface{}) *TextPrinter

Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.

func (*HeaderPrinter) Printf ΒΆ added in v0.0.1

func (p *HeaderPrinter) Printf(format string, a ...interface{}) *TextPrinter

Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.

func (*HeaderPrinter) Println ΒΆ added in v0.0.1

func (p *HeaderPrinter) Println(a ...interface{}) *TextPrinter

Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.

func (HeaderPrinter) Sprint ΒΆ added in v0.0.1

func (p HeaderPrinter) Sprint(a ...interface{}) string

Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.

func (HeaderPrinter) Sprintf ΒΆ added in v0.0.1

func (p HeaderPrinter) Sprintf(format string, a ...interface{}) string

Sprintf formats according to a format specifier and returns the resulting string.

func (HeaderPrinter) Sprintln ΒΆ added in v0.0.1

func (p HeaderPrinter) Sprintln(a ...interface{}) string

Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.

func (HeaderPrinter) WithBackgroundStyle ΒΆ added in v0.1.0

func (p HeaderPrinter) WithBackgroundStyle(style *Style) *HeaderPrinter

WithBackgroundStyle changes the background styling of the header.

func (HeaderPrinter) WithFullWidth ΒΆ added in v0.1.0

func (p HeaderPrinter) WithFullWidth(b ...bool) *HeaderPrinter

WithFullWidth enables full width on a HeaderPrinter.

func (HeaderPrinter) WithMargin ΒΆ added in v0.1.0

func (p HeaderPrinter) WithMargin(margin int) *HeaderPrinter

WithMargin changes the background styling of the header.

func (HeaderPrinter) WithTextStyle ΒΆ added in v0.1.0

func (p HeaderPrinter) WithTextStyle(style *Style) *HeaderPrinter

WithTextStyle returns a new HeaderPrinter with changed

type Letter ΒΆ added in v0.8.0

type Letter struct {
	String string
	Style  *Style
}

Letter is an object, which holds a string and a specific Style for it.

func (Letter) WithString ΒΆ added in v0.8.0

func (l Letter) WithString(s string) *Letter

WithString returns a new Letter with a specific String.

func (Letter) WithStyle ΒΆ added in v0.8.0

func (l Letter) WithStyle(style *Style) *Letter

WithStyle returns a new Letter with a specific Style.

type Letters ΒΆ added in v0.8.0

type Letters []Letter

Letters is a slice of Letter.

func NewLettersFromString ΒΆ added in v0.8.0

func NewLettersFromString(text string) Letters

NewLettersFromString creates a Letters object from a string, which is prefilled with the LetterStyle from ThemeDefault. You can override the ThemeDefault LetterStyle if you want to.

func NewLettersFromStringWithStyle ΒΆ added in v0.8.0

func NewLettersFromStringWithStyle(text string, style *Style) Letters

NewLettersFromStringWithStyle creates a Letters object from a string and applies a Style to it.

type LivePrinter ΒΆ added in v0.5.0

type LivePrinter interface {
	// GenericStart runs Start, but returns a LivePrinter.
	// This is used for the interface LivePrinter.
	// You most likely want to use Start instead of this in your program.
	GenericStart() *LivePrinter

	// GenericStop runs Stop, but returns a LivePrinter.
	// This is used for the interface LivePrinter.
	// You most likely want to use Stop instead of this in your program.
	GenericStop() *LivePrinter
}

LivePrinter is a printer which can update it's output live.

type ParagraphPrinter ΒΆ added in v0.5.0

type ParagraphPrinter struct {
	MaxWidth int
}

ParagraphPrinter can print paragraphs to a fixed line width. The text will split between words, so that words will stick together. It's like in a book.

func (*ParagraphPrinter) Print ΒΆ added in v0.5.0

func (p *ParagraphPrinter) Print(a ...interface{}) *TextPrinter

Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.

func (*ParagraphPrinter) Printf ΒΆ added in v0.5.0

func (p *ParagraphPrinter) Printf(format string, a ...interface{}) *TextPrinter

Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.

func (*ParagraphPrinter) Println ΒΆ added in v0.5.0

func (p *ParagraphPrinter) Println(a ...interface{}) *TextPrinter

Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.

func (ParagraphPrinter) Sprint ΒΆ added in v0.5.0

func (p ParagraphPrinter) Sprint(a ...interface{}) string

Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.

func (ParagraphPrinter) Sprintf ΒΆ added in v0.5.0

func (p ParagraphPrinter) Sprintf(format string, a ...interface{}) string

Sprintf formats according to a format specifier and returns the resulting string.

func (ParagraphPrinter) Sprintln ΒΆ added in v0.5.0

func (p ParagraphPrinter) Sprintln(a ...interface{}) string

Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.

func (ParagraphPrinter) WithMaxWidth ΒΆ added in v0.5.0

func (p ParagraphPrinter) WithMaxWidth(width int) *ParagraphPrinter

WithMaxWidth returns a new ParagraphPrinter with a specific MaxWidth

type Prefix ΒΆ

type Prefix struct {
	Text  string
	Style *Style
}

Prefix contains the data used as the beginning of a printed text via a PrefixPrinter.

type PrefixPrinter ΒΆ

type PrefixPrinter struct {
	Prefix       Prefix
	Scope        Scope
	MessageStyle *Style
	Fatal        bool
}

PrefixPrinter is the printer used to print a Prefix.

func (PrefixPrinter) GetFormattedPrefix ΒΆ

func (p PrefixPrinter) GetFormattedPrefix() string

GetFormattedPrefix returns the Prefix as a styled text string.

func (*PrefixPrinter) Print ΒΆ

func (p *PrefixPrinter) Print(a ...interface{}) *TextPrinter

Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.

func (*PrefixPrinter) Printf ΒΆ

func (p *PrefixPrinter) Printf(format string, a ...interface{}) *TextPrinter

Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.

func (*PrefixPrinter) Println ΒΆ

func (p *PrefixPrinter) Println(a ...interface{}) *TextPrinter

Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.

func (*PrefixPrinter) Sprint ΒΆ

func (p *PrefixPrinter) Sprint(a ...interface{}) string

Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.

func (PrefixPrinter) Sprintf ΒΆ

func (p PrefixPrinter) Sprintf(format string, a ...interface{}) string

Sprintf formats according to a format specifier and returns the resulting string.

func (PrefixPrinter) Sprintln ΒΆ

func (p PrefixPrinter) Sprintln(a ...interface{}) string

Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.

func (PrefixPrinter) WithFatal ΒΆ added in v0.3.0

func (p PrefixPrinter) WithFatal(b ...bool) *PrefixPrinter

WithFatal sets if the printer should panic after printing. NOTE: The printer will only panic if either PrefixPrinter.Println, PrefixPrinter.Print or PrefixPrinter.Printf is called.

func (PrefixPrinter) WithMessageStyle ΒΆ added in v0.1.0

func (p PrefixPrinter) WithMessageStyle(style *Style) *PrefixPrinter

WithMessageStyle adds a custom prefix to the printer.

func (PrefixPrinter) WithPrefix ΒΆ added in v0.1.0

func (p PrefixPrinter) WithPrefix(prefix Prefix) *PrefixPrinter

WithPrefix adds a custom prefix to the printer.

func (PrefixPrinter) WithScope ΒΆ

func (p PrefixPrinter) WithScope(scope Scope) *PrefixPrinter

WithScope adds a scope to the Prefix.

type Progressbar ΒΆ added in v0.2.1

type Progressbar struct {
	Title                     string
	Total                     int
	Current                   int
	UpdateDelay               time.Duration
	BarCharacter              string
	LastCharacter             string
	ElapsedTimeRoundingFactor time.Duration
	BarFiller                 string

	ShowElapsedTime bool
	ShowCount       bool
	ShowTitle       bool
	ShowPercentage  bool
	RemoveWhenDone  bool

	TitleStyle *Style
	BarStyle   *Style

	IsActive bool
	// contains filtered or unexported fields
}

Progressbar shows a progress animation in the terminal.

func (*Progressbar) Add ΒΆ added in v0.2.1

func (p *Progressbar) Add(count int) *Progressbar

Add to current value.

func (Progressbar) GenericStart ΒΆ added in v0.5.0

func (p Progressbar) GenericStart() *LivePrinter

GenericStart runs Start, but returns a LivePrinter. This is used for the interface LivePrinter. You most likely want to use Start instead of this in your program.

func (Progressbar) GenericStop ΒΆ added in v0.5.0

func (p Progressbar) GenericStop() *LivePrinter

GenericStop runs Stop, but returns a LivePrinter. This is used for the interface LivePrinter. You most likely want to use Stop instead of this in your program.

func (*Progressbar) GetElapsedTime ΒΆ added in v0.2.1

func (p *Progressbar) GetElapsedTime() time.Duration

GetElapsedTime returns the elapsed time, since the progressbar was started.

func (*Progressbar) Increment ΒΆ added in v0.2.1

func (p *Progressbar) Increment() *Progressbar

Increment current value by one.

func (Progressbar) Start ΒΆ added in v0.2.1

func (p Progressbar) Start() *Progressbar

Start the progressbar.

func (*Progressbar) Stop ΒΆ added in v0.2.1

func (p *Progressbar) Stop() *Progressbar

Stop the progressbar.

func (Progressbar) WithBarCharacter ΒΆ added in v0.8.0

func (p Progressbar) WithBarCharacter(char string) *Progressbar

WithBarCharacter sets the bar character of the progressbar.

func (Progressbar) WithBarStyle ΒΆ added in v0.3.0

func (p Progressbar) WithBarStyle(style *Style) *Progressbar

WithBarStyle sets the style of the bar.

func (Progressbar) WithCurrent ΒΆ added in v0.3.0

func (p Progressbar) WithCurrent(current int) *Progressbar

WithCurrent sets the current value of the progressbar.

func (Progressbar) WithElapsedTimeRoundingFactor ΒΆ added in v0.3.0

func (p Progressbar) WithElapsedTimeRoundingFactor(duration time.Duration) *Progressbar

WithElapsedTimeRoundingFactor sets the rounding factor of the elapsed time.

func (Progressbar) WithLastCharacter ΒΆ added in v0.3.0

func (p Progressbar) WithLastCharacter(char string) *Progressbar

WithLastCharacter sets the last character of the progressbar.

func (Progressbar) WithRemoveWhenDone ΒΆ added in v0.7.0

func (p Progressbar) WithRemoveWhenDone(b ...bool) *Progressbar

WithRemoveWhenDone sets if the progressbar should be removed when it is done.

func (Progressbar) WithShowCount ΒΆ added in v0.3.0

func (p Progressbar) WithShowCount(b ...bool) *Progressbar

WithShowCount sets if the total and current count should be displayed in the progressbar.

func (Progressbar) WithShowElapsedTime ΒΆ added in v0.3.0

func (p Progressbar) WithShowElapsedTime(b ...bool) *Progressbar

WithShowElapsedTime sets if the elapsed time should be displayed in the progressbar.

func (Progressbar) WithShowPercentage ΒΆ added in v0.3.0

func (p Progressbar) WithShowPercentage(b ...bool) *Progressbar

WithShowPercentage sets if the completed percentage should be displayed in the progressbar.

func (Progressbar) WithShowTitle ΒΆ added in v0.3.0

func (p Progressbar) WithShowTitle(b ...bool) *Progressbar

WithShowTitle sets if the title should be displayed in the progressbar.

func (Progressbar) WithTitle ΒΆ added in v0.3.0

func (p Progressbar) WithTitle(name string) *Progressbar

WithTitle sets the name of the progressbar.

func (Progressbar) WithTitleStyle ΒΆ added in v0.3.0

func (p Progressbar) WithTitleStyle(style *Style) *Progressbar

WithTitleStyle sets the style of the title.

func (Progressbar) WithTotal ΒΆ added in v0.3.0

func (p Progressbar) WithTotal(total int) *Progressbar

WithTotal sets the total value of the progressbar.

func (Progressbar) WithUpdateDelay ΒΆ added in v0.3.0

func (p Progressbar) WithUpdateDelay(delay time.Duration) *Progressbar

WithUpdateDelay sets the update delay of the progressbar.

type RGB ΒΆ added in v0.5.1

type RGB struct {
	R uint8
	G uint8
	B uint8
}

RGB color model is an additive color model in which red, green, and blue light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials of the three additive primary colors, red, green, and blue. https://en.wikipedia.org/wiki/RGB_color_model

func NewRGB ΒΆ added in v0.5.1

func NewRGB(r, g, b uint8) RGB

NewRGB returns a new RGB.

func NewRGBFromHEX ΒΆ added in v0.5.1

func NewRGBFromHEX(hex string) (RGB, error)

NewRGBFromHEX converts a HEX and returns a new RGB.

func (RGB) Fade ΒΆ added in v0.5.1

func (p RGB) Fade(min, max, current float32, end RGB) RGB

Fade fades one RGB value to another RGB value, by giving the function a minimum, maximum and current value.

func (RGB) GetValues ΒΆ added in v0.5.1

func (p RGB) GetValues() (r, g, b uint8)

GetValues returns the RGB values separately.

func (RGB) Print ΒΆ added in v0.5.1

func (p RGB) Print(a ...interface{}) *TextPrinter

Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.

func (RGB) Printf ΒΆ added in v0.5.1

func (p RGB) Printf(format string, a ...interface{}) *TextPrinter

Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.

func (RGB) Println ΒΆ added in v0.5.1

func (p RGB) Println(a ...interface{}) *TextPrinter

Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.

func (RGB) Sprint ΒΆ added in v0.5.1

func (p RGB) Sprint(a ...interface{}) string

Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.

func (RGB) Sprintf ΒΆ added in v0.5.1

func (p RGB) Sprintf(format string, a ...interface{}) string

Sprintf formats according to a format specifier and returns the resulting string.

func (RGB) Sprintln ΒΆ added in v0.5.1

func (p RGB) Sprintln(a ...interface{}) string

Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.

type RenderPrinter ΒΆ added in v0.5.0

type RenderPrinter interface {
	// Render the XXX to the terminal.
	Render()

	// Srender returns the rendered string of XXX.
	Srender() string
}

RenderPrinter is used to display renderable content. Example for renderable content is a Table.

type Scope ΒΆ

type Scope struct {
	Text  string
	Style *Style
}

Scope contains the data of the optional scope of a prefix. If it has a text, it will be printed after the Prefix in brackets.

type SectionPrinter ΒΆ added in v0.3.2

type SectionPrinter struct {
	Style           *Style
	Level           int
	IndentCharacter string
	TopPadding      int
	BottomPadding   int
}

SectionPrinter prints a new section title. It can be used to structure longer text, or different chapters of your program.

func (*SectionPrinter) Print ΒΆ added in v0.3.2

func (p *SectionPrinter) Print(a ...interface{}) *TextPrinter

Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.

func (*SectionPrinter) Printf ΒΆ added in v0.3.2

func (p *SectionPrinter) Printf(format string, a ...interface{}) *TextPrinter

Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.

func (*SectionPrinter) Println ΒΆ added in v0.3.2

func (p *SectionPrinter) Println(a ...interface{}) *TextPrinter

Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.

func (SectionPrinter) Sprint ΒΆ added in v0.3.2

func (p SectionPrinter) Sprint(a ...interface{}) string

Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.

func (SectionPrinter) Sprintf ΒΆ added in v0.3.2

func (p SectionPrinter) Sprintf(format string, a ...interface{}) string

Sprintf formats according to a format specifier and returns the resulting string.

func (SectionPrinter) Sprintln ΒΆ added in v0.3.2

func (p SectionPrinter) Sprintln(a ...interface{}) string

Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.

func (SectionPrinter) WithBottomPadding ΒΆ added in v0.5.0

func (p SectionPrinter) WithBottomPadding(padding int) *SectionPrinter

WithBottomPadding returns a new SectionPrinter with a specific top padding.

func (SectionPrinter) WithIndentCharacter ΒΆ added in v0.8.0

func (p SectionPrinter) WithIndentCharacter(char string) *SectionPrinter

WithIndentCharacter returns a new SectionPrinter with a specific IndentCharacter.

func (SectionPrinter) WithLevel ΒΆ added in v0.4.0

func (p SectionPrinter) WithLevel(level int) *SectionPrinter

WithLevel returns a new SectionPrinter with a specific level.

func (SectionPrinter) WithStyle ΒΆ added in v0.4.0

func (p SectionPrinter) WithStyle(style *Style) *SectionPrinter

WithStyle returns a new SectionPrinter with a specific style.

func (SectionPrinter) WithTopPadding ΒΆ added in v0.4.0

func (p SectionPrinter) WithTopPadding(padding int) *SectionPrinter

WithTopPadding returns a new SectionPrinter with a specific top padding.

type Spinner ΒΆ added in v0.1.0

type Spinner struct {
	Text           string
	Sequence       []string
	Style          *Style
	Delay          time.Duration
	MessageStyle   *Style
	SuccessPrinter TextPrinter
	FailPrinter    TextPrinter
	WarningPrinter TextPrinter
	RemoveWhenDone bool

	IsActive bool
}

Spinner is a loading animation, which can be used if the progress is unknown. It's an animation loop, which can have a text and supports throwing errors or warnings. A TextPrinter is used to display all outputs, after the spinner is done.

func (*Spinner) Fail ΒΆ added in v0.1.0

func (s *Spinner) Fail(message ...interface{})

Fail displays the fail printer. If no message is given, the text of the spinner will be reused as the default message.

func (*Spinner) GenericStart ΒΆ added in v0.5.0

func (s *Spinner) GenericStart() *LivePrinter

GenericStart runs Start, but returns a LivePrinter. This is used for the interface LivePrinter. You most likely want to use Start instead of this in your program.

func (*Spinner) GenericStop ΒΆ added in v0.5.0

func (s *Spinner) GenericStop() *LivePrinter

GenericStop runs Stop, but returns a LivePrinter. This is used for the interface LivePrinter. You most likely want to use Stop instead of this in your program.

func (Spinner) Start ΒΆ added in v0.1.0

func (s Spinner) Start(text ...interface{}) *Spinner

Start the spinner.

func (*Spinner) Stop ΒΆ added in v0.1.0

func (s *Spinner) Stop()

Stop terminates the Spinner immediately. The Spinner will not resolve into anything.

func (*Spinner) Success ΒΆ added in v0.1.0

func (s *Spinner) Success(message ...interface{})

Success displays the success printer. If no message is given, the text of the spinner will be reused as the default message.

func (*Spinner) UpdateText ΒΆ added in v0.2.0

func (s *Spinner) UpdateText(text string)

UpdateText updates the message of the active spinner. Can be used live.

func (*Spinner) Warning ΒΆ added in v0.1.0

func (s *Spinner) Warning(message ...interface{})

Warning displays the warning printer. If no message is given, the text of the spinner will be reused as the default message.

func (Spinner) WithDelay ΒΆ added in v0.1.0

func (s Spinner) WithDelay(delay time.Duration) *Spinner

WithDelay adds a delay to the spinner.

func (Spinner) WithMessageStyle ΒΆ added in v0.1.0

func (s Spinner) WithMessageStyle(style *Style) *Spinner

WithMessageStyle adds a style to the spinner message.

func (Spinner) WithRemoveWhenDone ΒΆ added in v0.3.0

func (s Spinner) WithRemoveWhenDone(b ...bool) *Spinner

WithRemoveWhenDone removes the spinner after it is done.

func (Spinner) WithSequence ΒΆ added in v0.1.0

func (s Spinner) WithSequence(sequence ...string) *Spinner

WithSequence adds a sequence to the spinner.

func (Spinner) WithStyle ΒΆ added in v0.1.0

func (s Spinner) WithStyle(style *Style) *Spinner

WithStyle adds a style to the spinner.

func (Spinner) WithText ΒΆ added in v0.1.0

func (s Spinner) WithText(text string) *Spinner

WithText adds a text to the spinner.

type Style ΒΆ

type Style []Color

Style is a collection of colors. Can include foreground, background and styling (eg. Bold, Underscore, etc.) colors.

func NewStyle ΒΆ added in v0.0.1

func NewStyle(colors ...Color) *Style

NewStyle returns a new Style. Accepts multiple colors.

func (Style) Add ΒΆ added in v0.4.0

func (s Style) Add(styles ...Style) Style

Add styles to the current Style.

func (Style) Code ΒΆ

func (s Style) Code() string

Code convert to code string. returns like "32;45;3".

func (Style) Print ΒΆ

func (s Style) Print(a ...interface{})

Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Style.

func (Style) Printf ΒΆ

func (s Style) Printf(format string, a ...interface{})

Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Style.

func (Style) Println ΒΆ

func (s Style) Println(a ...interface{})

Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Style.

func (Style) Sprint ΒΆ

func (s Style) Sprint(a ...interface{}) string

Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string. Input will be colored with the parent Style.

func (Style) Sprintf ΒΆ

func (s Style) Sprintf(format string, a ...interface{}) string

Sprintf formats according to a format specifier and returns the resulting string. Input will be colored with the parent Style.

func (Style) Sprintln ΒΆ

func (s Style) Sprintln(a ...interface{}) string

Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended. Input will be colored with the parent Style.

func (Style) String ΒΆ

func (s Style) String() string

String convert to code string. returns like "32;45;3".

type Table ΒΆ added in v0.5.0

type Table struct {
	Style          *Style
	HasHeader      bool
	HeaderStyle    *Style
	Separator      string
	SeparatorStyle *Style
	Data           TableData
}

Table is able to render tables.

func (Table) Render ΒΆ added in v0.5.0

func (p Table) Render()

Render prints the Table to the terminal.

func (Table) Srender ΒΆ added in v0.5.0

func (p Table) Srender() string

Srender renders the Table as a string.

func (Table) WithCSVReader ΒΆ added in v0.5.1

func (p Table) WithCSVReader(reader *csv.Reader) *Table

WithCSVReader return a new Table with specified Data extracted from CSV.

func (Table) WithData ΒΆ added in v0.5.0

func (p Table) WithData(data [][]string) *Table

WithData returns a new Table with specific Data.

func (Table) WithHasHeader ΒΆ added in v0.5.0

func (p Table) WithHasHeader(b ...bool) *Table

WithHasHeader returns a new Table, where the first line is marked as a header.

func (Table) WithHeaderStyle ΒΆ added in v0.5.0

func (p Table) WithHeaderStyle(style *Style) *Table

WithHeaderStyle returns a new Table with a specific HeaderStyle.

func (Table) WithSeparator ΒΆ added in v0.5.0

func (p Table) WithSeparator(separator string) *Table

WithSeparator returns a new Table with a specific separator.

func (Table) WithSeparatorStyle ΒΆ added in v0.5.0

func (p Table) WithSeparatorStyle(style *Style) *Table

WithSeparatorStyle returns a new Table with a specific SeparatorStyle.

func (Table) WithStyle ΒΆ added in v0.5.0

func (p Table) WithStyle(style *Style) *Table

WithStyle returns a new Table with a specific Style.

type TableData ΒΆ added in v0.5.0

type TableData [][]string

TableData is the type that contains the data of a Table.

type TextPrinter ΒΆ added in v0.5.0

type TextPrinter interface {
	// Sprint formats using the default formats for its operands and returns the resulting string.
	// Spaces are added between operands when neither is a string.
	Sprint(a ...interface{}) string

	// Sprintln formats using the default formats for its operands and returns the resulting string.
	// Spaces are always added between operands and a newline is appended.
	Sprintln(a ...interface{}) string

	// Sprintf formats according to a format specifier and returns the resulting string.
	Sprintf(format string, a ...interface{}) string

	// Print formats using the default formats for its operands and writes to standard output.
	// Spaces are added between operands when neither is a string.
	// It returns the number of bytes written and any write error encountered.
	Print(a ...interface{}) *TextPrinter

	// Println formats using the default formats for its operands and writes to standard output.
	// Spaces are always added between operands and a newline is appended.
	// It returns the number of bytes written and any write error encountered.
	Println(a ...interface{}) *TextPrinter

	// Printf formats according to a format specifier and writes to standard output.
	// It returns the number of bytes written and any write error encountered.
	Printf(format string, a ...interface{}) *TextPrinter
}

TextPrinter contains methods to print formatted text to the console or return it as a string.

type Theme ΒΆ added in v0.6.0

type Theme struct {
	PrimaryStyle            Style
	SecondaryStyle          Style
	HighlightStyle          Style
	InfoMessageStyle        Style
	InfoPrefixStyle         Style
	SuccessMessageStyle     Style
	SuccessPrefixStyle      Style
	WarningMessageStyle     Style
	WarningPrefixStyle      Style
	ErrorMessageStyle       Style
	ErrorPrefixStyle        Style
	FatalMessageStyle       Style
	FatalPrefixStyle        Style
	DescriptionMessageStyle Style
	DescriptionPrefixStyle  Style
	ScopeStyle              Style
	ProgressbarBarStyle     Style
	ProgressbarTitleStyle   Style
	HeaderTextStyle         Style
	HeaderBackgroundStyle   Style
	SpinnerStyle            Style
	SpinnerTextStyle        Style
	TableStyle              Style
	TableHeaderStyle        Style
	TableSeparatorStyle     Style
	SectionStyle            Style
	ListTextStyle           Style
	ListBulletStyle         Style
	LetterStyle             Style
}

Theme for PTerm. Theme contains every Style used in PTerm. You can create own themes for your application or use one of the existing themes.

func (Theme) WithDescriptionMessageStyle ΒΆ added in v0.6.0

func (t Theme) WithDescriptionMessageStyle(style Style) Theme

WithDescriptionMessageStyle returns a new theme with overridden value.

func (Theme) WithDescriptionPrefixStyle ΒΆ added in v0.6.0

func (t Theme) WithDescriptionPrefixStyle(style Style) Theme

WithDescriptionPrefixStyle returns a new theme with overridden value.

func (Theme) WithErrorMessageStyle ΒΆ added in v0.6.0

func (t Theme) WithErrorMessageStyle(style Style) Theme

WithErrorMessageStyle returns a new theme with overridden value.

func (Theme) WithErrorPrefixStyle ΒΆ added in v0.6.0

func (t Theme) WithErrorPrefixStyle(style Style) Theme

WithErrorPrefixStyle returns a new theme with overridden value.

func (Theme) WithFatalMessageStyle ΒΆ added in v0.6.0

func (t Theme) WithFatalMessageStyle(style Style) Theme

WithFatalMessageStyle returns a new theme with overridden value.

func (Theme) WithFatalPrefixStyle ΒΆ added in v0.6.0

func (t Theme) WithFatalPrefixStyle(style Style) Theme

WithFatalPrefixStyle returns a new theme with overridden value.

func (Theme) WithHighlightStyle ΒΆ added in v0.6.0

func (t Theme) WithHighlightStyle(style Style) Theme

WithHighlightStyle returns a new theme with overridden value.

func (Theme) WithInfoMessageStyle ΒΆ added in v0.6.0

func (t Theme) WithInfoMessageStyle(style Style) Theme

WithInfoMessageStyle returns a new theme with overridden value.

func (Theme) WithInfoPrefixStyle ΒΆ added in v0.6.0

func (t Theme) WithInfoPrefixStyle(style Style) Theme

WithInfoPrefixStyle returns a new theme with overridden value.

func (Theme) WithLetterStyle ΒΆ added in v0.8.0

func (t Theme) WithLetterStyle(style Style) Theme

WithLetterStyle returns a new theme with overridden value.

func (Theme) WithListBulletStyle ΒΆ added in v0.8.0

func (t Theme) WithListBulletStyle(style Style) Theme

WithListBulletStyle returns a new theme with overridden value.

func (Theme) WithListTextStyle ΒΆ added in v0.8.0

func (t Theme) WithListTextStyle(style Style) Theme

WithListTextStyle returns a new theme with overridden value.

func (Theme) WithPrimaryStyle ΒΆ added in v0.6.0

func (t Theme) WithPrimaryStyle(style Style) Theme

WithPrimaryStyle returns a new theme with overridden value.

func (Theme) WithSecondaryStyle ΒΆ added in v0.6.0

func (t Theme) WithSecondaryStyle(style Style) Theme

WithSecondaryStyle returns a new theme with overridden value.

func (Theme) WithSuccessMessageStyle ΒΆ added in v0.6.0

func (t Theme) WithSuccessMessageStyle(style Style) Theme

WithSuccessMessageStyle returns a new theme with overridden value.

func (Theme) WithSuccessPrefixStyle ΒΆ added in v0.6.0

func (t Theme) WithSuccessPrefixStyle(style Style) Theme

WithSuccessPrefixStyle returns a new theme with overridden value.

func (Theme) WithWarningMessageStyle ΒΆ added in v0.6.0

func (t Theme) WithWarningMessageStyle(style Style) Theme

WithWarningMessageStyle returns a new theme with overridden value.

func (Theme) WithWarningPrefixStyle ΒΆ added in v0.6.0

func (t Theme) WithWarningPrefixStyle(style Style) Theme

WithWarningPrefixStyle returns a new theme with overridden value.

Directories ΒΆ

Path Synopsis
_examples
bigtext command
bulletlist command
demo command
header command
header-custom command
paragraph command
print-color-rgb command
progressbar command
section command
spinner command
table command
theme command

Jump to

Keyboard shortcuts

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