Links
Comment on page

Area

The area printer can be used to display dynamically updating live content

Basic Usage

area, _ := pterm.DefaultArea.Start() // Start the Area printer.
for i := 0; i < 10; i++ {
str, _ := pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString(time.Now().Format("15:04:05"))).Srender() // Save current time in str.
str = pterm.DefaultCenter.Sprint(str) // Center str.
area.Update(str) // Update Area contents.
time.Sleep(time.Second)
}
area.Stop()

Options

Name
Type
Description
RemoveWhenDone
bool
Sets if the area should be removed when Stop() is called
Fullscreen
bool
Sets if the area should be the same size as the terminal
Center
bool
Sets if the content of the area should be centered

Using Options

Methods

Name
Description
Clear()
Clears the content of the area
GetContent()
Returns the current content of the area
Update(text ...interface{})
Updates the content of the area
This printer implements the LivePrinter interface.
Method
Description
Start()
Returns itself and errors
Stop()
Returns itself and errors
GenericStart()
Returns the started LivePrinter and errors
GenericStop()
Returns the stopped LivePrinter and errors

Full Specification

pkg.go.dev contains the full specification for this printer and more technical descriptions.