diff --git a/README.md b/README.md
index 80be38aa2..3f7a273bf 100644
--- a/README.md
+++ b/README.md
@@ -180,9 +180,9 @@ Your financial support enables me to focus more on my projects. Thank you very m
You can find all the examples, with their source code, here: [`./_examples`](./_examples)
-### area
+### area/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/area/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/area/demo/animation.svg)
@@ -214,9 +214,9 @@ func main() {
-### barchart
+### barchart/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/demo/animation.svg)
@@ -254,9 +254,137 @@ func main() {
-### barchart-mixed-values
+### barchart/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart-mixed-values/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ positiveBars := pterm.Bars{
+ pterm.Bar{
+ Label: "Bar 1",
+ Value: 5,
+ },
+ pterm.Bar{
+ Label: "Bar 2",
+ Value: 3,
+ },
+ pterm.Bar{
+ Label: "Longer Label",
+ Value: 7,
+ },
+ }
+
+ pterm.Info.Println("Chart example with positive only values (bars use 100% of chart area)")
+ _ = pterm.DefaultBarChart.WithBars(positiveBars).Render()
+ _ = pterm.DefaultBarChart.WithHorizontal().WithBars(positiveBars).Render()
+}
+
+```
+
+
+
+### barchart/mixed-values
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/mixed-values/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ mixedBars := pterm.Bars{
+ pterm.Bar{
+ Label: "Bar 1",
+ Value: 2,
+ },
+ pterm.Bar{
+ Label: "Bar 2",
+ Value: -3,
+ },
+ pterm.Bar{
+ Label: "Bar 3",
+ Value: -2,
+ },
+ pterm.Bar{
+ Label: "Bar 4",
+ Value: 5,
+ },
+ pterm.Bar{
+ Label: "Longer Label",
+ Value: 7,
+ },
+ }
+
+ pterm.DefaultSection.Println("Chart example with mixed values (note screen space usage in case when ABSOLUTE values of negative and positive parts are differ too much)")
+ _ = pterm.DefaultBarChart.WithBars(mixedBars).WithShowValue().Render()
+ _ = pterm.DefaultBarChart.WithHorizontal().WithBars(mixedBars).WithShowValue().Render()
+}
+
+```
+
+
+
+### barchart/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ positiveBars := pterm.Bars{
+ pterm.Bar{
+ Label: "Bar 1",
+ Value: 5,
+ },
+ pterm.Bar{
+ Label: "Bar 2",
+ Value: 3,
+ },
+ pterm.Bar{
+ Label: "Longer Label",
+ Value: 7,
+ },
+ }
+
+ pterm.Info.Println("Chart example with positive only values (bars use 100% of chart area)")
+ _ = pterm.DefaultBarChart.WithBars(positiveBars).Render()
+ _ = pterm.DefaultBarChart.WithHorizontal().WithBars(positiveBars).Render()
+}
+
+```
+
+
+
+### barchart/mixed-values
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/mixed-values/animation.svg)
@@ -302,9 +430,9 @@ func main() {
-### barchart-negative-values
+### barchart/negative-values
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart-negative-values/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/negative-values/animation.svg)
@@ -342,9 +470,36 @@ func main() {
-### bigtext
+### basictext/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/basictext/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // A BasicText printer is used to print text, without special formatting.
+ // As it implements the TextPrinter interface, you can use it in combination with other printers.
+ 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.")
+ // If you just want to print text, you should use this instead:
+ // pterm.Println("Hello, World!")
+}
+
+```
+
+
+
+### bigtext/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bigtext/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bigtext/demo/animation.svg)
@@ -376,9 +531,2407 @@ func main() {
-### box
+### box/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/box/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ pterm.Info.Println("This might not be rendered correctly on GitHub,\nbut it will work in a real terminal.\nThis is because GitHub does not use a monospaced font by default for SVGs.")
+
+ panel1 := pterm.DefaultBox.Sprint("Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit,\nsed do eiusmod tempor incididunt\nut labore et dolore\nmagna aliqua.")
+ panel2 := pterm.DefaultBox.WithTitle("title").Sprint("Ut enim ad minim veniam,\nquis nostrud exercitation\nullamco laboris\nnisi ut aliquip\nex ea commodo\nconsequat.")
+ panel3 := pterm.DefaultBox.WithTitle("bottom center title").WithTitleBottomCenter().Sprint("Duis aute irure\ndolor in reprehenderit\nin voluptate velit esse cillum\ndolore eu fugiat\nnulla pariatur.")
+
+ panels, _ := pterm.DefaultPanel.WithPanels(pterm.Panels{
+ {{Data: panel1}, {Data: panel2}},
+ {{Data: panel3}},
+ }).Srender()
+
+ pterm.DefaultBox.WithTitle("Lorem Ipsum").WithTitleBottomRight().WithRightPadding(0).WithBottomPadding(0).Println(panels)
+}
+
+```
+
+
+
+### bulletlist/customized
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/customized/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ // Print a customized list with different styles and levels.
+ 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()
+}
+
+```
+
+
+
+### bulletlist/customized
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/customized/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ // Print a customized list with different styles and levels.
+ 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()
+}
+
+```
+
+
+
+### bulletlist/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print a list with different levels.
+ // Useful to generate lists automatically from data.
+ pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{
+ {Level: 0, Text: "Level 0"},
+ {Level: 1, Text: "Level 1"},
+ {Level: 2, Text: "Level 2"},
+ }).Render()
+
+ // Convert a text to a list and print it.
+ pterm.NewBulletListFromString(`0
+ 1
+ 2
+ 3`, " ").Render()
+}
+
+```
+
+
+
+### center/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/center/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ pterm.DefaultCenter.Println("This text is centered!\nIt centeres the whole block by default.\nIn that way you can do stuff like this:")
+
+ // Generate BigLetters
+ s, _ := pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString("PTerm")).Srender()
+ pterm.DefaultCenter.Println(s) // Print BigLetters with the default CenterPrinter
+
+ pterm.DefaultCenter.WithCenterEachLineSeparately().Println("This text is centered!\nBut each line is\ncentered\nseparately")
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/disable-color
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-color/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableColor()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/disable-color
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-color/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableColor()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/disable-output
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-output/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ for i := 0; i < 15; i++ {
+ switch i {
+ case 5:
+ pterm.Info.Println("Disabled Output!")
+ pterm.DisableOutput()
+ case 10:
+ pterm.EnableOutput()
+ pterm.Info.Println("Enabled Output!")
+ }
+
+ pterm.Printf("Printing something... [%d/%d]\n", i, 15)
+ }
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/disable-color
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-color/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableColor()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/disable-output
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-output/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ for i := 0; i < 15; i++ {
+ switch i {
+ case 5:
+ pterm.Info.Println("Disabled Output!")
+ pterm.DisableOutput()
+ case 10:
+ pterm.EnableOutput()
+ pterm.Info.Println("Enabled Output!")
+ }
+
+ pterm.Printf("Printing something... [%d/%d]\n", i, 15)
+ }
+}
+
+```
+
+
+
+### coloring/disable-styling
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-styling/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableStyling()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/disable-color
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-color/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableColor()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/disable-output
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-output/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ for i := 0; i < 15; i++ {
+ switch i {
+ case 5:
+ pterm.Info.Println("Disabled Output!")
+ pterm.DisableOutput()
+ case 10:
+ pterm.EnableOutput()
+ pterm.Info.Println("Enabled Output!")
+ }
+
+ pterm.Printf("Printing something... [%d/%d]\n", i, 15)
+ }
+}
+
+```
+
+
+
+### coloring/disable-styling
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-styling/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableStyling()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/fade-colors
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-colors/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ // Print info.
+ pterm.Info.Println("RGB colors only work in Terminals which support TrueColor.")
+
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients end point.
+
+ // For loop over the range of the terminal height.
+ for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
+ // Print string which is colored with the faded RGB value.
+ from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to).Println("Hello, World!")
+ }
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/disable-color
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-color/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableColor()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/disable-output
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-output/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ for i := 0; i < 15; i++ {
+ switch i {
+ case 5:
+ pterm.Info.Println("Disabled Output!")
+ pterm.DisableOutput()
+ case 10:
+ pterm.EnableOutput()
+ pterm.Info.Println("Enabled Output!")
+ }
+
+ pterm.Printf("Printing something... [%d/%d]\n", i, 15)
+ }
+}
+
+```
+
+
+
+### coloring/disable-styling
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-styling/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableStyling()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/fade-colors
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-colors/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ // Print info.
+ pterm.Info.Println("RGB colors only work in Terminals which support TrueColor.")
+
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients end point.
+
+ // For loop over the range of the terminal height.
+ for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
+ // Print string which is colored with the faded RGB value.
+ from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to).Println("Hello, World!")
+ }
+}
+
+```
+
+
+
+### coloring/fade-multiple-colors
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-multiple-colors/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "strings"
+
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+ to2 := pterm.NewRGB(255, 0, 0) // This RGB value is used as the gradients second point.
+ to3 := pterm.NewRGB(0, 255, 0) // This RGB value is used as the gradients third point.
+ to4 := pterm.NewRGB(255, 255, 255) // This RGB value is used as the gradients end point.
+
+ str := "RGB colors only work in Terminals which support TrueColor."
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+
+ // Print info.
+ pterm.Info.Println(fadeInfo)
+
+ // For loop over the range of the terminal height.
+ for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
+ // Print string which is colored with the faded RGB value.
+ from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to, to2, to3, to4).Println("Hello, World!")
+ }
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/disable-color
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-color/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableColor()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/disable-output
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-output/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ for i := 0; i < 15; i++ {
+ switch i {
+ case 5:
+ pterm.Info.Println("Disabled Output!")
+ pterm.DisableOutput()
+ case 10:
+ pterm.EnableOutput()
+ pterm.Info.Println("Enabled Output!")
+ }
+
+ pterm.Printf("Printing something... [%d/%d]\n", i, 15)
+ }
+}
+
+```
+
+
+
+### coloring/disable-styling
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-styling/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableStyling()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/fade-colors
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/box/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-colors/animation.svg)
@@ -387,30 +2940,31 @@ func main() {
```go
package main
-import "github.com/pterm/pterm"
+import (
+ "github.com/pterm/pterm"
+)
func main() {
- pterm.Info.Println("This might not be rendered correctly on GitHub,\nbut it will work in a real terminal.\nThis is because GitHub does not use a monospaced font by default for SVGs.")
-
- panel1 := pterm.DefaultBox.Sprint("Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit,\nsed do eiusmod tempor incididunt\nut labore et dolore\nmagna aliqua.")
- panel2 := pterm.DefaultBox.WithTitle("title").Sprint("Ut enim ad minim veniam,\nquis nostrud exercitation\nullamco laboris\nnisi ut aliquip\nex ea commodo\nconsequat.")
- panel3 := pterm.DefaultBox.WithTitle("bottom center title").WithTitleBottomCenter().Sprint("Duis aute irure\ndolor in reprehenderit\nin voluptate velit esse cillum\ndolore eu fugiat\nnulla pariatur.")
+ // Print info.
+ pterm.Info.Println("RGB colors only work in Terminals which support TrueColor.")
- panels, _ := pterm.DefaultPanel.WithPanels(pterm.Panels{
- {{Data: panel1}, {Data: panel2}},
- {{Data: panel3}},
- }).Srender()
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients end point.
- pterm.DefaultBox.WithTitle("Lorem Ipsum").WithTitleBottomRight().WithRightPadding(0).WithBottomPadding(0).Println(panels)
+ // For loop over the range of the terminal height.
+ for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
+ // Print string which is colored with the faded RGB value.
+ from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to).Println("Hello, World!")
+ }
}
```
-### bulletlist
+### coloring/fade-multiple-colors
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-multiple-colors/animation.svg)
@@ -419,31 +2973,45 @@ func main() {
```go
package main
-import "github.com/pterm/pterm"
+import (
+ "strings"
+
+ "github.com/pterm/pterm"
+)
func main() {
- // Print a list with different levels.
- // Useful to generate lists automatically from data.
- pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{
- {Level: 0, Text: "Level 0"},
- {Level: 1, Text: "Level 1"},
- {Level: 2, Text: "Level 2"},
- }).Render()
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+ to2 := pterm.NewRGB(255, 0, 0) // This RGB value is used as the gradients second point.
+ to3 := pterm.NewRGB(0, 255, 0) // This RGB value is used as the gradients third point.
+ to4 := pterm.NewRGB(255, 255, 255) // This RGB value is used as the gradients end point.
- // Convert a text to a list and print it.
- pterm.NewBulletListFromString(`0
- 1
- 2
- 3`, " ").Render()
+ str := "RGB colors only work in Terminals which support TrueColor."
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+
+ // Print info.
+ pterm.Info.Println(fadeInfo)
+
+ // For loop over the range of the terminal height.
+ for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
+ // Print string which is colored with the faded RGB value.
+ from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to, to2, to3, to4).Println("Hello, World!")
+ }
}
```
-### bulletlist-custom
+### coloring/override-default-printers
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist-custom/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/override-default-printers/animation.svg)
@@ -452,26 +3020,29 @@ func main() {
```go
package main
-import (
- "github.com/pterm/pterm"
-)
+import "github.com/pterm/pterm"
func main() {
- // Print a customized list with different styles and levels.
- 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()
+ // Print default error.
+ pterm.Error.Println("This is the default Error")
+
+ // Customize default error.
+ pterm.Error.Prefix = pterm.Prefix{
+ Text: "OVERRIDE",
+ Style: pterm.NewStyle(pterm.BgCyan, pterm.FgRed),
+ }
+
+ // Print new default error.
+ pterm.Error.Println("This is the default Error after the prefix was overridden")
}
```
-### center
+### coloring/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/center/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
@@ -483,22 +3054,36 @@ package main
import "github.com/pterm/pterm"
func main() {
- pterm.DefaultCenter.Println("This text is centered!\nIt centeres the whole block by default.\nIn that way you can do stuff like this:")
-
- // Generate BigLetters
- s, _ := pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString("PTerm")).Srender()
- pterm.DefaultCenter.Println(s) // Print BigLetters with the default CenterPrinter
+ // Print 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.DefaultCenter.WithCenterEachLineSeparately().Println("This text is centered!\nBut each line is\ncentered\nseparately")
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
}
```
-### demo
+### coloring/disable-color
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/demo/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-color/animation.svg)
@@ -524,6 +3109,7 @@ var pseudoProgramList = strings.Split("pseudo-excel pseudo-photoshop pseudo-chro
"pseudo-dops pseudo-git pseudo-vsc pseudo-intellij pseudo-minecraft pseudo-scoop pseudo-chocolatey", " ")
func main() {
+ pterm.DisableColor()
introScreen()
clear()
pseudoApplicationHeader()
@@ -622,14 +3208,13 @@ func pseudoApplicationHeader() *pterm.TextPrinter {
}
func introScreen() {
- ptermLogo, _ := pterm.DefaultBigText.WithLetters(
+ pterm.DefaultBigText.WithLetters(
pterm.NewLettersFromStringWithStyle("P", pterm.NewStyle(pterm.FgLightCyan)),
pterm.NewLettersFromStringWithStyle("Term", pterm.NewStyle(pterm.FgLightMagenta))).
- Srender()
-
- pterm.DefaultCenter.Print(ptermLogo)
+ Render()
- pterm.DefaultCenter.Print(pterm.DefaultHeader.WithFullWidth().WithBackgroundStyle(pterm.NewStyle(pterm.BgLightBlue)).WithMargin(10).Sprint("PTDP - PTerm Demo Program"))
+ 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." +
@@ -639,7 +3224,7 @@ func introScreen() {
"\n" +
"\nThis demo was updated at: " + pterm.Green(time.Now().Format("02 Jan 2006 - 15:04:05 MST")))
pterm.Println()
- introSpinner, _ := pterm.DefaultSpinner.WithShowTimer(false).WithRemoveWhenDone(true).Start("Waiting for 15 seconds...")
+ introSpinner, _ := pterm.DefaultSpinner.WithRemoveWhenDone(true).Start("Waiting for 15 seconds...")
time.Sleep(second)
for i := 14; i > 0; i-- {
if i > 1 {
@@ -665,9 +3250,41 @@ func randomInt(min, max int) int {
-### disable-color
+### coloring/disable-output
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-output/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ for i := 0; i < 15; i++ {
+ switch i {
+ case 5:
+ pterm.Info.Println("Disabled Output!")
+ pterm.DisableOutput()
+ case 10:
+ pterm.EnableOutput()
+ pterm.Info.Println("Enabled Output!")
+ }
+
+ pterm.Printf("Printing something... [%d/%d]\n", i, 15)
+ }
+}
+
+```
+
+
+
+### coloring/disable-styling
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/disable-color/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-styling/animation.svg)
@@ -693,7 +3310,7 @@ var pseudoProgramList = strings.Split("pseudo-excel pseudo-photoshop pseudo-chro
"pseudo-dops pseudo-git pseudo-vsc pseudo-intellij pseudo-minecraft pseudo-scoop pseudo-chocolatey", " ")
func main() {
- pterm.DisableColor()
+ pterm.DisableStyling()
introScreen()
clear()
pseudoApplicationHeader()
@@ -821,22 +3438,133 @@ func introScreen() {
introSpinner.Stop()
}
-func clear() {
- print("\033[H\033[2J")
-}
+func clear() {
+ print("\033[H\033[2J")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/fade-colors
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-colors/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ // Print info.
+ pterm.Info.Println("RGB colors only work in Terminals which support TrueColor.")
+
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients end point.
+
+ // For loop over the range of the terminal height.
+ for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
+ // Print string which is colored with the faded RGB value.
+ from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to).Println("Hello, World!")
+ }
+}
+
+```
+
+
+
+### coloring/fade-multiple-colors
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-multiple-colors/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "strings"
+
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+ to2 := pterm.NewRGB(255, 0, 0) // This RGB value is used as the gradients second point.
+ to3 := pterm.NewRGB(0, 255, 0) // This RGB value is used as the gradients third point.
+ to4 := pterm.NewRGB(255, 255, 255) // This RGB value is used as the gradients end point.
+
+ str := "RGB colors only work in Terminals which support TrueColor."
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+
+ // Print info.
+ pterm.Info.Println(fadeInfo)
+
+ // For loop over the range of the terminal height.
+ for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
+ // Print string which is colored with the faded RGB value.
+ from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to, to2, to3, to4).Println("Hello, World!")
+ }
+}
+
+```
+
+
+
+### coloring/override-default-printers
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/override-default-printers/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
-func randomInt(min, max int) int {
- rand.Seed(time.Now().UnixNano())
- return rand.Intn(max-min+1) + min
+func main() {
+ // Print default error.
+ pterm.Error.Println("This is the default Error")
+
+ // Customize default error.
+ pterm.Error.Prefix = pterm.Prefix{
+ Text: "OVERRIDE",
+ Style: pterm.NewStyle(pterm.BgCyan, pterm.FgRed),
+ }
+
+ // Print new default error.
+ pterm.Error.Println("This is the default Error after the prefix was overridden")
}
```
-### disable-output
+### coloring/print-color-rgb
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/disable-output/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/print-color-rgb/animation.svg)
@@ -848,27 +3576,20 @@ package main
import "github.com/pterm/pterm"
func main() {
- for i := 0; i < 15; i++ {
- switch i {
- case 5:
- pterm.Info.Println("Disabled Output!")
- pterm.DisableOutput()
- case 10:
- pterm.EnableOutput()
- pterm.Info.Println("Enabled Output!")
- }
-
- pterm.Printf("Printing something... [%d/%d]\n", i, 15)
- }
+ // Print strings with a custom RGB color.
+ // NOTICE: This only works with terminals which support TrueColor.
+ 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!")
}
```
-### disable-styling
+### demo/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/disable-styling/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/demo/demo/animation.svg)
@@ -894,7 +3615,6 @@ var pseudoProgramList = strings.Split("pseudo-excel pseudo-photoshop pseudo-chro
"pseudo-dops pseudo-git pseudo-vsc pseudo-intellij pseudo-minecraft pseudo-scoop pseudo-chocolatey", " ")
func main() {
- pterm.DisableStyling()
introScreen()
clear()
pseudoApplicationHeader()
@@ -993,13 +3713,14 @@ func pseudoApplicationHeader() *pterm.TextPrinter {
}
func introScreen() {
- pterm.DefaultBigText.WithLetters(
+ ptermLogo, _ := pterm.DefaultBigText.WithLetters(
pterm.NewLettersFromStringWithStyle("P", pterm.NewStyle(pterm.FgLightCyan)),
pterm.NewLettersFromStringWithStyle("Term", pterm.NewStyle(pterm.FgLightMagenta))).
- Render()
+ Srender()
- pterm.DefaultHeader.WithBackgroundStyle(pterm.NewStyle(pterm.BgLightBlue)).WithMargin(10).Println(
- "PTDP - PTerm Demo Program")
+ pterm.DefaultCenter.Print(ptermLogo)
+
+ pterm.DefaultCenter.Print(pterm.DefaultHeader.WithFullWidth().WithBackgroundStyle(pterm.NewStyle(pterm.BgLightBlue)).WithMargin(10).Sprint("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." +
@@ -1009,7 +3730,7 @@ func introScreen() {
"\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...")
+ introSpinner, _ := pterm.DefaultSpinner.WithShowTimer(false).WithRemoveWhenDone(true).Start("Waiting for 15 seconds...")
time.Sleep(second)
for i := 14; i > 0; i-- {
if i > 1 {
@@ -1035,9 +3756,9 @@ func randomInt(min, max int) int {
-### header
+### header/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/header/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/header/demo/animation.svg)
@@ -1059,9 +3780,9 @@ func main() {
-### header-custom
+### header-custom/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/header-custom/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/header-custom/demo/animation.svg)
@@ -1099,40 +3820,9 @@ func main() {
-### override-default-printers
-
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/override-default-printers/animation.svg)
-
-
-
-SHOW SOURCE
-
-```go
-package main
-
-import "github.com/pterm/pterm"
-
-func main() {
- // Print default error.
- pterm.Error.Println("This is the default Error")
-
- // Customize default error.
- pterm.Error.Prefix = pterm.Prefix{
- Text: "OVERRIDE",
- Style: pterm.NewStyle(pterm.BgCyan, pterm.FgRed),
- }
-
- // Print new default error.
- pterm.Error.Println("This is the default Error after the prefix was overridden")
-}
-
-```
-
-
-
-### panel
+### panel/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/panel/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/panel/demo/animation.svg)
@@ -1158,9 +3848,9 @@ func main() {
-### paragraph
+### paragraph/customized
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/paragraph/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/paragraph/customized/animation.svg)
@@ -1172,15 +3862,15 @@ package main
import "github.com/pterm/pterm"
func main() {
- // Print long text with default paragraph printer.
- pterm.DefaultParagraph.Println("This is the default paragraph printer. As you can see, no words are separated, " +
+ // Print a paragraph with a custom maximal width.
+ 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")
// Print one line space.
pterm.Println()
- // Print long text without paragraph printer.
+ // Print text without a paragraph printer.
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")
}
@@ -1189,9 +3879,9 @@ func main() {
-### paragraph-custom
+### paragraph/customized
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/paragraph-custom/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/paragraph/customized/animation.svg)
@@ -1220,40 +3910,9 @@ func main() {
-### prefix
-
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/prefix/animation.svg)
-
-
-
-SHOW SOURCE
-
-```go
-package main
-
-import "github.com/pterm/pterm"
-
-func main() {
- // Enable debug messages.
- pterm.EnableDebugMessages()
-
- pterm.Debug.Println("Hello, World!") // Print Debug.
- pterm.Info.Println("Hello, World!") // Print Info.
- pterm.Success.Println("Hello, World!") // Print Success.
- pterm.Warning.Println("Hello, World!") // Print Warning.
- pterm.Error.Println("Errors show the filename and linenumber inside the terminal!") // Print Error.
- pterm.Info.WithShowLineNumber().Println("Other PrefixPrinters can do that too!") // Print Error.
- // Temporarily set Fatal to false, so that the CI won't crash.
- pterm.Fatal.WithFatal(false).Println("Hello, World!") // Print Fatal.
-}
-
-```
-
-
-
-### print-basic-text
+### paragraph/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/print-basic-text/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/paragraph/demo/animation.svg)
@@ -1265,127 +3924,26 @@ package main
import "github.com/pterm/pterm"
func main() {
- // A BasicText printer is used to print text, without special formatting.
- // As it implements the TextPrinter interface, you can use it in combination with other printers.
- 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.")
- // If you just want to print text, you should use this instead:
- // pterm.Println("Hello, World!")
-}
-
-```
-
-
-
-### print-color-fade
-
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/print-color-fade/animation.svg)
-
-
-
-SHOW SOURCE
-
-```go
-package main
-
-import (
- "github.com/pterm/pterm"
-)
-
-func main() {
- // Print info.
- pterm.Info.Println("RGB colors only work in Terminals which support TrueColor.")
-
- from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
- to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients end point.
-
- // For loop over the range of the terminal height.
- for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
- // Print string which is colored with the faded RGB value.
- from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to).Println("Hello, World!")
- }
-}
-
-```
-
-
-
-### print-color-fade-multiple
-
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/print-color-fade-multiple/animation.svg)
-
-
-
-SHOW SOURCE
-
-```go
-package main
-
-import (
- "strings"
-
- "github.com/pterm/pterm"
-)
-
-func main() {
- from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
- to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
- to2 := pterm.NewRGB(255, 0, 0) // This RGB value is used as the gradients second point.
- to3 := pterm.NewRGB(0, 255, 0) // This RGB value is used as the gradients third point.
- to4 := pterm.NewRGB(255, 255, 255) // This RGB value is used as the gradients end point.
-
- str := "RGB colors only work in Terminals which support TrueColor."
- strs := strings.Split(str, "")
- var fadeInfo string // String which will be used to print info.
- // For loop over the range of the string length.
- for i := 0; i < len(str); i++ {
- // Append faded letter to info string.
- fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
- }
-
- // Print info.
- pterm.Info.Println(fadeInfo)
-
- // For loop over the range of the terminal height.
- for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
- // Print string which is colored with the faded RGB value.
- from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to, to2, to3, to4).Println("Hello, World!")
- }
-}
-
-```
-
-
-
-### print-color-rgb
-
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/print-color-rgb/animation.svg)
-
-
-
-SHOW SOURCE
-
-```go
-package main
+ // Print long text with default paragraph printer.
+ 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")
-import "github.com/pterm/pterm"
+ // Print one line space.
+ pterm.Println()
-func main() {
- // Print strings with a custom RGB color.
- // NOTICE: This only works with terminals which support TrueColor.
- 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 long text without paragraph printer.
+ 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-with-color
+### prefix/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/print-with-color/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/prefix/demo/animation.svg)
@@ -1397,36 +3955,26 @@ package main
import "github.com/pterm/pterm"
func main() {
- // Print 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!"))
+ // Enable debug messages.
+ pterm.EnableDebugMessages()
- // Print strings with set color.
- 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.Println() // Print one line space.
- 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")
+ pterm.Debug.Println("Hello, World!") // Print Debug.
+ pterm.Info.Println("Hello, World!") // Print Info.
+ pterm.Success.Println("Hello, World!") // Print Success.
+ pterm.Warning.Println("Hello, World!") // Print Warning.
+ pterm.Error.Println("Errors show the filename and linenumber inside the terminal!") // Print Error.
+ pterm.Info.WithShowLineNumber().Println("Other PrefixPrinters can do that too!") // Print Error.
+ // Temporarily set Fatal to false, so that the CI won't crash.
+ pterm.Fatal.WithFatal(false).Println("Hello, World!") // Print Fatal.
}
```
-### progressbar
+### progressbar/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/progressbar/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/progressbar/demo/animation.svg)
@@ -1462,9 +4010,9 @@ func main() {
-### section
+### section/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/section/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/section/demo/animation.svg)
@@ -1491,9 +4039,9 @@ func main() {
-### spinner
+### spinner/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/spinner/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/spinner/demo/animation.svg)
@@ -1538,9 +4086,9 @@ func main() {
-### style
+### style/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/style/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/style/demo/animation.svg)
@@ -1565,9 +4113,9 @@ func main() {
-### table
+### table/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/table/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/table/demo/animation.svg)
@@ -1589,7 +4137,7 @@ func main() {
}).Render()
pterm.Println() // Blank line
-
+
// Create a table with right alignment.
pterm.DefaultTable.WithHasHeader().WithData(pterm.TableData{
{"Firstname", "Lastname", "Email"},
@@ -1603,9 +4151,9 @@ func main() {
-### theme
+### theme/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/theme/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/theme/demo/animation.svg)
@@ -1647,9 +4195,9 @@ func main() {
-### tree
+### tree/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/tree/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/tree/demo/animation.svg)
diff --git a/_examples/README.md b/_examples/README.md
new file mode 100644
index 000000000..f5cac288a
--- /dev/null
+++ b/_examples/README.md
@@ -0,0 +1,4075 @@
+# PTerm Examples
+
+> This directory contains examples of using the PTerm library.
+
+
+### area/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/area/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "time"
+
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ pterm.Info.Println("The previous text will stay in place, while the area updates.")
+ pterm.Print("\n\n") // Add two new lines as spacer.
+
+ area, _ := pterm.DefaultArea.WithCenter().Start() // Start the Area printer, with the Center option.
+ for i := 0; i < 10; i++ {
+ str, _ := pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString(time.Now().Format("15:04:05"))).Srender() // Save current time in str.
+ area.Update(str) // Update Area contents.
+ time.Sleep(time.Second)
+ }
+ area.Stop()
+}
+
+```
+
+
+
+### barchart/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ positiveBars := pterm.Bars{
+ pterm.Bar{
+ Label: "Bar 1",
+ Value: 5,
+ },
+ pterm.Bar{
+ Label: "Bar 2",
+ Value: 3,
+ },
+ pterm.Bar{
+ Label: "Longer Label",
+ Value: 7,
+ },
+ }
+
+ pterm.Info.Println("Chart example with positive only values (bars use 100% of chart area)")
+ _ = pterm.DefaultBarChart.WithBars(positiveBars).Render()
+ _ = pterm.DefaultBarChart.WithHorizontal().WithBars(positiveBars).Render()
+}
+
+```
+
+
+
+### barchart/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ positiveBars := pterm.Bars{
+ pterm.Bar{
+ Label: "Bar 1",
+ Value: 5,
+ },
+ pterm.Bar{
+ Label: "Bar 2",
+ Value: 3,
+ },
+ pterm.Bar{
+ Label: "Longer Label",
+ Value: 7,
+ },
+ }
+
+ pterm.Info.Println("Chart example with positive only values (bars use 100% of chart area)")
+ _ = pterm.DefaultBarChart.WithBars(positiveBars).Render()
+ _ = pterm.DefaultBarChart.WithHorizontal().WithBars(positiveBars).Render()
+}
+
+```
+
+
+
+### barchart/mixed-values
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/mixed-values/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ mixedBars := pterm.Bars{
+ pterm.Bar{
+ Label: "Bar 1",
+ Value: 2,
+ },
+ pterm.Bar{
+ Label: "Bar 2",
+ Value: -3,
+ },
+ pterm.Bar{
+ Label: "Bar 3",
+ Value: -2,
+ },
+ pterm.Bar{
+ Label: "Bar 4",
+ Value: 5,
+ },
+ pterm.Bar{
+ Label: "Longer Label",
+ Value: 7,
+ },
+ }
+
+ pterm.DefaultSection.Println("Chart example with mixed values (note screen space usage in case when ABSOLUTE values of negative and positive parts are differ too much)")
+ _ = pterm.DefaultBarChart.WithBars(mixedBars).WithShowValue().Render()
+ _ = pterm.DefaultBarChart.WithHorizontal().WithBars(mixedBars).WithShowValue().Render()
+}
+
+```
+
+
+
+### barchart/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ positiveBars := pterm.Bars{
+ pterm.Bar{
+ Label: "Bar 1",
+ Value: 5,
+ },
+ pterm.Bar{
+ Label: "Bar 2",
+ Value: 3,
+ },
+ pterm.Bar{
+ Label: "Longer Label",
+ Value: 7,
+ },
+ }
+
+ pterm.Info.Println("Chart example with positive only values (bars use 100% of chart area)")
+ _ = pterm.DefaultBarChart.WithBars(positiveBars).Render()
+ _ = pterm.DefaultBarChart.WithHorizontal().WithBars(positiveBars).Render()
+}
+
+```
+
+
+
+### barchart/mixed-values
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/mixed-values/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ mixedBars := pterm.Bars{
+ pterm.Bar{
+ Label: "Bar 1",
+ Value: 2,
+ },
+ pterm.Bar{
+ Label: "Bar 2",
+ Value: -3,
+ },
+ pterm.Bar{
+ Label: "Bar 3",
+ Value: -2,
+ },
+ pterm.Bar{
+ Label: "Bar 4",
+ Value: 5,
+ },
+ pterm.Bar{
+ Label: "Longer Label",
+ Value: 7,
+ },
+ }
+
+ pterm.DefaultSection.Println("Chart example with mixed values (note screen space usage in case when ABSOLUTE values of negative and positive parts are differ too much)")
+ _ = pterm.DefaultBarChart.WithBars(mixedBars).WithShowValue().Render()
+ _ = pterm.DefaultBarChart.WithHorizontal().WithBars(mixedBars).WithShowValue().Render()
+}
+
+```
+
+
+
+### barchart/negative-values
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/negative-values/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ negativeBars := pterm.Bars{
+ pterm.Bar{
+ Label: "Bar 1",
+ Value: -5,
+ },
+ pterm.Bar{
+ Label: "Bar 2",
+ Value: -3,
+ },
+ pterm.Bar{
+ Label: "Longer Label",
+ Value: -7,
+ },
+ }
+
+ pterm.Info.Println("Chart example with negative only values (bars use 100% of chart area)")
+ _ = pterm.DefaultBarChart.WithBars(negativeBars).WithShowValue().Render()
+ _ = pterm.DefaultBarChart.WithHorizontal().WithBars(negativeBars).WithShowValue().Render()
+}
+
+```
+
+
+
+### basictext/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/basictext/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // A BasicText printer is used to print text, without special formatting.
+ // As it implements the TextPrinter interface, you can use it in combination with other printers.
+ 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.")
+ // If you just want to print text, you should use this instead:
+ // pterm.Println("Hello, World!")
+}
+
+```
+
+
+
+### bigtext/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bigtext/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print a large text with the LetterStyle from the standard theme.
+ // Useful for title screens.
+ pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString("PTerm")).Render()
+
+ // Print a large text with differently colored letters.
+ pterm.DefaultBigText.WithLetters(
+ pterm.NewLettersFromStringWithStyle("P", pterm.NewStyle(pterm.FgCyan)),
+ pterm.NewLettersFromStringWithStyle("Term", pterm.NewStyle(pterm.FgLightMagenta))).
+ Render()
+
+ // NewLettersFromStringWithRGB can be used to create a large text with a specific RGB color.
+ pterm.DefaultBigText.WithLetters(
+ pterm.NewLettersFromStringWithRGB("PTerm", pterm.NewRGB(255, 215, 0))).
+ Render()
+}
+
+```
+
+
+
+### box/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/box/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ pterm.Info.Println("This might not be rendered correctly on GitHub,\nbut it will work in a real terminal.\nThis is because GitHub does not use a monospaced font by default for SVGs.")
+
+ panel1 := pterm.DefaultBox.Sprint("Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit,\nsed do eiusmod tempor incididunt\nut labore et dolore\nmagna aliqua.")
+ panel2 := pterm.DefaultBox.WithTitle("title").Sprint("Ut enim ad minim veniam,\nquis nostrud exercitation\nullamco laboris\nnisi ut aliquip\nex ea commodo\nconsequat.")
+ panel3 := pterm.DefaultBox.WithTitle("bottom center title").WithTitleBottomCenter().Sprint("Duis aute irure\ndolor in reprehenderit\nin voluptate velit esse cillum\ndolore eu fugiat\nnulla pariatur.")
+
+ panels, _ := pterm.DefaultPanel.WithPanels(pterm.Panels{
+ {{Data: panel1}, {Data: panel2}},
+ {{Data: panel3}},
+ }).Srender()
+
+ pterm.DefaultBox.WithTitle("Lorem Ipsum").WithTitleBottomRight().WithRightPadding(0).WithBottomPadding(0).Println(panels)
+}
+
+```
+
+
+
+### bulletlist/customized
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/customized/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ // Print a customized list with different styles and levels.
+ 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()
+}
+
+```
+
+
+
+### bulletlist/customized
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/customized/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ // Print a customized list with different styles and levels.
+ 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()
+}
+
+```
+
+
+
+### bulletlist/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print a list with different levels.
+ // Useful to generate lists automatically from data.
+ pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{
+ {Level: 0, Text: "Level 0"},
+ {Level: 1, Text: "Level 1"},
+ {Level: 2, Text: "Level 2"},
+ }).Render()
+
+ // Convert a text to a list and print it.
+ pterm.NewBulletListFromString(`0
+ 1
+ 2
+ 3`, " ").Render()
+}
+
+```
+
+
+
+### center/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/center/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ pterm.DefaultCenter.Println("This text is centered!\nIt centeres the whole block by default.\nIn that way you can do stuff like this:")
+
+ // Generate BigLetters
+ s, _ := pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString("PTerm")).Srender()
+ pterm.DefaultCenter.Println(s) // Print BigLetters with the default CenterPrinter
+
+ pterm.DefaultCenter.WithCenterEachLineSeparately().Println("This text is centered!\nBut each line is\ncentered\nseparately")
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/disable-color
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-color/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableColor()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/disable-color
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-color/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableColor()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/disable-output
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-output/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ for i := 0; i < 15; i++ {
+ switch i {
+ case 5:
+ pterm.Info.Println("Disabled Output!")
+ pterm.DisableOutput()
+ case 10:
+ pterm.EnableOutput()
+ pterm.Info.Println("Enabled Output!")
+ }
+
+ pterm.Printf("Printing something... [%d/%d]\n", i, 15)
+ }
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/disable-color
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-color/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableColor()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/disable-output
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-output/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ for i := 0; i < 15; i++ {
+ switch i {
+ case 5:
+ pterm.Info.Println("Disabled Output!")
+ pterm.DisableOutput()
+ case 10:
+ pterm.EnableOutput()
+ pterm.Info.Println("Enabled Output!")
+ }
+
+ pterm.Printf("Printing something... [%d/%d]\n", i, 15)
+ }
+}
+
+```
+
+
+
+### coloring/disable-styling
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-styling/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableStyling()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/disable-color
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-color/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableColor()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/disable-output
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-output/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ for i := 0; i < 15; i++ {
+ switch i {
+ case 5:
+ pterm.Info.Println("Disabled Output!")
+ pterm.DisableOutput()
+ case 10:
+ pterm.EnableOutput()
+ pterm.Info.Println("Enabled Output!")
+ }
+
+ pterm.Printf("Printing something... [%d/%d]\n", i, 15)
+ }
+}
+
+```
+
+
+
+### coloring/disable-styling
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-styling/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableStyling()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/fade-colors
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-colors/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ // Print info.
+ pterm.Info.Println("RGB colors only work in Terminals which support TrueColor.")
+
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients end point.
+
+ // For loop over the range of the terminal height.
+ for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
+ // Print string which is colored with the faded RGB value.
+ from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to).Println("Hello, World!")
+ }
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/disable-color
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-color/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableColor()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/disable-output
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-output/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ for i := 0; i < 15; i++ {
+ switch i {
+ case 5:
+ pterm.Info.Println("Disabled Output!")
+ pterm.DisableOutput()
+ case 10:
+ pterm.EnableOutput()
+ pterm.Info.Println("Enabled Output!")
+ }
+
+ pterm.Printf("Printing something... [%d/%d]\n", i, 15)
+ }
+}
+
+```
+
+
+
+### coloring/disable-styling
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-styling/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableStyling()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/fade-colors
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-colors/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ // Print info.
+ pterm.Info.Println("RGB colors only work in Terminals which support TrueColor.")
+
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients end point.
+
+ // For loop over the range of the terminal height.
+ for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
+ // Print string which is colored with the faded RGB value.
+ from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to).Println("Hello, World!")
+ }
+}
+
+```
+
+
+
+### coloring/fade-multiple-colors
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-multiple-colors/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "strings"
+
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+ to2 := pterm.NewRGB(255, 0, 0) // This RGB value is used as the gradients second point.
+ to3 := pterm.NewRGB(0, 255, 0) // This RGB value is used as the gradients third point.
+ to4 := pterm.NewRGB(255, 255, 255) // This RGB value is used as the gradients end point.
+
+ str := "RGB colors only work in Terminals which support TrueColor."
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+
+ // Print info.
+ pterm.Info.Println(fadeInfo)
+
+ // For loop over the range of the terminal height.
+ for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
+ // Print string which is colored with the faded RGB value.
+ from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to, to2, to3, to4).Println("Hello, World!")
+ }
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/disable-color
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-color/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableColor()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/disable-output
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-output/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ for i := 0; i < 15; i++ {
+ switch i {
+ case 5:
+ pterm.Info.Println("Disabled Output!")
+ pterm.DisableOutput()
+ case 10:
+ pterm.EnableOutput()
+ pterm.Info.Println("Enabled Output!")
+ }
+
+ pterm.Printf("Printing something... [%d/%d]\n", i, 15)
+ }
+}
+
+```
+
+
+
+### coloring/disable-styling
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-styling/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableStyling()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/fade-colors
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-colors/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ // Print info.
+ pterm.Info.Println("RGB colors only work in Terminals which support TrueColor.")
+
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients end point.
+
+ // For loop over the range of the terminal height.
+ for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
+ // Print string which is colored with the faded RGB value.
+ from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to).Println("Hello, World!")
+ }
+}
+
+```
+
+
+
+### coloring/fade-multiple-colors
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-multiple-colors/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "strings"
+
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+ to2 := pterm.NewRGB(255, 0, 0) // This RGB value is used as the gradients second point.
+ to3 := pterm.NewRGB(0, 255, 0) // This RGB value is used as the gradients third point.
+ to4 := pterm.NewRGB(255, 255, 255) // This RGB value is used as the gradients end point.
+
+ str := "RGB colors only work in Terminals which support TrueColor."
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+
+ // Print info.
+ pterm.Info.Println(fadeInfo)
+
+ // For loop over the range of the terminal height.
+ for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
+ // Print string which is colored with the faded RGB value.
+ from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to, to2, to3, to4).Println("Hello, World!")
+ }
+}
+
+```
+
+
+
+### coloring/override-default-printers
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/override-default-printers/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print default error.
+ pterm.Error.Println("This is the default Error")
+
+ // Customize default error.
+ pterm.Error.Prefix = pterm.Prefix{
+ Text: "OVERRIDE",
+ Style: pterm.NewStyle(pterm.BgCyan, pterm.FgRed),
+ }
+
+ // Print new default error.
+ pterm.Error.Println("This is the default Error after the prefix was overridden")
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/disable-color
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-color/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableColor()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/disable-output
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-output/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ for i := 0; i < 15; i++ {
+ switch i {
+ case 5:
+ pterm.Info.Println("Disabled Output!")
+ pterm.DisableOutput()
+ case 10:
+ pterm.EnableOutput()
+ pterm.Info.Println("Enabled Output!")
+ }
+
+ pterm.Printf("Printing something... [%d/%d]\n", i, 15)
+ }
+}
+
+```
+
+
+
+### coloring/disable-styling
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-styling/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableStyling()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/fade-colors
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-colors/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ // Print info.
+ pterm.Info.Println("RGB colors only work in Terminals which support TrueColor.")
+
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients end point.
+
+ // For loop over the range of the terminal height.
+ for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
+ // Print string which is colored with the faded RGB value.
+ from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to).Println("Hello, World!")
+ }
+}
+
+```
+
+
+
+### coloring/fade-multiple-colors
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-multiple-colors/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "strings"
+
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+ to2 := pterm.NewRGB(255, 0, 0) // This RGB value is used as the gradients second point.
+ to3 := pterm.NewRGB(0, 255, 0) // This RGB value is used as the gradients third point.
+ to4 := pterm.NewRGB(255, 255, 255) // This RGB value is used as the gradients end point.
+
+ str := "RGB colors only work in Terminals which support TrueColor."
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+
+ // Print info.
+ pterm.Info.Println(fadeInfo)
+
+ // For loop over the range of the terminal height.
+ for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
+ // Print string which is colored with the faded RGB value.
+ from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to, to2, to3, to4).Println("Hello, World!")
+ }
+}
+
+```
+
+
+
+### coloring/override-default-printers
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/override-default-printers/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print default error.
+ pterm.Error.Println("This is the default Error")
+
+ // Customize default error.
+ pterm.Error.Prefix = pterm.Prefix{
+ Text: "OVERRIDE",
+ Style: pterm.NewStyle(pterm.BgCyan, pterm.FgRed),
+ }
+
+ // Print new default error.
+ pterm.Error.Println("This is the default Error after the prefix was overridden")
+}
+
+```
+
+
+
+### coloring/print-color-rgb
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/print-color-rgb/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print strings with a custom RGB color.
+ // NOTICE: This only works with terminals which support TrueColor.
+ 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!")
+}
+
+```
+
+
+
+### demo/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/demo/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+func pseudoApplicationHeader() *pterm.TextPrinter {
+ return pterm.DefaultHeader.WithBackgroundStyle(pterm.NewStyle(pterm.BgLightBlue)).WithMargin(10).Println(
+ "Pseudo Application created with PTerm")
+}
+
+func introScreen() {
+ ptermLogo, _ := pterm.DefaultBigText.WithLetters(
+ pterm.NewLettersFromStringWithStyle("P", pterm.NewStyle(pterm.FgLightCyan)),
+ pterm.NewLettersFromStringWithStyle("Term", pterm.NewStyle(pterm.FgLightMagenta))).
+ Srender()
+
+ pterm.DefaultCenter.Print(ptermLogo)
+
+ pterm.DefaultCenter.Print(pterm.DefaultHeader.WithFullWidth().WithBackgroundStyle(pterm.NewStyle(pterm.BgLightBlue)).WithMargin(10).Sprint("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.WithShowTimer(false).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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### header/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/header/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print a default header.
+ pterm.DefaultHeader.Println("This is the default header!")
+ pterm.Println() // spacer
+ pterm.DefaultHeader.WithFullWidth().Println("This is a full-width header.")
+}
+
+```
+
+
+
+### header-custom/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/header-custom/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+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).
+ WithBackgroundStyle(pterm.NewStyle(pterm.BgCyan)).
+ WithTextStyle(pterm.NewStyle(pterm.FgBlack)).
+ Println("This is a custom 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,
+ }
+
+ // Print header.
+ newHeader.Println("This is a custom header!")
+}
+
+```
+
+
+
+### panel/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/panel/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Declare panels in a two dimensional grid system.
+ panels := pterm.Panels{
+ {{Data: "This is the first panel"}, {Data: pterm.DefaultHeader.Sprint("Hello, World!")}, {Data: "This\npanel\ncontains\nmultiple\nlines"}},
+ {{Data: pterm.Red("This is another\npanel line")}, {Data: "This is the second panel\nwith a new line"}},
+ }
+
+ // Print panels.
+ _ = pterm.DefaultPanel.WithPanels(panels).WithPadding(5).Render()
+}
+
+```
+
+
+
+### paragraph/customized
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/paragraph/customized/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print a paragraph with a custom maximal width.
+ 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")
+
+ // Print one line space.
+ pterm.Println()
+
+ // Print text without a paragraph printer.
+ 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/customized
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/paragraph/customized/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print a paragraph with a custom maximal width.
+ 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")
+
+ // Print one line space.
+ pterm.Println()
+
+ // Print text without a paragraph printer.
+ 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/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/paragraph/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print long text with default paragraph printer.
+ 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")
+
+ // Print one line space.
+ pterm.Println()
+
+ // Print long text without paragraph printer.
+ 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")
+}
+
+```
+
+
+
+### prefix/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/prefix/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Enable debug messages.
+ pterm.EnableDebugMessages()
+
+ pterm.Debug.Println("Hello, World!") // Print Debug.
+ pterm.Info.Println("Hello, World!") // Print Info.
+ pterm.Success.Println("Hello, World!") // Print Success.
+ pterm.Warning.Println("Hello, World!") // Print Warning.
+ pterm.Error.Println("Errors show the filename and linenumber inside the terminal!") // Print Error.
+ pterm.Info.WithShowLineNumber().Println("Other PrefixPrinters can do that too!") // Print Error.
+ // Temporarily set Fatal to false, so that the CI won't crash.
+ pterm.Fatal.WithFatal(false).Println("Hello, World!") // Print Fatal.
+}
+
+```
+
+
+
+### progressbar/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/progressbar/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "strings"
+ "time"
+
+ "github.com/pterm/pterm"
+)
+
+// Slice of strings with placeholder text.
+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", " ")
+
+func main() {
+ // Create progressbar as fork from the default progressbar.
+ p, _ := pterm.DefaultProgressbar.WithTotal(len(fakeInstallList)).WithTitle("Downloading stuff").Start()
+
+ for i := 0; i < p.Total; i++ {
+ p.UpdateTitle("Downloading " + fakeInstallList[i]) // Update the title of the progressbar.
+ pterm.Success.Println("Downloading " + fakeInstallList[i]) // If a progressbar is running, each print will be printed above the progressbar.
+ p.Increment() // Increment the progressbar by one. Use Add(x int) to increment by a custom amount.
+ time.Sleep(time.Millisecond * 350) // Sleep 350 milliseconds.
+ }
+}
+
+```
+
+
+
+### section/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/section/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print a section with level one.
+ pterm.DefaultSection.Println("This is a section!")
+ // Print placeholder.
+ pterm.Info.Println("And here is some text.\nThis text could be anything.\nBasically it's just a placeholder")
+
+ // Print a section with level two.
+ pterm.DefaultSection.WithLevel(2).Println("This is another section!")
+ // Print placeholder.
+ pterm.Info.Println("And this is\nmore placeholder text")
+}
+
+```
+
+
+
+### spinner/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/spinner/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "time"
+
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ // Create and start a fork of the default spinner.
+ spinnerSuccess, _ := pterm.DefaultSpinner.Start("Doing something important... (will succeed)")
+ time.Sleep(time.Second * 2) // Simulate 3 seconds of processing something.
+ spinnerSuccess.Success() // Resolve spinner with success message.
+
+ // Create and start a fork of the default spinner.
+ spinnerWarning, _ := pterm.DefaultSpinner.Start("Doing something important... (will warn)")
+ time.Sleep(time.Second * 2) // Simulate 3 seconds of processing something.
+ spinnerWarning.Warning() // Resolve spinner with warning message.
+
+ // Create and start a fork of the default spinner.
+ spinnerFail, _ := pterm.DefaultSpinner.Start("Doing something important... (will fail)")
+ time.Sleep(time.Second * 2) // Simulate 3 seconds of processing something.
+ spinnerFail.Fail() // Resolve spinner with error message.
+
+ // Create and start a fork of the default spinner.
+ spinnerLiveText, _ := pterm.DefaultSpinner.Start("Doing a lot of stuff...")
+ time.Sleep(time.Second) // Simulate 2 seconds of processing something.
+ spinnerLiveText.UpdateText("It's really much") // Update spinner text.
+ time.Sleep(time.Second) // Simulate 2 seconds of processing something.
+ spinnerLiveText.UpdateText("We're nearly done!") // Update spinner text.
+ time.Sleep(time.Second) // Simulate 2 seconds of processing something.
+ spinnerLiveText.Success("Finally!") // Resolve spinner with success message.
+}
+
+```
+
+
+
+### style/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/style/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Create styles as new variables
+ primary := pterm.NewStyle(pterm.FgLightCyan, pterm.BgGray, pterm.Bold)
+ secondary := pterm.NewStyle(pterm.FgLightGreen, pterm.BgWhite, pterm.Italic)
+
+ // Use created styles
+ primary.Println("Hello, World!")
+ secondary.Println("Hello, World!")
+}
+
+```
+
+
+
+### table/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/table/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Create a fork of the default table, fill it with data and print it.
+ // Data can also be generated and inserted later.
+ 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()
+
+ pterm.Println() // Blank line
+
+ // Create a table with right alignment.
+ 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"},
+ }).WithRightAlignment().Render()
+}
+
+```
+
+
+
+### theme/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/theme/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+ "reflect"
+ "time"
+)
+
+func main() {
+ // Print info.
+ 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() // Print one line space.
+
+ // Print every value of the default theme with its own style.
+ 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)
+ }
+ }
+}
+
+```
+
+
+
+### tree/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/tree/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ // You can use a LeveledList here, for easy generation.
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Users"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs(x86)"},
+ pterm.LeveledListItem{Level: 1, Text: "dev"},
+ pterm.LeveledListItem{Level: 0, Text: "D:"},
+ pterm.LeveledListItem{Level: 0, Text: "E:"},
+ pterm.LeveledListItem{Level: 1, Text: "Movies"},
+ pterm.LeveledListItem{Level: 1, Text: "Music"},
+ pterm.LeveledListItem{Level: 2, Text: "LinkinPark"},
+ pterm.LeveledListItem{Level: 1, Text: "Games"},
+ pterm.LeveledListItem{Level: 2, Text: "Shooter"},
+ pterm.LeveledListItem{Level: 3, Text: "CallOfDuty"},
+ pterm.LeveledListItem{Level: 3, Text: "CS:GO"},
+ pterm.LeveledListItem{Level: 3, Text: "Battlefield"},
+ pterm.LeveledListItem{Level: 4, Text: "Battlefield 1"},
+ pterm.LeveledListItem{Level: 4, Text: "Battlefield 2"},
+ pterm.LeveledListItem{Level: 0, Text: "F:"},
+ pterm.LeveledListItem{Level: 1, Text: "dev"},
+ pterm.LeveledListItem{Level: 2, Text: "dops"},
+ pterm.LeveledListItem{Level: 2, Text: "PTerm"},
+ }
+
+ // Generate tree from LeveledList.
+ root := pterm.NewTreeFromLeveledList(leveledList)
+
+ // Render TreePrinter
+ pterm.DefaultTree.WithRoot(root).Render()
+}
+
+```
+
+
+
+
+
diff --git a/_examples/area/README.md b/_examples/area/README.md
index 206827c31..ddcdda210 100644
--- a/_examples/area/README.md
+++ b/_examples/area/README.md
@@ -1,6 +1,10 @@
-# area
+### area/demo
-![Animation](animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/area/demo/animation.svg)
+
+
+
+SHOW SOURCE
```go
package main
@@ -25,3 +29,6 @@ func main() {
}
```
+
+
+
diff --git a/_examples/area/animation.svg b/_examples/area/animation.svg
deleted file mode 100644
index 31f22fae8..000000000
--- a/_examples/area/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
\ No newline at end of file
diff --git a/_examples/area/demo/README.md b/_examples/area/demo/README.md
new file mode 100644
index 000000000..d4ad4924c
--- /dev/null
+++ b/_examples/area/demo/README.md
@@ -0,0 +1,27 @@
+# area/demo
+
+![Animation](animation.svg)
+
+```go
+package main
+
+import (
+ "time"
+
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ pterm.Info.Println("The previous text will stay in place, while the area updates.")
+ pterm.Print("\n\n") // Add two new lines as spacer.
+
+ area, _ := pterm.DefaultArea.WithCenter().Start() // Start the Area printer, with the Center option.
+ for i := 0; i < 10; i++ {
+ str, _ := pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString(time.Now().Format("15:04:05"))).Srender() // Save current time in str.
+ area.Update(str) // Update Area contents.
+ time.Sleep(time.Second)
+ }
+ area.Stop()
+}
+
+```
diff --git a/_examples/area/demo/animation.svg b/_examples/area/demo/animation.svg
new file mode 100644
index 000000000..c2828ea07
--- /dev/null
+++ b/_examples/area/demo/animation.svg
@@ -0,0 +1,10 @@
+ INFO Theprevioustextwillstayinplace,whiletheareaupdates.███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████Restartinganimation...
\ No newline at end of file
diff --git a/_examples/area/main.go b/_examples/area/demo/main.go
similarity index 100%
rename from _examples/area/main.go
rename to _examples/area/demo/main.go
diff --git a/_examples/barchart-mixed-values/animation.svg b/_examples/barchart-mixed-values/animation.svg
deleted file mode 100644
index 942feb6ea..000000000
--- a/_examples/barchart-mixed-values/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-#Chartexamplewithmixedvalues(notescreenspaceusageincasewhenABSOLUTEvaluesofnegativeandpositivepartsarediffertoomuch)257██████████████████-3-2Bar1Bar2Bar3Bar4LongerLabelBar1███████2Bar2███████████-3Bar3███████-2Bar4██████████████████5LongerLabel██████████████████████████7Bar4█Restartinganimation...
\ No newline at end of file
diff --git a/_examples/barchart-negative-values/animation.svg b/_examples/barchart-negative-values/animation.svg
deleted file mode 100644
index a0b835d02..000000000
--- a/_examples/barchart-negative-values/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
- INFO Chartexamplewithnegativeonlyvalues(barsuse100%ofchartarea)████████████-5-3-7Bar1Bar2LongerLabelBar1█████████████████████████████████████-5Bar2██████████████████████-3LongerLabel█████████████████████████████████████████████████████-7Bar1████████████████████████LongerLabel█████Restartinganimation...
\ No newline at end of file
diff --git a/_examples/barchart/README.md b/_examples/barchart/README.md
index bbaf9280e..b565646d9 100644
--- a/_examples/barchart/README.md
+++ b/_examples/barchart/README.md
@@ -1,6 +1,10 @@
-# barchart
+### barchart/demo
-![Animation](animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/demo/animation.svg)
+
+
+
+SHOW SOURCE
```go
package main
@@ -31,3 +35,94 @@ func main() {
}
```
+
+
+
+### barchart/mixed-values
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/mixed-values/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ mixedBars := pterm.Bars{
+ pterm.Bar{
+ Label: "Bar 1",
+ Value: 2,
+ },
+ pterm.Bar{
+ Label: "Bar 2",
+ Value: -3,
+ },
+ pterm.Bar{
+ Label: "Bar 3",
+ Value: -2,
+ },
+ pterm.Bar{
+ Label: "Bar 4",
+ Value: 5,
+ },
+ pterm.Bar{
+ Label: "Longer Label",
+ Value: 7,
+ },
+ }
+
+ pterm.DefaultSection.Println("Chart example with mixed values (note screen space usage in case when ABSOLUTE values of negative and positive parts are differ too much)")
+ _ = pterm.DefaultBarChart.WithBars(mixedBars).WithShowValue().Render()
+ _ = pterm.DefaultBarChart.WithHorizontal().WithBars(mixedBars).WithShowValue().Render()
+}
+
+```
+
+
+
+### barchart/negative-values
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/negative-values/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ negativeBars := pterm.Bars{
+ pterm.Bar{
+ Label: "Bar 1",
+ Value: -5,
+ },
+ pterm.Bar{
+ Label: "Bar 2",
+ Value: -3,
+ },
+ pterm.Bar{
+ Label: "Longer Label",
+ Value: -7,
+ },
+ }
+
+ pterm.Info.Println("Chart example with negative only values (bars use 100% of chart area)")
+ _ = pterm.DefaultBarChart.WithBars(negativeBars).WithShowValue().Render()
+ _ = pterm.DefaultBarChart.WithHorizontal().WithBars(negativeBars).WithShowValue().Render()
+}
+
+```
+
+
+
diff --git a/_examples/barchart/animation.svg b/_examples/barchart/animation.svg
deleted file mode 100644
index 0e6277746..000000000
--- a/_examples/barchart/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
- INFO Chartexamplewithpositiveonlyvalues(barsuse100%ofchartarea)████████████Bar1Bar2LongerLabelBar1█████████████████████████████████████Bar2██████████████████████LongerLabel█████████████████████████████████████████████████████Bar1██████████████████████████LongerLabel███████Restartinganimation...
\ No newline at end of file
diff --git a/_examples/barchart/demo/README.md b/_examples/barchart/demo/README.md
new file mode 100644
index 000000000..e857b4ea7
--- /dev/null
+++ b/_examples/barchart/demo/README.md
@@ -0,0 +1,33 @@
+# barchart/demo
+
+![Animation](animation.svg)
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ positiveBars := pterm.Bars{
+ pterm.Bar{
+ Label: "Bar 1",
+ Value: 5,
+ },
+ pterm.Bar{
+ Label: "Bar 2",
+ Value: 3,
+ },
+ pterm.Bar{
+ Label: "Longer Label",
+ Value: 7,
+ },
+ }
+
+ pterm.Info.Println("Chart example with positive only values (bars use 100% of chart area)")
+ _ = pterm.DefaultBarChart.WithBars(positiveBars).Render()
+ _ = pterm.DefaultBarChart.WithHorizontal().WithBars(positiveBars).Render()
+}
+
+```
diff --git a/_examples/barchart/demo/animation.svg b/_examples/barchart/demo/animation.svg
new file mode 100644
index 000000000..39cf9d094
--- /dev/null
+++ b/_examples/barchart/demo/animation.svg
@@ -0,0 +1,10 @@
+ INFO Chartexamplewithpositiveonlyvalues(barsuse100%ofchartarea)████████████Bar1Bar2LongerLabelBar1█████████████████████████████████████Bar2██████████████████████LongerLabel█████████████████████████████████████████████████████Bar2LongerLabel██████████████████████Restartinganimation...
\ No newline at end of file
diff --git a/_examples/barchart/main.go b/_examples/barchart/demo/main.go
similarity index 100%
rename from _examples/barchart/main.go
rename to _examples/barchart/demo/main.go
diff --git a/_examples/barchart-mixed-values/README.md b/_examples/barchart/mixed-values/README.md
similarity index 96%
rename from _examples/barchart-mixed-values/README.md
rename to _examples/barchart/mixed-values/README.md
index 4f015a834..192ab865b 100644
--- a/_examples/barchart-mixed-values/README.md
+++ b/_examples/barchart/mixed-values/README.md
@@ -1,4 +1,4 @@
-# barchart-mixed-values
+# barchart/mixed-values
![Animation](animation.svg)
diff --git a/_examples/barchart/mixed-values/animation.svg b/_examples/barchart/mixed-values/animation.svg
new file mode 100644
index 000000000..2f3ffac8f
--- /dev/null
+++ b/_examples/barchart/mixed-values/animation.svg
@@ -0,0 +1,10 @@
+#Chartexamplewithmixedvalues(notescreenspaceusageincasewhenABSOLUTEvaluesofnegativeandpositivepartsarediffertoomuch)257██████████████████-3-2Bar1Bar2Bar3Bar4LongerLabelBar1███████2Bar2███████████-3Bar3███████-2Bar4██████████████████5LongerLabel██████████████████████████7Bar4█Restartinganimation...
\ No newline at end of file
diff --git a/_examples/barchart-mixed-values/main.go b/_examples/barchart/mixed-values/main.go
similarity index 100%
rename from _examples/barchart-mixed-values/main.go
rename to _examples/barchart/mixed-values/main.go
diff --git a/_examples/barchart-negative-values/README.md b/_examples/barchart/negative-values/README.md
similarity index 95%
rename from _examples/barchart-negative-values/README.md
rename to _examples/barchart/negative-values/README.md
index d790face6..0519c866e 100644
--- a/_examples/barchart-negative-values/README.md
+++ b/_examples/barchart/negative-values/README.md
@@ -1,4 +1,4 @@
-# barchart-negative-values
+# barchart/negative-values
![Animation](animation.svg)
diff --git a/_examples/barchart/negative-values/animation.svg b/_examples/barchart/negative-values/animation.svg
new file mode 100644
index 000000000..aebb652cf
--- /dev/null
+++ b/_examples/barchart/negative-values/animation.svg
@@ -0,0 +1,10 @@
+ INFO Chartexamplewithnegativeonlyvalues(barsuse100%ofchartarea)████████████-5-3-7Bar1Bar2LongerLabelBar1█████████████████████████████████████-5Bar2██████████████████████-3LongerLabel█████████████████████████████████████████████████████-7Bar2LongerLabel█████████████████████Restartinganimation...
\ No newline at end of file
diff --git a/_examples/barchart-negative-values/main.go b/_examples/barchart/negative-values/main.go
similarity index 100%
rename from _examples/barchart-negative-values/main.go
rename to _examples/barchart/negative-values/main.go
diff --git a/_examples/basictext/README.md b/_examples/basictext/README.md
new file mode 100644
index 000000000..19d8eb1ef
--- /dev/null
+++ b/_examples/basictext/README.md
@@ -0,0 +1,27 @@
+### basictext/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/basictext/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // A BasicText printer is used to print text, without special formatting.
+ // As it implements the TextPrinter interface, you can use it in combination with other printers.
+ 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.")
+ // If you just want to print text, you should use this instead:
+ // pterm.Println("Hello, World!")
+}
+
+```
+
+
+
diff --git a/_examples/print-basic-text/README.md b/_examples/basictext/demo/README.md
similarity index 97%
rename from _examples/print-basic-text/README.md
rename to _examples/basictext/demo/README.md
index ce498440a..64518301b 100644
--- a/_examples/print-basic-text/README.md
+++ b/_examples/basictext/demo/README.md
@@ -1,4 +1,4 @@
-# print-basic-text
+# basictext/demo
![Animation](animation.svg)
diff --git a/_examples/basictext/demo/animation.svg b/_examples/basictext/demo/animation.svg
new file mode 100644
index 000000000..4785ae7cf
--- /dev/null
+++ b/_examples/basictext/demo/animation.svg
@@ -0,0 +1,10 @@
+Defaultbasictextprinter.CanbeusedinanyTextPrintercontext.Forexampletoresolveprogressbarsandspinners.Restartinganimation...
\ No newline at end of file
diff --git a/_examples/print-basic-text/main.go b/_examples/basictext/demo/main.go
similarity index 100%
rename from _examples/print-basic-text/main.go
rename to _examples/basictext/demo/main.go
diff --git a/_examples/bigtext/README.md b/_examples/bigtext/README.md
index 22615dc6d..99d195ca5 100644
--- a/_examples/bigtext/README.md
+++ b/_examples/bigtext/README.md
@@ -1,6 +1,10 @@
-# bigtext
+### bigtext/demo
-![Animation](animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bigtext/demo/animation.svg)
+
+
+
+SHOW SOURCE
```go
package main
@@ -25,3 +29,6 @@ func main() {
}
```
+
+
+
diff --git a/_examples/bigtext/animation.svg b/_examples/bigtext/animation.svg
deleted file mode 100644
index 9bf595cbe..000000000
--- a/_examples/bigtext/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████Restartinganimation...
\ No newline at end of file
diff --git a/_examples/bigtext/demo/README.md b/_examples/bigtext/demo/README.md
new file mode 100644
index 000000000..5f1e4f5f2
--- /dev/null
+++ b/_examples/bigtext/demo/README.md
@@ -0,0 +1,27 @@
+# bigtext/demo
+
+![Animation](animation.svg)
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print a large text with the LetterStyle from the standard theme.
+ // Useful for title screens.
+ pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString("PTerm")).Render()
+
+ // Print a large text with differently colored letters.
+ pterm.DefaultBigText.WithLetters(
+ pterm.NewLettersFromStringWithStyle("P", pterm.NewStyle(pterm.FgCyan)),
+ pterm.NewLettersFromStringWithStyle("Term", pterm.NewStyle(pterm.FgLightMagenta))).
+ Render()
+
+ // NewLettersFromStringWithRGB can be used to create a large text with a specific RGB color.
+ pterm.DefaultBigText.WithLetters(
+ pterm.NewLettersFromStringWithRGB("PTerm", pterm.NewRGB(255, 215, 0))).
+ Render()
+}
+
+```
diff --git a/_examples/bigtext/demo/animation.svg b/_examples/bigtext/demo/animation.svg
new file mode 100644
index 000000000..9a6d705ad
--- /dev/null
+++ b/_examples/bigtext/demo/animation.svg
@@ -0,0 +1,10 @@
+██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████Restartinganimation...
\ No newline at end of file
diff --git a/_examples/bigtext/main.go b/_examples/bigtext/demo/main.go
similarity index 100%
rename from _examples/bigtext/main.go
rename to _examples/bigtext/demo/main.go
diff --git a/_examples/box/README.md b/_examples/box/README.md
index 30a758090..06272a26b 100644
--- a/_examples/box/README.md
+++ b/_examples/box/README.md
@@ -1,6 +1,10 @@
-# box
+### box/demo
-![Animation](animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/box/demo/animation.svg)
+
+
+
+SHOW SOURCE
```go
package main
@@ -23,3 +27,6 @@ func main() {
}
```
+
+
+
diff --git a/_examples/box/animation.svg b/_examples/box/animation.svg
deleted file mode 100644
index 567dd52c2..000000000
--- a/_examples/box/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
- INFO ThismightnotberenderedcorrectlyonGitHub, butitwillworkinarealterminal. ThisisbecauseGitHubdoesnotuseamonospacedfontbydefaultforSVGs.┌────────────────────────────────────────────────────────────────────┐|┌──────────────────────────────────┐┌─title───────────────────┐|||Loremipsumdolorsitamet,||Utenimadminimveniam,||||consecteturadipiscingelit,||quisnostrudexercitation||||seddoeiusmodtemporincididunt||ullamcolaboris||||utlaboreetdolore||nisiutaliquip||||magnaaliqua.||exeacommodo|||└──────────────────────────────────┘|consequat.|||└───────────────────────────┘||┌────────────────────────────────┐|||Duisauteirure||||dolorinreprehenderit||||involuptatevelitessecillum||||doloreeufugiat||||nullapariatur.|||└─────bottomcentertitle──────┘|||└──────────────────────────────────────────────────────LoremIpsum─┘┌────────────────────────────────────────────────|┌─────────────────|┌──────────────────────────────────┐┌─title────────────|||└─|└──────────────────────────────────|└────────────────────────|┌──────────────────────────|└──────────────────────────────────────────Restartinganimation...
\ No newline at end of file
diff --git a/_examples/box/demo/README.md b/_examples/box/demo/README.md
new file mode 100644
index 000000000..c4e6305e6
--- /dev/null
+++ b/_examples/box/demo/README.md
@@ -0,0 +1,25 @@
+# box/demo
+
+![Animation](animation.svg)
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ pterm.Info.Println("This might not be rendered correctly on GitHub,\nbut it will work in a real terminal.\nThis is because GitHub does not use a monospaced font by default for SVGs.")
+
+ panel1 := pterm.DefaultBox.Sprint("Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit,\nsed do eiusmod tempor incididunt\nut labore et dolore\nmagna aliqua.")
+ panel2 := pterm.DefaultBox.WithTitle("title").Sprint("Ut enim ad minim veniam,\nquis nostrud exercitation\nullamco laboris\nnisi ut aliquip\nex ea commodo\nconsequat.")
+ panel3 := pterm.DefaultBox.WithTitle("bottom center title").WithTitleBottomCenter().Sprint("Duis aute irure\ndolor in reprehenderit\nin voluptate velit esse cillum\ndolore eu fugiat\nnulla pariatur.")
+
+ panels, _ := pterm.DefaultPanel.WithPanels(pterm.Panels{
+ {{Data: panel1}, {Data: panel2}},
+ {{Data: panel3}},
+ }).Srender()
+
+ pterm.DefaultBox.WithTitle("Lorem Ipsum").WithTitleBottomRight().WithRightPadding(0).WithBottomPadding(0).Println(panels)
+}
+
+```
diff --git a/_examples/box/demo/animation.svg b/_examples/box/demo/animation.svg
new file mode 100644
index 000000000..14a1b6a13
--- /dev/null
+++ b/_examples/box/demo/animation.svg
@@ -0,0 +1,10 @@
+ INFO ThismightnotberenderedcorrectlyonGitHub, butitwillworkinarealterminal. ThisisbecauseGitHubdoesnotuseamonospacedfontbydefaultforSVGs.┌────────────────────────────────────────────────────────────────────┐|┌──────────────────────────────────┐┌─title───────────────────┐|||Loremipsumdolorsitamet,||Utenimadminimveniam,||||consecteturadipiscingelit,||quisnostrudexercitation||||seddoeiusmodtemporincididunt||ullamcolaboris||||utlaboreetdolore||nisiutaliquip||||magnaaliqua.||exeacommodo|||└──────────────────────────────────┘|consequat.|||└───────────────────────────┘||┌────────────────────────────────┐|||Duisauteirure||||dolorinreprehenderit||||involuptatevelitessecillum|||||doloreeufugiat||||nullapariatur.|||└─────bottomcentertitle──────┘|||└──────────────────────────────────────────────────────LoremIpsum─┘┌────────────────────────────────────────────────|┌─────────────────|┌──────────────────────────────────┐┌─title────────────|||└─|└──────────────────────────────────|└────────────────────────|┌──────────────────────────└──────────────────────────────────────────────Restartinganimation...
\ No newline at end of file
diff --git a/_examples/box/main.go b/_examples/box/demo/main.go
similarity index 100%
rename from _examples/box/main.go
rename to _examples/box/demo/main.go
diff --git a/_examples/bulletlist-custom/animation.svg b/_examples/bulletlist-custom/animation.svg
deleted file mode 100644
index 70ecb687e..000000000
--- a/_examples/bulletlist-custom/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-•Blue-Green>CyanRestartinganimation...
\ No newline at end of file
diff --git a/_examples/bulletlist/README.md b/_examples/bulletlist/README.md
index ea6634eaa..eab0c73e2 100644
--- a/_examples/bulletlist/README.md
+++ b/_examples/bulletlist/README.md
@@ -1,6 +1,38 @@
-# bulletlist
+### bulletlist/customized
-![Animation](animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/customized/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ // Print a customized list with different styles and levels.
+ 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()
+}
+
+```
+
+
+
+### bulletlist/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/demo/animation.svg)
+
+
+
+SHOW SOURCE
```go
package main
@@ -24,3 +56,6 @@ func main() {
}
```
+
+
+
diff --git a/_examples/bulletlist/animation.svg b/_examples/bulletlist/animation.svg
deleted file mode 100644
index fb28094d6..000000000
--- a/_examples/bulletlist/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-•Level0•Level1•Level2•0•1•2•3Restartinganimation...
\ No newline at end of file
diff --git a/_examples/bulletlist-custom/README.md b/_examples/bulletlist/customized/README.md
similarity index 96%
rename from _examples/bulletlist-custom/README.md
rename to _examples/bulletlist/customized/README.md
index 9b9b6c5c4..64d8dc113 100644
--- a/_examples/bulletlist-custom/README.md
+++ b/_examples/bulletlist/customized/README.md
@@ -1,4 +1,4 @@
-# bulletlist-custom
+# bulletlist/customized
![Animation](animation.svg)
diff --git a/_examples/bulletlist/customized/animation.svg b/_examples/bulletlist/customized/animation.svg
new file mode 100644
index 000000000..a36bfa8f7
--- /dev/null
+++ b/_examples/bulletlist/customized/animation.svg
@@ -0,0 +1,10 @@
+•Blue-Green>CyanRestartinganimation...
\ No newline at end of file
diff --git a/_examples/bulletlist-custom/main.go b/_examples/bulletlist/customized/main.go
similarity index 100%
rename from _examples/bulletlist-custom/main.go
rename to _examples/bulletlist/customized/main.go
diff --git a/_examples/bulletlist/demo/README.md b/_examples/bulletlist/demo/README.md
new file mode 100644
index 000000000..30e1da8c7
--- /dev/null
+++ b/_examples/bulletlist/demo/README.md
@@ -0,0 +1,26 @@
+# bulletlist/demo
+
+![Animation](animation.svg)
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print a list with different levels.
+ // Useful to generate lists automatically from data.
+ pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{
+ {Level: 0, Text: "Level 0"},
+ {Level: 1, Text: "Level 1"},
+ {Level: 2, Text: "Level 2"},
+ }).Render()
+
+ // Convert a text to a list and print it.
+ pterm.NewBulletListFromString(`0
+ 1
+ 2
+ 3`, " ").Render()
+}
+
+```
diff --git a/_examples/bulletlist/demo/animation.svg b/_examples/bulletlist/demo/animation.svg
new file mode 100644
index 000000000..4f1b76ebb
--- /dev/null
+++ b/_examples/bulletlist/demo/animation.svg
@@ -0,0 +1,10 @@
+•Level0•Level1•Level2•0•1•2•3Restartinganimation...
\ No newline at end of file
diff --git a/_examples/bulletlist/main.go b/_examples/bulletlist/demo/main.go
similarity index 100%
rename from _examples/bulletlist/main.go
rename to _examples/bulletlist/demo/main.go
diff --git a/_examples/center/README.md b/_examples/center/README.md
index 0d2ad2403..f2ec4b872 100644
--- a/_examples/center/README.md
+++ b/_examples/center/README.md
@@ -1,6 +1,10 @@
-# center
+### center/demo
-![Animation](animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/center/demo/animation.svg)
+
+
+
+SHOW SOURCE
```go
package main
@@ -18,3 +22,6 @@ func main() {
}
```
+
+
+
diff --git a/_examples/center/animation.svg b/_examples/center/animation.svg
deleted file mode 100644
index db8236664..000000000
--- a/_examples/center/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-Thistextiscentered!Itcenteresthewholeblockbydefault.Inthatwayyoucandostufflikethis:███████████████████████████████████████████████████████████████████████████████████████████████████████████████████Thistextiscentered!ButeachlineiscenteredseparatelyRestartinganimation...
\ No newline at end of file
diff --git a/_examples/center/demo/README.md b/_examples/center/demo/README.md
new file mode 100644
index 000000000..45c82d865
--- /dev/null
+++ b/_examples/center/demo/README.md
@@ -0,0 +1,20 @@
+# center/demo
+
+![Animation](animation.svg)
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ pterm.DefaultCenter.Println("This text is centered!\nIt centeres the whole block by default.\nIn that way you can do stuff like this:")
+
+ // Generate BigLetters
+ s, _ := pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString("PTerm")).Srender()
+ pterm.DefaultCenter.Println(s) // Print BigLetters with the default CenterPrinter
+
+ pterm.DefaultCenter.WithCenterEachLineSeparately().Println("This text is centered!\nBut each line is\ncentered\nseparately")
+}
+
+```
diff --git a/_examples/center/demo/animation.svg b/_examples/center/demo/animation.svg
new file mode 100644
index 000000000..bada96dc7
--- /dev/null
+++ b/_examples/center/demo/animation.svg
@@ -0,0 +1,10 @@
+Thistextiscentered!Itcenteresthewholeblockbydefault.Inthatwayyoucandostufflikethis:███████████████████████████████████████████████████████████████████████████████████████████████████████████████████Thistextiscentered!ButeachlineiscenteredseparatelyRestartinganimation...
\ No newline at end of file
diff --git a/_examples/center/main.go b/_examples/center/demo/main.go
similarity index 100%
rename from _examples/center/main.go
rename to _examples/center/demo/main.go
diff --git a/_examples/print-with-color/README.md b/_examples/coloring/demo/README.md
similarity index 98%
rename from _examples/print-with-color/README.md
rename to _examples/coloring/demo/README.md
index fb5e134e8..185fa0a97 100644
--- a/_examples/print-with-color/README.md
+++ b/_examples/coloring/demo/README.md
@@ -1,4 +1,4 @@
-# print-with-color
+# coloring/demo
![Animation](animation.svg)
diff --git a/_examples/coloring/demo/animation.svg b/_examples/coloring/demo/animation.svg
new file mode 100644
index 000000000..84b40057a
--- /dev/null
+++ b/_examples/coloring/demo/animation.svg
@@ -0,0 +1,10 @@
+Hello,World!Evennestedcolorsaresupported!FgBlackFgRedFgGreenFgYellowFgBlueFgMagentaFgCyanFgWhiteFgLightRedFgLightGreenFgLightYellowFgLightBlueFgLightMagentaFgLightCyanFgLightWhiteRestartinganimation...
\ No newline at end of file
diff --git a/_examples/print-with-color/main.go b/_examples/coloring/demo/main.go
similarity index 100%
rename from _examples/print-with-color/main.go
rename to _examples/coloring/demo/main.go
diff --git a/_examples/disable-color/README.md b/_examples/coloring/disable-color/README.md
similarity index 99%
rename from _examples/disable-color/README.md
rename to _examples/coloring/disable-color/README.md
index 39561cc55..c469e464b 100644
--- a/_examples/disable-color/README.md
+++ b/_examples/coloring/disable-color/README.md
@@ -1,4 +1,4 @@
-# disable-color
+# coloring/disable-color
![Animation](animation.svg)
diff --git a/_examples/coloring/disable-color/animation.svg b/_examples/coloring/disable-color/animation.svg
new file mode 100644
index 000000000..0b9937164
--- /dev/null
+++ b/_examples/coloring/disable-color/animation.svg
@@ -0,0 +1,10 @@
+███████████████████████████████████████████████████████████████████████████████████████████████████████████████████PTDP-PTermDemoProgramINFOThisanimationwasgeneratedwiththelatestversionofPTerm!PTermworksonnearlyeveryterminalandoperatingsystem.It'ssupereasytouse!Ifyouwant,youcancustomizeeverything:)Youcanseethecodeofthisdemointhe./_examples/demodirectory.Thisdemowasupdatedat:21Apr2022-01:54:35CESTPseudoApplicationcreatedwithPTerm#InstallingpseudoprogramsSUCCESSInstallingpseudo-excelSUCCESSInstallingpseudo-photoshopSUCCESSInstallingpseudo-chromeSUCCESSInstallingpseudo-outlookSUCCESSInstallingpseudo-explorerSUCCESSInstallingpseudo-dopsSUCCESSInstallingpseudo-gitSUCCESSInstallingpseudo-vscSUCCESSInstallingpseudo-intellijInstallingpseudo-minecraft[9/12]███████████████████████████░░░░░░░░░75%|5sWARNINGCouldnotinstallpseudo-minecraftThecompanypolicyforbidsgames.SUCCESSInstallingpseudo-scoopSUCCESSInstallingpseudo-chocolateyInstallingpseudo-chocolatey[11/12]███████████████████████████████░░░92%|6s##ProgramInstallReportProgramName|Status|Sizepseudo-excel|pass|112mbpseudo-photoshop|pass|75mbpseudo-chrome|pass|40mbpseudo-outlook|pass|17mbpseudo-explorer|pass|54mbpseudo-dops|pass|73mbpseudo-git|pass|119mbpseudo-vsc|pass|51mbpseudo-intellij|pass|109mbpseudo-minecraft|fail|0mbpseudo-scoop|pass|13mbpseudo-chocolatey|pass|47mb│├──pseudo-Tabs│├─┬pseudo-Extensions││├──RefinedGitHub││└──GitHubDarkTheme│└─┬pseudo-Bookmarks│└──PTerm├──pseudo-outlook├──pseudo-explorer├──pseudo-dops├──pseudo-git├──pseudo-vsc├──pseudo-intellij├──pseudo-scoop└──pseudo-chocolatey#TrueColorSupportINFOIfyourterminalhasTrueColorsupport,youcanuseRGBcolors!Youcanevenfadethem:)#BulletListPrinter•Goodbye•Haveaniceday!▀Waitingfor15seconds...(0s)▀Waitingfor15seconds...(0s)▄Waitingfor15seconds...(0s)▄Waitingfor15seconds...(1s)▀Waitingfor15seconds...(1s)▀Waitingfor14seconds...▀Waitingfor14seconds...(1s)▄Waitingfor14seconds...(1s)▄Waitingfor14seconds...(1s)▀Waitingfor14seconds...(2s)▀Waitingfor14seconds...(2s)▀Waitingfor13seconds...▄Waitingfor13seconds...(2s)▄Waitingfor13seconds...(2s)▀Waitingfor13seconds...(2s)▀Waitingfor13seconds...(3s)▄Waitingfor13seconds...(3s)▄Waitingfor12seconds...▄Waitingfor12seconds...(3s)▀Waitingfor12seconds...(3s)▀Waitingfor12seconds...(3s)▄Waitingfor12seconds...(4s)▄Waitingfor12seconds...(4s)▄Waitingfor11seconds...▀Waitingfor11seconds...(4s)▀Waitingfor11seconds...(4s)▄Waitingfor11seconds...(4s)▄Waitingfor11seconds...(5s)▀Waitingfor11seconds...(5s)▀Waitingfor10seconds...▀Waitingfor10seconds...(5s)▄Waitingfor10seconds...(5s)▄Waitingfor10seconds...(5s)▀Waitingfor10seconds...(6s)▀Waitingfor10seconds...(6s)▀Waitingfor9seconds...▄Waitingfor9seconds...(6s)▄Waitingfor9seconds...(6s)▀Waitingfor9seconds...(6s)▀Waitingfor9seconds...(7s)▄Waitingfor9seconds...(7s)▄Waitingfor8seconds...▄Waitingfor8seconds...(7s)▀Waitingfor8seconds...(7s)▀Waitingfor8seconds...(7s)▄Waitingfor8seconds...(8s)▄Waitingfor8seconds...(8s)▄Waitingfor7seconds...▀Waitingfor7seconds...(8s)▀Waitingfor7seconds...(8s)▄Waitingfor7seconds...(8s)▄Waitingfor7seconds...(9s)▀Waitingfor7seconds...(9s)▀Waitingfor6seconds...▀Waitingfor6seconds...(9s)▄Waitingfor6seconds...(9s)▄Waitingfor6seconds...(9s)▀Waitingfor6seconds...(10s)▀Waitingfor6seconds...(10s)▀Waitingfor5seconds...▄Waitingfor5seconds...(10s)▄Waitingfor5seconds...(10s)▀Waitingfor5seconds...(10s)▀Waitingfor5seconds...(11s)▄Waitingfor5seconds...(11s)▄Waitingfor4seconds...▄Waitingfor4seconds...(11s)▀Waitingfor4seconds...(11s)▀Waitingfor4seconds...(11s)▄Waitingfor4seconds...(12s)▄Waitingfor4seconds...(12s)▄Waitingfor3seconds...▀Waitingfor3seconds...(12s)▀Waitingfor3seconds...(12s)▄Waitingfor3seconds...(12s)▄Waitingfor3seconds...(13s)▀Waitingfor3seconds...(13s)▀Waitingfor2seconds...▀Waitingfor2seconds...(13s)▄Waitingfor2seconds...(13s)▄Waitingfor2seconds...(13s)▀Waitingfor2seconds...(14s)▀Waitingfor2seconds...(14s)▀Waitingfor1second...▄Waitingfor1second...(14s)▄Waitingfor1second...(14s)▀Waitingfor1second...(14s)▀Waitingfor1second...(15s)▄Waitingfor1second...(15s)Installingstuff[0/12]0%|0sInstallingpseudo-excel[1/12]████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░8%|0sInstallingpseudo-photoshop[2/12]██████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░17%|1sInstallingpseudo-chrome[2/12]███████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░17%|1sInstallingpseudo-chrome[3/12]██████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░25%|1sInstallingpseudo-outlook[3/12]██████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░25%|2sInstallingpseudo-outlook[4/12]█████████████░░░░░░░░░░░░░░░░░░░░░░░░░33%|2sInstallingpseudo-explorer[4/12]█████████████░░░░░░░░░░░░░░░░░░░░░░░░33%|2sInstallingpseudo-explorer[5/12]████████████████░░░░░░░░░░░░░░░░░░░░░42%|2sInstallingpseudo-dops[5/12]█████████████████░░░░░░░░░░░░░░░░░░░░░░░░42%|3sInstallingpseudo-dops[6/12]█████████████████████░░░░░░░░░░░░░░░░░░░░50%|3sInstallingpseudo-git[7/12]████████████████████████░░░░░░░░░░░░░░░░░░58%|3sInstallingpseudo-vsc[8/12]████████████████████████████░░░░░░░░░░░░░░67%|4sInstallingpseudo-intellij[8/12]█████████████████████████░░░░░░░░░░░░67%|4sInstallingpseudo-intellij[9/12]████████████████████████████░░░░░░░░░75%|4sInstallingpseudo-scoop[9/12]██████████████████████████████░░░░░░░░░░75%|5sInstallingpseudo-scoop[10/12]████████████████████████████████░░░░░░░83%|5s#TreePrinter├──pseudo-excel├──pseudo-photoshop├─┬pseudo-chromeRestartinganimation...
\ No newline at end of file
diff --git a/_examples/disable-color/main.go b/_examples/coloring/disable-color/main.go
similarity index 100%
rename from _examples/disable-color/main.go
rename to _examples/coloring/disable-color/main.go
diff --git a/_examples/disable-output/README.md b/_examples/coloring/disable-output/README.md
similarity index 93%
rename from _examples/disable-output/README.md
rename to _examples/coloring/disable-output/README.md
index 5adec41d5..1af7b7a1a 100644
--- a/_examples/disable-output/README.md
+++ b/_examples/coloring/disable-output/README.md
@@ -1,4 +1,4 @@
-# disable-output
+# coloring/disable-output
![Animation](animation.svg)
diff --git a/_examples/coloring/disable-output/animation.svg b/_examples/coloring/disable-output/animation.svg
new file mode 100644
index 000000000..f896041c9
--- /dev/null
+++ b/_examples/coloring/disable-output/animation.svg
@@ -0,0 +1,10 @@
+Printingsomething...[0/15]Printingsomething...[1/15]Printingsomething...[2/15]Printingsomething...[3/15]Printingsomething...[4/15] INFO DisabledOutput! INFO EnabledOutput!Printingsomething...[10/15]Printingsomething...[11/15]Printingsomething...[12/15]Printingsomething...[13/15]Printingsomething...[14/15]Restartinganimation...
\ No newline at end of file
diff --git a/_examples/disable-output/main.go b/_examples/coloring/disable-output/main.go
similarity index 100%
rename from _examples/disable-output/main.go
rename to _examples/coloring/disable-output/main.go
diff --git a/_examples/disable-styling/README.md b/_examples/coloring/disable-styling/README.md
similarity index 99%
rename from _examples/disable-styling/README.md
rename to _examples/coloring/disable-styling/README.md
index ae4555074..96fb179a6 100644
--- a/_examples/disable-styling/README.md
+++ b/_examples/coloring/disable-styling/README.md
@@ -1,4 +1,4 @@
-# disable-styling
+# coloring/disable-styling
![Animation](animation.svg)
diff --git a/_examples/coloring/disable-styling/animation.svg b/_examples/coloring/disable-styling/animation.svg
new file mode 100644
index 000000000..40e7d6152
--- /dev/null
+++ b/_examples/coloring/disable-styling/animation.svg
@@ -0,0 +1,10 @@
+PTermPTDP-PTermDemoProgramINFO:ThisanimationwasgeneratedwiththelatestversionofPTerm!PTermworksonnearlyeveryterminalandoperatingsystem.It'ssupereasytouse!Ifyouwant,youcancustomizeeverything:)Youcanseethecodeofthisdemointhe./_examples/demodirectory.Thisdemowasupdatedat:21Apr2022-01:55:17CESTWaitingfor15seconds...Waitingfor14seconds...Waitingfor13seconds...Waitingfor12seconds...Waitingfor11seconds...Waitingfor10seconds...Waitingfor9seconds...Waitingfor8seconds...Waitingfor7seconds...Waitingfor6seconds...Waitingfor5seconds...Waitingfor4seconds...Waitingfor3seconds...Waitingfor2seconds...PseudoApplicationcreatedwithPTerm#InstallingpseudoprogramsInstallingstuffSUCCESS:Installingpseudo-excelSUCCESS:Installingpseudo-photoshopSUCCESS:Installingpseudo-chromeSUCCESS:Installingpseudo-outlookSUCCESS:Installingpseudo-explorerSUCCESS:Installingpseudo-dopsSUCCESS:Installingpseudo-gitSUCCESS:Installingpseudo-vscSUCCESS:Installingpseudo-intellijWARNING:Couldnotinstallpseudo-minecraftThecompanypolicyforbidsgames.SUCCESS:Installingpseudo-scoopSUCCESS:Installingpseudo-chocolatey##ProgramInstallReportProgramName|Status|Sizepseudo-excel|pass|137mbpseudo-photoshop|pass|24mbpseudo-chrome|pass|37mbpseudo-outlook|pass|117mbpseudo-explorer|pass|24mbpseudo-dops|pass|150mbpseudo-git|pass|10mbpseudo-vsc|pass|56mbpseudo-intellij|pass|182mbpseudo-minecraft|fail|0mbpseudo-scoop|pass|194mbpseudo-chocolatey|pass|61mb│├──pseudo-Tabs│├─┬pseudo-Extensions││├──RefinedGitHub││└──GitHubDarkTheme│└─┬pseudo-Bookmarks│└──PTerm├──pseudo-outlook├──pseudo-explorer├──pseudo-dops├──pseudo-git├──pseudo-vsc├──pseudo-intellij├──pseudo-scoop└──pseudo-chocolatey#TrueColorSupportINFO:IfyourterminalhasTrueColorsupport,youcanuseRGBcolors!Youcanevenfadethem:)#BulletListPrinter•Goodbye•Haveaniceday!Waitingfor1second...#TreePrinter├──pseudo-excel├──pseudo-photoshop├─┬pseudo-chromeRestartinganimation...
\ No newline at end of file
diff --git a/_examples/disable-styling/main.go b/_examples/coloring/disable-styling/main.go
similarity index 100%
rename from _examples/disable-styling/main.go
rename to _examples/coloring/disable-styling/main.go
diff --git a/_examples/print-color-fade/README.md b/_examples/coloring/fade-colors/README.md
similarity index 96%
rename from _examples/print-color-fade/README.md
rename to _examples/coloring/fade-colors/README.md
index 35c1dbd01..6b8e97526 100644
--- a/_examples/print-color-fade/README.md
+++ b/_examples/coloring/fade-colors/README.md
@@ -1,4 +1,4 @@
-# print-color-fade
+# coloring/fade-colors
![Animation](animation.svg)
diff --git a/_examples/coloring/fade-colors/animation.svg b/_examples/coloring/fade-colors/animation.svg
new file mode 100644
index 000000000..b7a66e0dd
--- /dev/null
+++ b/_examples/coloring/fade-colors/animation.svg
@@ -0,0 +1,10 @@
+Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World! INFO RGBcolorsonlyworkinTerminalswhichsupportTrueColor.Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Restartinganimation...
\ No newline at end of file
diff --git a/_examples/print-color-fade/main.go b/_examples/coloring/fade-colors/main.go
similarity index 100%
rename from _examples/print-color-fade/main.go
rename to _examples/coloring/fade-colors/main.go
diff --git a/_examples/print-color-fade-multiple/README.md b/_examples/coloring/fade-multiple-colors/README.md
similarity index 97%
rename from _examples/print-color-fade-multiple/README.md
rename to _examples/coloring/fade-multiple-colors/README.md
index 85b091cee..7c000c825 100644
--- a/_examples/print-color-fade-multiple/README.md
+++ b/_examples/coloring/fade-multiple-colors/README.md
@@ -1,4 +1,4 @@
-# print-color-fade-multiple
+# coloring/fade-multiple-colors
![Animation](animation.svg)
diff --git a/_examples/coloring/fade-multiple-colors/animation.svg b/_examples/coloring/fade-multiple-colors/animation.svg
new file mode 100644
index 000000000..466f9f795
--- /dev/null
+++ b/_examples/coloring/fade-multiple-colors/animation.svg
@@ -0,0 +1,10 @@
+Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World! INFO RGBcolorsonlyworkinTerminalsw INFO RGBcolorsonlyworkinTerminalswhichsupportTrueColor.Hello,World!Hello,World!Hello,World!Hello,World!Restartinganimation...
\ No newline at end of file
diff --git a/_examples/print-color-fade-multiple/main.go b/_examples/coloring/fade-multiple-colors/main.go
similarity index 100%
rename from _examples/print-color-fade-multiple/main.go
rename to _examples/coloring/fade-multiple-colors/main.go
diff --git a/_examples/override-default-printers/README.md b/_examples/coloring/override-default-printers/README.md
similarity index 92%
rename from _examples/override-default-printers/README.md
rename to _examples/coloring/override-default-printers/README.md
index 567c7161f..48d79e267 100644
--- a/_examples/override-default-printers/README.md
+++ b/_examples/coloring/override-default-printers/README.md
@@ -1,4 +1,4 @@
-# override-default-printers
+# coloring/override-default-printers
![Animation](animation.svg)
diff --git a/_examples/override-default-printers/animation.svg b/_examples/coloring/override-default-printers/animation.svg
similarity index 58%
rename from _examples/override-default-printers/animation.svg
rename to _examples/coloring/override-default-printers/animation.svg
index 07ba754bf..cf5ecce62 100644
--- a/_examples/override-default-printers/animation.svg
+++ b/_examples/coloring/override-default-printers/animation.svg
@@ -1,4 +1,4 @@
- ERROR ThisisthedefaultError OVERRIDE ThisisthedefaultErroraftertheprefixwasoverriddenRestartinganimation...
\ No newline at end of file
+}.a{fill:rgb(35,35,35)}.b{fill:#ff5f58}.c{fill:#ffbd2e}.d{fill:#18c132}.e{font-family:'JetBrainsMono',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace}.f{fill:rgb(232,131,136)}.g{white-space:pre}.h{fill:rgb(243,86,86);white-space:pre}.i{fill:rgb(102,194,205)}.j{fill:rgb(255,0,4);white-space:pre}.k{fill:transparent}.m{animation-duration:6.758511s;animation-iteration-count:infinite;animation-name:l;animation-timing-function:steps(1,end)}.n{fill:rgb(160,160,160);white-space:pre}@keyframes l{0%{transform:translateX(-0px)}26%{transform:translateX(-252px)}100%{transform:translateX(-504px)}} ERROR ThisisthedefaultError OVERRIDE ThisisthedefaultErroraftertheprefixwasoverriddenRestartinganimation...
\ No newline at end of file
diff --git a/_examples/override-default-printers/main.go b/_examples/coloring/override-default-printers/main.go
similarity index 100%
rename from _examples/override-default-printers/main.go
rename to _examples/coloring/override-default-printers/main.go
diff --git a/_examples/print-color-rgb/README.md b/_examples/coloring/print-color-rgb/README.md
similarity index 94%
rename from _examples/print-color-rgb/README.md
rename to _examples/coloring/print-color-rgb/README.md
index e96e5084b..4d35e7be6 100644
--- a/_examples/print-color-rgb/README.md
+++ b/_examples/coloring/print-color-rgb/README.md
@@ -1,4 +1,4 @@
-# print-color-rgb
+# coloring/print-color-rgb
![Animation](animation.svg)
diff --git a/_examples/print-color-rgb/animation.svg b/_examples/coloring/print-color-rgb/animation.svg
similarity index 59%
rename from _examples/print-color-rgb/animation.svg
rename to _examples/coloring/print-color-rgb/animation.svg
index f7ff6765e..7e7a55ae4 100644
--- a/_examples/print-color-rgb/animation.svg
+++ b/_examples/coloring/print-color-rgb/animation.svg
@@ -1,4 +1,4 @@
-ThistextisprintedwithacustomRGB!ThistextisprintedwithacustomRGB!ThistextisprintedwithacustomRGB!Restartinganimation...
\ No newline at end of file
+}.a{fill:rgb(35,35,35)}.b{fill:#ff5f58}.c{fill:#ffbd2e}.d{fill:#18c132}.e{font-family:'JetBrainsMono',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace}.f{fill:rgb(178,44,199);white-space:pre}.g{fill:rgb(15,199,209);white-space:pre}.h{fill:rgb(201,144,30);white-space:pre}.i{fill:transparent}.k{animation-duration:6.755445s;animation-iteration-count:infinite;animation-name:j;animation-timing-function:steps(1,end)}.l{fill:rgb(160,160,160);white-space:pre}@keyframes j{0%{transform:translateX(-0px)}26%{transform:translateX(-252px)}100%{transform:translateX(-504px)}}ThistextisprintedwithacustomRGB!ThistextisprintedwithacustomRGB!ThistextisprintedwithacustomRGB!Restartinganimation...
\ No newline at end of file
diff --git a/_examples/print-color-rgb/main.go b/_examples/coloring/print-color-rgb/main.go
similarity index 100%
rename from _examples/print-color-rgb/main.go
rename to _examples/coloring/print-color-rgb/main.go
diff --git a/_examples/demo/animation.svg b/_examples/demo/animation.svg
deleted file mode 100644
index 0d5afe5e2..000000000
--- a/_examples/demo/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-███████████████████████████████████████████████████████████████████████████████████████████████████████████████████ PTDP - PTerm Demo Program INFO ThisanimationwasgeneratedwiththelatestversionofPTerm! PTermworksonnearlyeveryterminalandoperatingsystem. It'ssupereasytouse! Ifyouwant,youcancustomizeeverything:) Youcanseethecodeofthisdemointhe./_examples/demodirectory. Thisdemowasupdatedat:20Apr2022-22:18:04UTC▀Waitingfor15seconds...▀Waitingfor14seconds...▀Waitingfor14seconds...▀Waitingfor13seconds...▄Waitingfor13seconds...▄Waitingfor12seconds...▄Waitingfor12seconds...▄Waitingfor11seconds...▀Waitingfor11seconds...▀Waitingfor10seconds...▀Waitingfor10seconds...▀Waitingfor9seconds...▄Waitingfor9seconds...▄Waitingfor8seconds...▄Waitingfor8seconds...▄Waitingfor7seconds...▀Waitingfor7seconds...▀Waitingfor6seconds...▀Waitingfor6seconds...▀Waitingfor5seconds...▄Waitingfor5seconds...▄Waitingfor4seconds...▄Waitingfor4seconds...▄Waitingfor3seconds...▀Waitingfor3seconds...▀Waitingfor2seconds...▀Waitingfor2seconds...▀Waitingfor1second...▄Waitingfor1second... Pseudo Application created with PTerm #Installingpseudoprograms SUCCESS Installingpseudo-excel SUCCESS Installingpseudo-photoshop SUCCESS Installingpseudo-chrome SUCCESS Installingpseudo-outlook SUCCESS Installingpseudo-explorer SUCCESS Installingpseudo-dops SUCCESS Installingpseudo-git SUCCESS Installingpseudo-vsc SUCCESS Installingpseudo-intellij WARNING Couldnotinstallpseudo-minecraft Thecompanypolicyforbidsgames. SUCCESS Installingpseudo-scoop SUCCESS Installingpseudo-chocolateyInstallingpseudo-chocolatey[11/12]███████████████████████████████░░░92%|6s##ProgramInstallReportProgramName|Status|Sizepseudo-excel|pass|193mbpseudo-photoshop|pass|85mbpseudo-chrome|pass|181mbpseudo-outlook|pass|14mbpseudo-explorer|pass|106mbpseudo-dops|pass|183mbpseudo-git|pass|143mbpseudo-vsc|pass|53mbpseudo-intellij|pass|102mbpseudo-minecraft|fail|0mbpseudo-scoop|pass|46mbpseudo-chocolatey|pass|131mb#TreePrinter└─┬C:├──Go├──Windows└─┬Programs├──pseudo-excel├──pseudo-photoshop├─┬pseudo-chrome│├──pseudo-Tabs│├─┬pseudo-Extensions││├──RefinedGitHub││└──GitHubDarkTheme│└─┬pseudo-Bookmarks│└──PTerm├──pseudo-outlook├──pseudo-explorer├──pseudo-dops├──pseudo-git├──pseudo-vsc├──pseudo-intellij├──pseudo-scoop└──pseudo-chocolatey#TrueColorSupport INFO IfyourterminalhasTrueColorsupport,youcanuseRGBcolors! Youcanevenfadethem:)#BulletListPrinter•Goodbye•Haveaniceday!▀Waitingfor15seconds...▄Waitingfor15seconds...▄Waitingfor15seconds...▄Waitingfor14seconds...▄Waitingfor14seconds...▄Waitingfor13seconds...▀Waitingfor13seconds...▀Waitingfor12seconds...▀Waitingfor12seconds...▀Waitingfor11seconds...▄Waitingfor11seconds...▄Waitingfor10seconds...▄Waitingfor10seconds...▄Waitingfor9seconds...▀Waitingfor9seconds...▀Waitingfor8seconds...▀Waitingfor8seconds...▀Waitingfor7seconds...▄Waitingfor7seconds...▄Waitingfor6seconds...▄Waitingfor6seconds...▄Waitingfor5seconds...▀Waitingfor5seconds...▀Waitingfor4seconds...▀Waitingfor4seconds...▀Waitingfor3seconds...▄Waitingfor3seconds...▄Waitingfor2seconds...▄Waitingfor2seconds...▄Waitingfor1second...▀Waitingfor1second...Installingpseudo-excel[1/12]████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░8%|0sInstallingpseudo-photoshop[2/12]██████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░17%|1sInstallingpseudo-chrome[3/12]██████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░25%|1sInstallingpseudo-outlook[4/12]█████████████░░░░░░░░░░░░░░░░░░░░░░░░░33%|2sInstallingpseudo-explorer[5/12]████████████████░░░░░░░░░░░░░░░░░░░░░42%|2sInstallingpseudo-dops[5/12]█████████████████░░░░░░░░░░░░░░░░░░░░░░░░42%|3sInstallingpseudo-dops[6/12]█████████████████████░░░░░░░░░░░░░░░░░░░░50%|3sInstallingpseudo-git[6/12]█████████████████████░░░░░░░░░░░░░░░░░░░░░50%|3sInstallingpseudo-git[7/12]████████████████████████░░░░░░░░░░░░░░░░░░58%|3sInstallingpseudo-vsc[7/12]████████████████████████░░░░░░░░░░░░░░░░░░58%|4sInstallingpseudo-vsc[8/12]████████████████████████████░░░░░░░░░░░░░░67%|4sInstallingpseudo-intellij[9/12]████████████████████████████░░░░░░░░░75%|4sInstallingpseudo-minecraft[9/12]███████████████████████████░░░░░░░░░75%|5sInstallingpseudo-scoop[10/12]████████████████████████████████░░░░░░░83%|5sInstallingpseudo-chocolatey[10/12]████████████████████████████░░░░░░83%|6spseudo-outlook|pass|pse││├── INFO IfyourterminalhasTrueColorsupp YoucRestartinganimation...
\ No newline at end of file
diff --git a/_examples/demo/README.md b/_examples/demo/demo/README.md
similarity index 99%
rename from _examples/demo/README.md
rename to _examples/demo/demo/README.md
index 4738b2e1f..6c89b7803 100644
--- a/_examples/demo/README.md
+++ b/_examples/demo/demo/README.md
@@ -1,4 +1,4 @@
-# demo
+# demo/demo
![Animation](animation.svg)
diff --git a/_examples/demo/demo/animation.svg b/_examples/demo/demo/animation.svg
new file mode 100644
index 000000000..b109d53ff
--- /dev/null
+++ b/_examples/demo/demo/animation.svg
@@ -0,0 +1,10 @@
+███████████████████████████████████████████████████████████████████████████████████████████████████████████████████ PTDP - PTerm Demo Program INFO ThisanimationwasgeneratedwiththelatestversionofPTerm! PTermworksonnearlyeveryterminalandoperatingsystem. It'ssupereasytouse! Ifyouwant,youcancustomizeeverything:) Youcanseethecodeofthisdemointhe./_examples/demodirectory. Thisdemowasupdatedat:21Apr2022-01:56:04CEST▀Waitingfor15seconds...▀Waitingfor14seconds...▀Waitingfor14seconds...▀Waitingfor13seconds...▄Waitingfor13seconds...▄Waitingfor12seconds...▄Waitingfor12seconds...▄Waitingfor11seconds...▀Waitingfor11seconds...▀Waitingfor10seconds...▀Waitingfor10seconds...▀Waitingfor9seconds...▄Waitingfor9seconds...▄Waitingfor8seconds...▄Waitingfor8seconds...▄Waitingfor7seconds...▀Waitingfor7seconds...▀Waitingfor6seconds...▀Waitingfor6seconds...▀Waitingfor5seconds...▄Waitingfor5seconds...▄Waitingfor4seconds...▄Waitingfor4seconds...▄Waitingfor3seconds...▀Waitingfor3seconds...▀Waitingfor2seconds...▀Waitingfor2seconds...▀Waitingfor1second...▄Waitingfor1second... Pseudo Application created with PTerm #Installingpseudoprograms SUCCESS Installingpseudo-excel SUCCESS Installingpseudo-photoshop SUCCESS Installingpseudo-chrome SUCCESS Installingpseudo-outlook SUCCESS Installingpseudo-explorer SUCCESS Installingpseudo-dops SUCCESS Installingpseudo-git SUCCESS Installingpseudo-vsc SUCCESS Installingpseudo-intellij WARNING Couldnotinstallpseudo-minecraft Thecompanypolicyforbidsgames. SUCCESS Installingpseudo-scoop SUCCESS Installingpseudo-chocolateyInstallingpseudo-chocolatey[11/12]███████████████████████████████░░░92%|6s##ProgramInstallReportProgramName|Status|Sizepseudo-excel|pass|199mbpseudo-photoshop|pass|176mbpseudo-chrome|pass|174mbpseudo-outlook|pass|83mbpseudo-explorer|pass|149mbpseudo-dops|pass|68mbpseudo-git|pass|67mbpseudo-vsc|pass|152mbpseudo-intellij|pass|98mbpseudo-minecraft|fail|0mbpseudo-scoop|pass|60mbpseudo-chocolatey|pass|48mb#TreePrinter├──Go├──Windows└─┬Programs├──pseudo-excel├──pseudo-photoshop├─┬pseudo-chrome│├──pseudo-Tabs│├─┬pseudo-Extensions││├──RefinedGitHub││└──GitHubDarkTheme│└─┬pseudo-Bookmarks│└──PTerm├──pseudo-outlook├──pseudo-explorer├──pseudo-dops├──pseudo-git├──pseudo-vsc├──pseudo-intellij├──pseudo-scoop└──pseudo-chocolatey#TrueColorSupport INFO IfyourterminalhasTrueColorsupport,youcanuseRGBcolors! Youcanevenfadethem:)#BulletListPrinter•Goodbye•Haveaniceday!▀Waitingfor15seconds...▄Waitingfor15seconds...▄Waitingfor15seconds...▄Waitingfor14seconds...▄Waitingfor14seconds...▄Waitingfor13seconds...▀Waitingfor13seconds...▀Waitingfor12seconds...▀Waitingfor12seconds...▀Waitingfor11seconds...▄Waitingfor11seconds...▄Waitingfor10seconds...▄Waitingfor10seconds...▄Waitingfor9seconds...▀Waitingfor9seconds...▀Waitingfor8seconds...▀Waitingfor8seconds...▀Waitingfor7seconds...▄Waitingfor7seconds...▄Waitingfor6seconds...▄Waitingfor6seconds...▄Waitingfor5seconds...▀Waitingfor5seconds...▀Waitingfor4seconds...▀Waitingfor4seconds...▀Waitingfor3seconds...▄Waitingfor3seconds...▄Waitingfor2seconds...▄Waitingfor2seconds...▄Waitingfor1second...▀Waitingfor1second...Installingpseudo-excel[0/12]0%|0sInstallingpseudo-excel[1/12]████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░8%|0sInstallingpseudo-photoshop[2/12]██████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░17%|1sInstallingpseudo-chrome[3/12]██████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░25%|1sInstallingpseudo-outlook[4/12]█████████████░░░░░░░░░░░░░░░░░░░░░░░░░33%|2sInstallingpseudo-explorer[5/12]████████████████░░░░░░░░░░░░░░░░░░░░░42%|2sInstallingpseudo-dops[6/12]█████████████████████░░░░░░░░░░░░░░░░░░░░50%|3sInstallingpseudo-git[7/12]████████████████████████░░░░░░░░░░░░░░░░░░58%|3sInstallingpseudo-vsc[7/12]████████████████████████░░░░░░░░░░░░░░░░░░58%|4sInstallingpseudo-vsc[8/12]████████████████████████████░░░░░░░░░░░░░░67%|4sInstallingpseudo-intellij[9/12]████████████████████████████░░░░░░░░░75%|4sInstallingpseudo-minecraft[9/12]███████████████████████████░░░░░░░░░75%|5sInstallingpseudo-scoop[10/12]████████████████████████████████░░░░░░░83%|5spseudo-outlook|pass|pse└─┬C:││├── INFO IfyourterminalhasTrueColorsupp YoucRestartinganimation...
\ No newline at end of file
diff --git a/_examples/demo/main.go b/_examples/demo/demo/main.go
similarity index 100%
rename from _examples/demo/main.go
rename to _examples/demo/demo/main.go
diff --git a/_examples/disable-color/animation.svg b/_examples/disable-color/animation.svg
deleted file mode 100644
index b69178f94..000000000
--- a/_examples/disable-color/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-███████████████████████████████████████████████████████████████████████████████████████████████████████████████████PTDP-PTermDemoProgramINFOThisanimationwasgeneratedwiththelatestversionofPTerm!PTermworksonnearlyeveryterminalandoperatingsystem.It'ssupereasytouse!Ifyouwant,youcancustomizeeverything:)Youcanseethecodeofthisdemointhe./_examples/demodirectory.Thisdemowasupdatedat:20Apr2022-22:18:43UTCPseudoApplicationcreatedwithPTerm#InstallingpseudoprogramsSUCCESSInstallingpseudo-excelSUCCESSInstallingpseudo-photoshopSUCCESSInstallingpseudo-chromeSUCCESSInstallingpseudo-outlookSUCCESSInstallingpseudo-explorerSUCCESSInstallingpseudo-dopsSUCCESSInstallingpseudo-gitSUCCESSInstallingpseudo-vscSUCCESSInstallingpseudo-intellijWARNINGCouldnotinstallpseudo-minecraftThecompanypolicyforbidsgames.SUCCESSInstallingpseudo-scoopSUCCESSInstallingpseudo-chocolateyInstallingpseudo-chocolatey[11/12]███████████████████████████████░░░92%|6s##ProgramInstallReportProgramName|Status|Sizepseudo-excel|pass|18mbpseudo-photoshop|pass|48mbpseudo-chrome|pass|113mbpseudo-outlook|pass|78mbpseudo-explorer|pass|176mbpseudo-dops|pass|140mbpseudo-git|pass|26mbpseudo-vsc|pass|63mbpseudo-intellij|pass|147mbpseudo-minecraft|fail|0mbpseudo-scoop|pass|15mbpseudo-chocolatey|pass|62mb├──pseudo-excel├──pseudo-photoshop├─┬pseudo-chrome│├──pseudo-Tabs│├─┬pseudo-Extensions││├──RefinedGitHub││└──GitHubDarkTheme│└─┬pseudo-Bookmarks│└──PTerm├──pseudo-outlook├──pseudo-explorer├──pseudo-dops├──pseudo-git├──pseudo-vsc├──pseudo-intellij├──pseudo-scoop└──pseudo-chocolatey#TrueColorSupportINFOIfyourterminalhasTrueColorsupport,youcanuseRGBcolors!Youcanevenfadethem:)#BulletListPrinter•Goodbye•Haveaniceday!▀Waitingfor15seconds...(0s)▀Waitingfor15seconds...(0s)▄Waitingfor15seconds...(0s)▄Waitingfor15seconds...(1s)▀Waitingfor15seconds...(1s)▀Waitingfor14seconds...▀Waitingfor14seconds...(1s)▄Waitingfor14seconds...(1s)▄Waitingfor14seconds...(1s)▀Waitingfor14seconds...(2s)▀Waitingfor14seconds...(2s)▀Waitingfor13seconds...▄Waitingfor13seconds...(2s)▄Waitingfor13seconds...(2s)▀Waitingfor13seconds...(2s)▀Waitingfor13seconds...(3s)▄Waitingfor13seconds...(3s)▄Waitingfor12seconds...▄Waitingfor12seconds...(3s)▀Waitingfor12seconds...(3s)▀Waitingfor12seconds...(3s)▄Waitingfor12seconds...(4s)▄Waitingfor12seconds...(4s)▄Waitingfor11seconds...▀Waitingfor11seconds...(4s)▀Waitingfor11seconds...(4s)▄Waitingfor11seconds...(4s)▄Waitingfor11seconds...(5s)▀Waitingfor11seconds...(5s)▀Waitingfor10seconds...▀Waitingfor10seconds...(5s)▄Waitingfor10seconds...(5s)▄Waitingfor10seconds...(5s)▀Waitingfor10seconds...(6s)▀Waitingfor10seconds...(6s)▀Waitingfor9seconds...▄Waitingfor9seconds...(6s)▄Waitingfor9seconds...(6s)▀Waitingfor9seconds...(6s)▀Waitingfor9seconds...(7s)▄Waitingfor9seconds...(7s)▄Waitingfor8seconds...▄Waitingfor8seconds...(7s)▀Waitingfor8seconds...(7s)▀Waitingfor8seconds...(7s)▄Waitingfor8seconds...(8s)▄Waitingfor8seconds...(8s)▄Waitingfor7seconds...▀Waitingfor7seconds...(8s)▀Waitingfor7seconds...(8s)▄Waitingfor7seconds...(8s)▄Waitingfor7seconds...(9s)▀Waitingfor7seconds...(9s)▀Waitingfor6seconds...▀Waitingfor6seconds...(9s)▄Waitingfor6seconds...(9s)▄Waitingfor6seconds...(9s)▀Waitingfor6seconds...(10s)▀Waitingfor6seconds...(10s)▀Waitingfor5seconds...▄Waitingfor5seconds...(10s)▄Waitingfor5seconds...(10s)▀Waitingfor5seconds...(10s)▀Waitingfor5seconds...(11s)▄Waitingfor5seconds...(11s)▄Waitingfor4seconds...▄Waitingfor4seconds...(11s)▀Waitingfor4seconds...(11s)▀Waitingfor4seconds...(11s)▄Waitingfor4seconds...(12s)▄Waitingfor4seconds...(12s)▄Waitingfor3seconds...▀Waitingfor3seconds...(12s)▀Waitingfor3seconds...(12s)▄Waitingfor3seconds...(12s)▄Waitingfor3seconds...(13s)▀Waitingfor3seconds...(13s)▀Waitingfor2seconds...▀Waitingfor2seconds...(13s)▄Waitingfor2seconds...(13s)▄Waitingfor2seconds...(13s)▀Waitingfor2seconds...(14s)▀Waitingfor2seconds...(14s)▀Waitingfor1second...▄Waitingfor1second...(14s)▄Waitingfor1second...(14s)▀Waitingfor1second...(14s)▀Waitingfor1second...(15s)▄Waitingfor1second...(15s)Installingstuff[0/12]0%|0sInstallingpseudo-excel[1/12]████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░8%|0sInstallingpseudo-photoshop[1/12]████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░8%|1sInstallingpseudo-photoshop[2/12]██████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░17%|1sInstallingpseudo-chrome[3/12]██████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░25%|1sInstallingpseudo-outlook[4/12]█████████████░░░░░░░░░░░░░░░░░░░░░░░░░33%|2sInstallingpseudo-explorer[5/12]████████████████░░░░░░░░░░░░░░░░░░░░░42%|2sInstallingpseudo-dops[6/12]█████████████████████░░░░░░░░░░░░░░░░░░░░50%|3sInstallingpseudo-git[6/12]█████████████████████░░░░░░░░░░░░░░░░░░░░░50%|3sInstallingpseudo-git[7/12]████████████████████████░░░░░░░░░░░░░░░░░░58%|3sInstallingpseudo-vsc[8/12]████████████████████████████░░░░░░░░░░░░░░67%|4sInstallingpseudo-intellij[8/12]█████████████████████████░░░░░░░░░░░░67%|4sInstallingpseudo-intellij[9/12]████████████████████████████░░░░░░░░░75%|4sInstallingpseudo-minecraft[9/12]███████████████████████████░░░░░░░░░75%|5sInstallingpseudo-scoop[9/12]██████████████████████████████░░░░░░░░░░75%|5sInstallingpseudo-scoop[10/12]████████████████████████████████░░░░░░░83%|5sInstallingpseudo-chocolatey[10/12]████████████████████████████░░░░░░83%|6s#TreePrinter└─┬C:├──Go├──Windows└─┬ProgramsRestartinganimation...
\ No newline at end of file
diff --git a/_examples/disable-output/animation.svg b/_examples/disable-output/animation.svg
deleted file mode 100644
index 02bb83af8..000000000
--- a/_examples/disable-output/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-Printingsomething...[0/15]Printingsomething...[1/15]Printingsomething...[2/15]Printingsomething...[3/15]Printingsomething...[4/15] INFO DisabledOutput! INFO EnabledOutput!Printingsomething...[10/15]Printingsomething...[11/15]Printingsomething...[12/15]Printingsomething...[13/15]Printingsomething...[14/15]Restartinganimation...
\ No newline at end of file
diff --git a/_examples/disable-styling/animation.svg b/_examples/disable-styling/animation.svg
deleted file mode 100644
index 78acad44c..000000000
--- a/_examples/disable-styling/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-PTermPTDP-PTermDemoProgramINFO:ThisanimationwasgeneratedwiththelatestversionofPTerm!PTermworksonnearlyeveryterminalandoperatingsystem.It'ssupereasytouse!Ifyouwant,youcancustomizeeverything:)Youcanseethecodeofthisdemointhe./_examples/demodirectory.Thisdemowasupdatedat:20Apr2022-22:19:22UTCWaitingfor15seconds...Waitingfor14seconds...Waitingfor13seconds...Waitingfor12seconds...Waitingfor11seconds...Waitingfor10seconds...Waitingfor9seconds...Waitingfor8seconds...Waitingfor7seconds...Waitingfor6seconds...Waitingfor5seconds...Waitingfor4seconds...Waitingfor3seconds...Waitingfor2seconds...Waitingfor1second...PseudoApplicationcreatedwithPTerm#InstallingpseudoprogramsInstallingstuffSUCCESS:Installingpseudo-excelSUCCESS:Installingpseudo-photoshopSUCCESS:Installingpseudo-chromeSUCCESS:Installingpseudo-outlookSUCCESS:Installingpseudo-explorerSUCCESS:Installingpseudo-dopsSUCCESS:Installingpseudo-gitSUCCESS:Installingpseudo-vscSUCCESS:Installingpseudo-intellijWARNING:Couldnotinstallpseudo-minecraftThecompanypolicyforbidsgames.SUCCESS:Installingpseudo-scoopSUCCESS:Installingpseudo-chocolatey##ProgramInstallReportProgramName|Status|Sizepseudo-excel|pass|25mbpseudo-photoshop|pass|199mbpseudo-chrome|pass|82mbpseudo-outlook|pass|32mbpseudo-explorer|pass|114mbpseudo-dops|pass|57mbpseudo-git|pass|106mbpseudo-vsc|pass|155mbpseudo-intellij|pass|80mbpseudo-minecraft|fail|0mbpseudo-scoop|pass|88mbpseudo-chocolatey|pass|105mb├──Windows└─┬Programs├──pseudo-excel├──pseudo-photoshop├─┬pseudo-chrome│├──pseudo-Tabs│├─┬pseudo-Extensions││├──RefinedGitHub││└──GitHubDarkTheme│└─┬pseudo-Bookmarks│└──PTerm├──pseudo-outlook├──pseudo-explorer├──pseudo-dops├──pseudo-git├──pseudo-vsc├──pseudo-intellij├──pseudo-scoop└──pseudo-chocolatey#TrueColorSupportINFO:IfyourterminalhasTrueColorsupport,youcanuseRGBcolors!Youcanevenfadethem:)#BulletListPrinter•Goodbye•Haveaniceday!#TreePrinter└─┬C:├──GoRestartinganimation...
\ No newline at end of file
diff --git a/_examples/header-custom/animation.svg b/_examples/header-custom/animation.svg
deleted file mode 100644
index c7921ab66..000000000
--- a/_examples/header-custom/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
- This is a custom header! This is a custom header! Restartinganimation...
\ No newline at end of file
diff --git a/_examples/header-custom/README.md b/_examples/header-custom/demo/README.md
similarity index 97%
rename from _examples/header-custom/README.md
rename to _examples/header-custom/demo/README.md
index c8d2ec956..f5031ce31 100644
--- a/_examples/header-custom/README.md
+++ b/_examples/header-custom/demo/README.md
@@ -1,4 +1,4 @@
-# header-custom
+# header-custom/demo
![Animation](animation.svg)
diff --git a/_examples/header-custom/demo/animation.svg b/_examples/header-custom/demo/animation.svg
new file mode 100644
index 000000000..172c4618a
--- /dev/null
+++ b/_examples/header-custom/demo/animation.svg
@@ -0,0 +1,10 @@
+ This is a custom header! This is a custom header! Restartinganimation...
\ No newline at end of file
diff --git a/_examples/header-custom/main.go b/_examples/header-custom/demo/main.go
similarity index 100%
rename from _examples/header-custom/main.go
rename to _examples/header-custom/demo/main.go
diff --git a/_examples/header/README.md b/_examples/header/README.md
index 9ad70d682..267f373de 100644
--- a/_examples/header/README.md
+++ b/_examples/header/README.md
@@ -1,6 +1,10 @@
-# header
+### header/demo
-![Animation](animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/header/demo/animation.svg)
+
+
+
+SHOW SOURCE
```go
package main
@@ -15,3 +19,6 @@ func main() {
}
```
+
+
+
diff --git a/_examples/header/animation.svg b/_examples/header/animation.svg
deleted file mode 100644
index 8468f55cd..000000000
--- a/_examples/header/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
- This is the default header! This is a full-width header. Restartinganimation...
\ No newline at end of file
diff --git a/_examples/header/demo/README.md b/_examples/header/demo/README.md
new file mode 100644
index 000000000..30eb7488a
--- /dev/null
+++ b/_examples/header/demo/README.md
@@ -0,0 +1,17 @@
+# header/demo
+
+![Animation](animation.svg)
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print a default header.
+ pterm.DefaultHeader.Println("This is the default header!")
+ pterm.Println() // spacer
+ pterm.DefaultHeader.WithFullWidth().Println("This is a full-width header.")
+}
+
+```
diff --git a/_examples/header/demo/animation.svg b/_examples/header/demo/animation.svg
new file mode 100644
index 000000000..fa66abc6a
--- /dev/null
+++ b/_examples/header/demo/animation.svg
@@ -0,0 +1,10 @@
+ This is the default header! This is a full-width header. Restartinganimation...
\ No newline at end of file
diff --git a/_examples/header/main.go b/_examples/header/demo/main.go
similarity index 100%
rename from _examples/header/main.go
rename to _examples/header/demo/main.go
diff --git a/_examples/panel/animation.svg b/_examples/panel/animation.svg
deleted file mode 100644
index aab802acf..000000000
--- a/_examples/panel/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-Thisisthefirstpanel This Hello, World! panel containsmultiplelinesThisisanotherThisisthesecondpanelpanellinewithanewlineRestartinganimation...
\ No newline at end of file
diff --git a/_examples/panel/README.md b/_examples/panel/demo/README.md
similarity index 97%
rename from _examples/panel/README.md
rename to _examples/panel/demo/README.md
index 220be07bc..96fc214d7 100644
--- a/_examples/panel/README.md
+++ b/_examples/panel/demo/README.md
@@ -1,4 +1,4 @@
-# panel
+# panel/demo
![Animation](animation.svg)
diff --git a/_examples/panel/demo/animation.svg b/_examples/panel/demo/animation.svg
new file mode 100644
index 000000000..c980c1e40
--- /dev/null
+++ b/_examples/panel/demo/animation.svg
@@ -0,0 +1,10 @@
+Thisisthefirstpanel This Hello, World! panel containsmultiplelinesThisisanotherThisisthesecondpanelpanellinewithanewlineRestartinganimation...
\ No newline at end of file
diff --git a/_examples/panel/main.go b/_examples/panel/demo/main.go
similarity index 100%
rename from _examples/panel/main.go
rename to _examples/panel/demo/main.go
diff --git a/_examples/paragraph-custom/animation.svg b/_examples/paragraph-custom/animation.svg
deleted file mode 100644
index 88ea6af5b..000000000
--- a/_examples/paragraph-custom/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-Thisisacustomparagraphprinter.Asyoucansee,nowordsareseparated,butthetextissplitatthespaces.Thisisusefulforcontinuoustextofallkinds.Youcanmanuallychangethelinewidthifyouwantto.Loremipsumdolorsitamet,consetetursadipscingelitr,seddiamnonumyeirmodtemporinviduntutlaboreetdoloremagnaaliquyamThistextiswrittenwiththedefaultPrintln()function.Nointelligentsplittinghere.Loremipsumdolorsitamet,consetetursadipscingelitr,seddiamnonumyeirmodtemporinviduntutlaboreetdoloremagnaaliquyamRestartinganimation...
\ No newline at end of file
diff --git a/_examples/paragraph/animation.svg b/_examples/paragraph/animation.svg
deleted file mode 100644
index 85fe6c920..000000000
--- a/_examples/paragraph/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-Thisisthedefaultparagraphprinter.Asyoucansee,nowordsareseparated,butthetextissplitatthespaces.Thisisusefulforcontinuoustextofallkinds.Youcanmanuallychangethelinewidthifyouwantto.Loremipsumdolorsitamet,consetetursadipscingelitr,seddiamnonumyeirmodtemporinviduntutlaboreetdoloremagnaaliquyamThistextiswrittenwiththedefaultPrintln()function.Nointelligentsplittinghere.Loremipsumdolorsitamet,consetetursadipscingelitr,seddiamnonumyeirmodtemporinviduntutlaboreetdoloremagnaaliquyamRestartinganimation...
\ No newline at end of file
diff --git a/_examples/paragraph-custom/README.md b/_examples/paragraph/customized/README.md
similarity index 97%
rename from _examples/paragraph-custom/README.md
rename to _examples/paragraph/customized/README.md
index 3d15cd0a4..e8d112c1f 100644
--- a/_examples/paragraph-custom/README.md
+++ b/_examples/paragraph/customized/README.md
@@ -1,4 +1,4 @@
-# paragraph-custom
+# paragraph/customized
![Animation](animation.svg)
diff --git a/_examples/paragraph/customized/animation.svg b/_examples/paragraph/customized/animation.svg
new file mode 100644
index 000000000..cdf51f0c6
--- /dev/null
+++ b/_examples/paragraph/customized/animation.svg
@@ -0,0 +1,10 @@
+Thisisacustomparagraphprinter.Asyoucansee,nowordsareseparated,butthetextissplitatthespaces.Thisisusefulforcontinuoustextofallkinds.Youcanmanuallychangethelinewidthifyouwantto.Loremipsumdolorsitamet,consetetursadipscingelitr,seddiamnonumyeirmodtemporinviduntutlaboreetdoloremagnaaliquyamThistextiswrittenwiththedefaultPrintln()function.Nointelligentsplittinghere.Loremipsumdolorsitamet,consetetursadipscingelitr,seddiamnonumyeirmodtemporinviduntutlaboreetdoloremagnaaliquyamRestartinganimation...
\ No newline at end of file
diff --git a/_examples/paragraph-custom/main.go b/_examples/paragraph/customized/main.go
similarity index 100%
rename from _examples/paragraph-custom/main.go
rename to _examples/paragraph/customized/main.go
diff --git a/_examples/paragraph/README.md b/_examples/paragraph/demo/README.md
similarity index 98%
rename from _examples/paragraph/README.md
rename to _examples/paragraph/demo/README.md
index 07ad0d57c..2e0167587 100644
--- a/_examples/paragraph/README.md
+++ b/_examples/paragraph/demo/README.md
@@ -1,4 +1,4 @@
-# paragraph
+# paragraph/demo
![Animation](animation.svg)
diff --git a/_examples/paragraph/demo/animation.svg b/_examples/paragraph/demo/animation.svg
new file mode 100644
index 000000000..fa23567e4
--- /dev/null
+++ b/_examples/paragraph/demo/animation.svg
@@ -0,0 +1,10 @@
+Thisisthedefaultparagraphprinter.Asyoucansee,nowordsareseparated,butthetextissplitatthespaces.Thisisusefulforcontinuoustextofallkinds.Youcanmanuallychangethelinewidthifyouwantto.Loremipsumdolorsitamet,consetetursadipscingelitr,seddiamnonumyeirmodtemporinviduntutlaboreetdoloremagnaaliquyamThistextiswrittenwiththedefaultPrintln()function.Nointelligentsplittinghere.Loremipsumdolorsitamet,consetetursadipscingelitr,seddiamnonumyeirmodtemporinviduntutlaboreetdoloremagnaaliquyamRestartinganimation...
\ No newline at end of file
diff --git a/_examples/paragraph/main.go b/_examples/paragraph/demo/main.go
similarity index 100%
rename from _examples/paragraph/main.go
rename to _examples/paragraph/demo/main.go
diff --git a/_examples/prefix/animation.svg b/_examples/prefix/animation.svg
deleted file mode 100644
index 3a9282ead..000000000
--- a/_examples/prefix/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
- DEBUG Hello,World! INFO Hello,World! SUCCESS Hello,World! WARNING Hello,World! ERROR Errorsshowthefilenameandlinenumberinsidetheterminal! INFO OtherPrefixPrinterscandothattoo!└(/github/workspace/_examples/prefix/main.go:14) FATAL Hello,World!Restartinganimation...
\ No newline at end of file
diff --git a/_examples/prefix/README.md b/_examples/prefix/demo/README.md
similarity index 98%
rename from _examples/prefix/README.md
rename to _examples/prefix/demo/README.md
index 3d23fe3ec..d46d8ac63 100644
--- a/_examples/prefix/README.md
+++ b/_examples/prefix/demo/README.md
@@ -1,4 +1,4 @@
-# prefix
+# prefix/demo
![Animation](animation.svg)
diff --git a/_examples/prefix/demo/animation.svg b/_examples/prefix/demo/animation.svg
new file mode 100644
index 000000000..566e28b75
--- /dev/null
+++ b/_examples/prefix/demo/animation.svg
@@ -0,0 +1,10 @@
+ DEBUG Hello,World! INFO Hello,World! SUCCESS Hello,World! WARNING Hello,World! ERROR Errorsshowthefilenameandlinenumberinsidetheterminal! INFO OtherPrefixPrinterscandothattoo!└(/mnt/d/dev/go/pterm/pterm/_examples/prefix/demo/main.go:14) FATAL Hello,World!Restartinganimation...
\ No newline at end of file
diff --git a/_examples/prefix/main.go b/_examples/prefix/demo/main.go
similarity index 100%
rename from _examples/prefix/main.go
rename to _examples/prefix/demo/main.go
diff --git a/_examples/print-basic-text/animation.svg b/_examples/print-basic-text/animation.svg
deleted file mode 100644
index f8e0480f3..000000000
--- a/_examples/print-basic-text/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-Defaultbasictextprinter.CanbeusedinanyTextPrintercontext.Forexampletoresolveprogressbarsandspinners.Restartinganimation...
\ No newline at end of file
diff --git a/_examples/print-color-fade-multiple/animation.svg b/_examples/print-color-fade-multiple/animation.svg
deleted file mode 100644
index ee0589893..000000000
--- a/_examples/print-color-fade-multiple/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
- INFO RGBcolorsonlyworkinTerminalswhichsupportTrueColor.Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World! INFO RGBcolorsonlyworkinTerminalswRestartinganimation...
\ No newline at end of file
diff --git a/_examples/print-color-fade/animation.svg b/_examples/print-color-fade/animation.svg
deleted file mode 100644
index 64f1bd2a7..000000000
--- a/_examples/print-color-fade/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
- INFO RGBcolorsonlyworkinTerminalswhichsupportTrueColor.Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Hello,World!Restartinganimation...
\ No newline at end of file
diff --git a/_examples/print-with-color/animation.svg b/_examples/print-with-color/animation.svg
deleted file mode 100644
index 812846748..000000000
--- a/_examples/print-with-color/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-Hello,World!Evennestedcolorsaresupported!FgBlackFgRedFgGreenFgYellowFgBlueFgMagentaFgCyanFgWhiteFgLightRedFgLightGreenFgLightYellowFgLightBlueFgLightMagentaFgLightCyanFgLightWhiteRestartinganimation...
\ No newline at end of file
diff --git a/_examples/progressbar/animation.svg b/_examples/progressbar/animation.svg
deleted file mode 100644
index cb00e35b8..000000000
--- a/_examples/progressbar/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
- SUCCESS Downloadingpseudo-excel SUCCESS Downloadingpseudo-photoshop SUCCESS Downloadingpseudo-chrome SUCCESS Downloadingpseudo-outlook SUCCESS Downloadingpseudo-explorer SUCCESS Downloadingpseudo-dops SUCCESS Downloadingpseudo-git SUCCESS Downloadingpseudo-vsc SUCCESS Downloadingpseudo-intellij SUCCESS Downloadingpseudo-minecraft SUCCESS Downloadingpseudo-scoop SUCCESS Downloadingpseudo-chocolateyDownloadingpseudo-chocolatey[12/12]████████████████████████████████100%|4sDownloadingpseudo-excel[1/12]████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░8%|0sDownloadingpseudo-photoshop[1/12]███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░8%|0sDownloadingpseudo-photoshop[2/12]██████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░17%|0sDownloadingpseudo-chrome[2/12]███████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░17%|1sDownloadingpseudo-chrome[3/12]██████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░25%|1sDownloadingpseudo-outlook[4/12]█████████████░░░░░░░░░░░░░░░░░░░░░░░░33%|1sDownloadingpseudo-explorer[4/12]████████████░░░░░░░░░░░░░░░░░░░░░░░░33%|1sDownloadingpseudo-explorer[5/12]███████████████░░░░░░░░░░░░░░░░░░░░░42%|1sDownloadingpseudo-dops[6/12]████████████████████░░░░░░░░░░░░░░░░░░░░50%|2sDownloadingpseudo-git[7/12]████████████████████████░░░░░░░░░░░░░░░░░58%|2sDownloadingpseudo-vsc[8/12]███████████████████████████░░░░░░░░░░░░░░67%|2sDownloadingpseudo-intellij[9/12]███████████████████████████░░░░░░░░░75%|3sDownloadingpseudo-minecraft[9/12]██████████████████████████░░░░░░░░░75%|3sDownloadingpseudo-minecraft[10/12]████████████████████████████░░░░░░83%|3sDownloadingpseudo-scoop[10/12]███████████████████████████████░░░░░░░83%|4sDownloadingpseudo-scoop[11/12]██████████████████████████████████░░░░92%|4sRestartinganimation...
\ No newline at end of file
diff --git a/_examples/progressbar/README.md b/_examples/progressbar/demo/README.md
similarity index 98%
rename from _examples/progressbar/README.md
rename to _examples/progressbar/demo/README.md
index 250d14098..3b1306ef3 100644
--- a/_examples/progressbar/README.md
+++ b/_examples/progressbar/demo/README.md
@@ -1,4 +1,4 @@
-# progressbar
+# progressbar/demo
![Animation](animation.svg)
diff --git a/_examples/progressbar/demo/animation.svg b/_examples/progressbar/demo/animation.svg
new file mode 100644
index 000000000..305fdb169
--- /dev/null
+++ b/_examples/progressbar/demo/animation.svg
@@ -0,0 +1,10 @@
+ SUCCESS Downloadingpseudo-excel SUCCESS Downloadingpseudo-photoshop SUCCESS Downloadingpseudo-chrome SUCCESS Downloadingpseudo-outlook SUCCESS Downloadingpseudo-explorer SUCCESS Downloadingpseudo-dops SUCCESS Downloadingpseudo-git SUCCESS Downloadingpseudo-vsc SUCCESS Downloadingpseudo-intellij SUCCESS Downloadingpseudo-minecraft SUCCESS Downloadingpseudo-scoop SUCCESS Downloadingpseudo-chocolateyDownloadingpseudo-chocolatey[12/12]████████████████████████████████100%|4sDownloadingpseudo-excel[0/12]0%|0sDownloadingpseudo-excel[1/12]████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░8%|0sDownloadingpseudo-photoshop[2/12]██████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░17%|0sDownloadingpseudo-chrome[3/12]██████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░25%|1sDownloadingpseudo-outlook[4/12]█████████████░░░░░░░░░░░░░░░░░░░░░░░░33%|1sDownloadingpseudo-explorer[4/12]████████████░░░░░░░░░░░░░░░░░░░░░░░░33%|1sDownloadingpseudo-explorer[5/12]███████████████░░░░░░░░░░░░░░░░░░░░░42%|1sDownloadingpseudo-dops[6/12]████████████████████░░░░░░░░░░░░░░░░░░░░50%|2sDownloadingpseudo-git[7/12]████████████████████████░░░░░░░░░░░░░░░░░58%|2sDownloadingpseudo-vsc[8/12]███████████████████████████░░░░░░░░░░░░░░67%|2sDownloadingpseudo-intellij[9/12]███████████████████████████░░░░░░░░░75%|3sDownloadingpseudo-minecraft[10/12]████████████████████████████░░░░░░83%|3sDownloadingpseudo-scoop[11/12]██████████████████████████████████░░░░92%|4sRestartinganimation...
\ No newline at end of file
diff --git a/_examples/progressbar/main.go b/_examples/progressbar/demo/main.go
similarity index 100%
rename from _examples/progressbar/main.go
rename to _examples/progressbar/demo/main.go
diff --git a/_examples/section/README.md b/_examples/section/demo/README.md
similarity index 97%
rename from _examples/section/README.md
rename to _examples/section/demo/README.md
index dd04dbf02..a57d406a3 100644
--- a/_examples/section/README.md
+++ b/_examples/section/demo/README.md
@@ -1,4 +1,4 @@
-# section
+# section/demo
![Animation](animation.svg)
diff --git a/_examples/section/animation.svg b/_examples/section/demo/animation.svg
similarity index 59%
rename from _examples/section/animation.svg
rename to _examples/section/demo/animation.svg
index cbc9e3a7f..381f26664 100644
--- a/_examples/section/animation.svg
+++ b/_examples/section/demo/animation.svg
@@ -1,4 +1,4 @@
-#Thisisasection! INFO Andhereissometext. Thistextcouldbeanything. Basicallyit'sjustaplaceholder##Thisisanothersection! INFO Andthisis moreplaceholdertextRestartinganimation...
\ No newline at end of file
+}.a{fill:rgb(35,35,35)}.b{fill:#ff5f58}.c{fill:#ffbd2e}.d{fill:#18c132}.e{font-family:'JetBrainsMono',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace}.f{fill:rgb(160,160,160);white-space:pre}.g{fill:rgb(255,241,0);font-weight:bold;white-space:pre}.h{fill:rgb(102,194,205)}.i{white-space:pre}.j{fill:rgb(126,231,233);white-space:pre}.k{fill:transparent}.m{animation-duration:6.84496s;animation-iteration-count:infinite;animation-name:l;animation-timing-function:steps(1,end)}@keyframes l{0%{transform:translateX(-0px)}26.9%{transform:translateX(-252px)}27%{transform:translateX(-504px)}100%{transform:translateX(-756px)}}#Thisisasection! INFO Andhereissometext. Thistextcouldbeanything. Basicallyit'sjustaplaceholder##Thisisanothersection! INFO Andthisis moreplaceholdertextRestartinganimation...
\ No newline at end of file
diff --git a/_examples/section/main.go b/_examples/section/demo/main.go
similarity index 100%
rename from _examples/section/main.go
rename to _examples/section/demo/main.go
diff --git a/_examples/spinner/animation.svg b/_examples/spinner/animation.svg
deleted file mode 100644
index 4403516f5..000000000
--- a/_examples/spinner/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-▄Doingsomethingimportant...(willsucceed)(1s) SUCCESS Doingsomethingimportant...(willsucceed)▄Doingsomethingimportant...(willwarn)(1s) WARNING Doingsomethingimportant...(willwarn)▄Doingsomethingimportant...(willfail)(1s) ERROR Doingsomethingimportant...(willfail) SUCCESS Finally!▀Doingsomethingimportant...(willsucceed)(0s)▀Doingsomethingimportant...(willsucceed)(0s)▄Doingsomethingimportant...(willsucceed)(0s)▀Doingsomethingimportant...(willsucceed)(1s)▀Doingsomethingimportant...(willsucceed)(1s)▄Doingsomethingimportant...(willsucceed)(1s)▀Doingsomethingimportant...(willsucceed)(2s)▀Doingsomethingimportant...(willsucceed)(2s)▀Doingsomethingimportant...(willwarn)(0s)▀Doingsomethingimportant...(willwarn)(0s)▄Doingsomethingimportant...(willwarn)(0s)▀Doingsomethingimportant...(willwarn)(1s)▀Doingsomethingimportant...(willwarn)(1s)▄Doingsomethingimportant...(willwarn)(1s)▀Doingsomethingimportant...(willwarn)(2s)▀Doingsomethingimportant...(willwarn)(2s)▀Doingsomethingimportant...(willfail)(0s)▀Doingsomethingimportant...(willfail)(0s)▄Doingsomethingimportant...(willfail)(0s)▀Doingsomethingimportant...(willfail)(1s)▀Doingsomethingimportant...(willfail)(1s)▄Doingsomethingimportant...(willfail)(1s)▀Doingsomethingimportant...(willfail)(2s)▀Doingsomethingimportant...(willfail)(2s)▀Doingalotofstuff...(0s)▀Doingalotofstuff...(0s)▄Doingalotofstuff...(0s)▄Doingalotofstuff...(1s)▀Doingalotofstuff...(1s)▀It'sreallymuch▀It'sreallymuch(1s)▄It'sreallymuch(1s)▄It'sreallymuch(1s)▀It'sreallymuch(2s)▀It'sreallymuch(2s)▀We'renearlydone!▄We'renearlydone!(2s)▄We'renearlydone!(2s)▀We'renearlydone!(2s)▀We'renearlydone!(3s)▄We'renearlydone!(3s)Restartinganimation...
\ No newline at end of file
diff --git a/_examples/spinner/README.md b/_examples/spinner/demo/README.md
similarity index 99%
rename from _examples/spinner/README.md
rename to _examples/spinner/demo/README.md
index 95583c282..674548da8 100644
--- a/_examples/spinner/README.md
+++ b/_examples/spinner/demo/README.md
@@ -1,4 +1,4 @@
-# spinner
+# spinner/demo
![Animation](animation.svg)
diff --git a/_examples/spinner/demo/animation.svg b/_examples/spinner/demo/animation.svg
new file mode 100644
index 000000000..d2ad0350e
--- /dev/null
+++ b/_examples/spinner/demo/animation.svg
@@ -0,0 +1,10 @@
+▄Doingsomethingimportant...(willsucceed)(1s) SUCCESS Doingsomethingimportant...(willsucceed)▄Doingsomethingimportant...(willwarn)(1s) WARNING Doingsomethingimportant...(willwarn)▄Doingsomethingimportant...(willfail)(1s) ERROR Doingsomethingimportant...(willfail) SUCCESS Finally!▀Doingsomethingimportant...(willsucceed)(0s)▀Doingsomethingimportant...(willsucceed)(0s)▄Doingsomethingimportant...(willsucceed)(0s)▀Doingsomethingimportant...(willsucceed)(1s)▀Doingsomethingimportant...(willsucceed)(1s)▄Doingsomethingimportant...(willsucceed)(1s)▀Doingsomethingimportant...(willsucceed)(2s)▀Doingsomethingimportant...(willsucceed)(2s)▀Doingsomethingimportant...(willwarn)(0s)▀Doingsomethingimportant...(willwarn)(0s)▄Doingsomethingimportant...(willwarn)(0s)▀Doingsomethingimportant...(willwarn)(1s)▀Doingsomethingimportant...(willwarn)(1s)▄Doingsomethingimportant...(willwarn)(1s)▀Doingsomethingimportant...(willwarn)(2s)▀Doingsomethingimportant...(willwarn)(2s)▀Doingsomethingimportant...(willfail)(0s)▀Doingsomethingimportant...(willfail)(0s)▄Doingsomethingimportant...(willfail)(0s)▀Doingsomethingimportant...(willfail)(1s)▀Doingsomethingimportant...(willfail)(1s)▄Doingsomethingimportant...(willfail)(1s)▀Doingsomethingimportant...(willfail)(2s)▀Doingsomethingimportant...(willfail)(2s)▀Doingalotofstuff...(0s)▀Doingalotofstuff...(0s)▄Doingalotofstuff...(0s)▄Doingalotofstuff...(1s)▀Doingalotofstuff...(1s)▀It'sreallymuch▀It'sreallymuch(1s)▄It'sreallymuch(1s)▄It'sreallymuch(1s)▀It'sreallymuch(2s)▀It'sreallymuch(2s)▀We'renearlydone!▄We'renearlydone!(2s)▄We'renearlydone!(2s)▀We'renearlydone!(2s)▀We'renearlydone!(3s)▄We'renearlydone!(3s)Restartinganimation...
\ No newline at end of file
diff --git a/_examples/spinner/main.go b/_examples/spinner/demo/main.go
similarity index 100%
rename from _examples/spinner/main.go
rename to _examples/spinner/demo/main.go
diff --git a/_examples/style/animation.svg b/_examples/style/animation.svg
deleted file mode 100644
index 6db76bdd8..000000000
--- a/_examples/style/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-Hello, World!Hello, World!Restartinganimation...
\ No newline at end of file
diff --git a/_examples/style/README.md b/_examples/style/demo/README.md
similarity index 96%
rename from _examples/style/README.md
rename to _examples/style/demo/README.md
index 1b11de92e..9aa6b06df 100644
--- a/_examples/style/README.md
+++ b/_examples/style/demo/README.md
@@ -1,4 +1,4 @@
-# style
+# style/demo
![Animation](animation.svg)
diff --git a/_examples/style/demo/animation.svg b/_examples/style/demo/animation.svg
new file mode 100644
index 000000000..d5b3e5378
--- /dev/null
+++ b/_examples/style/demo/animation.svg
@@ -0,0 +1,10 @@
+Hello, World!Hello, World!Restartinganimation...
\ No newline at end of file
diff --git a/_examples/style/main.go b/_examples/style/demo/main.go
similarity index 100%
rename from _examples/style/main.go
rename to _examples/style/demo/main.go
diff --git a/_examples/table/animation.svg b/_examples/table/animation.svg
deleted file mode 100644
index 6754d9665..000000000
--- a/_examples/table/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-Firstname|Lastname|EmailPaul|Dean|nisi.dictum.augue@velitAliquam.co.ukCallie|Mckay|egestas.nunc.sed@est.comLibby|Camacho|aliquet.lobortis@semper.comFirstname|Lastname|EmailPaul|Dean|nisi.dictum.augue@velitAliquam.co.ukCallie|Mckay|egestas.nunc.sed@est.comLibby|Camacho|aliquet.lobortis@semper.comRestartinganimation...
\ No newline at end of file
diff --git a/_examples/table/README.md b/_examples/table/demo/README.md
similarity index 98%
rename from _examples/table/README.md
rename to _examples/table/demo/README.md
index 23ed3fba8..2150f3622 100644
--- a/_examples/table/README.md
+++ b/_examples/table/demo/README.md
@@ -1,4 +1,4 @@
-# table
+# table/demo
![Animation](animation.svg)
@@ -18,7 +18,7 @@ func main() {
}).Render()
pterm.Println() // Blank line
-
+
// Create a table with right alignment.
pterm.DefaultTable.WithHasHeader().WithData(pterm.TableData{
{"Firstname", "Lastname", "Email"},
diff --git a/_examples/table/demo/animation.svg b/_examples/table/demo/animation.svg
new file mode 100644
index 000000000..c1d22eac2
--- /dev/null
+++ b/_examples/table/demo/animation.svg
@@ -0,0 +1,10 @@
+Firstname|Lastname|EmailPaul|Dean|nisi.dictum.augue@velitAliquam.co.ukCallie|Mckay|egestas.nunc.sed@est.comLibby|Camacho|aliquet.lobortis@semper.comFirstname|Lastname|EmailPaul|Dean|nisi.dictum.augue@velitAliquam.co.ukCallie|Mckay|egestas.nunc.sed@est.comLibby|Camacho|aliquet.lobortis@semper.comRestartinganimation...
\ No newline at end of file
diff --git a/_examples/table/main.go b/_examples/table/demo/main.go
similarity index 98%
rename from _examples/table/main.go
rename to _examples/table/demo/main.go
index 94f41c624..491f99d4e 100644
--- a/_examples/table/main.go
+++ b/_examples/table/demo/main.go
@@ -13,7 +13,7 @@ func main() {
}).Render()
pterm.Println() // Blank line
-
+
// Create a table with right alignment.
pterm.DefaultTable.WithHasHeader().WithData(pterm.TableData{
{"Firstname", "Lastname", "Email"},
diff --git a/_examples/theme/animation.svg b/_examples/theme/animation.svg
deleted file mode 100644
index 993d43409..000000000
--- a/_examples/theme/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
- INFO Thesearethedefaultthemestyles. Youcanmodifythemeasilytoyourpersonalpreference, orcreatenewthemesfromscratch:)PrimaryStyleSecondaryStyleHighlightStyleInfoMessageStyleInfoPrefixStyleSuccessMessageStyleSuccessPrefixStyleWarningMessageStyleWarningPrefixStyleErrorMessageStyleErrorPrefixStyleFatalMessageStyleFatalPrefixStyleDescriptionMessageStyleDescriptionPrefixStyleScopeStyleProgressbarBarStyleProgressbarTitleStyleHeaderTextStyleHeaderBackgroundStyleSpinnerStyleSpinnerTextStyleTimerStyleTableStyleTableHeaderStyleTableSeparatorStyleSectionStyleBulletListTextStyleBulletListBulletStyleTreeStyleTreeTextStyleLetterStyleDebugMessageStyleDebugPrefixStyleBoxStyleBoxTextStyleBarLabelStyleBarStyleRestartinganimation...
\ No newline at end of file
diff --git a/_examples/theme/README.md b/_examples/theme/demo/README.md
similarity index 98%
rename from _examples/theme/README.md
rename to _examples/theme/demo/README.md
index 2d4de7678..5e15c3299 100644
--- a/_examples/theme/README.md
+++ b/_examples/theme/demo/README.md
@@ -1,4 +1,4 @@
-# theme
+# theme/demo
![Animation](animation.svg)
diff --git a/_examples/theme/demo/animation.svg b/_examples/theme/demo/animation.svg
new file mode 100644
index 000000000..f732c324f
--- /dev/null
+++ b/_examples/theme/demo/animation.svg
@@ -0,0 +1,10 @@
+ INFO Thesearethedefaultthemestyles. Youcanmodifythemeasilytoyourpersonalpreference, orcreatenewthemesfromscratch:)PrimaryStyleSecondaryStyleHighlightStyleInfoMessageStyleInfoPrefixStyleSuccessMessageStyleSuccessPrefixStyleWarningMessageStyleWarningPrefixStyleErrorMessageStyleErrorPrefixStyleFatalMessageStyleFatalPrefixStyleDescriptionMessageStyleDescriptionPrefixStyleScopeStyleProgressbarBarStyleProgressbarTitleStyleHeaderTextStyleHeaderBackgroundStyleSpinnerStyleSpinnerTextStyleTimerStyleTableStyleTableHeaderStyleTableSeparatorStyleSectionStyleBulletListTextStyleBulletListBulletStyleTreeStyleTreeTextStyleLetterStyleDebugMessageStyleDebugPrefixStyleBoxStyleBoxTextStyleBarLabelStyleBarStyleRestartinganimation...
\ No newline at end of file
diff --git a/_examples/theme/main.go b/_examples/theme/demo/main.go
similarity index 100%
rename from _examples/theme/main.go
rename to _examples/theme/demo/main.go
diff --git a/_examples/tree/animation.svg b/_examples/tree/animation.svg
deleted file mode 100644
index b2bb8015c..000000000
--- a/_examples/tree/animation.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-├─┬C:│├──Users│├──Windows│├──Programs│├──Programs(x86)│└──dev├──D:├─┬E:│├──Movies│├─┬Music││└──LinkinPark│└─┬Games│└─┬Shooter│├──CallOfDuty│├──CS:GO│└─┬Battlefield│├──Battlefield1│└──Battlefield2└─│├─┬Muestartinganimation...
\ No newline at end of file
diff --git a/_examples/tree/README.md b/_examples/tree/demo/README.md
similarity index 99%
rename from _examples/tree/README.md
rename to _examples/tree/demo/README.md
index 7a9eab639..fad742f82 100644
--- a/_examples/tree/README.md
+++ b/_examples/tree/demo/README.md
@@ -1,4 +1,4 @@
-# tree
+# tree/demo
![Animation](animation.svg)
diff --git a/_examples/tree/demo/animation.svg b/_examples/tree/demo/animation.svg
new file mode 100644
index 000000000..829a73ce0
--- /dev/null
+++ b/_examples/tree/demo/animation.svg
@@ -0,0 +1,10 @@
+├─┬C:│├──Users│├──Windows│├──Programs│├──Programs(x86)│└──dev├──D:├─┬E:│├──Movies│├─┬Music││└──LinkinPark│└─┬Games│└─┬Shooter│├──CallOfDuty│├──CS:GO│└─┬Battlefield│├──Battlefield1│└──Battlefield2└─┬F:└─┬dev├──dops└──PTerm│├─┬Mu└─Restartinganimation...
\ No newline at end of file
diff --git a/_examples/tree/main.go b/_examples/tree/demo/main.go
similarity index 100%
rename from _examples/tree/main.go
rename to _examples/tree/demo/main.go
diff --git a/ci/main.go b/ci/main.go
index 6b1d7b5e4..ff069cd3c 100644
--- a/ci/main.go
+++ b/ci/main.go
@@ -43,32 +43,40 @@ func main() {
os.WriteFile("./docs/docs/putils.md", []byte(putilsReadme), 0600)
log.Output(1, "## Generating Examples")
- files, err := os.ReadDir("./_examples/")
- if err != nil {
- log.Panic(err)
- }
-
+ files, _ := os.ReadDir("./_examples/")
var readmeExamples string
-
- for _, f := range files {
- processFile(f)
- }
-
- for _, f := range files {
- exampleCode, err := os.ReadFile("./_examples/" + f.Name() + "/main.go")
- if err != nil {
- log.Panic(err)
+ for _, section := range files {
+ var sectionExamples string
+ log.Output(2, "Section: "+section.Name())
+ examples, _ := os.ReadDir("./_examples/" + section.Name())
+
+ for _, example := range examples {
+ processFile(section.Name() + "/" + example.Name())
+ log.Output(2, "## Generating readme for example: "+example.Name())
+ exampleCode, err := os.ReadFile("./_examples/" + section.Name() + "/" + example.Name() + "/main.go")
+ if err != nil {
+ log.Panic(err)
+ }
+
+ sectionExamples += "### " + section.Name() + "/" + example.Name() + "\n\n"
+ sectionExamples += "![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/" + section.Name() + "/" + example.Name() + "/animation.svg)\n\n"
+ sectionExamples += "\n\nSHOW SOURCE
\n\n"
+ sectionExamples += "```go\n"
+ sectionExamples += string(exampleCode) + "\n"
+ sectionExamples += "```\n\n"
+ sectionExamples += " \n\n"
+
+ readmeExamples += sectionExamples
}
-
- readmeExamples += "### " + f.Name() + "\n\n"
- readmeExamples += "![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/" + f.Name() + "/animation.svg)\n\n"
- readmeExamples += "\n\nSHOW SOURCE
\n\n"
- readmeExamples += "```go\n"
- readmeExamples += string(exampleCode) + "\n"
- readmeExamples += "```\n\n"
- readmeExamples += " \n\n"
+ os.WriteFile("./_examples/"+section.Name()+"/README.md", []byte(sectionExamples), 0600)
}
+ log.Output(3, "### Generating examples README")
+ examplesReadme, _ := os.ReadFile("./_examples/README.md")
+ examplesReadmeContent := string(examplesReadme)
+ examplesReadmeContent = writeBetween("examples", examplesReadmeContent, "\n"+readmeExamples+"\n")
+ os.WriteFile("./_examples/README.md", []byte(examplesReadmeContent), 0600)
+
log.Output(3, "### Appending examples to root README.md")
readmeContent, err := os.ReadFile("./README.md")
@@ -117,34 +125,34 @@ func main() {
}
}
-func processFile(f os.DirEntry) {
- log.Output(3, "### ['"+f.Name()+"'] Generating animations for example")
- animationDataPath := "./_examples/" + f.Name() + "/animation_data.json"
- animationSvgPath := "./_examples/" + f.Name() + "/animation.svg"
- exampleCode, err := os.ReadFile("./_examples/" + f.Name() + "/main.go")
+func processFile(dir string) {
+ log.Output(3, "### ['"+dir+"'] Generating animations for example")
+ animationDataPath := "./_examples/" + dir + "/animation_data.json"
+ animationSvgPath := "./_examples/" + dir + "/animation.svg"
+ exampleCode, err := os.ReadFile("./_examples/" + dir + "/main.go")
if err != nil {
log.Panic(err)
}
if fileExists(animationDataPath) {
- log.Output(4, "#### ['"+f.Name()+"'] animation_data.json already exists. Removing it.")
+ log.Output(4, "#### ['"+dir+"'] animation_data.json already exists. Removing it.")
err = os.Remove(animationDataPath)
if err != nil {
log.Panic(err)
}
}
if fileExists(animationSvgPath) {
- log.Output(4, "#### ['"+f.Name()+"'] animation.svg already exists. Removing it.")
+ log.Output(4, "#### ['"+dir+"'] animation.svg already exists. Removing it.")
err := os.Remove(animationSvgPath)
if err != nil {
log.Panic(err)
}
}
- log.Output(4, "#### ['"+f.Name()+"'] Running asciinema")
- execute(`asciinema rec ` + animationDataPath + ` -c "go run ./_examples/` + f.Name() + `"`)
+ log.Output(4, "#### ['"+dir+"'] Running asciinema")
+ execute(`asciinema rec ` + animationDataPath + ` -c "go run ./_examples/` + dir + `"`)
- log.Output(4, "#### ['"+f.Name()+"'] Adding sleep to end of animation_data.json")
+ log.Output(4, "#### ['"+dir+"'] Adding sleep to end of animation_data.json")
animationDataLines := getLinesFromFile(animationDataPath)
animationDataLastLine := animationDataLines[len(animationDataLines)-1]
re := regexp.MustCompile(`\[\d[^,]*`).FindAllString(animationDataLastLine, 1)[0]
@@ -152,22 +160,22 @@ func processFile(f os.DirEntry) {
sleepString := `[` + strconv.FormatFloat(lastTime+5, 'f', 6, 64) + `, "o", "\nRestarting animation...\n"]`
animationDataFile, err := os.OpenFile(animationDataPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600)
if err != nil {
- log.Panicf("[%s] %s", f.Name(), err.Error())
+ log.Panicf("[%s] %s", dir, err.Error())
}
defer animationDataFile.Close()
_, err = animationDataFile.WriteString(sleepString)
if err != nil {
- log.Panicf("[%s] %s", f.Name(), err.Error())
+ log.Panicf("[%s] %s", dir, err.Error())
}
- log.Output(4, "#### ['"+f.Name()+"'] Generating SVG")
+ log.Output(4, "#### ['"+dir+"'] Generating SVG")
execute(`svg-term --in ` + animationDataPath + ` --out ` + animationSvgPath + ` --no-cursor --window true --no-optimize --profile "./ci/terminal-theme.txt" --term "iterm2"`)
- log.Output(4, "#### ['"+f.Name()+"'] Overwriting SVG font")
+ log.Output(4, "#### ['"+dir+"'] Overwriting SVG font")
svgContent, err := os.ReadFile(animationSvgPath)
if err != nil {
- log.Panicf("[%s] %s", f.Name(), err.Error())
+ log.Panicf("[%s] %s", dir, err.Error())
}
svgContent = []byte(strings.ReplaceAll(string(svgContent), `font-family:`, `font-family:'JetBrainsMono',`))
@@ -187,19 +195,19 @@ func processFile(f os.DirEntry) {
os.Remove(animationSvgPath)
os.WriteFile(animationSvgPath, svgContent, 0600)
- log.Output(4, "#### ['"+f.Name()+"'] Generating README.md")
- readmeString := "# " + f.Name() + "\n\n![Animation](animation.svg)\n\n"
+ log.Output(4, "#### ['"+dir+"'] Generating README.md")
+ readmeString := "# " + dir + "\n\n![Animation](animation.svg)\n\n"
readmeString += "```go\n"
readmeString += string(exampleCode)
readmeString += "\n```\n"
- err = os.WriteFile("./_examples/"+f.Name()+"/README.md", []byte(readmeString), 0600)
+ err = os.WriteFile("./_examples/"+dir+"/README.md", []byte(readmeString), 0600)
if err != nil {
log.Panic(err)
}
- log.Output(4, "#### ['"+f.Name()+"'] Adding example to global example list")
+ log.Output(4, "#### ['"+dir+"'] Adding example to global example list")
- log.Output(4, "#### ['"+f.Name()+"'] Cleaning files")
+ log.Output(4, "#### ['"+dir+"'] Cleaning files")
os.Remove(animationDataPath)
// wg.Done()
diff --git a/docs/README.md b/docs/README.md
index 80be38aa2..3f7a273bf 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -180,9 +180,9 @@ Your financial support enables me to focus more on my projects. Thank you very m
You can find all the examples, with their source code, here: [`./_examples`](./_examples)
-### area
+### area/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/area/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/area/demo/animation.svg)
@@ -214,9 +214,9 @@ func main() {
-### barchart
+### barchart/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/demo/animation.svg)
@@ -254,9 +254,137 @@ func main() {
-### barchart-mixed-values
+### barchart/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart-mixed-values/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ positiveBars := pterm.Bars{
+ pterm.Bar{
+ Label: "Bar 1",
+ Value: 5,
+ },
+ pterm.Bar{
+ Label: "Bar 2",
+ Value: 3,
+ },
+ pterm.Bar{
+ Label: "Longer Label",
+ Value: 7,
+ },
+ }
+
+ pterm.Info.Println("Chart example with positive only values (bars use 100% of chart area)")
+ _ = pterm.DefaultBarChart.WithBars(positiveBars).Render()
+ _ = pterm.DefaultBarChart.WithHorizontal().WithBars(positiveBars).Render()
+}
+
+```
+
+
+
+### barchart/mixed-values
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/mixed-values/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ mixedBars := pterm.Bars{
+ pterm.Bar{
+ Label: "Bar 1",
+ Value: 2,
+ },
+ pterm.Bar{
+ Label: "Bar 2",
+ Value: -3,
+ },
+ pterm.Bar{
+ Label: "Bar 3",
+ Value: -2,
+ },
+ pterm.Bar{
+ Label: "Bar 4",
+ Value: 5,
+ },
+ pterm.Bar{
+ Label: "Longer Label",
+ Value: 7,
+ },
+ }
+
+ pterm.DefaultSection.Println("Chart example with mixed values (note screen space usage in case when ABSOLUTE values of negative and positive parts are differ too much)")
+ _ = pterm.DefaultBarChart.WithBars(mixedBars).WithShowValue().Render()
+ _ = pterm.DefaultBarChart.WithHorizontal().WithBars(mixedBars).WithShowValue().Render()
+}
+
+```
+
+
+
+### barchart/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ positiveBars := pterm.Bars{
+ pterm.Bar{
+ Label: "Bar 1",
+ Value: 5,
+ },
+ pterm.Bar{
+ Label: "Bar 2",
+ Value: 3,
+ },
+ pterm.Bar{
+ Label: "Longer Label",
+ Value: 7,
+ },
+ }
+
+ pterm.Info.Println("Chart example with positive only values (bars use 100% of chart area)")
+ _ = pterm.DefaultBarChart.WithBars(positiveBars).Render()
+ _ = pterm.DefaultBarChart.WithHorizontal().WithBars(positiveBars).Render()
+}
+
+```
+
+
+
+### barchart/mixed-values
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/mixed-values/animation.svg)
@@ -302,9 +430,9 @@ func main() {
-### barchart-negative-values
+### barchart/negative-values
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart-negative-values/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/negative-values/animation.svg)
@@ -342,9 +470,36 @@ func main() {
-### bigtext
+### basictext/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/basictext/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // A BasicText printer is used to print text, without special formatting.
+ // As it implements the TextPrinter interface, you can use it in combination with other printers.
+ 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.")
+ // If you just want to print text, you should use this instead:
+ // pterm.Println("Hello, World!")
+}
+
+```
+
+
+
+### bigtext/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bigtext/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bigtext/demo/animation.svg)
@@ -376,9 +531,2407 @@ func main() {
-### box
+### box/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/box/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ pterm.Info.Println("This might not be rendered correctly on GitHub,\nbut it will work in a real terminal.\nThis is because GitHub does not use a monospaced font by default for SVGs.")
+
+ panel1 := pterm.DefaultBox.Sprint("Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit,\nsed do eiusmod tempor incididunt\nut labore et dolore\nmagna aliqua.")
+ panel2 := pterm.DefaultBox.WithTitle("title").Sprint("Ut enim ad minim veniam,\nquis nostrud exercitation\nullamco laboris\nnisi ut aliquip\nex ea commodo\nconsequat.")
+ panel3 := pterm.DefaultBox.WithTitle("bottom center title").WithTitleBottomCenter().Sprint("Duis aute irure\ndolor in reprehenderit\nin voluptate velit esse cillum\ndolore eu fugiat\nnulla pariatur.")
+
+ panels, _ := pterm.DefaultPanel.WithPanels(pterm.Panels{
+ {{Data: panel1}, {Data: panel2}},
+ {{Data: panel3}},
+ }).Srender()
+
+ pterm.DefaultBox.WithTitle("Lorem Ipsum").WithTitleBottomRight().WithRightPadding(0).WithBottomPadding(0).Println(panels)
+}
+
+```
+
+
+
+### bulletlist/customized
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/customized/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ // Print a customized list with different styles and levels.
+ 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()
+}
+
+```
+
+
+
+### bulletlist/customized
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/customized/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ // Print a customized list with different styles and levels.
+ 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()
+}
+
+```
+
+
+
+### bulletlist/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print a list with different levels.
+ // Useful to generate lists automatically from data.
+ pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{
+ {Level: 0, Text: "Level 0"},
+ {Level: 1, Text: "Level 1"},
+ {Level: 2, Text: "Level 2"},
+ }).Render()
+
+ // Convert a text to a list and print it.
+ pterm.NewBulletListFromString(`0
+ 1
+ 2
+ 3`, " ").Render()
+}
+
+```
+
+
+
+### center/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/center/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ pterm.DefaultCenter.Println("This text is centered!\nIt centeres the whole block by default.\nIn that way you can do stuff like this:")
+
+ // Generate BigLetters
+ s, _ := pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString("PTerm")).Srender()
+ pterm.DefaultCenter.Println(s) // Print BigLetters with the default CenterPrinter
+
+ pterm.DefaultCenter.WithCenterEachLineSeparately().Println("This text is centered!\nBut each line is\ncentered\nseparately")
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/disable-color
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-color/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableColor()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/disable-color
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-color/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableColor()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/disable-output
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-output/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ for i := 0; i < 15; i++ {
+ switch i {
+ case 5:
+ pterm.Info.Println("Disabled Output!")
+ pterm.DisableOutput()
+ case 10:
+ pterm.EnableOutput()
+ pterm.Info.Println("Enabled Output!")
+ }
+
+ pterm.Printf("Printing something... [%d/%d]\n", i, 15)
+ }
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/disable-color
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-color/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableColor()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/disable-output
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-output/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ for i := 0; i < 15; i++ {
+ switch i {
+ case 5:
+ pterm.Info.Println("Disabled Output!")
+ pterm.DisableOutput()
+ case 10:
+ pterm.EnableOutput()
+ pterm.Info.Println("Enabled Output!")
+ }
+
+ pterm.Printf("Printing something... [%d/%d]\n", i, 15)
+ }
+}
+
+```
+
+
+
+### coloring/disable-styling
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-styling/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableStyling()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/disable-color
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-color/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableColor()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/disable-output
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-output/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ for i := 0; i < 15; i++ {
+ switch i {
+ case 5:
+ pterm.Info.Println("Disabled Output!")
+ pterm.DisableOutput()
+ case 10:
+ pterm.EnableOutput()
+ pterm.Info.Println("Enabled Output!")
+ }
+
+ pterm.Printf("Printing something... [%d/%d]\n", i, 15)
+ }
+}
+
+```
+
+
+
+### coloring/disable-styling
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-styling/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableStyling()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/fade-colors
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-colors/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ // Print info.
+ pterm.Info.Println("RGB colors only work in Terminals which support TrueColor.")
+
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients end point.
+
+ // For loop over the range of the terminal height.
+ for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
+ // Print string which is colored with the faded RGB value.
+ from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to).Println("Hello, World!")
+ }
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/disable-color
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-color/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableColor()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/disable-output
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-output/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ for i := 0; i < 15; i++ {
+ switch i {
+ case 5:
+ pterm.Info.Println("Disabled Output!")
+ pterm.DisableOutput()
+ case 10:
+ pterm.EnableOutput()
+ pterm.Info.Println("Enabled Output!")
+ }
+
+ pterm.Printf("Printing something... [%d/%d]\n", i, 15)
+ }
+}
+
+```
+
+
+
+### coloring/disable-styling
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-styling/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableStyling()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/fade-colors
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-colors/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ // Print info.
+ pterm.Info.Println("RGB colors only work in Terminals which support TrueColor.")
+
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients end point.
+
+ // For loop over the range of the terminal height.
+ for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
+ // Print string which is colored with the faded RGB value.
+ from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to).Println("Hello, World!")
+ }
+}
+
+```
+
+
+
+### coloring/fade-multiple-colors
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-multiple-colors/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "strings"
+
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+ to2 := pterm.NewRGB(255, 0, 0) // This RGB value is used as the gradients second point.
+ to3 := pterm.NewRGB(0, 255, 0) // This RGB value is used as the gradients third point.
+ to4 := pterm.NewRGB(255, 255, 255) // This RGB value is used as the gradients end point.
+
+ str := "RGB colors only work in Terminals which support TrueColor."
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+
+ // Print info.
+ pterm.Info.Println(fadeInfo)
+
+ // For loop over the range of the terminal height.
+ for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
+ // Print string which is colored with the faded RGB value.
+ from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to, to2, to3, to4).Println("Hello, World!")
+ }
+}
+
+```
+
+
+
+### coloring/demo
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ // Print 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!"))
+
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
+}
+
+```
+
+
+
+### coloring/disable-color
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-color/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableColor()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/disable-output
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-output/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ for i := 0; i < 15; i++ {
+ switch i {
+ case 5:
+ pterm.Info.Println("Disabled Output!")
+ pterm.DisableOutput()
+ case 10:
+ pterm.EnableOutput()
+ pterm.Info.Println("Enabled Output!")
+ }
+
+ pterm.Printf("Printing something... [%d/%d]\n", i, 15)
+ }
+}
+
+```
+
+
+
+### coloring/disable-styling
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-styling/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "math/rand"
+ "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() {
+ pterm.DisableStyling()
+ introScreen()
+ clear()
+ pseudoApplicationHeader()
+ time.Sleep(second)
+ installingPseudoList()
+ time.Sleep(second * 2)
+ pterm.DefaultSection.WithLevel(2).Println("Program Install Report")
+ installedProgramsSize()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("Tree Printer")
+ installedTree()
+ time.Sleep(second * 4)
+ pterm.DefaultSection.Println("TrueColor Support")
+ fadeText()
+ time.Sleep(second)
+ pterm.DefaultSection.Println("Bullet List Printer")
+ listPrinter()
+}
+
+func installedTree() {
+ leveledList := pterm.LeveledList{
+ pterm.LeveledListItem{Level: 0, Text: "C:"},
+ pterm.LeveledListItem{Level: 1, Text: "Go"},
+ pterm.LeveledListItem{Level: 1, Text: "Windows"},
+ pterm.LeveledListItem{Level: 1, Text: "Programs"},
+ }
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 2, Text: s})
+ }
+ if s == "pseudo-chrome" {
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Tabs"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Extensions"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "Refined GitHub"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "GitHub Dark Theme"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 3, Text: "pseudo-Bookmarks"})
+ leveledList = append(leveledList, pterm.LeveledListItem{Level: 4, Text: "PTerm"})
+ }
+ }
+
+ pterm.DefaultTree.WithRoot(pterm.NewTreeFromLeveledList(leveledList)).Render()
+}
+
+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.UpdateTitle("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 / 2)
+ }
+ p.Stop()
+}
+
+func listPrinter() {
+ pterm.NewBulletListFromString(`Good bye
+ Have a nice day!`, " ").Render()
+}
+
+func fadeText() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+
+ str := "If your terminal has TrueColor support, you can use RGB colors!\nYou can even fade them :)"
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+ pterm.Info.Println(fadeInfo)
+}
+
+func installedProgramsSize() {
+ d := pterm.TableData{{"Program Name", "Status", "Size"}}
+ for _, s := range pseudoProgramList {
+ if s != "pseudo-minecraft" {
+ d = append(d, []string{s, pterm.LightGreen("pass"), strconv.Itoa(randomInt(7, 200)) + "mb"})
+ } else {
+ d = append(d, []string{pterm.LightRed(s), pterm.LightRed("fail"), "0mb"})
+ }
+ }
+ pterm.DefaultTable.WithHasHeader().WithData(d).Render()
+}
+
+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.FgLightCyan)),
+ 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")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/fade-colors
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/box/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-colors/animation.svg)
@@ -387,30 +2940,31 @@ func main() {
```go
package main
-import "github.com/pterm/pterm"
+import (
+ "github.com/pterm/pterm"
+)
func main() {
- pterm.Info.Println("This might not be rendered correctly on GitHub,\nbut it will work in a real terminal.\nThis is because GitHub does not use a monospaced font by default for SVGs.")
-
- panel1 := pterm.DefaultBox.Sprint("Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit,\nsed do eiusmod tempor incididunt\nut labore et dolore\nmagna aliqua.")
- panel2 := pterm.DefaultBox.WithTitle("title").Sprint("Ut enim ad minim veniam,\nquis nostrud exercitation\nullamco laboris\nnisi ut aliquip\nex ea commodo\nconsequat.")
- panel3 := pterm.DefaultBox.WithTitle("bottom center title").WithTitleBottomCenter().Sprint("Duis aute irure\ndolor in reprehenderit\nin voluptate velit esse cillum\ndolore eu fugiat\nnulla pariatur.")
+ // Print info.
+ pterm.Info.Println("RGB colors only work in Terminals which support TrueColor.")
- panels, _ := pterm.DefaultPanel.WithPanels(pterm.Panels{
- {{Data: panel1}, {Data: panel2}},
- {{Data: panel3}},
- }).Srender()
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients end point.
- pterm.DefaultBox.WithTitle("Lorem Ipsum").WithTitleBottomRight().WithRightPadding(0).WithBottomPadding(0).Println(panels)
+ // For loop over the range of the terminal height.
+ for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
+ // Print string which is colored with the faded RGB value.
+ from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to).Println("Hello, World!")
+ }
}
```
-### bulletlist
+### coloring/fade-multiple-colors
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-multiple-colors/animation.svg)
@@ -419,31 +2973,45 @@ func main() {
```go
package main
-import "github.com/pterm/pterm"
+import (
+ "strings"
+
+ "github.com/pterm/pterm"
+)
func main() {
- // Print a list with different levels.
- // Useful to generate lists automatically from data.
- pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{
- {Level: 0, Text: "Level 0"},
- {Level: 1, Text: "Level 1"},
- {Level: 2, Text: "Level 2"},
- }).Render()
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+ to2 := pterm.NewRGB(255, 0, 0) // This RGB value is used as the gradients second point.
+ to3 := pterm.NewRGB(0, 255, 0) // This RGB value is used as the gradients third point.
+ to4 := pterm.NewRGB(255, 255, 255) // This RGB value is used as the gradients end point.
- // Convert a text to a list and print it.
- pterm.NewBulletListFromString(`0
- 1
- 2
- 3`, " ").Render()
+ str := "RGB colors only work in Terminals which support TrueColor."
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+
+ // Print info.
+ pterm.Info.Println(fadeInfo)
+
+ // For loop over the range of the terminal height.
+ for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
+ // Print string which is colored with the faded RGB value.
+ from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to, to2, to3, to4).Println("Hello, World!")
+ }
}
```
-### bulletlist-custom
+### coloring/override-default-printers
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist-custom/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/override-default-printers/animation.svg)
@@ -452,26 +3020,29 @@ func main() {
```go
package main
-import (
- "github.com/pterm/pterm"
-)
+import "github.com/pterm/pterm"
func main() {
- // Print a customized list with different styles and levels.
- 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()
+ // Print default error.
+ pterm.Error.Println("This is the default Error")
+
+ // Customize default error.
+ pterm.Error.Prefix = pterm.Prefix{
+ Text: "OVERRIDE",
+ Style: pterm.NewStyle(pterm.BgCyan, pterm.FgRed),
+ }
+
+ // Print new default error.
+ pterm.Error.Println("This is the default Error after the prefix was overridden")
}
```
-### center
+### coloring/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/center/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/demo/animation.svg)
@@ -483,22 +3054,36 @@ package main
import "github.com/pterm/pterm"
func main() {
- pterm.DefaultCenter.Println("This text is centered!\nIt centeres the whole block by default.\nIn that way you can do stuff like this:")
-
- // Generate BigLetters
- s, _ := pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString("PTerm")).Srender()
- pterm.DefaultCenter.Println(s) // Print BigLetters with the default CenterPrinter
+ // Print 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.DefaultCenter.WithCenterEachLineSeparately().Println("This text is centered!\nBut each line is\ncentered\nseparately")
+ // Print strings with set color.
+ 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.Println() // Print one line space.
+ 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")
}
```
-### demo
+### coloring/disable-color
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/demo/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-color/animation.svg)
@@ -524,6 +3109,7 @@ var pseudoProgramList = strings.Split("pseudo-excel pseudo-photoshop pseudo-chro
"pseudo-dops pseudo-git pseudo-vsc pseudo-intellij pseudo-minecraft pseudo-scoop pseudo-chocolatey", " ")
func main() {
+ pterm.DisableColor()
introScreen()
clear()
pseudoApplicationHeader()
@@ -622,14 +3208,13 @@ func pseudoApplicationHeader() *pterm.TextPrinter {
}
func introScreen() {
- ptermLogo, _ := pterm.DefaultBigText.WithLetters(
+ pterm.DefaultBigText.WithLetters(
pterm.NewLettersFromStringWithStyle("P", pterm.NewStyle(pterm.FgLightCyan)),
pterm.NewLettersFromStringWithStyle("Term", pterm.NewStyle(pterm.FgLightMagenta))).
- Srender()
-
- pterm.DefaultCenter.Print(ptermLogo)
+ Render()
- pterm.DefaultCenter.Print(pterm.DefaultHeader.WithFullWidth().WithBackgroundStyle(pterm.NewStyle(pterm.BgLightBlue)).WithMargin(10).Sprint("PTDP - PTerm Demo Program"))
+ 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." +
@@ -639,7 +3224,7 @@ func introScreen() {
"\n" +
"\nThis demo was updated at: " + pterm.Green(time.Now().Format("02 Jan 2006 - 15:04:05 MST")))
pterm.Println()
- introSpinner, _ := pterm.DefaultSpinner.WithShowTimer(false).WithRemoveWhenDone(true).Start("Waiting for 15 seconds...")
+ introSpinner, _ := pterm.DefaultSpinner.WithRemoveWhenDone(true).Start("Waiting for 15 seconds...")
time.Sleep(second)
for i := 14; i > 0; i-- {
if i > 1 {
@@ -665,9 +3250,41 @@ func randomInt(min, max int) int {
-### disable-color
+### coloring/disable-output
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-output/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
+
+func main() {
+ for i := 0; i < 15; i++ {
+ switch i {
+ case 5:
+ pterm.Info.Println("Disabled Output!")
+ pterm.DisableOutput()
+ case 10:
+ pterm.EnableOutput()
+ pterm.Info.Println("Enabled Output!")
+ }
+
+ pterm.Printf("Printing something... [%d/%d]\n", i, 15)
+ }
+}
+
+```
+
+
+
+### coloring/disable-styling
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/disable-color/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/disable-styling/animation.svg)
@@ -693,7 +3310,7 @@ var pseudoProgramList = strings.Split("pseudo-excel pseudo-photoshop pseudo-chro
"pseudo-dops pseudo-git pseudo-vsc pseudo-intellij pseudo-minecraft pseudo-scoop pseudo-chocolatey", " ")
func main() {
- pterm.DisableColor()
+ pterm.DisableStyling()
introScreen()
clear()
pseudoApplicationHeader()
@@ -821,22 +3438,133 @@ func introScreen() {
introSpinner.Stop()
}
-func clear() {
- print("\033[H\033[2J")
-}
+func clear() {
+ print("\033[H\033[2J")
+}
+
+func randomInt(min, max int) int {
+ rand.Seed(time.Now().UnixNano())
+ return rand.Intn(max-min+1) + min
+}
+
+```
+
+
+
+### coloring/fade-colors
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-colors/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ // Print info.
+ pterm.Info.Println("RGB colors only work in Terminals which support TrueColor.")
+
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients end point.
+
+ // For loop over the range of the terminal height.
+ for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
+ // Print string which is colored with the faded RGB value.
+ from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to).Println("Hello, World!")
+ }
+}
+
+```
+
+
+
+### coloring/fade-multiple-colors
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-multiple-colors/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import (
+ "strings"
+
+ "github.com/pterm/pterm"
+)
+
+func main() {
+ from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
+ to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
+ to2 := pterm.NewRGB(255, 0, 0) // This RGB value is used as the gradients second point.
+ to3 := pterm.NewRGB(0, 255, 0) // This RGB value is used as the gradients third point.
+ to4 := pterm.NewRGB(255, 255, 255) // This RGB value is used as the gradients end point.
+
+ str := "RGB colors only work in Terminals which support TrueColor."
+ strs := strings.Split(str, "")
+ var fadeInfo string // String which will be used to print info.
+ // For loop over the range of the string length.
+ for i := 0; i < len(str); i++ {
+ // Append faded letter to info string.
+ fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
+ }
+
+ // Print info.
+ pterm.Info.Println(fadeInfo)
+
+ // For loop over the range of the terminal height.
+ for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
+ // Print string which is colored with the faded RGB value.
+ from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to, to2, to3, to4).Println("Hello, World!")
+ }
+}
+
+```
+
+
+
+### coloring/override-default-printers
+
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/override-default-printers/animation.svg)
+
+
+
+SHOW SOURCE
+
+```go
+package main
+
+import "github.com/pterm/pterm"
-func randomInt(min, max int) int {
- rand.Seed(time.Now().UnixNano())
- return rand.Intn(max-min+1) + min
+func main() {
+ // Print default error.
+ pterm.Error.Println("This is the default Error")
+
+ // Customize default error.
+ pterm.Error.Prefix = pterm.Prefix{
+ Text: "OVERRIDE",
+ Style: pterm.NewStyle(pterm.BgCyan, pterm.FgRed),
+ }
+
+ // Print new default error.
+ pterm.Error.Println("This is the default Error after the prefix was overridden")
}
```
-### disable-output
+### coloring/print-color-rgb
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/disable-output/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/print-color-rgb/animation.svg)
@@ -848,27 +3576,20 @@ package main
import "github.com/pterm/pterm"
func main() {
- for i := 0; i < 15; i++ {
- switch i {
- case 5:
- pterm.Info.Println("Disabled Output!")
- pterm.DisableOutput()
- case 10:
- pterm.EnableOutput()
- pterm.Info.Println("Enabled Output!")
- }
-
- pterm.Printf("Printing something... [%d/%d]\n", i, 15)
- }
+ // Print strings with a custom RGB color.
+ // NOTICE: This only works with terminals which support TrueColor.
+ 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!")
}
```
-### disable-styling
+### demo/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/disable-styling/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/demo/demo/animation.svg)
@@ -894,7 +3615,6 @@ var pseudoProgramList = strings.Split("pseudo-excel pseudo-photoshop pseudo-chro
"pseudo-dops pseudo-git pseudo-vsc pseudo-intellij pseudo-minecraft pseudo-scoop pseudo-chocolatey", " ")
func main() {
- pterm.DisableStyling()
introScreen()
clear()
pseudoApplicationHeader()
@@ -993,13 +3713,14 @@ func pseudoApplicationHeader() *pterm.TextPrinter {
}
func introScreen() {
- pterm.DefaultBigText.WithLetters(
+ ptermLogo, _ := pterm.DefaultBigText.WithLetters(
pterm.NewLettersFromStringWithStyle("P", pterm.NewStyle(pterm.FgLightCyan)),
pterm.NewLettersFromStringWithStyle("Term", pterm.NewStyle(pterm.FgLightMagenta))).
- Render()
+ Srender()
- pterm.DefaultHeader.WithBackgroundStyle(pterm.NewStyle(pterm.BgLightBlue)).WithMargin(10).Println(
- "PTDP - PTerm Demo Program")
+ pterm.DefaultCenter.Print(ptermLogo)
+
+ pterm.DefaultCenter.Print(pterm.DefaultHeader.WithFullWidth().WithBackgroundStyle(pterm.NewStyle(pterm.BgLightBlue)).WithMargin(10).Sprint("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." +
@@ -1009,7 +3730,7 @@ func introScreen() {
"\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...")
+ introSpinner, _ := pterm.DefaultSpinner.WithShowTimer(false).WithRemoveWhenDone(true).Start("Waiting for 15 seconds...")
time.Sleep(second)
for i := 14; i > 0; i-- {
if i > 1 {
@@ -1035,9 +3756,9 @@ func randomInt(min, max int) int {
-### header
+### header/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/header/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/header/demo/animation.svg)
@@ -1059,9 +3780,9 @@ func main() {
-### header-custom
+### header-custom/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/header-custom/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/header-custom/demo/animation.svg)
@@ -1099,40 +3820,9 @@ func main() {
-### override-default-printers
-
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/override-default-printers/animation.svg)
-
-
-
-SHOW SOURCE
-
-```go
-package main
-
-import "github.com/pterm/pterm"
-
-func main() {
- // Print default error.
- pterm.Error.Println("This is the default Error")
-
- // Customize default error.
- pterm.Error.Prefix = pterm.Prefix{
- Text: "OVERRIDE",
- Style: pterm.NewStyle(pterm.BgCyan, pterm.FgRed),
- }
-
- // Print new default error.
- pterm.Error.Println("This is the default Error after the prefix was overridden")
-}
-
-```
-
-
-
-### panel
+### panel/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/panel/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/panel/demo/animation.svg)
@@ -1158,9 +3848,9 @@ func main() {
-### paragraph
+### paragraph/customized
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/paragraph/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/paragraph/customized/animation.svg)
@@ -1172,15 +3862,15 @@ package main
import "github.com/pterm/pterm"
func main() {
- // Print long text with default paragraph printer.
- pterm.DefaultParagraph.Println("This is the default paragraph printer. As you can see, no words are separated, " +
+ // Print a paragraph with a custom maximal width.
+ 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")
// Print one line space.
pterm.Println()
- // Print long text without paragraph printer.
+ // Print text without a paragraph printer.
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")
}
@@ -1189,9 +3879,9 @@ func main() {
-### paragraph-custom
+### paragraph/customized
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/paragraph-custom/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/paragraph/customized/animation.svg)
@@ -1220,40 +3910,9 @@ func main() {
-### prefix
-
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/prefix/animation.svg)
-
-
-
-SHOW SOURCE
-
-```go
-package main
-
-import "github.com/pterm/pterm"
-
-func main() {
- // Enable debug messages.
- pterm.EnableDebugMessages()
-
- pterm.Debug.Println("Hello, World!") // Print Debug.
- pterm.Info.Println("Hello, World!") // Print Info.
- pterm.Success.Println("Hello, World!") // Print Success.
- pterm.Warning.Println("Hello, World!") // Print Warning.
- pterm.Error.Println("Errors show the filename and linenumber inside the terminal!") // Print Error.
- pterm.Info.WithShowLineNumber().Println("Other PrefixPrinters can do that too!") // Print Error.
- // Temporarily set Fatal to false, so that the CI won't crash.
- pterm.Fatal.WithFatal(false).Println("Hello, World!") // Print Fatal.
-}
-
-```
-
-
-
-### print-basic-text
+### paragraph/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/print-basic-text/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/paragraph/demo/animation.svg)
@@ -1265,127 +3924,26 @@ package main
import "github.com/pterm/pterm"
func main() {
- // A BasicText printer is used to print text, without special formatting.
- // As it implements the TextPrinter interface, you can use it in combination with other printers.
- 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.")
- // If you just want to print text, you should use this instead:
- // pterm.Println("Hello, World!")
-}
-
-```
-
-
-
-### print-color-fade
-
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/print-color-fade/animation.svg)
-
-
-
-SHOW SOURCE
-
-```go
-package main
-
-import (
- "github.com/pterm/pterm"
-)
-
-func main() {
- // Print info.
- pterm.Info.Println("RGB colors only work in Terminals which support TrueColor.")
-
- from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
- to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients end point.
-
- // For loop over the range of the terminal height.
- for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
- // Print string which is colored with the faded RGB value.
- from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to).Println("Hello, World!")
- }
-}
-
-```
-
-
-
-### print-color-fade-multiple
-
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/print-color-fade-multiple/animation.svg)
-
-
-
-SHOW SOURCE
-
-```go
-package main
-
-import (
- "strings"
-
- "github.com/pterm/pterm"
-)
-
-func main() {
- from := pterm.NewRGB(0, 255, 255) // This RGB value is used as the gradients start point.
- to := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients first point.
- to2 := pterm.NewRGB(255, 0, 0) // This RGB value is used as the gradients second point.
- to3 := pterm.NewRGB(0, 255, 0) // This RGB value is used as the gradients third point.
- to4 := pterm.NewRGB(255, 255, 255) // This RGB value is used as the gradients end point.
-
- str := "RGB colors only work in Terminals which support TrueColor."
- strs := strings.Split(str, "")
- var fadeInfo string // String which will be used to print info.
- // For loop over the range of the string length.
- for i := 0; i < len(str); i++ {
- // Append faded letter to info string.
- fadeInfo += from.Fade(0, float32(len(str)), float32(i), to).Sprint(strs[i])
- }
-
- // Print info.
- pterm.Info.Println(fadeInfo)
-
- // For loop over the range of the terminal height.
- for i := 0; i < pterm.GetTerminalHeight()-2; i++ {
- // Print string which is colored with the faded RGB value.
- from.Fade(0, float32(pterm.GetTerminalHeight()-2), float32(i), to, to2, to3, to4).Println("Hello, World!")
- }
-}
-
-```
-
-
-
-### print-color-rgb
-
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/print-color-rgb/animation.svg)
-
-
-
-SHOW SOURCE
-
-```go
-package main
+ // Print long text with default paragraph printer.
+ 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")
-import "github.com/pterm/pterm"
+ // Print one line space.
+ pterm.Println()
-func main() {
- // Print strings with a custom RGB color.
- // NOTICE: This only works with terminals which support TrueColor.
- 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 long text without paragraph printer.
+ 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-with-color
+### prefix/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/print-with-color/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/prefix/demo/animation.svg)
@@ -1397,36 +3955,26 @@ package main
import "github.com/pterm/pterm"
func main() {
- // Print 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!"))
+ // Enable debug messages.
+ pterm.EnableDebugMessages()
- // Print strings with set color.
- 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.Println() // Print one line space.
- 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")
+ pterm.Debug.Println("Hello, World!") // Print Debug.
+ pterm.Info.Println("Hello, World!") // Print Info.
+ pterm.Success.Println("Hello, World!") // Print Success.
+ pterm.Warning.Println("Hello, World!") // Print Warning.
+ pterm.Error.Println("Errors show the filename and linenumber inside the terminal!") // Print Error.
+ pterm.Info.WithShowLineNumber().Println("Other PrefixPrinters can do that too!") // Print Error.
+ // Temporarily set Fatal to false, so that the CI won't crash.
+ pterm.Fatal.WithFatal(false).Println("Hello, World!") // Print Fatal.
}
```
-### progressbar
+### progressbar/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/progressbar/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/progressbar/demo/animation.svg)
@@ -1462,9 +4010,9 @@ func main() {
-### section
+### section/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/section/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/section/demo/animation.svg)
@@ -1491,9 +4039,9 @@ func main() {
-### spinner
+### spinner/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/spinner/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/spinner/demo/animation.svg)
@@ -1538,9 +4086,9 @@ func main() {
-### style
+### style/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/style/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/style/demo/animation.svg)
@@ -1565,9 +4113,9 @@ func main() {
-### table
+### table/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/table/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/table/demo/animation.svg)
@@ -1589,7 +4137,7 @@ func main() {
}).Render()
pterm.Println() // Blank line
-
+
// Create a table with right alignment.
pterm.DefaultTable.WithHasHeader().WithData(pterm.TableData{
{"Firstname", "Lastname", "Email"},
@@ -1603,9 +4151,9 @@ func main() {
-### theme
+### theme/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/theme/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/theme/demo/animation.svg)
@@ -1647,9 +4195,9 @@ func main() {
-### tree
+### tree/demo
-![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/tree/animation.svg)
+![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/tree/demo/animation.svg)