From 1746577e598aab1e45140facf26ab65383e521ae Mon Sep 17 00:00:00 2001 From: MarvinJWendt Date: Thu, 21 Apr 2022 01:01:50 +0200 Subject: [PATCH 1/7] added new dir structure to examples --- _examples/area/README.md | 27 --- _examples/area/animation.svg | 10 -- _examples/area/main.go | 20 --- _examples/barchart-mixed-values/README.md | 41 ----- _examples/barchart-mixed-values/animation.svg | 10 -- _examples/barchart-mixed-values/main.go | 34 ---- _examples/barchart-negative-values/README.md | 33 ---- .../barchart-negative-values/animation.svg | 10 -- _examples/barchart-negative-values/main.go | 26 --- _examples/barchart/README.md | 33 ---- _examples/barchart/animation.svg | 10 -- _examples/barchart/main.go | 26 --- _examples/bigtext/README.md | 27 --- _examples/bigtext/animation.svg | 10 -- _examples/bigtext/main.go | 20 --- _examples/box/README.md | 25 --- _examples/box/animation.svg | 10 -- _examples/box/main.go | 18 -- _examples/bulletlist-custom/README.md | 21 --- _examples/bulletlist-custom/animation.svg | 10 -- _examples/bulletlist-custom/main.go | 14 -- _examples/bulletlist/README.md | 26 --- _examples/bulletlist/animation.svg | 10 -- _examples/bulletlist/main.go | 19 -- _examples/center/README.md | 20 --- _examples/center/animation.svg | 10 -- _examples/center/main.go | 13 -- _examples/demo/README.md | 162 ------------------ _examples/demo/animation.svg | 10 -- _examples/demo/main.go | 155 ----------------- _examples/disable-color/README.md | 162 ------------------ _examples/disable-color/animation.svg | 10 -- _examples/disable-color/main.go | 155 ----------------- _examples/disable-output/README.md | 25 --- _examples/disable-output/animation.svg | 10 -- _examples/disable-output/main.go | 18 -- _examples/disable-styling/README.md | 162 ------------------ _examples/disable-styling/animation.svg | 10 -- _examples/disable-styling/main.go | 155 ----------------- _examples/header-custom/README.md | 33 ---- _examples/header-custom/animation.svg | 10 -- _examples/header-custom/main.go | 26 --- _examples/header/README.md | 17 -- _examples/header/animation.svg | 10 -- _examples/header/main.go | 10 -- _examples/override-default-printers/README.md | 24 --- .../override-default-printers/animation.svg | 10 -- _examples/override-default-printers/main.go | 17 -- _examples/panel/README.md | 21 --- _examples/panel/animation.svg | 10 -- _examples/panel/main.go | 14 -- _examples/paragraph-custom/README.md | 24 --- _examples/paragraph-custom/animation.svg | 10 -- _examples/paragraph-custom/main.go | 17 -- _examples/paragraph/README.md | 24 --- _examples/paragraph/animation.svg | 10 -- _examples/paragraph/main.go | 17 -- _examples/prefix/README.md | 24 --- _examples/prefix/animation.svg | 10 -- _examples/prefix/main.go | 17 -- _examples/print-basic-text/README.md | 20 --- _examples/print-basic-text/animation.svg | 10 -- _examples/print-basic-text/main.go | 13 -- _examples/print-color-fade-multiple/README.md | 40 ----- .../print-color-fade-multiple/animation.svg | 10 -- _examples/print-color-fade-multiple/main.go | 33 ---- _examples/print-color-fade/README.md | 26 --- _examples/print-color-fade/animation.svg | 10 -- _examples/print-color-fade/main.go | 19 -- _examples/print-color-rgb/README.md | 18 -- _examples/print-color-rgb/animation.svg | 10 -- _examples/print-color-rgb/main.go | 11 -- _examples/print-with-color/README.md | 34 ---- _examples/print-with-color/animation.svg | 10 -- _examples/print-with-color/main.go | 27 --- _examples/progressbar/README.md | 31 ---- _examples/progressbar/animation.svg | 10 -- _examples/progressbar/main.go | 24 --- _examples/section/README.md | 22 --- _examples/section/animation.svg | 10 -- _examples/section/main.go | 15 -- _examples/spinner/README.md | 40 ----- _examples/spinner/animation.svg | 10 -- _examples/spinner/main.go | 33 ---- _examples/style/README.md | 20 --- _examples/style/animation.svg | 10 -- _examples/style/main.go | 13 -- _examples/table/README.md | 31 ---- _examples/table/animation.svg | 10 -- _examples/table/main.go | 24 --- _examples/theme/README.md | 37 ---- _examples/theme/animation.svg | 10 -- _examples/theme/main.go | 30 ---- _examples/tree/README.md | 46 ----- _examples/tree/animation.svg | 10 -- _examples/tree/main.go | 39 ----- 96 files changed, 2688 deletions(-) delete mode 100644 _examples/area/README.md delete mode 100644 _examples/area/animation.svg delete mode 100644 _examples/area/main.go delete mode 100644 _examples/barchart-mixed-values/README.md delete mode 100644 _examples/barchart-mixed-values/animation.svg delete mode 100644 _examples/barchart-mixed-values/main.go delete mode 100644 _examples/barchart-negative-values/README.md delete mode 100644 _examples/barchart-negative-values/animation.svg delete mode 100644 _examples/barchart-negative-values/main.go delete mode 100644 _examples/barchart/README.md delete mode 100644 _examples/barchart/animation.svg delete mode 100644 _examples/barchart/main.go delete mode 100644 _examples/bigtext/README.md delete mode 100644 _examples/bigtext/animation.svg delete mode 100644 _examples/bigtext/main.go delete mode 100644 _examples/box/README.md delete mode 100644 _examples/box/animation.svg delete mode 100644 _examples/box/main.go delete mode 100644 _examples/bulletlist-custom/README.md delete mode 100644 _examples/bulletlist-custom/animation.svg delete mode 100644 _examples/bulletlist-custom/main.go delete mode 100644 _examples/bulletlist/README.md delete mode 100644 _examples/bulletlist/animation.svg delete mode 100644 _examples/bulletlist/main.go delete mode 100644 _examples/center/README.md delete mode 100644 _examples/center/animation.svg delete mode 100644 _examples/center/main.go delete mode 100644 _examples/demo/README.md delete mode 100644 _examples/demo/animation.svg delete mode 100644 _examples/demo/main.go delete mode 100644 _examples/disable-color/README.md delete mode 100644 _examples/disable-color/animation.svg delete mode 100644 _examples/disable-color/main.go delete mode 100644 _examples/disable-output/README.md delete mode 100644 _examples/disable-output/animation.svg delete mode 100644 _examples/disable-output/main.go delete mode 100644 _examples/disable-styling/README.md delete mode 100644 _examples/disable-styling/animation.svg delete mode 100644 _examples/disable-styling/main.go delete mode 100644 _examples/header-custom/README.md delete mode 100644 _examples/header-custom/animation.svg delete mode 100644 _examples/header-custom/main.go delete mode 100644 _examples/header/README.md delete mode 100644 _examples/header/animation.svg delete mode 100644 _examples/header/main.go delete mode 100644 _examples/override-default-printers/README.md delete mode 100644 _examples/override-default-printers/animation.svg delete mode 100644 _examples/override-default-printers/main.go delete mode 100644 _examples/panel/README.md delete mode 100644 _examples/panel/animation.svg delete mode 100644 _examples/panel/main.go delete mode 100644 _examples/paragraph-custom/README.md delete mode 100644 _examples/paragraph-custom/animation.svg delete mode 100644 _examples/paragraph-custom/main.go delete mode 100644 _examples/paragraph/README.md delete mode 100644 _examples/paragraph/animation.svg delete mode 100644 _examples/paragraph/main.go delete mode 100644 _examples/prefix/README.md delete mode 100644 _examples/prefix/animation.svg delete mode 100644 _examples/prefix/main.go delete mode 100644 _examples/print-basic-text/README.md delete mode 100644 _examples/print-basic-text/animation.svg delete mode 100644 _examples/print-basic-text/main.go delete mode 100644 _examples/print-color-fade-multiple/README.md delete mode 100644 _examples/print-color-fade-multiple/animation.svg delete mode 100644 _examples/print-color-fade-multiple/main.go delete mode 100644 _examples/print-color-fade/README.md delete mode 100644 _examples/print-color-fade/animation.svg delete mode 100644 _examples/print-color-fade/main.go delete mode 100644 _examples/print-color-rgb/README.md delete mode 100644 _examples/print-color-rgb/animation.svg delete mode 100644 _examples/print-color-rgb/main.go delete mode 100644 _examples/print-with-color/README.md delete mode 100644 _examples/print-with-color/animation.svg delete mode 100644 _examples/print-with-color/main.go delete mode 100644 _examples/progressbar/README.md delete mode 100644 _examples/progressbar/animation.svg delete mode 100644 _examples/progressbar/main.go delete mode 100644 _examples/section/README.md delete mode 100644 _examples/section/animation.svg delete mode 100644 _examples/section/main.go delete mode 100644 _examples/spinner/README.md delete mode 100644 _examples/spinner/animation.svg delete mode 100644 _examples/spinner/main.go delete mode 100644 _examples/style/README.md delete mode 100644 _examples/style/animation.svg delete mode 100644 _examples/style/main.go delete mode 100644 _examples/table/README.md delete mode 100644 _examples/table/animation.svg delete mode 100644 _examples/table/main.go delete mode 100644 _examples/theme/README.md delete mode 100644 _examples/theme/animation.svg delete mode 100644 _examples/theme/main.go delete mode 100644 _examples/tree/README.md delete mode 100644 _examples/tree/animation.svg delete mode 100644 _examples/tree/main.go diff --git a/_examples/area/README.md b/_examples/area/README.md deleted file mode 100644 index 206827c31..000000000 --- a/_examples/area/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# area - -![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/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 @@ - INFO Theprevioustextwillstayinplace,whiletheareaupdates.████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████Restartinganimation... \ No newline at end of file diff --git a/_examples/area/main.go b/_examples/area/main.go deleted file mode 100644 index 44ffb88df..000000000 --- a/_examples/area/main.go +++ /dev/null @@ -1,20 +0,0 @@ -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/barchart-mixed-values/README.md b/_examples/barchart-mixed-values/README.md deleted file mode 100644 index 4f015a834..000000000 --- a/_examples/barchart-mixed-values/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# barchart-mixed-values - -![Animation](animation.svg) - -```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() -} - -``` 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██████████████████████████7Bar4Restartinganimation... \ No newline at end of file diff --git a/_examples/barchart-mixed-values/main.go b/_examples/barchart-mixed-values/main.go deleted file mode 100644 index 10c10f91e..000000000 --- a/_examples/barchart-mixed-values/main.go +++ /dev/null @@ -1,34 +0,0 @@ -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() -} diff --git a/_examples/barchart-negative-values/README.md b/_examples/barchart-negative-values/README.md deleted file mode 100644 index d790face6..000000000 --- a/_examples/barchart-negative-values/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# barchart-negative-values - -![Animation](animation.svg) - -```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-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-negative-values/main.go b/_examples/barchart-negative-values/main.go deleted file mode 100644 index 94a117cdf..000000000 --- a/_examples/barchart-negative-values/main.go +++ /dev/null @@ -1,26 +0,0 @@ -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/README.md b/_examples/barchart/README.md deleted file mode 100644 index bbaf9280e..000000000 --- a/_examples/barchart/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# barchart - -![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/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/main.go b/_examples/barchart/main.go deleted file mode 100644 index 16aefe1e8..000000000 --- a/_examples/barchart/main.go +++ /dev/null @@ -1,26 +0,0 @@ -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/bigtext/README.md b/_examples/bigtext/README.md deleted file mode 100644 index 22615dc6d..000000000 --- a/_examples/bigtext/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# bigtext - -![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/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/main.go b/_examples/bigtext/main.go deleted file mode 100644 index eff801c1d..000000000 --- a/_examples/bigtext/main.go +++ /dev/null @@ -1,20 +0,0 @@ -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/box/README.md b/_examples/box/README.md deleted file mode 100644 index 30a758090..000000000 --- a/_examples/box/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# box - -![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/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/main.go b/_examples/box/main.go deleted file mode 100644 index f25a80e3a..000000000 --- a/_examples/box/main.go +++ /dev/null @@ -1,18 +0,0 @@ -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/bulletlist-custom/README.md b/_examples/bulletlist-custom/README.md deleted file mode 100644 index 9b9b6c5c4..000000000 --- a/_examples/bulletlist-custom/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# bulletlist-custom - -![Animation](animation.svg) - -```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() -} - -``` 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-custom/main.go b/_examples/bulletlist-custom/main.go deleted file mode 100644 index 75c90a311..000000000 --- a/_examples/bulletlist-custom/main.go +++ /dev/null @@ -1,14 +0,0 @@ -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() -} diff --git a/_examples/bulletlist/README.md b/_examples/bulletlist/README.md deleted file mode 100644 index ea6634eaa..000000000 --- a/_examples/bulletlist/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# bulletlist - -![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/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 @@ -Level0Level1Level20123Restartinganimation... \ No newline at end of file diff --git a/_examples/bulletlist/main.go b/_examples/bulletlist/main.go deleted file mode 100644 index ef3b781c4..000000000 --- a/_examples/bulletlist/main.go +++ /dev/null @@ -1,19 +0,0 @@ -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/center/README.md b/_examples/center/README.md deleted file mode 100644 index 0d2ad2403..000000000 --- a/_examples/center/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# center - -![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/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/main.go b/_examples/center/main.go deleted file mode 100644 index 9c879169c..000000000 --- a/_examples/center/main.go +++ /dev/null @@ -1,13 +0,0 @@ -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/demo/README.md b/_examples/demo/README.md deleted file mode 100644 index 4738b2e1f..000000000 --- a/_examples/demo/README.md +++ /dev/null @@ -1,162 +0,0 @@ -# demo - -![Animation](animation.svg) - -```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 -} - -``` 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:04UTCWaitingfor15seconds...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:)#BulletListPrinterGoodbyeHaveaniceday!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/main.go b/_examples/demo/main.go deleted file mode 100644 index 6017a5587..000000000 --- a/_examples/demo/main.go +++ /dev/null @@ -1,155 +0,0 @@ -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 -} diff --git a/_examples/disable-color/README.md b/_examples/disable-color/README.md deleted file mode 100644 index 39561cc55..000000000 --- a/_examples/disable-color/README.md +++ /dev/null @@ -1,162 +0,0 @@ -# disable-color - -![Animation](animation.svg) - -```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 -} - -``` 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:)#BulletListPrinterGoodbyeHaveaniceday!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-color/main.go b/_examples/disable-color/main.go deleted file mode 100644 index 02f24ad53..000000000 --- a/_examples/disable-color/main.go +++ /dev/null @@ -1,155 +0,0 @@ -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 -} diff --git a/_examples/disable-output/README.md b/_examples/disable-output/README.md deleted file mode 100644 index 5adec41d5..000000000 --- a/_examples/disable-output/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# disable-output - -![Animation](animation.svg) - -```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) - } -} - -``` 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-output/main.go b/_examples/disable-output/main.go deleted file mode 100644 index e604abb11..000000000 --- a/_examples/disable-output/main.go +++ /dev/null @@ -1,18 +0,0 @@ -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) - } -} diff --git a/_examples/disable-styling/README.md b/_examples/disable-styling/README.md deleted file mode 100644 index ae4555074..000000000 --- a/_examples/disable-styling/README.md +++ /dev/null @@ -1,162 +0,0 @@ -# disable-styling - -![Animation](animation.svg) - -```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 -} - -``` 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:)#BulletListPrinterGoodbyeHaveaniceday!#TreePrinter└─┬C:├──GoRestartinganimation... \ No newline at end of file diff --git a/_examples/disable-styling/main.go b/_examples/disable-styling/main.go deleted file mode 100644 index ac30ac5b1..000000000 --- a/_examples/disable-styling/main.go +++ /dev/null @@ -1,155 +0,0 @@ -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 -} diff --git a/_examples/header-custom/README.md b/_examples/header-custom/README.md deleted file mode 100644 index c8d2ec956..000000000 --- a/_examples/header-custom/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# header-custom - -![Animation](animation.svg) - -```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!") -} - -``` 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/main.go b/_examples/header-custom/main.go deleted file mode 100644 index 3ca553b4b..000000000 --- a/_examples/header-custom/main.go +++ /dev/null @@ -1,26 +0,0 @@ -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!") -} diff --git a/_examples/header/README.md b/_examples/header/README.md deleted file mode 100644 index 9ad70d682..000000000 --- a/_examples/header/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# header - -![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/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/main.go b/_examples/header/main.go deleted file mode 100644 index a654d4d0d..000000000 --- a/_examples/header/main.go +++ /dev/null @@ -1,10 +0,0 @@ -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/override-default-printers/README.md b/_examples/override-default-printers/README.md deleted file mode 100644 index 567c7161f..000000000 --- a/_examples/override-default-printers/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# override-default-printers - -![Animation](animation.svg) - -```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") -} - -``` diff --git a/_examples/override-default-printers/animation.svg b/_examples/override-default-printers/animation.svg deleted file mode 100644 index 07ba754bf..000000000 --- a/_examples/override-default-printers/animation.svg +++ /dev/null @@ -1,10 +0,0 @@ - ERROR ThisisthedefaultError OVERRIDE ThisisthedefaultErroraftertheprefixwasoverriddenRestartinganimation... \ No newline at end of file diff --git a/_examples/override-default-printers/main.go b/_examples/override-default-printers/main.go deleted file mode 100644 index 52eb93008..000000000 --- a/_examples/override-default-printers/main.go +++ /dev/null @@ -1,17 +0,0 @@ -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") -} diff --git a/_examples/panel/README.md b/_examples/panel/README.md deleted file mode 100644 index 220be07bc..000000000 --- a/_examples/panel/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# panel - -![Animation](animation.svg) - -```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() -} - -``` 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/main.go b/_examples/panel/main.go deleted file mode 100644 index 8726df44a..000000000 --- a/_examples/panel/main.go +++ /dev/null @@ -1,14 +0,0 @@ -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() -} diff --git a/_examples/paragraph-custom/README.md b/_examples/paragraph-custom/README.md deleted file mode 100644 index 3d15cd0a4..000000000 --- a/_examples/paragraph-custom/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# paragraph-custom - -![Animation](animation.svg) - -```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") -} - -``` 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-custom/main.go b/_examples/paragraph-custom/main.go deleted file mode 100644 index 39cdf8643..000000000 --- a/_examples/paragraph-custom/main.go +++ /dev/null @@ -1,17 +0,0 @@ -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") -} diff --git a/_examples/paragraph/README.md b/_examples/paragraph/README.md deleted file mode 100644 index 07ad0d57c..000000000 --- a/_examples/paragraph/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# paragraph - -![Animation](animation.svg) - -```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") -} - -``` 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/main.go b/_examples/paragraph/main.go deleted file mode 100644 index 4558ea73c..000000000 --- a/_examples/paragraph/main.go +++ /dev/null @@ -1,17 +0,0 @@ -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") -} diff --git a/_examples/prefix/README.md b/_examples/prefix/README.md deleted file mode 100644 index 3d23fe3ec..000000000 --- a/_examples/prefix/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# prefix - -![Animation](animation.svg) - -```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. -} - -``` 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/main.go b/_examples/prefix/main.go deleted file mode 100644 index b032b4503..000000000 --- a/_examples/prefix/main.go +++ /dev/null @@ -1,17 +0,0 @@ -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. -} diff --git a/_examples/print-basic-text/README.md b/_examples/print-basic-text/README.md deleted file mode 100644 index ce498440a..000000000 --- a/_examples/print-basic-text/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# print-basic-text - -![Animation](animation.svg) - -```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/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-basic-text/main.go b/_examples/print-basic-text/main.go deleted file mode 100644 index 249e53e04..000000000 --- a/_examples/print-basic-text/main.go +++ /dev/null @@ -1,13 +0,0 @@ -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-color-fade-multiple/README.md b/_examples/print-color-fade-multiple/README.md deleted file mode 100644 index 85b091cee..000000000 --- a/_examples/print-color-fade-multiple/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# print-color-fade-multiple - -![Animation](animation.svg) - -```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!") - } -} - -``` 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-multiple/main.go b/_examples/print-color-fade-multiple/main.go deleted file mode 100644 index c81700f0e..000000000 --- a/_examples/print-color-fade-multiple/main.go +++ /dev/null @@ -1,33 +0,0 @@ -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!") - } -} diff --git a/_examples/print-color-fade/README.md b/_examples/print-color-fade/README.md deleted file mode 100644 index 35c1dbd01..000000000 --- a/_examples/print-color-fade/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# print-color-fade - -![Animation](animation.svg) - -```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!") - } -} - -``` 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-color-fade/main.go b/_examples/print-color-fade/main.go deleted file mode 100644 index 23473fcc6..000000000 --- a/_examples/print-color-fade/main.go +++ /dev/null @@ -1,19 +0,0 @@ -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!") - } -} diff --git a/_examples/print-color-rgb/README.md b/_examples/print-color-rgb/README.md deleted file mode 100644 index e96e5084b..000000000 --- a/_examples/print-color-rgb/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# print-color-rgb - -![Animation](animation.svg) - -```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!") -} - -``` diff --git a/_examples/print-color-rgb/animation.svg b/_examples/print-color-rgb/animation.svg deleted file mode 100644 index f7ff6765e..000000000 --- a/_examples/print-color-rgb/animation.svg +++ /dev/null @@ -1,10 +0,0 @@ -ThistextisprintedwithacustomRGB!ThistextisprintedwithacustomRGB!ThistextisprintedwithacustomRGB!Restartinganimation... \ No newline at end of file diff --git a/_examples/print-color-rgb/main.go b/_examples/print-color-rgb/main.go deleted file mode 100644 index c849785d1..000000000 --- a/_examples/print-color-rgb/main.go +++ /dev/null @@ -1,11 +0,0 @@ -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!") -} diff --git a/_examples/print-with-color/README.md b/_examples/print-with-color/README.md deleted file mode 100644 index fb5e134e8..000000000 --- a/_examples/print-with-color/README.md +++ /dev/null @@ -1,34 +0,0 @@ -# print-with-color - -![Animation](animation.svg) - -```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") -} - -``` 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/print-with-color/main.go b/_examples/print-with-color/main.go deleted file mode 100644 index bc2123645..000000000 --- a/_examples/print-with-color/main.go +++ /dev/null @@ -1,27 +0,0 @@ -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") -} diff --git a/_examples/progressbar/README.md b/_examples/progressbar/README.md deleted file mode 100644 index 250d14098..000000000 --- a/_examples/progressbar/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# progressbar - -![Animation](animation.svg) - -```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. - } -} - -``` 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/main.go b/_examples/progressbar/main.go deleted file mode 100644 index 68819b458..000000000 --- a/_examples/progressbar/main.go +++ /dev/null @@ -1,24 +0,0 @@ -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. - } -} diff --git a/_examples/section/README.md b/_examples/section/README.md deleted file mode 100644 index dd04dbf02..000000000 --- a/_examples/section/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# section - -![Animation](animation.svg) - -```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") -} - -``` diff --git a/_examples/section/animation.svg b/_examples/section/animation.svg deleted file mode 100644 index cbc9e3a7f..000000000 --- a/_examples/section/animation.svg +++ /dev/null @@ -1,10 +0,0 @@ -#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/main.go deleted file mode 100644 index 80933f69d..000000000 --- a/_examples/section/main.go +++ /dev/null @@ -1,15 +0,0 @@ -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") -} diff --git a/_examples/spinner/README.md b/_examples/spinner/README.md deleted file mode 100644 index 95583c282..000000000 --- a/_examples/spinner/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# spinner - -![Animation](animation.svg) - -```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. -} - -``` 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'sreallymuchIt'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/main.go deleted file mode 100644 index cacd45f56..000000000 --- a/_examples/spinner/main.go +++ /dev/null @@ -1,33 +0,0 @@ -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. -} diff --git a/_examples/style/README.md b/_examples/style/README.md deleted file mode 100644 index 1b11de92e..000000000 --- a/_examples/style/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# style - -![Animation](animation.svg) - -```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!") -} - -``` 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/main.go b/_examples/style/main.go deleted file mode 100644 index 74ff150dc..000000000 --- a/_examples/style/main.go +++ /dev/null @@ -1,13 +0,0 @@ -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!") -} diff --git a/_examples/table/README.md b/_examples/table/README.md deleted file mode 100644 index 23ed3fba8..000000000 --- a/_examples/table/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# table - -![Animation](animation.svg) - -```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() -} - -``` 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/main.go b/_examples/table/main.go deleted file mode 100644 index 94f41c624..000000000 --- a/_examples/table/main.go +++ /dev/null @@ -1,24 +0,0 @@ -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() -} diff --git a/_examples/theme/README.md b/_examples/theme/README.md deleted file mode 100644 index 2d4de7678..000000000 --- a/_examples/theme/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# theme - -![Animation](animation.svg) - -```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) - } - } -} - -``` 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/main.go b/_examples/theme/main.go deleted file mode 100644 index 6813d3f41..000000000 --- a/_examples/theme/main.go +++ /dev/null @@ -1,30 +0,0 @@ -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) - } - } -} diff --git a/_examples/tree/README.md b/_examples/tree/README.md deleted file mode 100644 index 7a9eab639..000000000 --- a/_examples/tree/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# tree - -![Animation](animation.svg) - -```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/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/main.go b/_examples/tree/main.go deleted file mode 100644 index b6dbf894c..000000000 --- a/_examples/tree/main.go +++ /dev/null @@ -1,39 +0,0 @@ -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() -} From c3d768eca72ccc118d7ba836515ac09e4d5a0f33 Mon Sep 17 00:00:00 2001 From: MarvinJWendt Date: Thu, 21 Apr 2022 01:04:21 +0200 Subject: [PATCH 2/7] added new dir structure to examples --- _examples/README.md | 4 + _examples/area/demo/README.md | 27 +++ _examples/area/demo/animation.svg | 10 ++ _examples/area/demo/main.go | 20 +++ _examples/barchart/demo/README.md | 33 ++++ _examples/barchart/demo/animation.svg | 10 ++ _examples/barchart/demo/main.go | 26 +++ _examples/barchart/mixed-values/README.md | 41 +++++ _examples/barchart/mixed-values/animation.svg | 10 ++ _examples/barchart/mixed-values/main.go | 34 ++++ _examples/barchart/negative-values/README.md | 33 ++++ .../barchart/negative-values/animation.svg | 10 ++ _examples/barchart/negative-values/main.go | 26 +++ _examples/basictext/demo/README.md | 20 +++ _examples/basictext/demo/animation.svg | 10 ++ _examples/basictext/demo/main.go | 13 ++ _examples/bigtext/demo/README.md | 27 +++ _examples/bigtext/demo/animation.svg | 10 ++ _examples/bigtext/demo/main.go | 20 +++ _examples/box/demo/README.md | 25 +++ _examples/box/demo/animation.svg | 10 ++ _examples/box/demo/main.go | 18 ++ _examples/bulletlist/customized/README.md | 21 +++ _examples/bulletlist/customized/animation.svg | 10 ++ _examples/bulletlist/customized/main.go | 14 ++ _examples/bulletlist/demo/README.md | 26 +++ _examples/bulletlist/demo/animation.svg | 10 ++ _examples/bulletlist/demo/main.go | 19 ++ _examples/center/demo/README.md | 20 +++ _examples/center/demo/animation.svg | 10 ++ _examples/center/demo/main.go | 13 ++ _examples/coloring/demo/README.md | 34 ++++ _examples/coloring/demo/animation.svg | 10 ++ _examples/coloring/demo/main.go | 27 +++ _examples/coloring/disable-color/README.md | 162 ++++++++++++++++++ .../coloring/disable-color/animation.svg | 10 ++ _examples/coloring/disable-color/main.go | 155 +++++++++++++++++ _examples/coloring/disable-output/README.md | 25 +++ .../coloring/disable-output/animation.svg | 10 ++ _examples/coloring/disable-output/main.go | 18 ++ _examples/coloring/disable-styling/README.md | 162 ++++++++++++++++++ .../coloring/disable-styling/animation.svg | 10 ++ _examples/coloring/disable-styling/main.go | 155 +++++++++++++++++ _examples/coloring/fade-colors/README.md | 26 +++ _examples/coloring/fade-colors/animation.svg | 10 ++ _examples/coloring/fade-colors/main.go | 19 ++ .../coloring/fade-multiple-colors/README.md | 40 +++++ .../fade-multiple-colors/animation.svg | 10 ++ .../coloring/fade-multiple-colors/main.go | 33 ++++ .../override-default-printers/README.md | 24 +++ .../override-default-printers/animation.svg | 10 ++ .../override-default-printers/main.go | 17 ++ _examples/coloring/print-color-rgb/README.md | 18 ++ .../coloring/print-color-rgb/animation.svg | 10 ++ _examples/coloring/print-color-rgb/main.go | 11 ++ _examples/demo/demo/README.md | 162 ++++++++++++++++++ _examples/demo/demo/animation.svg | 10 ++ _examples/demo/demo/main.go | 155 +++++++++++++++++ _examples/header-custom/demo/README.md | 33 ++++ _examples/header-custom/demo/animation.svg | 10 ++ _examples/header-custom/demo/main.go | 26 +++ _examples/header/demo/README.md | 17 ++ _examples/header/demo/animation.svg | 10 ++ _examples/header/demo/main.go | 10 ++ _examples/panel/demo/README.md | 21 +++ _examples/panel/demo/animation.svg | 10 ++ _examples/panel/demo/main.go | 14 ++ _examples/paragraph/customized/README.md | 24 +++ _examples/paragraph/customized/animation.svg | 10 ++ _examples/paragraph/customized/main.go | 17 ++ _examples/paragraph/demo/README.md | 24 +++ _examples/paragraph/demo/animation.svg | 10 ++ _examples/paragraph/demo/main.go | 17 ++ _examples/prefix/demo/README.md | 24 +++ _examples/prefix/demo/animation.svg | 10 ++ _examples/prefix/demo/main.go | 17 ++ _examples/progressbar/demo/README.md | 31 ++++ _examples/progressbar/demo/animation.svg | 10 ++ _examples/progressbar/demo/main.go | 24 +++ _examples/section/demo/README.md | 22 +++ _examples/section/demo/animation.svg | 10 ++ _examples/section/demo/main.go | 15 ++ _examples/spinner/demo/README.md | 40 +++++ _examples/spinner/demo/animation.svg | 10 ++ _examples/spinner/demo/main.go | 33 ++++ _examples/style/demo/README.md | 20 +++ _examples/style/demo/animation.svg | 10 ++ _examples/style/demo/main.go | 13 ++ _examples/table/demo/README.md | 31 ++++ _examples/table/demo/animation.svg | 10 ++ _examples/table/demo/main.go | 24 +++ _examples/theme/demo/README.md | 37 ++++ _examples/theme/demo/animation.svg | 10 ++ _examples/theme/demo/main.go | 30 ++++ _examples/tree/demo/README.md | 46 +++++ _examples/tree/demo/animation.svg | 10 ++ _examples/tree/demo/main.go | 39 +++++ 97 files changed, 2692 insertions(+) create mode 100644 _examples/README.md create mode 100644 _examples/area/demo/README.md create mode 100644 _examples/area/demo/animation.svg create mode 100644 _examples/area/demo/main.go create mode 100644 _examples/barchart/demo/README.md create mode 100644 _examples/barchart/demo/animation.svg create mode 100644 _examples/barchart/demo/main.go create mode 100644 _examples/barchart/mixed-values/README.md create mode 100644 _examples/barchart/mixed-values/animation.svg create mode 100644 _examples/barchart/mixed-values/main.go create mode 100644 _examples/barchart/negative-values/README.md create mode 100644 _examples/barchart/negative-values/animation.svg create mode 100644 _examples/barchart/negative-values/main.go create mode 100644 _examples/basictext/demo/README.md create mode 100644 _examples/basictext/demo/animation.svg create mode 100644 _examples/basictext/demo/main.go create mode 100644 _examples/bigtext/demo/README.md create mode 100644 _examples/bigtext/demo/animation.svg create mode 100644 _examples/bigtext/demo/main.go create mode 100644 _examples/box/demo/README.md create mode 100644 _examples/box/demo/animation.svg create mode 100644 _examples/box/demo/main.go create mode 100644 _examples/bulletlist/customized/README.md create mode 100644 _examples/bulletlist/customized/animation.svg create mode 100644 _examples/bulletlist/customized/main.go create mode 100644 _examples/bulletlist/demo/README.md create mode 100644 _examples/bulletlist/demo/animation.svg create mode 100644 _examples/bulletlist/demo/main.go create mode 100644 _examples/center/demo/README.md create mode 100644 _examples/center/demo/animation.svg create mode 100644 _examples/center/demo/main.go create mode 100644 _examples/coloring/demo/README.md create mode 100644 _examples/coloring/demo/animation.svg create mode 100644 _examples/coloring/demo/main.go create mode 100644 _examples/coloring/disable-color/README.md create mode 100644 _examples/coloring/disable-color/animation.svg create mode 100644 _examples/coloring/disable-color/main.go create mode 100644 _examples/coloring/disable-output/README.md create mode 100644 _examples/coloring/disable-output/animation.svg create mode 100644 _examples/coloring/disable-output/main.go create mode 100644 _examples/coloring/disable-styling/README.md create mode 100644 _examples/coloring/disable-styling/animation.svg create mode 100644 _examples/coloring/disable-styling/main.go create mode 100644 _examples/coloring/fade-colors/README.md create mode 100644 _examples/coloring/fade-colors/animation.svg create mode 100644 _examples/coloring/fade-colors/main.go create mode 100644 _examples/coloring/fade-multiple-colors/README.md create mode 100644 _examples/coloring/fade-multiple-colors/animation.svg create mode 100644 _examples/coloring/fade-multiple-colors/main.go create mode 100644 _examples/coloring/override-default-printers/README.md create mode 100644 _examples/coloring/override-default-printers/animation.svg create mode 100644 _examples/coloring/override-default-printers/main.go create mode 100644 _examples/coloring/print-color-rgb/README.md create mode 100644 _examples/coloring/print-color-rgb/animation.svg create mode 100644 _examples/coloring/print-color-rgb/main.go create mode 100644 _examples/demo/demo/README.md create mode 100644 _examples/demo/demo/animation.svg create mode 100644 _examples/demo/demo/main.go create mode 100644 _examples/header-custom/demo/README.md create mode 100644 _examples/header-custom/demo/animation.svg create mode 100644 _examples/header-custom/demo/main.go create mode 100644 _examples/header/demo/README.md create mode 100644 _examples/header/demo/animation.svg create mode 100644 _examples/header/demo/main.go create mode 100644 _examples/panel/demo/README.md create mode 100644 _examples/panel/demo/animation.svg create mode 100644 _examples/panel/demo/main.go create mode 100644 _examples/paragraph/customized/README.md create mode 100644 _examples/paragraph/customized/animation.svg create mode 100644 _examples/paragraph/customized/main.go create mode 100644 _examples/paragraph/demo/README.md create mode 100644 _examples/paragraph/demo/animation.svg create mode 100644 _examples/paragraph/demo/main.go create mode 100644 _examples/prefix/demo/README.md create mode 100644 _examples/prefix/demo/animation.svg create mode 100644 _examples/prefix/demo/main.go create mode 100644 _examples/progressbar/demo/README.md create mode 100644 _examples/progressbar/demo/animation.svg create mode 100644 _examples/progressbar/demo/main.go create mode 100644 _examples/section/demo/README.md create mode 100644 _examples/section/demo/animation.svg create mode 100644 _examples/section/demo/main.go create mode 100644 _examples/spinner/demo/README.md create mode 100644 _examples/spinner/demo/animation.svg create mode 100644 _examples/spinner/demo/main.go create mode 100644 _examples/style/demo/README.md create mode 100644 _examples/style/demo/animation.svg create mode 100644 _examples/style/demo/main.go create mode 100644 _examples/table/demo/README.md create mode 100644 _examples/table/demo/animation.svg create mode 100644 _examples/table/demo/main.go create mode 100644 _examples/theme/demo/README.md create mode 100644 _examples/theme/demo/animation.svg create mode 100644 _examples/theme/demo/main.go create mode 100644 _examples/tree/demo/README.md create mode 100644 _examples/tree/demo/animation.svg create mode 100644 _examples/tree/demo/main.go diff --git a/_examples/README.md b/_examples/README.md new file mode 100644 index 000000000..7d0ea6060 --- /dev/null +++ b/_examples/README.md @@ -0,0 +1,4 @@ +# PTerm Examples + +> This directory contains examples of using the PTerm library. + diff --git a/_examples/area/demo/README.md b/_examples/area/demo/README.md new file mode 100644 index 000000000..206827c31 --- /dev/null +++ b/_examples/area/demo/README.md @@ -0,0 +1,27 @@ +# area + +![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..31f22fae8 --- /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/demo/main.go b/_examples/area/demo/main.go new file mode 100644 index 000000000..44ffb88df --- /dev/null +++ b/_examples/area/demo/main.go @@ -0,0 +1,20 @@ +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/barchart/demo/README.md b/_examples/barchart/demo/README.md new file mode 100644 index 000000000..bbaf9280e --- /dev/null +++ b/_examples/barchart/demo/README.md @@ -0,0 +1,33 @@ +# barchart + +![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..0e6277746 --- /dev/null +++ b/_examples/barchart/demo/animation.svg @@ -0,0 +1,10 @@ + INFO Chartexamplewithpositiveonlyvalues(barsuse100%ofchartarea)████████████Bar1Bar2LongerLabelBar1█████████████████████████████████████Bar2██████████████████████LongerLabel█████████████████████████████████████████████████████Bar1██████████████████████████LongerLabel███████Restartinganimation... \ No newline at end of file diff --git a/_examples/barchart/demo/main.go b/_examples/barchart/demo/main.go new file mode 100644 index 000000000..16aefe1e8 --- /dev/null +++ b/_examples/barchart/demo/main.go @@ -0,0 +1,26 @@ +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/mixed-values/README.md b/_examples/barchart/mixed-values/README.md new file mode 100644 index 000000000..4f015a834 --- /dev/null +++ b/_examples/barchart/mixed-values/README.md @@ -0,0 +1,41 @@ +# barchart-mixed-values + +![Animation](animation.svg) + +```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() +} + +``` diff --git a/_examples/barchart/mixed-values/animation.svg b/_examples/barchart/mixed-values/animation.svg new file mode 100644 index 000000000..942feb6ea --- /dev/null +++ b/_examples/barchart/mixed-values/animation.svg @@ -0,0 +1,10 @@ +#Chartexamplewithmixedvalues(notescreenspaceusageincasewhenABSOLUTEvaluesofnegativeandpositivepartsarediffertoomuch)257██████████████████-3-2Bar1Bar2Bar3Bar4LongerLabelBar1███████2Bar2███████████-3Bar3███████-2Bar4██████████████████5LongerLabel██████████████████████████7Bar4Restartinganimation... \ No newline at end of file diff --git a/_examples/barchart/mixed-values/main.go b/_examples/barchart/mixed-values/main.go new file mode 100644 index 000000000..10c10f91e --- /dev/null +++ b/_examples/barchart/mixed-values/main.go @@ -0,0 +1,34 @@ +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() +} diff --git a/_examples/barchart/negative-values/README.md b/_examples/barchart/negative-values/README.md new file mode 100644 index 000000000..d790face6 --- /dev/null +++ b/_examples/barchart/negative-values/README.md @@ -0,0 +1,33 @@ +# barchart-negative-values + +![Animation](animation.svg) + +```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/negative-values/animation.svg b/_examples/barchart/negative-values/animation.svg new file mode 100644 index 000000000..a0b835d02 --- /dev/null +++ b/_examples/barchart/negative-values/animation.svg @@ -0,0 +1,10 @@ + INFO Chartexamplewithnegativeonlyvalues(barsuse100%ofchartarea)████████████-5-3-7Bar1Bar2LongerLabelBar1█████████████████████████████████████-5Bar2██████████████████████-3LongerLabel█████████████████████████████████████████████████████-7Bar1████████████████████████LongerLabel█████Restartinganimation... \ No newline at end of file diff --git a/_examples/barchart/negative-values/main.go b/_examples/barchart/negative-values/main.go new file mode 100644 index 000000000..94a117cdf --- /dev/null +++ b/_examples/barchart/negative-values/main.go @@ -0,0 +1,26 @@ +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/basictext/demo/README.md b/_examples/basictext/demo/README.md new file mode 100644 index 000000000..ce498440a --- /dev/null +++ b/_examples/basictext/demo/README.md @@ -0,0 +1,20 @@ +# print-basic-text + +![Animation](animation.svg) + +```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/basictext/demo/animation.svg b/_examples/basictext/demo/animation.svg new file mode 100644 index 000000000..f8e0480f3 --- /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/basictext/demo/main.go b/_examples/basictext/demo/main.go new file mode 100644 index 000000000..249e53e04 --- /dev/null +++ b/_examples/basictext/demo/main.go @@ -0,0 +1,13 @@ +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/bigtext/demo/README.md b/_examples/bigtext/demo/README.md new file mode 100644 index 000000000..22615dc6d --- /dev/null +++ b/_examples/bigtext/demo/README.md @@ -0,0 +1,27 @@ +# bigtext + +![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..9bf595cbe --- /dev/null +++ b/_examples/bigtext/demo/animation.svg @@ -0,0 +1,10 @@ +██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████Restartinganimation... \ No newline at end of file diff --git a/_examples/bigtext/demo/main.go b/_examples/bigtext/demo/main.go new file mode 100644 index 000000000..eff801c1d --- /dev/null +++ b/_examples/bigtext/demo/main.go @@ -0,0 +1,20 @@ +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/box/demo/README.md b/_examples/box/demo/README.md new file mode 100644 index 000000000..30a758090 --- /dev/null +++ b/_examples/box/demo/README.md @@ -0,0 +1,25 @@ +# box + +![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..567dd52c2 --- /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/demo/main.go b/_examples/box/demo/main.go new file mode 100644 index 000000000..f25a80e3a --- /dev/null +++ b/_examples/box/demo/main.go @@ -0,0 +1,18 @@ +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/bulletlist/customized/README.md b/_examples/bulletlist/customized/README.md new file mode 100644 index 000000000..9b9b6c5c4 --- /dev/null +++ b/_examples/bulletlist/customized/README.md @@ -0,0 +1,21 @@ +# bulletlist-custom + +![Animation](animation.svg) + +```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() +} + +``` diff --git a/_examples/bulletlist/customized/animation.svg b/_examples/bulletlist/customized/animation.svg new file mode 100644 index 000000000..70ecb687e --- /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/customized/main.go b/_examples/bulletlist/customized/main.go new file mode 100644 index 000000000..75c90a311 --- /dev/null +++ b/_examples/bulletlist/customized/main.go @@ -0,0 +1,14 @@ +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() +} diff --git a/_examples/bulletlist/demo/README.md b/_examples/bulletlist/demo/README.md new file mode 100644 index 000000000..ea6634eaa --- /dev/null +++ b/_examples/bulletlist/demo/README.md @@ -0,0 +1,26 @@ +# bulletlist + +![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..fb28094d6 --- /dev/null +++ b/_examples/bulletlist/demo/animation.svg @@ -0,0 +1,10 @@ +Level0Level1Level20123Restartinganimation... \ No newline at end of file diff --git a/_examples/bulletlist/demo/main.go b/_examples/bulletlist/demo/main.go new file mode 100644 index 000000000..ef3b781c4 --- /dev/null +++ b/_examples/bulletlist/demo/main.go @@ -0,0 +1,19 @@ +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/center/demo/README.md b/_examples/center/demo/README.md new file mode 100644 index 000000000..0d2ad2403 --- /dev/null +++ b/_examples/center/demo/README.md @@ -0,0 +1,20 @@ +# center + +![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..db8236664 --- /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/demo/main.go b/_examples/center/demo/main.go new file mode 100644 index 000000000..9c879169c --- /dev/null +++ b/_examples/center/demo/main.go @@ -0,0 +1,13 @@ +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/coloring/demo/README.md b/_examples/coloring/demo/README.md new file mode 100644 index 000000000..fb5e134e8 --- /dev/null +++ b/_examples/coloring/demo/README.md @@ -0,0 +1,34 @@ +# print-with-color + +![Animation](animation.svg) + +```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") +} + +``` diff --git a/_examples/coloring/demo/animation.svg b/_examples/coloring/demo/animation.svg new file mode 100644 index 000000000..812846748 --- /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/coloring/demo/main.go b/_examples/coloring/demo/main.go new file mode 100644 index 000000000..bc2123645 --- /dev/null +++ b/_examples/coloring/demo/main.go @@ -0,0 +1,27 @@ +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") +} diff --git a/_examples/coloring/disable-color/README.md b/_examples/coloring/disable-color/README.md new file mode 100644 index 000000000..39561cc55 --- /dev/null +++ b/_examples/coloring/disable-color/README.md @@ -0,0 +1,162 @@ +# disable-color + +![Animation](animation.svg) + +```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 +} + +``` diff --git a/_examples/coloring/disable-color/animation.svg b/_examples/coloring/disable-color/animation.svg new file mode 100644 index 000000000..b69178f94 --- /dev/null +++ b/_examples/coloring/disable-color/animation.svg @@ -0,0 +1,10 @@ +███████████████████████████████████████████████████████████████████████████████████████████████████████████████████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:)#BulletListPrinterGoodbyeHaveaniceday!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/coloring/disable-color/main.go b/_examples/coloring/disable-color/main.go new file mode 100644 index 000000000..02f24ad53 --- /dev/null +++ b/_examples/coloring/disable-color/main.go @@ -0,0 +1,155 @@ +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 +} diff --git a/_examples/coloring/disable-output/README.md b/_examples/coloring/disable-output/README.md new file mode 100644 index 000000000..5adec41d5 --- /dev/null +++ b/_examples/coloring/disable-output/README.md @@ -0,0 +1,25 @@ +# disable-output + +![Animation](animation.svg) + +```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) + } +} + +``` diff --git a/_examples/coloring/disable-output/animation.svg b/_examples/coloring/disable-output/animation.svg new file mode 100644 index 000000000..02bb83af8 --- /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/coloring/disable-output/main.go b/_examples/coloring/disable-output/main.go new file mode 100644 index 000000000..e604abb11 --- /dev/null +++ b/_examples/coloring/disable-output/main.go @@ -0,0 +1,18 @@ +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) + } +} diff --git a/_examples/coloring/disable-styling/README.md b/_examples/coloring/disable-styling/README.md new file mode 100644 index 000000000..ae4555074 --- /dev/null +++ b/_examples/coloring/disable-styling/README.md @@ -0,0 +1,162 @@ +# disable-styling + +![Animation](animation.svg) + +```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 +} + +``` diff --git a/_examples/coloring/disable-styling/animation.svg b/_examples/coloring/disable-styling/animation.svg new file mode 100644 index 000000000..78acad44c --- /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: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:)#BulletListPrinterGoodbyeHaveaniceday!#TreePrinter└─┬C:├──GoRestartinganimation... \ No newline at end of file diff --git a/_examples/coloring/disable-styling/main.go b/_examples/coloring/disable-styling/main.go new file mode 100644 index 000000000..ac30ac5b1 --- /dev/null +++ b/_examples/coloring/disable-styling/main.go @@ -0,0 +1,155 @@ +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 +} diff --git a/_examples/coloring/fade-colors/README.md b/_examples/coloring/fade-colors/README.md new file mode 100644 index 000000000..35c1dbd01 --- /dev/null +++ b/_examples/coloring/fade-colors/README.md @@ -0,0 +1,26 @@ +# print-color-fade + +![Animation](animation.svg) + +```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!") + } +} + +``` diff --git a/_examples/coloring/fade-colors/animation.svg b/_examples/coloring/fade-colors/animation.svg new file mode 100644 index 000000000..64f1bd2a7 --- /dev/null +++ b/_examples/coloring/fade-colors/animation.svg @@ -0,0 +1,10 @@ + 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/coloring/fade-colors/main.go b/_examples/coloring/fade-colors/main.go new file mode 100644 index 000000000..23473fcc6 --- /dev/null +++ b/_examples/coloring/fade-colors/main.go @@ -0,0 +1,19 @@ +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!") + } +} diff --git a/_examples/coloring/fade-multiple-colors/README.md b/_examples/coloring/fade-multiple-colors/README.md new file mode 100644 index 000000000..85b091cee --- /dev/null +++ b/_examples/coloring/fade-multiple-colors/README.md @@ -0,0 +1,40 @@ +# print-color-fade-multiple + +![Animation](animation.svg) + +```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!") + } +} + +``` diff --git a/_examples/coloring/fade-multiple-colors/animation.svg b/_examples/coloring/fade-multiple-colors/animation.svg new file mode 100644 index 000000000..ee0589893 --- /dev/null +++ b/_examples/coloring/fade-multiple-colors/animation.svg @@ -0,0 +1,10 @@ + 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/coloring/fade-multiple-colors/main.go b/_examples/coloring/fade-multiple-colors/main.go new file mode 100644 index 000000000..c81700f0e --- /dev/null +++ b/_examples/coloring/fade-multiple-colors/main.go @@ -0,0 +1,33 @@ +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!") + } +} diff --git a/_examples/coloring/override-default-printers/README.md b/_examples/coloring/override-default-printers/README.md new file mode 100644 index 000000000..567c7161f --- /dev/null +++ b/_examples/coloring/override-default-printers/README.md @@ -0,0 +1,24 @@ +# override-default-printers + +![Animation](animation.svg) + +```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") +} + +``` diff --git a/_examples/coloring/override-default-printers/animation.svg b/_examples/coloring/override-default-printers/animation.svg new file mode 100644 index 000000000..07ba754bf --- /dev/null +++ b/_examples/coloring/override-default-printers/animation.svg @@ -0,0 +1,10 @@ + ERROR ThisisthedefaultError OVERRIDE ThisisthedefaultErroraftertheprefixwasoverriddenRestartinganimation... \ No newline at end of file diff --git a/_examples/coloring/override-default-printers/main.go b/_examples/coloring/override-default-printers/main.go new file mode 100644 index 000000000..52eb93008 --- /dev/null +++ b/_examples/coloring/override-default-printers/main.go @@ -0,0 +1,17 @@ +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") +} diff --git a/_examples/coloring/print-color-rgb/README.md b/_examples/coloring/print-color-rgb/README.md new file mode 100644 index 000000000..e96e5084b --- /dev/null +++ b/_examples/coloring/print-color-rgb/README.md @@ -0,0 +1,18 @@ +# print-color-rgb + +![Animation](animation.svg) + +```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!") +} + +``` diff --git a/_examples/coloring/print-color-rgb/animation.svg b/_examples/coloring/print-color-rgb/animation.svg new file mode 100644 index 000000000..f7ff6765e --- /dev/null +++ b/_examples/coloring/print-color-rgb/animation.svg @@ -0,0 +1,10 @@ +ThistextisprintedwithacustomRGB!ThistextisprintedwithacustomRGB!ThistextisprintedwithacustomRGB!Restartinganimation... \ No newline at end of file diff --git a/_examples/coloring/print-color-rgb/main.go b/_examples/coloring/print-color-rgb/main.go new file mode 100644 index 000000000..c849785d1 --- /dev/null +++ b/_examples/coloring/print-color-rgb/main.go @@ -0,0 +1,11 @@ +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!") +} diff --git a/_examples/demo/demo/README.md b/_examples/demo/demo/README.md new file mode 100644 index 000000000..4738b2e1f --- /dev/null +++ b/_examples/demo/demo/README.md @@ -0,0 +1,162 @@ +# demo + +![Animation](animation.svg) + +```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 +} + +``` diff --git a/_examples/demo/demo/animation.svg b/_examples/demo/demo/animation.svg new file mode 100644 index 000000000..0d5afe5e2 --- /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:20Apr2022-22:18:04UTCWaitingfor15seconds...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:)#BulletListPrinterGoodbyeHaveaniceday!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/demo/main.go b/_examples/demo/demo/main.go new file mode 100644 index 000000000..6017a5587 --- /dev/null +++ b/_examples/demo/demo/main.go @@ -0,0 +1,155 @@ +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 +} diff --git a/_examples/header-custom/demo/README.md b/_examples/header-custom/demo/README.md new file mode 100644 index 000000000..c8d2ec956 --- /dev/null +++ b/_examples/header-custom/demo/README.md @@ -0,0 +1,33 @@ +# header-custom + +![Animation](animation.svg) + +```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!") +} + +``` diff --git a/_examples/header-custom/demo/animation.svg b/_examples/header-custom/demo/animation.svg new file mode 100644 index 000000000..c7921ab66 --- /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/demo/main.go b/_examples/header-custom/demo/main.go new file mode 100644 index 000000000..3ca553b4b --- /dev/null +++ b/_examples/header-custom/demo/main.go @@ -0,0 +1,26 @@ +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!") +} diff --git a/_examples/header/demo/README.md b/_examples/header/demo/README.md new file mode 100644 index 000000000..9ad70d682 --- /dev/null +++ b/_examples/header/demo/README.md @@ -0,0 +1,17 @@ +# header + +![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..8468f55cd --- /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/demo/main.go b/_examples/header/demo/main.go new file mode 100644 index 000000000..a654d4d0d --- /dev/null +++ b/_examples/header/demo/main.go @@ -0,0 +1,10 @@ +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/panel/demo/README.md b/_examples/panel/demo/README.md new file mode 100644 index 000000000..220be07bc --- /dev/null +++ b/_examples/panel/demo/README.md @@ -0,0 +1,21 @@ +# panel + +![Animation](animation.svg) + +```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() +} + +``` diff --git a/_examples/panel/demo/animation.svg b/_examples/panel/demo/animation.svg new file mode 100644 index 000000000..aab802acf --- /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/demo/main.go b/_examples/panel/demo/main.go new file mode 100644 index 000000000..8726df44a --- /dev/null +++ b/_examples/panel/demo/main.go @@ -0,0 +1,14 @@ +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() +} diff --git a/_examples/paragraph/customized/README.md b/_examples/paragraph/customized/README.md new file mode 100644 index 000000000..3d15cd0a4 --- /dev/null +++ b/_examples/paragraph/customized/README.md @@ -0,0 +1,24 @@ +# paragraph-custom + +![Animation](animation.svg) + +```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") +} + +``` diff --git a/_examples/paragraph/customized/animation.svg b/_examples/paragraph/customized/animation.svg new file mode 100644 index 000000000..88ea6af5b --- /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/customized/main.go b/_examples/paragraph/customized/main.go new file mode 100644 index 000000000..39cdf8643 --- /dev/null +++ b/_examples/paragraph/customized/main.go @@ -0,0 +1,17 @@ +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") +} diff --git a/_examples/paragraph/demo/README.md b/_examples/paragraph/demo/README.md new file mode 100644 index 000000000..07ad0d57c --- /dev/null +++ b/_examples/paragraph/demo/README.md @@ -0,0 +1,24 @@ +# paragraph + +![Animation](animation.svg) + +```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") +} + +``` diff --git a/_examples/paragraph/demo/animation.svg b/_examples/paragraph/demo/animation.svg new file mode 100644 index 000000000..85fe6c920 --- /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/demo/main.go b/_examples/paragraph/demo/main.go new file mode 100644 index 000000000..4558ea73c --- /dev/null +++ b/_examples/paragraph/demo/main.go @@ -0,0 +1,17 @@ +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") +} diff --git a/_examples/prefix/demo/README.md b/_examples/prefix/demo/README.md new file mode 100644 index 000000000..3d23fe3ec --- /dev/null +++ b/_examples/prefix/demo/README.md @@ -0,0 +1,24 @@ +# prefix + +![Animation](animation.svg) + +```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. +} + +``` diff --git a/_examples/prefix/demo/animation.svg b/_examples/prefix/demo/animation.svg new file mode 100644 index 000000000..3a9282ead --- /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!(/github/workspace/_examples/prefix/main.go:14) FATAL Hello,World!Restartinganimation... \ No newline at end of file diff --git a/_examples/prefix/demo/main.go b/_examples/prefix/demo/main.go new file mode 100644 index 000000000..b032b4503 --- /dev/null +++ b/_examples/prefix/demo/main.go @@ -0,0 +1,17 @@ +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. +} diff --git a/_examples/progressbar/demo/README.md b/_examples/progressbar/demo/README.md new file mode 100644 index 000000000..250d14098 --- /dev/null +++ b/_examples/progressbar/demo/README.md @@ -0,0 +1,31 @@ +# progressbar + +![Animation](animation.svg) + +```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. + } +} + +``` diff --git a/_examples/progressbar/demo/animation.svg b/_examples/progressbar/demo/animation.svg new file mode 100644 index 000000000..cb00e35b8 --- /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[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/demo/main.go b/_examples/progressbar/demo/main.go new file mode 100644 index 000000000..68819b458 --- /dev/null +++ b/_examples/progressbar/demo/main.go @@ -0,0 +1,24 @@ +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. + } +} diff --git a/_examples/section/demo/README.md b/_examples/section/demo/README.md new file mode 100644 index 000000000..dd04dbf02 --- /dev/null +++ b/_examples/section/demo/README.md @@ -0,0 +1,22 @@ +# section + +![Animation](animation.svg) + +```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") +} + +``` diff --git a/_examples/section/demo/animation.svg b/_examples/section/demo/animation.svg new file mode 100644 index 000000000..cbc9e3a7f --- /dev/null +++ b/_examples/section/demo/animation.svg @@ -0,0 +1,10 @@ +#Thisisasection! INFO Andhereissometext. Thistextcouldbeanything. Basicallyit'sjustaplaceholder##Thisisanothersection! INFO Andthisis moreplaceholdertextRestartinganimation... \ No newline at end of file diff --git a/_examples/section/demo/main.go b/_examples/section/demo/main.go new file mode 100644 index 000000000..80933f69d --- /dev/null +++ b/_examples/section/demo/main.go @@ -0,0 +1,15 @@ +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") +} diff --git a/_examples/spinner/demo/README.md b/_examples/spinner/demo/README.md new file mode 100644 index 000000000..95583c282 --- /dev/null +++ b/_examples/spinner/demo/README.md @@ -0,0 +1,40 @@ +# spinner + +![Animation](animation.svg) + +```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. +} + +``` diff --git a/_examples/spinner/demo/animation.svg b/_examples/spinner/demo/animation.svg new file mode 100644 index 000000000..4403516f5 --- /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'sreallymuchIt'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/demo/main.go b/_examples/spinner/demo/main.go new file mode 100644 index 000000000..cacd45f56 --- /dev/null +++ b/_examples/spinner/demo/main.go @@ -0,0 +1,33 @@ +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. +} diff --git a/_examples/style/demo/README.md b/_examples/style/demo/README.md new file mode 100644 index 000000000..1b11de92e --- /dev/null +++ b/_examples/style/demo/README.md @@ -0,0 +1,20 @@ +# style + +![Animation](animation.svg) + +```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!") +} + +``` diff --git a/_examples/style/demo/animation.svg b/_examples/style/demo/animation.svg new file mode 100644 index 000000000..6db76bdd8 --- /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/demo/main.go b/_examples/style/demo/main.go new file mode 100644 index 000000000..74ff150dc --- /dev/null +++ b/_examples/style/demo/main.go @@ -0,0 +1,13 @@ +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!") +} diff --git a/_examples/table/demo/README.md b/_examples/table/demo/README.md new file mode 100644 index 000000000..23ed3fba8 --- /dev/null +++ b/_examples/table/demo/README.md @@ -0,0 +1,31 @@ +# table + +![Animation](animation.svg) + +```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() +} + +``` diff --git a/_examples/table/demo/animation.svg b/_examples/table/demo/animation.svg new file mode 100644 index 000000000..6754d9665 --- /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/demo/main.go b/_examples/table/demo/main.go new file mode 100644 index 000000000..491f99d4e --- /dev/null +++ b/_examples/table/demo/main.go @@ -0,0 +1,24 @@ +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() +} diff --git a/_examples/theme/demo/README.md b/_examples/theme/demo/README.md new file mode 100644 index 000000000..2d4de7678 --- /dev/null +++ b/_examples/theme/demo/README.md @@ -0,0 +1,37 @@ +# theme + +![Animation](animation.svg) + +```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) + } + } +} + +``` diff --git a/_examples/theme/demo/animation.svg b/_examples/theme/demo/animation.svg new file mode 100644 index 000000000..993d43409 --- /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/demo/main.go b/_examples/theme/demo/main.go new file mode 100644 index 000000000..6813d3f41 --- /dev/null +++ b/_examples/theme/demo/main.go @@ -0,0 +1,30 @@ +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) + } + } +} diff --git a/_examples/tree/demo/README.md b/_examples/tree/demo/README.md new file mode 100644 index 000000000..7a9eab639 --- /dev/null +++ b/_examples/tree/demo/README.md @@ -0,0 +1,46 @@ +# tree + +![Animation](animation.svg) + +```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/tree/demo/animation.svg b/_examples/tree/demo/animation.svg new file mode 100644 index 000000000..b2bb8015c --- /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└─├─┬Muestartinganimation... \ No newline at end of file diff --git a/_examples/tree/demo/main.go b/_examples/tree/demo/main.go new file mode 100644 index 000000000..b6dbf894c --- /dev/null +++ b/_examples/tree/demo/main.go @@ -0,0 +1,39 @@ +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() +} From f23372e1c1485ca9cf2c506ce039c062cad0ffc7 Mon Sep 17 00:00:00 2001 From: MarvinJWendt Date: Thu, 21 Apr 2022 01:06:01 +0200 Subject: [PATCH 3/7] added new dir structure to examples --- _examples/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_examples/README.md b/_examples/README.md index 7d0ea6060..247b0668f 100644 --- a/_examples/README.md +++ b/_examples/README.md @@ -2,3 +2,5 @@ > This directory contains examples of using the PTerm library. + + From c7ceddd1240838cff2a0479229c40ce0f741c54b Mon Sep 17 00:00:00 2001 From: MarvinJWendt Date: Thu, 21 Apr 2022 01:51:33 +0200 Subject: [PATCH 4/7] updated example generation --- README.md | 602 +++---- _examples/README.md | 1521 +++++++++++++++++ _examples/area/demo/README.md | 2 +- _examples/area/demo/animation.svg | 4 +- _examples/barchart/demo/README.md | 2 +- _examples/barchart/demo/animation.svg | 4 +- _examples/barchart/mixed-values/README.md | 2 +- _examples/barchart/mixed-values/animation.svg | 4 +- _examples/barchart/negative-values/README.md | 2 +- .../barchart/negative-values/animation.svg | 4 +- _examples/basictext/demo/README.md | 2 +- _examples/basictext/demo/animation.svg | 10 - _examples/bigtext/demo/README.md | 2 +- _examples/bigtext/demo/animation.svg | 4 +- _examples/box/demo/README.md | 2 +- _examples/box/demo/animation.svg | 4 +- _examples/bulletlist/customized/README.md | 2 +- _examples/bulletlist/customized/animation.svg | 4 +- _examples/bulletlist/demo/README.md | 2 +- _examples/bulletlist/demo/animation.svg | 4 +- _examples/center/demo/README.md | 2 +- _examples/center/demo/animation.svg | 4 +- _examples/coloring/demo/README.md | 2 +- _examples/coloring/demo/animation.svg | 4 +- _examples/coloring/disable-color/README.md | 2 +- .../coloring/disable-color/animation.svg | 4 +- _examples/coloring/disable-output/README.md | 2 +- .../coloring/disable-output/animation.svg | 4 +- _examples/coloring/disable-styling/README.md | 2 +- .../coloring/disable-styling/animation.svg | 4 +- _examples/coloring/fade-colors/README.md | 2 +- _examples/coloring/fade-colors/animation.svg | 4 +- .../coloring/fade-multiple-colors/README.md | 2 +- .../fade-multiple-colors/animation.svg | 4 +- .../override-default-printers/README.md | 2 +- .../override-default-printers/animation.svg | 4 +- _examples/coloring/print-color-rgb/README.md | 2 +- .../coloring/print-color-rgb/animation.svg | 4 +- _examples/demo/demo/README.md | 2 +- _examples/demo/demo/animation.svg | 4 +- _examples/header-custom/demo/README.md | 2 +- _examples/header-custom/demo/animation.svg | 4 +- _examples/header/demo/README.md | 2 +- _examples/header/demo/animation.svg | 4 +- _examples/panel/demo/README.md | 2 +- _examples/panel/demo/animation.svg | 4 +- _examples/paragraph/customized/README.md | 2 +- _examples/paragraph/customized/animation.svg | 4 +- _examples/paragraph/demo/README.md | 2 +- _examples/paragraph/demo/animation.svg | 4 +- _examples/prefix/demo/README.md | 2 +- _examples/prefix/demo/animation.svg | 4 +- _examples/progressbar/demo/README.md | 2 +- _examples/progressbar/demo/animation.svg | 4 +- _examples/section/demo/README.md | 2 +- _examples/section/demo/animation.svg | 4 +- _examples/spinner/demo/README.md | 2 +- _examples/spinner/demo/animation.svg | 4 +- _examples/style/demo/README.md | 2 +- _examples/style/demo/animation.svg | 4 +- _examples/table/demo/README.md | 4 +- _examples/table/demo/animation.svg | 4 +- _examples/theme/demo/README.md | 2 +- _examples/theme/demo/animation.svg | 4 +- _examples/tree/demo/README.md | 2 +- _examples/tree/demo/animation.svg | 4 +- ci/main.go | 88 +- docs/README.md | 602 +++---- 68 files changed, 2264 insertions(+), 749 deletions(-) delete mode 100644 _examples/basictext/demo/animation.svg diff --git a/README.md b/README.md index 80be38aa2..88cd51f65 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,9 @@ func main() {
-### barchart-mixed-values +### barchart/mixed-values -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart-mixed-values/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/mixed-values/animation.svg)
@@ -302,9 +302,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 +342,36 @@ func main() {
-### bigtext +### basictext/demo -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bigtext/animation.svg) +![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)
@@ -376,9 +403,9 @@ func main() {
-### box +### box/demo -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/box/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/box/demo/animation.svg)
@@ -408,9 +435,37 @@ func main() {
-### bulletlist +### 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/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/demo/animation.svg)
@@ -441,9 +496,9 @@ func main() {
-### bulletlist-custom +### center/demo -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist-custom/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/center/demo/animation.svg)
@@ -452,26 +507,25 @@ 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() + 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") } ```
-### 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 +537,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 +592,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 +691,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 +707,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 +733,41 @@ func randomInt(min, max int) int {
-### disable-color +### coloring/disable-output -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/disable-color/animation.svg) +![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)
@@ -693,7 +793,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() @@ -834,9 +934,89 @@ func randomInt(min, max int) int {
-### disable-output +### 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/disable-output/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/override-default-printers/animation.svg)
@@ -848,27 +1028,51 @@ 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!") - } + // Print default error. + pterm.Error.Println("This is the default Error") - pterm.Printf("Printing something... [%d/%d]\n", i, 15) + // 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-styling +### coloring/print-color-rgb -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/disable-styling/animation.svg) +![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)
@@ -894,7 +1098,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 +1196,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 +1213,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 +1239,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 +1263,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 +1303,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 +1331,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 +1345,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 +1362,9 @@ func main() {
-### paragraph-custom +### paragraph/demo -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/paragraph-custom/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/paragraph/demo/animation.svg)
@@ -1203,15 +1376,15 @@ 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, " + + // 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 text without a paragraph printer. + // 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") } @@ -1220,9 +1393,9 @@ func main() {
-### prefix +### prefix/demo -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/prefix/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/prefix/demo/animation.svg)
@@ -1251,182 +1424,9 @@ func main() {
-### print-basic-text - -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/print-basic-text/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!") -} - -``` - -
- -### 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 - -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!") -} - -``` - -
- -### print-with-color +### progressbar/demo -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/print-with-color/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") -} - -``` - -
- -### progressbar - -![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 +1462,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 +1491,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 +1538,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 +1565,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 +1589,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 +1603,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 +1647,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 index 247b0668f..b50e345a9 100644 --- a/_examples/README.md +++ b/_examples/README.md @@ -3,4 +3,1525 @@ > 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/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/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/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/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/demo/README.md b/_examples/area/demo/README.md index 206827c31..d4ad4924c 100644 --- a/_examples/area/demo/README.md +++ b/_examples/area/demo/README.md @@ -1,4 +1,4 @@ -# area +# area/demo ![Animation](animation.svg) diff --git a/_examples/area/demo/animation.svg b/_examples/area/demo/animation.svg index 31f22fae8..c0115e8d4 100644 --- a/_examples/area/demo/animation.svg +++ b/_examples/area/demo/animation.svg @@ -1,4 +1,4 @@ - INFO Theprevioustextwillstayinplace,whiletheareaupdates.█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████Restartinganimation... \ No newline at end of file diff --git a/_examples/barchart/demo/README.md b/_examples/barchart/demo/README.md index bbaf9280e..e857b4ea7 100644 --- a/_examples/barchart/demo/README.md +++ b/_examples/barchart/demo/README.md @@ -1,4 +1,4 @@ -# barchart +# barchart/demo ![Animation](animation.svg) diff --git a/_examples/barchart/demo/animation.svg b/_examples/barchart/demo/animation.svg index 0e6277746..a84b59d44 100644 --- a/_examples/barchart/demo/animation.svg +++ b/_examples/barchart/demo/animation.svg @@ -1,4 +1,4 @@ - INFO Chartexamplewithpositiveonlyvalues(barsuse100%ofchartarea)████████████Bar1Bar2LongerLabelBar1█████████████████████████████████████Bar2██████████████████████LongerLabel█████████████████████████████████████████████████████Bar2LongerLabel██████████████████████Restartinganimation... \ No newline at end of file diff --git a/_examples/barchart/mixed-values/README.md b/_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 index 942feb6ea..5488dbbe5 100644 --- a/_examples/barchart/mixed-values/animation.svg +++ b/_examples/barchart/mixed-values/animation.svg @@ -1,4 +1,4 @@ -#Chartexamplewithmixedvalues(notescreenspaceusageincasewhenABSOLUTEvaluesofnegativeandpositivepartsarediffertoomuch)257██████████████████-3-2Bar1Bar2Bar3Bar4LongerLabelBar1███████2Bar2███████████-3Bar3███████-2Bar4██████████████████5LongerLabel██████████████████████████7Bar4Restartinganimation... \ No newline at end of file diff --git a/_examples/barchart/negative-values/README.md b/_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 index a0b835d02..d2348c512 100644 --- a/_examples/barchart/negative-values/animation.svg +++ b/_examples/barchart/negative-values/animation.svg @@ -1,4 +1,4 @@ - INFO Chartexamplewithnegativeonlyvalues(barsuse100%ofchartarea)████████████-5-3-7Bar1Bar2LongerLabelBar1█████████████████████████████████████-5Bar2██████████████████████-3LongerLabel█████████████████████████████████████████████████████-7Bar2LongerLabel█████████████████████Restartinganimation... \ No newline at end of file diff --git a/_examples/basictext/demo/README.md b/_examples/basictext/demo/README.md index ce498440a..64518301b 100644 --- a/_examples/basictext/demo/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 deleted file mode 100644 index f8e0480f3..000000000 --- a/_examples/basictext/demo/animation.svg +++ /dev/null @@ -1,10 +0,0 @@ -Defaultbasictextprinter.CanbeusedinanyTextPrintercontext.Forexampletoresolveprogressbarsandspinners.Restartinganimation... \ No newline at end of file diff --git a/_examples/bigtext/demo/README.md b/_examples/bigtext/demo/README.md index 22615dc6d..5f1e4f5f2 100644 --- a/_examples/bigtext/demo/README.md +++ b/_examples/bigtext/demo/README.md @@ -1,4 +1,4 @@ -# bigtext +# bigtext/demo ![Animation](animation.svg) diff --git a/_examples/bigtext/demo/animation.svg b/_examples/bigtext/demo/animation.svg index 9bf595cbe..9b85ab29f 100644 --- a/_examples/bigtext/demo/animation.svg +++ b/_examples/bigtext/demo/animation.svg @@ -1,4 +1,4 @@ -██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████Restartinganimation... \ No newline at end of file diff --git a/_examples/box/demo/README.md b/_examples/box/demo/README.md index 30a758090..c4e6305e6 100644 --- a/_examples/box/demo/README.md +++ b/_examples/box/demo/README.md @@ -1,4 +1,4 @@ -# box +# box/demo ![Animation](animation.svg) diff --git a/_examples/box/demo/animation.svg b/_examples/box/demo/animation.svg index 567dd52c2..ac0746ca3 100644 --- a/_examples/box/demo/animation.svg +++ b/_examples/box/demo/animation.svg @@ -1,4 +1,4 @@ - 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/bulletlist/customized/README.md b/_examples/bulletlist/customized/README.md index 9b9b6c5c4..64d8dc113 100644 --- a/_examples/bulletlist/customized/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 index 70ecb687e..8f51665c3 100644 --- a/_examples/bulletlist/customized/animation.svg +++ b/_examples/bulletlist/customized/animation.svg @@ -1,4 +1,4 @@ -Blue-Green>CyanRestartinganimation... \ No newline at end of file diff --git a/_examples/bulletlist/demo/README.md b/_examples/bulletlist/demo/README.md index ea6634eaa..30e1da8c7 100644 --- a/_examples/bulletlist/demo/README.md +++ b/_examples/bulletlist/demo/README.md @@ -1,4 +1,4 @@ -# bulletlist +# bulletlist/demo ![Animation](animation.svg) diff --git a/_examples/bulletlist/demo/animation.svg b/_examples/bulletlist/demo/animation.svg index fb28094d6..3549ce4e0 100644 --- a/_examples/bulletlist/demo/animation.svg +++ b/_examples/bulletlist/demo/animation.svg @@ -1,4 +1,4 @@ -Level0Level1Level20123Restartinganimation... \ No newline at end of file diff --git a/_examples/center/demo/README.md b/_examples/center/demo/README.md index 0d2ad2403..45c82d865 100644 --- a/_examples/center/demo/README.md +++ b/_examples/center/demo/README.md @@ -1,4 +1,4 @@ -# center +# center/demo ![Animation](animation.svg) diff --git a/_examples/center/demo/animation.svg b/_examples/center/demo/animation.svg index db8236664..9f0af23e8 100644 --- a/_examples/center/demo/animation.svg +++ b/_examples/center/demo/animation.svg @@ -1,4 +1,4 @@ -Thistextiscentered!Itcenteresthewholeblockbydefault.Inthatwayyoucandostufflikethis:███████████████████████████████████████████████████████████████████████████████████████████████████████████████████Thistextiscentered!ButeachlineiscenteredseparatelyRestartinganimation... \ No newline at end of file diff --git a/_examples/coloring/demo/README.md b/_examples/coloring/demo/README.md index fb5e134e8..185fa0a97 100644 --- a/_examples/coloring/demo/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 index 812846748..c488418a9 100644 --- a/_examples/coloring/demo/animation.svg +++ b/_examples/coloring/demo/animation.svg @@ -1,4 +1,4 @@ -Hello,World!Evennestedcolorsaresupported!FgBlackFgRedFgGreenFgYellowFgBlueFgMagentaFgCyanFgWhiteFgLightRedFgLightGreenFgLightYellowFgLightBlueFgLightMagentaFgLightCyanFgLightWhiteRestartinganimation... \ No newline at end of file diff --git a/_examples/coloring/disable-color/README.md b/_examples/coloring/disable-color/README.md index 39561cc55..c469e464b 100644 --- a/_examples/coloring/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 index b69178f94..effa6d3ca 100644 --- a/_examples/coloring/disable-color/animation.svg +++ b/_examples/coloring/disable-color/animation.svg @@ -1,4 +1,4 @@ -███████████████████████████████████████████████████████████████████████████████████████████████████████████████████PTDP-PTermDemoProgramINFOThisanimationwasgeneratedwiththelatestversionofPTerm!PTermworksonnearlyeveryterminalandoperatingsystem.It'ssupereasytouse!Ifyouwant,youcancustomizeeverything:)Youcanseethecodeofthisdemointhe./_examples/demodirectory.Thisdemowasupdatedat:21Apr2022-01:43:51CESTPseudoApplicationcreatedwithPTerm#InstallingpseudoprogramsSUCCESSInstallingpseudo-excelSUCCESSInstallingpseudo-photoshopSUCCESSInstallingpseudo-chromeSUCCESSInstallingpseudo-outlookSUCCESSInstallingpseudo-explorerSUCCESSInstallingpseudo-dopsSUCCESSInstallingpseudo-gitSUCCESSInstallingpseudo-vscSUCCESSInstallingpseudo-intellijWARNINGCouldnotinstallpseudo-minecraftThecompanypolicyforbidsgames.SUCCESSInstallingpseudo-scoopSUCCESSInstallingpseudo-chocolateyInstallingpseudo-chocolatey[11/12]███████████████████████████████░░░92%|6s##ProgramInstallReportProgramName|Status|Sizepseudo-excel|pass|174mbpseudo-photoshop|pass|120mbpseudo-chrome|pass|147mbpseudo-outlook|pass|52mbpseudo-explorer|pass|189mbpseudo-dops|pass|7mbpseudo-git|pass|46mbpseudo-vsc|pass|42mbpseudo-intellij|pass|190mbpseudo-minecraft|fail|0mbpseudo-scoop|pass|126mbpseudo-chocolatey|pass|25mb├──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:)#BulletListPrinterGoodbyeHaveaniceday!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[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[8/12]████████████████████████████░░░░░░░░░░░░░░67%|4sInstallingpseudo-intellij[9/12]████████████████████████████░░░░░░░░░75%|4sInstallingpseudo-minecraft[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/coloring/disable-output/README.md b/_examples/coloring/disable-output/README.md index 5adec41d5..1af7b7a1a 100644 --- a/_examples/coloring/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 index 02bb83af8..49ae2eba7 100644 --- a/_examples/coloring/disable-output/animation.svg +++ b/_examples/coloring/disable-output/animation.svg @@ -1,4 +1,4 @@ -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/coloring/disable-styling/README.md b/_examples/coloring/disable-styling/README.md index ae4555074..96fb179a6 100644 --- a/_examples/coloring/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 index 78acad44c..2dd4a84a7 100644 --- a/_examples/coloring/disable-styling/animation.svg +++ b/_examples/coloring/disable-styling/animation.svg @@ -1,4 +1,4 @@ -PTermPTDP-PTermDemoProgramINFO:ThisanimationwasgeneratedwiththelatestversionofPTerm!PTermworksonnearlyeveryterminalandoperatingsystem.It'ssupereasytouse!Ifyouwant,youcancustomizeeverything:)Youcanseethecodeofthisdemointhe./_examples/demodirectory.Thisdemowasupdatedat:21Apr2022-01:44:33CESTWaitingfor15seconds...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|64mbpseudo-photoshop|pass|150mbpseudo-chrome|pass|9mbpseudo-outlook|pass|157mbpseudo-explorer|pass|160mbpseudo-dops|pass|97mbpseudo-git|pass|25mbpseudo-vsc|pass|158mbpseudo-intellij|pass|90mbpseudo-minecraft|fail|0mbpseudo-scoop|pass|132mbpseudo-chocolatey|pass|68mb├──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:)#BulletListPrinterGoodbyeHaveaniceday!Waitingfor1second...#TreePrinter├──pseudo-excel├──pseudo-photoshop├─┬pseudo-chromeRestartinganimation... \ No newline at end of file diff --git a/_examples/coloring/fade-colors/README.md b/_examples/coloring/fade-colors/README.md index 35c1dbd01..6b8e97526 100644 --- a/_examples/coloring/fade-colors/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 index 64f1bd2a7..e069d11de 100644 --- a/_examples/coloring/fade-colors/animation.svg +++ b/_examples/coloring/fade-colors/animation.svg @@ -1,4 +1,4 @@ -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/coloring/fade-multiple-colors/README.md b/_examples/coloring/fade-multiple-colors/README.md index 85b091cee..7c000c825 100644 --- a/_examples/coloring/fade-multiple-colors/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 index ee0589893..11add53be 100644 --- a/_examples/coloring/fade-multiple-colors/animation.svg +++ b/_examples/coloring/fade-multiple-colors/animation.svg @@ -1,4 +1,4 @@ -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/coloring/override-default-printers/README.md b/_examples/coloring/override-default-printers/README.md index 567c7161f..48d79e267 100644 --- a/_examples/coloring/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/coloring/override-default-printers/animation.svg b/_examples/coloring/override-default-printers/animation.svg index 07ba754bf..6a5ac261e 100644 --- a/_examples/coloring/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 diff --git a/_examples/coloring/print-color-rgb/README.md b/_examples/coloring/print-color-rgb/README.md index e96e5084b..4d35e7be6 100644 --- a/_examples/coloring/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/coloring/print-color-rgb/animation.svg b/_examples/coloring/print-color-rgb/animation.svg index f7ff6765e..e4724f81f 100644 --- a/_examples/coloring/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 diff --git a/_examples/demo/demo/README.md b/_examples/demo/demo/README.md index 4738b2e1f..6c89b7803 100644 --- a/_examples/demo/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 index 0d5afe5e2..427ba5bcc 100644 --- a/_examples/demo/demo/animation.svg +++ b/_examples/demo/demo/animation.svg @@ -1,4 +1,4 @@ -███████████████████████████████████████████████████████████████████████████████████████████████████████████████████ PTDP - PTerm Demo Program INFO ThisanimationwasgeneratedwiththelatestversionofPTerm! PTermworksonnearlyeveryterminalandoperatingsystem. It'ssupereasytouse! Ifyouwant,youcancustomizeeverything:) Youcanseethecodeofthisdemointhe./_examples/demodirectory. Thisdemowasupdatedat:21Apr2022-01:45:20CESTWaitingfor15seconds...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-intellijInstallingpseudo-minecraft[9/12]███████████████████████████░░░░░░░░░75%|5s WARNING Couldnotinstallpseudo-minecraft Thecompanypolicyforbidsgames. SUCCESS Installingpseudo-scoop SUCCESS Installingpseudo-chocolateyInstallingpseudo-chocolatey[11/12]███████████████████████████████░░░92%|6s##ProgramInstallReportProgramName|Status|Sizepseudo-excel|pass|195mbpseudo-photoshop|pass|53mbpseudo-chrome|pass|180mbpseudo-outlook|pass|36mbpseudo-explorer|pass|88mbpseudo-dops|pass|73mbpseudo-git|pass|138mbpseudo-vsc|pass|127mbpseudo-intellij|pass|176mbpseudo-minecraft|fail|0mbpseudo-scoop|pass|65mbpseudo-chocolatey|pass|136mb#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:)#BulletListPrinterGoodbyeHaveaniceday!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[3/12]██████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░25%|2sInstallingpseudo-outlook[4/12]█████████████░░░░░░░░░░░░░░░░░░░░░░░░░33%|2sInstallingpseudo-explorer[5/12]████████████████░░░░░░░░░░░░░░░░░░░░░42%|2sInstallingpseudo-dops[6/12]█████████████████████░░░░░░░░░░░░░░░░░░░░50%|3sInstallingpseudo-git[7/12]████████████████████████░░░░░░░░░░░░░░░░░░58%|3sInstallingpseudo-vsc[8/12]████████████████████████████░░░░░░░░░░░░░░67%|4sInstallingpseudo-intellij[9/12]████████████████████████████░░░░░░░░░75%|4sInstallingpseudo-scoop[10/12]████████████████████████████████░░░░░░░83%|5spseudo-outlook|pass|pse└─┬C:├── INFO IfyourterminalhasTrueColorsupp YoucRestartinganimation... \ No newline at end of file diff --git a/_examples/header-custom/demo/README.md b/_examples/header-custom/demo/README.md index c8d2ec956..f5031ce31 100644 --- a/_examples/header-custom/demo/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 index c7921ab66..f6d10ba31 100644 --- a/_examples/header-custom/demo/animation.svg +++ b/_examples/header-custom/demo/animation.svg @@ -1,4 +1,4 @@ - This is a custom header! This is a custom header! Restartinganimation... \ No newline at end of file diff --git a/_examples/header/demo/README.md b/_examples/header/demo/README.md index 9ad70d682..30eb7488a 100644 --- a/_examples/header/demo/README.md +++ b/_examples/header/demo/README.md @@ -1,4 +1,4 @@ -# header +# header/demo ![Animation](animation.svg) diff --git a/_examples/header/demo/animation.svg b/_examples/header/demo/animation.svg index 8468f55cd..b82d5dfcd 100644 --- a/_examples/header/demo/animation.svg +++ b/_examples/header/demo/animation.svg @@ -1,4 +1,4 @@ - This is the default header! This is a full-width header. Restartinganimation... \ No newline at end of file diff --git a/_examples/panel/demo/README.md b/_examples/panel/demo/README.md index 220be07bc..96fc214d7 100644 --- a/_examples/panel/demo/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 index aab802acf..4f5355862 100644 --- a/_examples/panel/demo/animation.svg +++ b/_examples/panel/demo/animation.svg @@ -1,4 +1,4 @@ -Thisisthefirstpanel This Hello, World! panel containsmultiplelinesThisisanotherThisisthesecondpanelpanellinewithanewlineRestartinganimation... \ No newline at end of file diff --git a/_examples/paragraph/customized/README.md b/_examples/paragraph/customized/README.md index 3d15cd0a4..e8d112c1f 100644 --- a/_examples/paragraph/customized/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 index 88ea6af5b..85c1aa568 100644 --- a/_examples/paragraph/customized/animation.svg +++ b/_examples/paragraph/customized/animation.svg @@ -1,4 +1,4 @@ -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/demo/README.md b/_examples/paragraph/demo/README.md index 07ad0d57c..2e0167587 100644 --- a/_examples/paragraph/demo/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 index 85fe6c920..6ee2e95db 100644 --- a/_examples/paragraph/demo/animation.svg +++ b/_examples/paragraph/demo/animation.svg @@ -1,4 +1,4 @@ -Thisisthedefaultparagraphprinter.Asyoucansee,nowordsareseparated,butthetextissplitatthespaces.Thisisusefulforcontinuoustextofallkinds.Youcanmanuallychangethelinewidthifyouwantto.Loremipsumdolorsitamet,consetetursadipscingelitr,seddiamnonumyeirmodtemporinviduntutlaboreetdoloremagnaaliquyamThistextiswrittenwiththedefaultPrintln()function.Nointelligentsplittinghere.Loremipsumdolorsitamet,consetetursadipscingelitr,seddiamnonumyeirmodtemporinviduntutlaboreetdoloremagnaaliquyamRestartinganimation... \ No newline at end of file diff --git a/_examples/prefix/demo/README.md b/_examples/prefix/demo/README.md index 3d23fe3ec..d46d8ac63 100644 --- a/_examples/prefix/demo/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 index 3a9282ead..1e5178d5e 100644 --- a/_examples/prefix/demo/animation.svg +++ b/_examples/prefix/demo/animation.svg @@ -1,4 +1,4 @@ - 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/progressbar/demo/README.md b/_examples/progressbar/demo/README.md index 250d14098..3b1306ef3 100644 --- a/_examples/progressbar/demo/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 index cb00e35b8..4bd1215e5 100644 --- a/_examples/progressbar/demo/animation.svg +++ b/_examples/progressbar/demo/animation.svg @@ -1,4 +1,4 @@ - 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[2/12]███████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░17%|1sDownloadingpseudo-chrome[3/12]██████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░25%|1sDownloadingpseudo-outlook[4/12]█████████████░░░░░░░░░░░░░░░░░░░░░░░░33%|1sDownloadingpseudo-explorer[5/12]███████████████░░░░░░░░░░░░░░░░░░░░░42%|1sDownloadingpseudo-dops[5/12]█████████████████░░░░░░░░░░░░░░░░░░░░░░░42%|2sDownloadingpseudo-dops[6/12]████████████████████░░░░░░░░░░░░░░░░░░░░50%|2sDownloadingpseudo-git[7/12]████████████████████████░░░░░░░░░░░░░░░░░58%|2sDownloadingpseudo-vsc[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/section/demo/README.md b/_examples/section/demo/README.md index dd04dbf02..a57d406a3 100644 --- a/_examples/section/demo/README.md +++ b/_examples/section/demo/README.md @@ -1,4 +1,4 @@ -# section +# section/demo ![Animation](animation.svg) diff --git a/_examples/section/demo/animation.svg b/_examples/section/demo/animation.svg index cbc9e3a7f..1cf2c528d 100644 --- a/_examples/section/demo/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 diff --git a/_examples/spinner/demo/README.md b/_examples/spinner/demo/README.md index 95583c282..674548da8 100644 --- a/_examples/spinner/demo/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 index 4403516f5..eaf9ac47b 100644 --- a/_examples/spinner/demo/animation.svg +++ b/_examples/spinner/demo/animation.svg @@ -1,4 +1,4 @@ -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'sreallymuchIt'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/style/demo/README.md b/_examples/style/demo/README.md index 1b11de92e..9aa6b06df 100644 --- a/_examples/style/demo/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 index 6db76bdd8..40928f086 100644 --- a/_examples/style/demo/animation.svg +++ b/_examples/style/demo/animation.svg @@ -1,4 +1,4 @@ -Hello, World!Hello, World!Restartinganimation... \ No newline at end of file diff --git a/_examples/table/demo/README.md b/_examples/table/demo/README.md index 23ed3fba8..2150f3622 100644 --- a/_examples/table/demo/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 index 6754d9665..74d2d3a74 100644 --- a/_examples/table/demo/animation.svg +++ b/_examples/table/demo/animation.svg @@ -1,4 +1,4 @@ -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/theme/demo/README.md b/_examples/theme/demo/README.md index 2d4de7678..5e15c3299 100644 --- a/_examples/theme/demo/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 index 993d43409..f9128a8b4 100644 --- a/_examples/theme/demo/animation.svg +++ b/_examples/theme/demo/animation.svg @@ -1,4 +1,4 @@ - INFO Thesearethedefaultthemestyles. Youcanmodifythemeasilytoyourpersonalpreference, orcreatenewthemesfromscratch:)PrimaryStyleSecondaryStyleHighlightStyleInfoMessageStyleInfoPrefixStyleSuccessMessageStyleSuccessPrefixStyleWarningMessageStyleWarningPrefixStyleErrorMessageStyleErrorPrefixStyleFatalMessageStyleFatalPrefixStyleDescriptionMessageStyleDescriptionPrefixStyleScopeStyleProgressbarBarStyleProgressbarTitleStyleHeaderTextStyleHeaderBackgroundStyleSpinnerStyleSpinnerTextStyleTimerStyleTableStyleTableHeaderStyleTableSeparatorStyleSectionStyleBulletListTextStyleBulletListBulletStyleTreeStyleTreeTextStyleLetterStyleDebugMessageStyleDebugPrefixStyleBoxStyleBoxTextStyleBarLabelStyleBarStyleRestartinganimation... \ No newline at end of file diff --git a/_examples/tree/demo/README.md b/_examples/tree/demo/README.md index 7a9eab639..fad742f82 100644 --- a/_examples/tree/demo/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 index b2bb8015c..13f4917e6 100644 --- a/_examples/tree/demo/animation.svg +++ b/_examples/tree/demo/animation.svg @@ -1,4 +1,4 @@ -├─┬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/ci/main.go b/ci/main.go index 6b1d7b5e4..1e9b9bedb 100644 --- a/ci/main.go +++ b/ci/main.go @@ -43,32 +43,36 @@ 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 _, file := range files { + log.Output(2, "Section: "+file.Name()) + examples, _ := os.ReadDir("./_examples/" + file.Name()) + + for _, f := range examples { + processFile(file.Name() + "/" + f.Name()) + log.Output(2, "## Generating readme for example: "+f.Name()) + exampleCode, err := os.ReadFile("./_examples/" + file.Name() + "/" + f.Name() + "/main.go") + if err != nil { + log.Panic(err) + } + + readmeExamples += "### " + file.Name() + "/" + f.Name() + "\n\n" + readmeExamples += "![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/" + file.Name() + "/" + 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" } - - 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" } + log.Output(3, "### Generating examples README") + examplesReadme, err := os.ReadFile("./_examples/README.md") + examplesReadmeContent := string(examplesReadme) + examplesReadmeContent = writeBetween("examples", examplesReadmeContent, "\n"+readmeExamples+"\n") + os.WriteFile("./_examples/README.md", []byte(examplesReadmeContent), 0755) + log.Output(3, "### Appending examples to root README.md") readmeContent, err := os.ReadFile("./README.md") @@ -117,34 +121,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 +156,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 +191,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..88cd51f65 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,9 @@ func main() {
-### barchart-mixed-values +### barchart/mixed-values -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart-mixed-values/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/barchart/mixed-values/animation.svg)
@@ -302,9 +302,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 +342,36 @@ func main() {
-### bigtext +### basictext/demo -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bigtext/animation.svg) +![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)
@@ -376,9 +403,9 @@ func main() {
-### box +### box/demo -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/box/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/box/demo/animation.svg)
@@ -408,9 +435,37 @@ func main() {
-### bulletlist +### 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/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/demo/animation.svg)
@@ -441,9 +496,9 @@ func main() {
-### bulletlist-custom +### center/demo -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist-custom/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/center/demo/animation.svg)
@@ -452,26 +507,25 @@ 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() + 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") } ```
-### 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 +537,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 +592,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 +691,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 +707,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 +733,41 @@ func randomInt(min, max int) int {
-### disable-color +### coloring/disable-output -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/disable-color/animation.svg) +![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)
@@ -693,7 +793,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() @@ -834,9 +934,89 @@ func randomInt(min, max int) int {
-### disable-output +### 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/disable-output/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/override-default-printers/animation.svg)
@@ -848,27 +1028,51 @@ 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!") - } + // Print default error. + pterm.Error.Println("This is the default Error") - pterm.Printf("Printing something... [%d/%d]\n", i, 15) + // 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-styling +### coloring/print-color-rgb -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/disable-styling/animation.svg) +![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)
@@ -894,7 +1098,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 +1196,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 +1213,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 +1239,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 +1263,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 +1303,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 +1331,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 +1345,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 +1362,9 @@ func main() {
-### paragraph-custom +### paragraph/demo -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/paragraph-custom/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/paragraph/demo/animation.svg)
@@ -1203,15 +1376,15 @@ 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, " + + // 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 text without a paragraph printer. + // 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") } @@ -1220,9 +1393,9 @@ func main() {
-### prefix +### prefix/demo -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/prefix/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/prefix/demo/animation.svg)
@@ -1251,182 +1424,9 @@ func main() {
-### print-basic-text - -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/print-basic-text/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!") -} - -``` - -
- -### 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 - -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!") -} - -``` - -
- -### print-with-color +### progressbar/demo -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/print-with-color/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") -} - -``` - -
- -### progressbar - -![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 +1462,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 +1491,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 +1538,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 +1565,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 +1589,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 +1603,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 +1647,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)
From 357292c2d7a79143686df3509f3e6b6dbed2132a Mon Sep 17 00:00:00 2001 From: MarvinJWendt Date: Thu, 21 Apr 2022 01:59:00 +0200 Subject: [PATCH 5/7] updated example generation --- _examples/area/README.md | 34 +++++ _examples/area/demo/animation.svg | 2 +- _examples/barchart/README.md | 128 ++++++++++++++++++ _examples/barchart/demo/animation.svg | 2 +- _examples/barchart/mixed-values/animation.svg | 2 +- .../barchart/negative-values/animation.svg | 2 +- _examples/basictext/README.md | 27 ++++ _examples/basictext/demo/animation.svg | 10 ++ _examples/bigtext/README.md | 34 +++++ _examples/bigtext/demo/animation.svg | 2 +- _examples/box/README.md | 32 +++++ _examples/box/demo/animation.svg | 2 +- _examples/bulletlist/README.md | 61 +++++++++ _examples/bulletlist/customized/animation.svg | 2 +- _examples/bulletlist/demo/animation.svg | 2 +- _examples/center/README.md | 27 ++++ _examples/center/demo/animation.svg | 2 +- _examples/coloring/demo/animation.svg | 2 +- .../coloring/disable-color/animation.svg | 2 +- .../coloring/disable-output/animation.svg | 2 +- .../coloring/disable-styling/animation.svg | 2 +- _examples/coloring/fade-colors/animation.svg | 2 +- _examples/header/README.md | 24 ++++ _examples/header/demo/animation.svg | 2 +- ci/main.go | 36 ++--- 25 files changed, 412 insertions(+), 31 deletions(-) create mode 100644 _examples/area/README.md create mode 100644 _examples/barchart/README.md create mode 100644 _examples/basictext/README.md create mode 100644 _examples/basictext/demo/animation.svg create mode 100644 _examples/bigtext/README.md create mode 100644 _examples/box/README.md create mode 100644 _examples/bulletlist/README.md create mode 100644 _examples/center/README.md create mode 100644 _examples/header/README.md diff --git a/_examples/area/README.md b/_examples/area/README.md new file mode 100644 index 000000000..ddcdda210 --- /dev/null +++ b/_examples/area/README.md @@ -0,0 +1,34 @@ +### 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() +} + +``` + +
+ diff --git a/_examples/area/demo/animation.svg b/_examples/area/demo/animation.svg index c0115e8d4..c2828ea07 100644 --- a/_examples/area/demo/animation.svg +++ b/_examples/area/demo/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(102,194,205)}.g{white-space:pre}.h{fill:rgb(126,231,233);white-space:pre}.i{fill:rgb(160,160,160);white-space:pre}.j{fill:transparent}.l{animation-duration:15.467435s;animation-iteration-count:infinite;animation-name:k;animation-timing-function:steps(1,end)}@keyframes k{0%{transform:translateX(-0px)}9.4%{transform:translateX(-252px)}9.4%{transform:translateX(-504px)}9.4%{transform:translateX(-756px)}15.9%{transform:translateX(-1008px)}15.9%{transform:translateX(-1260px)}22.4%{transform:translateX(-1512px)}22.4%{transform:translateX(-1764px)}28.9%{transform:translateX(-2016px)}28.9%{transform:translateX(-2268px)}35.3%{transform:translateX(-2520px)}35.3%{transform:translateX(-2772px)}41.8%{transform:translateX(-3024px)}41.8%{transform:translateX(-3276px)}48.3%{transform:translateX(-3528px)}48.3%{transform:translateX(-3780px)}54.7%{transform:translateX(-4032px)}54.7%{transform:translateX(-4284px)}61.2%{transform:translateX(-4536px)}61.2%{transform:translateX(-4788px)}67.7%{transform:translateX(-5040px)}67.7%{transform:translateX(-5292px)}100%{transform:translateX(-5544px)}} INFO Theprevioustextwillstayinplace,whiletheareaupdates.█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████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(102,194,205)}.g{white-space:pre}.h{fill:rgb(126,231,233);white-space:pre}.i{fill:rgb(160,160,160);white-space:pre}.j{fill:transparent}.l{animation-duration:15.721856s;animation-iteration-count:infinite;animation-name:k;animation-timing-function:steps(1,end)}@keyframes k{0%{transform:translateX(-0px)}10.9%{transform:translateX(-252px)}10.9%{transform:translateX(-504px)}10.9%{transform:translateX(-756px)}17.3%{transform:translateX(-1008px)}17.3%{transform:translateX(-1260px)}23.6%{transform:translateX(-1512px)}23.6%{transform:translateX(-1764px)}30%{transform:translateX(-2016px)}30%{transform:translateX(-2268px)}36.4%{transform:translateX(-2520px)}36.4%{transform:translateX(-2772px)}42.7%{transform:translateX(-3024px)}42.7%{transform:translateX(-3276px)}49.1%{transform:translateX(-3528px)}49.1%{transform:translateX(-3780px)}55.5%{transform:translateX(-4032px)}55.5%{transform:translateX(-4284px)}61.8%{transform:translateX(-4536px)}61.8%{transform:translateX(-4788px)}68.2%{transform:translateX(-5040px)}68.2%{transform:translateX(-5292px)}100%{transform:translateX(-5544px)}} INFO Theprevioustextwillstayinplace,whiletheareaupdates.██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████Restartinganimation... \ No newline at end of file diff --git a/_examples/barchart/README.md b/_examples/barchart/README.md new file mode 100644 index 000000000..b565646d9 --- /dev/null +++ b/_examples/barchart/README.md @@ -0,0 +1,128 @@ +### 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() +} + +``` + +
+ diff --git a/_examples/barchart/demo/animation.svg b/_examples/barchart/demo/animation.svg index a84b59d44..39cf9d094 100644 --- a/_examples/barchart/demo/animation.svg +++ b/_examples/barchart/demo/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(102,194,205)}.g{white-space:pre}.h{fill:rgb(126,231,233);white-space:pre}.i{fill:rgb(0,198,255);white-space:pre}.j{fill:transparent}.l{animation-duration:6.48438s;animation-iteration-count:infinite;animation-name:k;animation-timing-function:steps(1,end)}.m{fill:rgb(160,160,160);white-space:pre}@keyframes k{0%{transform:translateX(-0px)}22.8%{transform:translateX(-252px)}22.9%{transform:translateX(-504px)}22.9%{transform:translateX(-756px)}22.9%{transform:translateX(-1008px)}22.9%{transform:translateX(-1260px)}22.9%{transform:translateX(-1512px)}100%{transform:translateX(-1764px)}} INFO Chartexamplewithpositiveonlyvalues(barsuse100%ofchartarea)████████████Bar1Bar2LongerLabelBar1█████████████████████████████████████Bar2██████████████████████LongerLabel█████████████████████████████████████████████████████Bar2LongerLabel██████████████████████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(102,194,205)}.g{white-space:pre}.h{fill:rgb(126,231,233);white-space:pre}.i{fill:rgb(0,198,255);white-space:pre}.j{fill:transparent}.l{animation-duration:6.711552s;animation-iteration-count:infinite;animation-name:k;animation-timing-function:steps(1,end)}.m{fill:rgb(160,160,160);white-space:pre}@keyframes k{0%{transform:translateX(-0px)}25.5%{transform:translateX(-252px)}25.5%{transform:translateX(-504px)}25.5%{transform:translateX(-756px)}25.5%{transform:translateX(-1008px)}25.5%{transform:translateX(-1260px)}25.5%{transform:translateX(-1512px)}100%{transform:translateX(-1764px)}} INFO Chartexamplewithpositiveonlyvalues(barsuse100%ofchartarea)████████████Bar1Bar2LongerLabelBar1█████████████████████████████████████Bar2██████████████████████LongerLabel█████████████████████████████████████████████████████Bar2LongerLabel██████████████████████Restartinganimation... \ No newline at end of file diff --git a/_examples/barchart/mixed-values/animation.svg b/_examples/barchart/mixed-values/animation.svg index 5488dbbe5..2f3ffac8f 100644 --- a/_examples/barchart/mixed-values/animation.svg +++ b/_examples/barchart/mixed-values/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(0,198,255);white-space:pre}.i{fill:rgb(126,231,233);white-space:pre}.j{fill:transparent}.l{animation-duration:6.640202s;animation-iteration-count:infinite;animation-name:k;animation-timing-function:steps(1,end)}@keyframes k{0%{transform:translateX(-0px)}24.7%{transform:translateX(-252px)}24.7%{transform:translateX(-504px)}24.7%{transform:translateX(-756px)}24.7%{transform:translateX(-1008px)}24.7%{transform:translateX(-1260px)}100%{transform:translateX(-1512px)}}#Chartexamplewithmixedvalues(notescreenspaceusageincasewhenABSOLUTEvaluesofnegativeandpositivepartsarediffertoomuch)257██████████████████-3-2Bar1Bar2Bar3Bar4LongerLabelBar1███████2Bar2███████████-3Bar3███████-2Bar4██████████████████5LongerLabel██████████████████████████7Bar4Restartinganimation... \ 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(0,198,255);white-space:pre}.i{fill:rgb(126,231,233);white-space:pre}.j{fill:transparent}.l{animation-duration:6.819075s;animation-iteration-count:infinite;animation-name:k;animation-timing-function:steps(1,end)}@keyframes k{0%{transform:translateX(-0px)}26.6%{transform:translateX(-252px)}26.7%{transform:translateX(-504px)}26.7%{transform:translateX(-756px)}26.7%{transform:translateX(-1008px)}26.7%{transform:translateX(-1260px)}100%{transform:translateX(-1512px)}}#Chartexamplewithmixedvalues(notescreenspaceusageincasewhenABSOLUTEvaluesofnegativeandpositivepartsarediffertoomuch)257██████████████████-3-2Bar1Bar2Bar3Bar4LongerLabelBar1███████2Bar2███████████-3Bar3███████-2Bar4██████████████████5LongerLabel██████████████████████████7Bar4Restartinganimation... \ No newline at end of file diff --git a/_examples/barchart/negative-values/animation.svg b/_examples/barchart/negative-values/animation.svg index d2348c512..aebb652cf 100644 --- a/_examples/barchart/negative-values/animation.svg +++ b/_examples/barchart/negative-values/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(102,194,205)}.g{white-space:pre}.h{fill:rgb(126,231,233);white-space:pre}.i{fill:rgb(0,198,255);white-space:pre}.j{fill:rgb(160,160,160);white-space:pre}.k{fill:transparent}.m{animation-duration:6.557405s;animation-iteration-count:infinite;animation-name:l;animation-timing-function:steps(1,end)}@keyframes l{0%{transform:translateX(-0px)}23.7%{transform:translateX(-252px)}23.7%{transform:translateX(-504px)}23.7%{transform:translateX(-756px)}23.7%{transform:translateX(-1008px)}23.7%{transform:translateX(-1260px)}23.8%{transform:translateX(-1512px)}100%{transform:translateX(-1764px)}} INFO Chartexamplewithnegativeonlyvalues(barsuse100%ofchartarea)████████████-5-3-7Bar1Bar2LongerLabelBar1█████████████████████████████████████-5Bar2██████████████████████-3LongerLabel█████████████████████████████████████████████████████-7Bar2LongerLabel█████████████████████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(102,194,205)}.g{white-space:pre}.h{fill:rgb(126,231,233);white-space:pre}.i{fill:rgb(0,198,255);white-space:pre}.j{fill:rgb(160,160,160);white-space:pre}.k{fill:transparent}.m{animation-duration:6.734918s;animation-iteration-count:infinite;animation-name:l;animation-timing-function:steps(1,end)}@keyframes l{0%{transform:translateX(-0px)}25.7%{transform:translateX(-252px)}25.7%{transform:translateX(-504px)}25.7%{transform:translateX(-756px)}25.8%{transform:translateX(-1008px)}25.8%{transform:translateX(-1260px)}25.8%{transform:translateX(-1512px)}100%{transform:translateX(-1764px)}} INFO Chartexamplewithnegativeonlyvalues(barsuse100%ofchartarea)████████████-5-3-7Bar1Bar2LongerLabelBar1█████████████████████████████████████-5Bar2██████████████████████-3LongerLabel█████████████████████████████████████████████████████-7Bar2LongerLabel█████████████████████Restartinganimation... \ No newline at end of file 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/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/bigtext/README.md b/_examples/bigtext/README.md new file mode 100644 index 000000000..99d195ca5 --- /dev/null +++ b/_examples/bigtext/README.md @@ -0,0 +1,34 @@ +### 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() +} + +``` + +
+ diff --git a/_examples/bigtext/demo/animation.svg b/_examples/bigtext/demo/animation.svg index 9b85ab29f..9a6d705ad 100644 --- a/_examples/bigtext/demo/animation.svg +++ b/_examples/bigtext/demo/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(0,198,255);white-space:pre}.h{fill:rgb(234,89,246);white-space:pre}.i{fill:transparent}.k{animation-duration:6.673623s;animation-iteration-count:infinite;animation-name:j;animation-timing-function:steps(1,end)}@keyframes j{0%{transform:translateX(-0px)}25.1%{transform:translateX(-252px)}25.1%{transform:translateX(-504px)}25.1%{transform:translateX(-756px)}100%{transform:translateX(-1008px)}}██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████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(160,160,160);white-space:pre}.g{fill:rgb(0,198,255);white-space:pre}.h{fill:rgb(234,89,246);white-space:pre}.i{fill:transparent}.k{animation-duration:6.750013s;animation-iteration-count:infinite;animation-name:j;animation-timing-function:steps(1,end)}@keyframes j{0%{transform:translateX(-0px)}25.9%{transform:translateX(-252px)}25.9%{transform:translateX(-504px)}25.9%{transform:translateX(-756px)}100%{transform:translateX(-1008px)}}██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████Restartinganimation... \ No newline at end of file diff --git a/_examples/box/README.md b/_examples/box/README.md new file mode 100644 index 000000000..06272a26b --- /dev/null +++ b/_examples/box/README.md @@ -0,0 +1,32 @@ +### 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) +} + +``` + +
+ diff --git a/_examples/box/demo/animation.svg b/_examples/box/demo/animation.svg index ac0746ca3..14a1b6a13 100644 --- a/_examples/box/demo/animation.svg +++ b/_examples/box/demo/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(102,194,205)}.g{white-space:pre}.h{fill:rgb(126,231,233);white-space:pre}.i{fill:rgb(160,160,160);white-space:pre}.j{fill:transparent}.l{animation-duration:6.479913s;animation-iteration-count:infinite;animation-name:k;animation-timing-function:steps(1,end)}@keyframes k{0%{transform:translateX(-0px)}22.8%{transform:translateX(-252px)}22.8%{transform:translateX(-504px)}22.8%{transform:translateX(-756px)}22.8%{transform:translateX(-1008px)}22.8%{transform:translateX(-1260px)}22.8%{transform:translateX(-1512px)}22.8%{transform:translateX(-1764px)}22.8%{transform:translateX(-2016px)}22.8%{transform:translateX(-2268px)}22.8%{transform:translateX(-2520px)}22.8%{transform:translateX(-2772px)}22.8%{transform:translateX(-3024px)}22.8%{transform:translateX(-3276px)}100%{transform:translateX(-3528px)}} 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 +}.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(102,194,205)}.g{white-space:pre}.h{fill:rgb(126,231,233);white-space:pre}.i{fill:rgb(160,160,160);white-space:pre}.j{fill:transparent}.l{animation-duration:6.679119s;animation-iteration-count:infinite;animation-name:k;animation-timing-function:steps(1,end)}@keyframes k{0%{transform:translateX(-0px)}25.1%{transform:translateX(-252px)}25.1%{transform:translateX(-504px)}25.1%{transform:translateX(-756px)}25.1%{transform:translateX(-1008px)}25.1%{transform:translateX(-1260px)}25.1%{transform:translateX(-1512px)}25.1%{transform:translateX(-1764px)}25.1%{transform:translateX(-2016px)}25.1%{transform:translateX(-2268px)}25.1%{transform:translateX(-2520px)}25.1%{transform:translateX(-2772px)}25.1%{transform:translateX(-3024px)}25.1%{transform:translateX(-3276px)}100%{transform:translateX(-3528px)}} 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/bulletlist/README.md b/_examples/bulletlist/README.md new file mode 100644 index 000000000..eab0c73e2 --- /dev/null +++ b/_examples/bulletlist/README.md @@ -0,0 +1,61 @@ +### 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() +} + +``` + +
+ diff --git a/_examples/bulletlist/customized/animation.svg b/_examples/bulletlist/customized/animation.svg index 8f51665c3..a36bfa8f7 100644 --- a/_examples/bulletlist/customized/animation.svg +++ b/_examples/bulletlist/customized/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(255,0,4);white-space:pre}.g{fill:rgb(0,71,255);white-space:pre}.h{fill:rgb(255,255,255);white-space:pre}.i{fill:rgb(124,255,0);white-space:pre}.j{fill:rgb(255,241,0);white-space:pre}.k{fill:rgb(0,198,255);white-space:pre}.l{fill:transparent}.n{animation-duration:6.6181909999999995s;animation-iteration-count:infinite;animation-name:m;animation-timing-function:steps(1,end)}.o{fill:rgb(160,160,160);white-space:pre}@keyframes m{0%{transform:translateX(-0px)}24.5%{transform:translateX(-252px)}100%{transform:translateX(-504px)}}Blue-Green>CyanRestartinganimation... \ 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(255,0,4);white-space:pre}.g{fill:rgb(0,71,255);white-space:pre}.h{fill:rgb(255,255,255);white-space:pre}.i{fill:rgb(124,255,0);white-space:pre}.j{fill:rgb(255,241,0);white-space:pre}.k{fill:rgb(0,198,255);white-space:pre}.l{fill:transparent}.n{animation-duration:6.561402s;animation-iteration-count:infinite;animation-name:m;animation-timing-function:steps(1,end)}.o{fill:rgb(160,160,160);white-space:pre}@keyframes m{0%{transform:translateX(-0px)}23.8%{transform:translateX(-252px)}100%{transform:translateX(-504px)}}Blue-Green>CyanRestartinganimation... \ No newline at end of file diff --git a/_examples/bulletlist/demo/animation.svg b/_examples/bulletlist/demo/animation.svg index 3549ce4e0..4f1b76ebb 100644 --- a/_examples/bulletlist/demo/animation.svg +++ b/_examples/bulletlist/demo/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(104,104,104);white-space:pre}.g{fill:rgb(160,160,160);white-space:pre}.h{fill:transparent}.j{animation-duration:6.382899s;animation-iteration-count:infinite;animation-name:i;animation-timing-function:steps(1,end)}@keyframes i{0%{transform:translateX(-0px)}21.7%{transform:translateX(-252px)}100%{transform:translateX(-504px)}}Level0Level1Level20123Restartinganimation... \ 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(104,104,104);white-space:pre}.g{fill:rgb(160,160,160);white-space:pre}.h{fill:transparent}.j{animation-duration:6.725628s;animation-iteration-count:infinite;animation-name:i;animation-timing-function:steps(1,end)}@keyframes i{0%{transform:translateX(-0px)}25.7%{transform:translateX(-252px)}100%{transform:translateX(-504px)}}Level0Level1Level20123Restartinganimation... \ No newline at end of file diff --git a/_examples/center/README.md b/_examples/center/README.md new file mode 100644 index 000000000..f2ec4b872 --- /dev/null +++ b/_examples/center/README.md @@ -0,0 +1,27 @@ +### 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") +} + +``` + +
+ diff --git a/_examples/center/demo/animation.svg b/_examples/center/demo/animation.svg index 9f0af23e8..bada96dc7 100644 --- a/_examples/center/demo/animation.svg +++ b/_examples/center/demo/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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:transparent}.i{animation-duration:6.556094s;animation-iteration-count:infinite;animation-name:h;animation-timing-function:steps(1,end)}@keyframes h{0%{transform:translateX(-0px)}23.7%{transform:translateX(-252px)}23.7%{transform:translateX(-504px)}23.7%{transform:translateX(-756px)}100%{transform:translateX(-1008px)}}Thistextiscentered!Itcenteresthewholeblockbydefault.Inthatwayyoucandostufflikethis:███████████████████████████████████████████████████████████████████████████████████████████████████████████████████Thistextiscentered!ButeachlineiscenteredseparatelyRestartinganimation... \ 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:transparent}.i{animation-duration:6.710663s;animation-iteration-count:infinite;animation-name:h;animation-timing-function:steps(1,end)}@keyframes h{0%{transform:translateX(-0px)}25.5%{transform:translateX(-252px)}25.5%{transform:translateX(-504px)}25.5%{transform:translateX(-756px)}100%{transform:translateX(-1008px)}}Thistextiscentered!Itcenteresthewholeblockbydefault.Inthatwayyoucandostufflikethis:███████████████████████████████████████████████████████████████████████████████████████████████████████████████████Thistextiscentered!ButeachlineiscenteredseparatelyRestartinganimation... \ No newline at end of file diff --git a/_examples/coloring/demo/animation.svg b/_examples/coloring/demo/animation.svg index c488418a9..84b40057a 100644 --- a/_examples/coloring/demo/animation.svg +++ b/_examples/coloring/demo/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(255,0,4);white-space:pre}.g{fill:rgb(124,255,0);white-space:pre}.h{fill:rgb(0,198,255);white-space:pre}.i{white-space:pre}.j{fill:rgb(255,241,0);white-space:pre}.k{fill:rgb(0,71,255);white-space:pre}.l{fill:rgb(255,0,255);white-space:pre}.m{fill:rgb(207,207,207);white-space:pre}.n{fill:rgb(243,86,86);white-space:pre}.o{fill:rgb(127,253,127);white-space:pre}.p{fill:rgb(220,239,139);white-space:pre}.q{fill:rgb(152,161,254);white-space:pre}.r{fill:rgb(234,89,246);white-space:pre}.s{fill:rgb(126,231,233);white-space:pre}.t{fill:rgb(255,255,255);white-space:pre}.u{fill:transparent}.w{animation-duration:6.379278s;animation-iteration-count:infinite;animation-name:v;animation-timing-function:steps(1,end)}.x{fill:rgb(160,160,160);white-space:pre}@keyframes v{0%{transform:translateX(-0px)}21.6%{transform:translateX(-252px)}21.6%{transform:translateX(-504px)}100%{transform:translateX(-756px)}}Hello,World!Evennestedcolorsaresupported!FgBlackFgRedFgGreenFgYellowFgBlueFgMagentaFgCyanFgWhiteFgLightRedFgLightGreenFgLightYellowFgLightBlueFgLightMagentaFgLightCyanFgLightWhiteRestartinganimation... \ 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(255,0,4);white-space:pre}.g{fill:rgb(124,255,0);white-space:pre}.h{fill:rgb(0,198,255);white-space:pre}.i{white-space:pre}.j{fill:rgb(255,241,0);white-space:pre}.k{fill:rgb(0,71,255);white-space:pre}.l{fill:rgb(255,0,255);white-space:pre}.m{fill:rgb(207,207,207);white-space:pre}.n{fill:rgb(243,86,86);white-space:pre}.o{fill:rgb(127,253,127);white-space:pre}.p{fill:rgb(220,239,139);white-space:pre}.q{fill:rgb(152,161,254);white-space:pre}.r{fill:rgb(234,89,246);white-space:pre}.s{fill:rgb(126,231,233);white-space:pre}.t{fill:rgb(255,255,255);white-space:pre}.u{fill:transparent}.w{animation-duration:6.688642s;animation-iteration-count:infinite;animation-name:v;animation-timing-function:steps(1,end)}.x{fill:rgb(160,160,160);white-space:pre}@keyframes v{0%{transform:translateX(-0px)}25.2%{transform:translateX(-252px)}25.2%{transform:translateX(-504px)}100%{transform:translateX(-756px)}}Hello,World!Evennestedcolorsaresupported!FgBlackFgRedFgGreenFgYellowFgBlueFgMagentaFgCyanFgWhiteFgLightRedFgLightGreenFgLightYellowFgLightBlueFgLightMagentaFgLightCyanFgLightWhiteRestartinganimation... \ No newline at end of file diff --git a/_examples/coloring/disable-color/animation.svg b/_examples/coloring/disable-color/animation.svg index effa6d3ca..0b9937164 100644 --- a/_examples/coloring/disable-color/animation.svg +++ b/_examples/coloring/disable-color/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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:transparent}.i{animation-duration:39.577941s;animation-iteration-count:infinite;animation-name:h;animation-timing-function:steps(1,end)}@keyframes h{0%{transform:translateX(-0px)}3.92%{transform:translateX(-252px)}3.92%{transform:translateX(-504px)}4.43%{transform:translateX(-756px)}4.94%{transform:translateX(-1008px)}5.44%{transform:translateX(-1260px)}5.95%{transform:translateX(-1512px)}6.45%{transform:translateX(-1764px)}6.45%{transform:translateX(-2016px)}6.96%{transform:translateX(-2268px)}7.47%{transform:translateX(-2520px)}7.97%{transform:translateX(-2772px)}8.48%{transform:translateX(-3024px)}8.98%{transform:translateX(-3276px)}8.99%{transform:translateX(-3528px)}9.49%{transform:translateX(-3780px)}10%{transform:translateX(-4032px)}10.51%{transform:translateX(-4284px)}11.01%{transform:translateX(-4536px)}11.5%{transform:translateX(-4788px)}11.52%{transform:translateX(-5040px)}12.03%{transform:translateX(-5292px)}12.53%{transform:translateX(-5544px)}13.04%{transform:translateX(-5796px)}13.55%{transform:translateX(-6048px)}14.03%{transform:translateX(-6300px)}14.05%{transform:translateX(-6552px)}14.56%{transform:translateX(-6804px)}15.07%{transform:translateX(-7056px)}15.57%{transform:translateX(-7308px)}16.08%{transform:translateX(-7560px)}16.56%{transform:translateX(-7812px)}16.59%{transform:translateX(-8064px)}17.09%{transform:translateX(-8316px)}17.6%{transform:translateX(-8568px)}18.1%{transform:translateX(-8820px)}18.61%{transform:translateX(-9072px)}19.09%{transform:translateX(-9324px)}19.12%{transform:translateX(-9576px)}19.62%{transform:translateX(-9828px)}20.13%{transform:translateX(-10080px)}20.64%{transform:translateX(-10332px)}21.14%{transform:translateX(-10584px)}21.61%{transform:translateX(-10836px)}21.65%{transform:translateX(-11088px)}22.16%{transform:translateX(-11340px)}22.66%{transform:translateX(-11592px)}23.17%{transform:translateX(-11844px)}23.68%{transform:translateX(-12096px)}24.14%{transform:translateX(-12348px)}24.18%{transform:translateX(-12600px)}24.69%{transform:translateX(-12852px)}25.2%{transform:translateX(-13104px)}25.7%{transform:translateX(-13356px)}26.21%{transform:translateX(-13608px)}26.67%{transform:translateX(-13860px)}26.72%{transform:translateX(-14112px)}27.22%{transform:translateX(-14364px)}27.73%{transform:translateX(-14616px)}28.24%{transform:translateX(-14868px)}28.74%{transform:translateX(-15120px)}29.2%{transform:translateX(-15372px)}29.25%{transform:translateX(-15624px)}29.76%{transform:translateX(-15876px)}30.26%{transform:translateX(-16128px)}30.77%{transform:translateX(-16380px)}31.27%{transform:translateX(-16632px)}31.73%{transform:translateX(-16884px)}31.78%{transform:translateX(-17136px)}32.29%{transform:translateX(-17388px)}32.79%{transform:translateX(-17640px)}33.3%{transform:translateX(-17892px)}33.81%{transform:translateX(-18144px)}34.25%{transform:translateX(-18396px)}34.31%{transform:translateX(-18648px)}34.82%{transform:translateX(-18900px)}35.33%{transform:translateX(-19152px)}35.83%{transform:translateX(-19404px)}36.34%{transform:translateX(-19656px)}36.78%{transform:translateX(-19908px)}36.85%{transform:translateX(-20160px)}37.35%{transform:translateX(-20412px)}37.86%{transform:translateX(-20664px)}38.37%{transform:translateX(-20916px)}38.87%{transform:translateX(-21168px)}39.31%{transform:translateX(-21420px)}39.38%{transform:translateX(-21672px)}39.89%{transform:translateX(-21924px)}40.39%{transform:translateX(-22176px)}40.9%{transform:translateX(-22428px)}41.41%{transform:translateX(-22680px)}41.84%{transform:translateX(-22932px)}41.84%{transform:translateX(-23184px)}44.36%{transform:translateX(-23436px)}44.37%{transform:translateX(-23688px)}45.63%{transform:translateX(-23940px)}45.63%{transform:translateX(-24192px)}46.9%{transform:translateX(-24444px)}46.9%{transform:translateX(-24696px)}48.16%{transform:translateX(-24948px)}48.16%{transform:translateX(-25200px)}49.43%{transform:translateX(-25452px)}49.43%{transform:translateX(-25704px)}50.69%{transform:translateX(-25956px)}50.69%{transform:translateX(-26208px)}51.96%{transform:translateX(-26460px)}51.96%{transform:translateX(-26712px)}53.22%{transform:translateX(-26964px)}53.22%{transform:translateX(-27216px)}54.49%{transform:translateX(-27468px)}54.49%{transform:translateX(-27720px)}55.76%{transform:translateX(-27972px)}55.76%{transform:translateX(-28224px)}57.02%{transform:translateX(-28476px)}57.02%{transform:translateX(-28728px)}58.29%{transform:translateX(-28980px)}58.29%{transform:translateX(-29232px)}59.55%{transform:translateX(-29484px)}64.61%{transform:translateX(-29736px)}64.61%{transform:translateX(-29988px)}74.72%{transform:translateX(-30240px)}74.72%{transform:translateX(-30492px)}84.84%{transform:translateX(-30744px)}84.84%{transform:translateX(-30996px)}87.37%{transform:translateX(-31248px)}100%{transform:translateX(-31500px)}}███████████████████████████████████████████████████████████████████████████████████████████████████████████████████PTDP-PTermDemoProgramINFOThisanimationwasgeneratedwiththelatestversionofPTerm!PTermworksonnearlyeveryterminalandoperatingsystem.It'ssupereasytouse!Ifyouwant,youcancustomizeeverything:)Youcanseethecodeofthisdemointhe./_examples/demodirectory.Thisdemowasupdatedat:21Apr2022-01:43:51CESTPseudoApplicationcreatedwithPTerm#InstallingpseudoprogramsSUCCESSInstallingpseudo-excelSUCCESSInstallingpseudo-photoshopSUCCESSInstallingpseudo-chromeSUCCESSInstallingpseudo-outlookSUCCESSInstallingpseudo-explorerSUCCESSInstallingpseudo-dopsSUCCESSInstallingpseudo-gitSUCCESSInstallingpseudo-vscSUCCESSInstallingpseudo-intellijWARNINGCouldnotinstallpseudo-minecraftThecompanypolicyforbidsgames.SUCCESSInstallingpseudo-scoopSUCCESSInstallingpseudo-chocolateyInstallingpseudo-chocolatey[11/12]███████████████████████████████░░░92%|6s##ProgramInstallReportProgramName|Status|Sizepseudo-excel|pass|174mbpseudo-photoshop|pass|120mbpseudo-chrome|pass|147mbpseudo-outlook|pass|52mbpseudo-explorer|pass|189mbpseudo-dops|pass|7mbpseudo-git|pass|46mbpseudo-vsc|pass|42mbpseudo-intellij|pass|190mbpseudo-minecraft|fail|0mbpseudo-scoop|pass|126mbpseudo-chocolatey|pass|25mb├──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:)#BulletListPrinterGoodbyeHaveaniceday!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[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[8/12]████████████████████████████░░░░░░░░░░░░░░67%|4sInstallingpseudo-intellij[9/12]████████████████████████████░░░░░░░░░75%|4sInstallingpseudo-minecraft[9/12]███████████████████████████░░░░░░░░░75%|5sInstallingpseudo-scoop[10/12]████████████████████████████████░░░░░░░83%|5s#TreePrinter├──pseudo-excel├──pseudo-photoshop├─┬pseudo-chromeRestartinganimation... \ 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:transparent}.i{animation-duration:39.615504s;animation-iteration-count:infinite;animation-name:h;animation-timing-function:steps(1,end)}@keyframes h{0%{transform:translateX(-0px)}4.01%{transform:translateX(-252px)}4.02%{transform:translateX(-504px)}4.52%{transform:translateX(-756px)}5.03%{transform:translateX(-1008px)}5.53%{transform:translateX(-1260px)}6.04%{transform:translateX(-1512px)}6.54%{transform:translateX(-1764px)}6.54%{transform:translateX(-2016px)}7.05%{transform:translateX(-2268px)}7.56%{transform:translateX(-2520px)}8.06%{transform:translateX(-2772px)}8.57%{transform:translateX(-3024px)}9.06%{transform:translateX(-3276px)}9.07%{transform:translateX(-3528px)}9.58%{transform:translateX(-3780px)}10.09%{transform:translateX(-4032px)}10.59%{transform:translateX(-4284px)}11.1%{transform:translateX(-4536px)}11.59%{transform:translateX(-4788px)}11.6%{transform:translateX(-5040px)}12.11%{transform:translateX(-5292px)}12.62%{transform:translateX(-5544px)}13.12%{transform:translateX(-5796px)}13.63%{transform:translateX(-6048px)}14.11%{transform:translateX(-6300px)}14.13%{transform:translateX(-6552px)}14.64%{transform:translateX(-6804px)}15.15%{transform:translateX(-7056px)}15.65%{transform:translateX(-7308px)}16.16%{transform:translateX(-7560px)}16.64%{transform:translateX(-7812px)}16.66%{transform:translateX(-8064px)}17.17%{transform:translateX(-8316px)}17.68%{transform:translateX(-8568px)}18.18%{transform:translateX(-8820px)}18.69%{transform:translateX(-9072px)}19.16%{transform:translateX(-9324px)}19.19%{transform:translateX(-9576px)}19.7%{transform:translateX(-9828px)}20.21%{transform:translateX(-10080px)}20.71%{transform:translateX(-10332px)}21.22%{transform:translateX(-10584px)}21.69%{transform:translateX(-10836px)}21.72%{transform:translateX(-11088px)}22.23%{transform:translateX(-11340px)}22.74%{transform:translateX(-11592px)}23.24%{transform:translateX(-11844px)}23.75%{transform:translateX(-12096px)}24.21%{transform:translateX(-12348px)}24.25%{transform:translateX(-12600px)}24.76%{transform:translateX(-12852px)}25.27%{transform:translateX(-13104px)}25.77%{transform:translateX(-13356px)}26.28%{transform:translateX(-13608px)}26.74%{transform:translateX(-13860px)}26.78%{transform:translateX(-14112px)}27.29%{transform:translateX(-14364px)}27.8%{transform:translateX(-14616px)}28.3%{transform:translateX(-14868px)}28.81%{transform:translateX(-15120px)}29.26%{transform:translateX(-15372px)}29.31%{transform:translateX(-15624px)}29.82%{transform:translateX(-15876px)}30.33%{transform:translateX(-16128px)}30.83%{transform:translateX(-16380px)}31.34%{transform:translateX(-16632px)}31.79%{transform:translateX(-16884px)}31.84%{transform:translateX(-17136px)}32.35%{transform:translateX(-17388px)}32.86%{transform:translateX(-17640px)}33.36%{transform:translateX(-17892px)}33.87%{transform:translateX(-18144px)}34.31%{transform:translateX(-18396px)}34.37%{transform:translateX(-18648px)}34.88%{transform:translateX(-18900px)}35.39%{transform:translateX(-19152px)}35.89%{transform:translateX(-19404px)}36.4%{transform:translateX(-19656px)}36.84%{transform:translateX(-19908px)}36.9%{transform:translateX(-20160px)}37.41%{transform:translateX(-20412px)}37.92%{transform:translateX(-20664px)}38.42%{transform:translateX(-20916px)}38.93%{transform:translateX(-21168px)}39.36%{transform:translateX(-21420px)}39.44%{transform:translateX(-21672px)}39.94%{transform:translateX(-21924px)}40.45%{transform:translateX(-22176px)}40.95%{transform:translateX(-22428px)}41.46%{transform:translateX(-22680px)}41.89%{transform:translateX(-22932px)}44.41%{transform:translateX(-23184px)}44.41%{transform:translateX(-23436px)}45.68%{transform:translateX(-23688px)}45.68%{transform:translateX(-23940px)}46.94%{transform:translateX(-24192px)}46.94%{transform:translateX(-24444px)}48.21%{transform:translateX(-24696px)}48.21%{transform:translateX(-24948px)}49.47%{transform:translateX(-25200px)}49.47%{transform:translateX(-25452px)}50.74%{transform:translateX(-25704px)}50.74%{transform:translateX(-25956px)}52%{transform:translateX(-26208px)}52%{transform:translateX(-26460px)}53.27%{transform:translateX(-26712px)}53.27%{transform:translateX(-26964px)}54.53%{transform:translateX(-27216px)}54.53%{transform:translateX(-27468px)}55.8%{transform:translateX(-27720px)}55.8%{transform:translateX(-27972px)}57.06%{transform:translateX(-28224px)}57.06%{transform:translateX(-28476px)}58.32%{transform:translateX(-28728px)}58.33%{transform:translateX(-28980px)}59.59%{transform:translateX(-29232px)}64.64%{transform:translateX(-29484px)}64.64%{transform:translateX(-29736px)}74.75%{transform:translateX(-29988px)}74.75%{transform:translateX(-30240px)}84.85%{transform:translateX(-30492px)}84.85%{transform:translateX(-30744px)}87.38%{transform:translateX(-30996px)}100%{transform:translateX(-31248px)}}███████████████████████████████████████████████████████████████████████████████████████████████████████████████████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:)#BulletListPrinterGoodbyeHaveaniceday!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/coloring/disable-output/animation.svg b/_examples/coloring/disable-output/animation.svg index 49ae2eba7..f896041c9 100644 --- a/_examples/coloring/disable-output/animation.svg +++ b/_examples/coloring/disable-output/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(102,194,205)}.h{white-space:pre}.i{fill:rgb(126,231,233);white-space:pre}.j{fill:transparent}.l{animation-duration:6.648108s;animation-iteration-count:infinite;animation-name:k;animation-timing-function:steps(1,end)}@keyframes k{0%{transform:translateX(-0px)}24.8%{transform:translateX(-252px)}24.8%{transform:translateX(-504px)}100%{transform:translateX(-756px)}}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 +}.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(102,194,205)}.h{white-space:pre}.i{fill:rgb(126,231,233);white-space:pre}.j{fill:transparent}.l{animation-duration:6.758166s;animation-iteration-count:infinite;animation-name:k;animation-timing-function:steps(1,end)}@keyframes k{0%{transform:translateX(-0px)}26%{transform:translateX(-252px)}100%{transform:translateX(-504px)}}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/coloring/disable-styling/animation.svg b/_examples/coloring/disable-styling/animation.svg index 2dd4a84a7..40e7d6152 100644 --- a/_examples/coloring/disable-styling/animation.svg +++ b/_examples/coloring/disable-styling/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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:transparent}.i{animation-duration:39.570886s;animation-iteration-count:infinite;animation-name:h;animation-timing-function:steps(1,end)}@keyframes h{0%{transform:translateX(-0px)}3.92%{transform:translateX(-252px)}3.92%{transform:translateX(-504px)}6.44%{transform:translateX(-756px)}8.97%{transform:translateX(-1008px)}11.5%{transform:translateX(-1260px)}14.03%{transform:translateX(-1512px)}16.55%{transform:translateX(-1764px)}19.08%{transform:translateX(-2016px)}21.61%{transform:translateX(-2268px)}24.14%{transform:translateX(-2520px)}26.66%{transform:translateX(-2772px)}29.19%{transform:translateX(-3024px)}31.72%{transform:translateX(-3276px)}34.25%{transform:translateX(-3528px)}36.77%{transform:translateX(-3780px)}39.3%{transform:translateX(-4032px)}41.83%{transform:translateX(-4284px)}44.36%{transform:translateX(-4536px)}45.62%{transform:translateX(-4788px)}46.89%{transform:translateX(-5040px)}48.15%{transform:translateX(-5292px)}49.42%{transform:translateX(-5544px)}50.68%{transform:translateX(-5796px)}51.95%{transform:translateX(-6048px)}53.22%{transform:translateX(-6300px)}54.48%{transform:translateX(-6552px)}55.75%{transform:translateX(-6804px)}57.01%{transform:translateX(-7056px)}58.28%{transform:translateX(-7308px)}59.54%{transform:translateX(-7560px)}64.6%{transform:translateX(-7812px)}64.6%{transform:translateX(-8064px)}74.72%{transform:translateX(-8316px)}74.72%{transform:translateX(-8568px)}84.84%{transform:translateX(-8820px)}84.84%{transform:translateX(-9072px)}87.36%{transform:translateX(-9324px)}87.36%{transform:translateX(-9576px)}100%{transform:translateX(-9828px)}}PTermPTDP-PTermDemoProgramINFO:ThisanimationwasgeneratedwiththelatestversionofPTerm!PTermworksonnearlyeveryterminalandoperatingsystem.It'ssupereasytouse!Ifyouwant,youcancustomizeeverything:)Youcanseethecodeofthisdemointhe./_examples/demodirectory.Thisdemowasupdatedat:21Apr2022-01:44:33CESTWaitingfor15seconds...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|64mbpseudo-photoshop|pass|150mbpseudo-chrome|pass|9mbpseudo-outlook|pass|157mbpseudo-explorer|pass|160mbpseudo-dops|pass|97mbpseudo-git|pass|25mbpseudo-vsc|pass|158mbpseudo-intellij|pass|90mbpseudo-minecraft|fail|0mbpseudo-scoop|pass|132mbpseudo-chocolatey|pass|68mb├──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:)#BulletListPrinterGoodbyeHaveaniceday!Waitingfor1second...#TreePrinter├──pseudo-excel├──pseudo-photoshop├─┬pseudo-chromeRestartinganimation... \ 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:transparent}.i{animation-duration:39.769578s;animation-iteration-count:infinite;animation-name:h;animation-timing-function:steps(1,end)}@keyframes h{0%{transform:translateX(-0px)}4.4%{transform:translateX(-252px)}4.4%{transform:translateX(-504px)}6.91%{transform:translateX(-756px)}9.43%{transform:translateX(-1008px)}11.94%{transform:translateX(-1260px)}14.46%{transform:translateX(-1512px)}16.97%{transform:translateX(-1764px)}19.49%{transform:translateX(-2016px)}22%{transform:translateX(-2268px)}24.52%{transform:translateX(-2520px)}27.03%{transform:translateX(-2772px)}29.55%{transform:translateX(-3024px)}32.06%{transform:translateX(-3276px)}34.58%{transform:translateX(-3528px)}37.09%{transform:translateX(-3780px)}39.61%{transform:translateX(-4032px)}42.12%{transform:translateX(-4284px)}44.64%{transform:translateX(-4536px)}45.9%{transform:translateX(-4788px)}47.16%{transform:translateX(-5040px)}48.41%{transform:translateX(-5292px)}49.67%{transform:translateX(-5544px)}50.93%{transform:translateX(-5796px)}52.19%{transform:translateX(-6048px)}53.45%{transform:translateX(-6300px)}54.71%{transform:translateX(-6552px)}55.97%{transform:translateX(-6804px)}57.23%{transform:translateX(-7056px)}58.49%{transform:translateX(-7308px)}59.75%{transform:translateX(-7560px)}64.78%{transform:translateX(-7812px)}64.78%{transform:translateX(-8064px)}74.85%{transform:translateX(-8316px)}74.85%{transform:translateX(-8568px)}84.91%{transform:translateX(-8820px)}84.91%{transform:translateX(-9072px)}87.43%{transform:translateX(-9324px)}100%{transform:translateX(-9576px)}}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:)#BulletListPrinterGoodbyeHaveaniceday!Waitingfor1second...#TreePrinter├──pseudo-excel├──pseudo-photoshop├─┬pseudo-chromeRestartinganimation... \ No newline at end of file diff --git a/_examples/coloring/fade-colors/animation.svg b/_examples/coloring/fade-colors/animation.svg index e069d11de..b7a66e0dd 100644 --- a/_examples/coloring/fade-colors/animation.svg +++ b/_examples/coloring/fade-colors/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(69,185,255);white-space:pre}.g{fill:rgb(81,173,255);white-space:pre}.h{fill:rgb(92,162,255);white-space:pre}.i{fill:rgb(104,150,255);white-space:pre}.j{fill:rgb(115,139,255);white-space:pre}.k{fill:rgb(127,127,255);white-space:pre}.l{fill:rgb(139,115,255);white-space:pre}.m{fill:rgb(150,104,255);white-space:pre}.n{fill:rgb(162,92,255);white-space:pre}.o{fill:rgb(173,81,255);white-space:pre}.p{fill:rgb(185,69,255);white-space:pre}.q{fill:rgb(197,57,255);white-space:pre}.r{fill:rgb(208,46,255);white-space:pre}.s{fill:rgb(220,34,255);white-space:pre}.t{fill:rgb(231,23,255);white-space:pre}.u{fill:rgb(243,11,255);white-space:pre}.v{fill:transparent}.x{animation-duration:6.551868s;animation-iteration-count:infinite;animation-name:w;animation-timing-function:steps(1,end)}.y{fill:rgb(102,194,205)}.z{white-space:pre}.A{fill:rgb(126,231,233);white-space:pre}.B{fill:rgb(0,255,255);white-space:pre}.C{fill:rgb(11,243,255);white-space:pre}.D{fill:rgb(23,231,255);white-space:pre}.E{fill:rgb(46,208,255);white-space:pre}.F{fill:rgb(57,197,255);white-space:pre}.G{fill:rgb(160,160,160);white-space:pre}@keyframes w{0%{transform:translateX(-0px)}23.7%{transform:translateX(-252px)}23.7%{transform:translateX(-504px)}100%{transform:translateX(-756px)}}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 +}.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(69,185,255);white-space:pre}.g{fill:rgb(81,173,255);white-space:pre}.h{fill:rgb(92,162,255);white-space:pre}.i{fill:rgb(104,150,255);white-space:pre}.j{fill:rgb(115,139,255);white-space:pre}.k{fill:rgb(127,127,255);white-space:pre}.l{fill:rgb(139,115,255);white-space:pre}.m{fill:rgb(150,104,255);white-space:pre}.n{fill:rgb(162,92,255);white-space:pre}.o{fill:rgb(173,81,255);white-space:pre}.p{fill:rgb(185,69,255);white-space:pre}.q{fill:rgb(197,57,255);white-space:pre}.r{fill:rgb(208,46,255);white-space:pre}.s{fill:rgb(220,34,255);white-space:pre}.t{fill:rgb(231,23,255);white-space:pre}.u{fill:rgb(243,11,255);white-space:pre}.v{fill:transparent}.x{animation-duration:6.719628s;animation-iteration-count:infinite;animation-name:w;animation-timing-function:steps(1,end)}.y{fill:rgb(102,194,205)}.z{white-space:pre}.A{fill:rgb(126,231,233);white-space:pre}.B{fill:rgb(0,255,255);white-space:pre}.C{fill:rgb(11,243,255);white-space:pre}.D{fill:rgb(23,231,255);white-space:pre}.E{fill:rgb(46,208,255);white-space:pre}.F{fill:rgb(57,197,255);white-space:pre}.G{fill:rgb(160,160,160);white-space:pre}@keyframes w{0%{transform:translateX(-0px)}25.6%{transform:translateX(-252px)}25.6%{transform:translateX(-504px)}100%{transform:translateX(-756px)}}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/header/README.md b/_examples/header/README.md new file mode 100644 index 000000000..267f373de --- /dev/null +++ b/_examples/header/README.md @@ -0,0 +1,24 @@ +### 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.") +} + +``` + +
+ diff --git a/_examples/header/demo/animation.svg b/_examples/header/demo/animation.svg index b82d5dfcd..fa66abc6a 100644 --- a/_examples/header/demo/animation.svg +++ b/_examples/header/demo/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(111,119,131)}.g{fill:rgb(160,160,160);white-space:pre}.h{fill:rgb(255,255,255);font-weight:bold;white-space:pre}.i{fill:transparent}.k{animation-duration:6.455657s;animation-iteration-count:infinite;animation-name:j;animation-timing-function:steps(1,end)}@keyframes j{0%{transform:translateX(-0px)}22.5%{transform:translateX(-252px)}100%{transform:translateX(-504px)}} This is the default header! This is a full-width header. 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(111,119,131)}.g{fill:rgb(160,160,160);white-space:pre}.h{fill:rgb(255,255,255);font-weight:bold;white-space:pre}.i{fill:transparent}.k{animation-duration:6.764622s;animation-iteration-count:infinite;animation-name:j;animation-timing-function:steps(1,end)}@keyframes j{0%{transform:translateX(-0px)}26.1%{transform:translateX(-252px)}100%{transform:translateX(-504px)}} This is the default header! This is a full-width header. Restartinganimation... \ No newline at end of file diff --git a/ci/main.go b/ci/main.go index 1e9b9bedb..49f3b28ca 100644 --- a/ci/main.go +++ b/ci/main.go @@ -45,33 +45,37 @@ func main() { log.Output(1, "## Generating Examples") files, _ := os.ReadDir("./_examples/") var readmeExamples string - for _, file := range files { - log.Output(2, "Section: "+file.Name()) - examples, _ := os.ReadDir("./_examples/" + file.Name()) - - for _, f := range examples { - processFile(file.Name() + "/" + f.Name()) - log.Output(2, "## Generating readme for example: "+f.Name()) - exampleCode, err := os.ReadFile("./_examples/" + file.Name() + "/" + f.Name() + "/main.go") + 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) } - readmeExamples += "### " + file.Name() + "/" + f.Name() + "\n\n" - readmeExamples += "![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/" + file.Name() + "/" + 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" + 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 } + os.WriteFile("./_examples/"+section.Name()+"/README.md", []byte(sectionExamples), 0600) } log.Output(3, "### Generating examples README") examplesReadme, err := os.ReadFile("./_examples/README.md") examplesReadmeContent := string(examplesReadme) examplesReadmeContent = writeBetween("examples", examplesReadmeContent, "\n"+readmeExamples+"\n") - os.WriteFile("./_examples/README.md", []byte(examplesReadmeContent), 0755) + os.WriteFile("./_examples/README.md", []byte(examplesReadmeContent), 0600) log.Output(3, "### Appending examples to root README.md") From 6045603c9d39aba3c3831d34659468e65bc79f98 Mon Sep 17 00:00:00 2001 From: MarvinJWendt Date: Thu, 21 Apr 2022 01:59:07 +0200 Subject: [PATCH 6/7] updated example generation --- README.md | 2722 ++++++++++++++++- _examples/README.md | 2722 ++++++++++++++++- .../fade-multiple-colors/animation.svg | 2 +- .../override-default-printers/animation.svg | 2 +- .../coloring/print-color-rgb/animation.svg | 2 +- _examples/demo/demo/animation.svg | 2 +- _examples/header-custom/demo/animation.svg | 2 +- _examples/panel/demo/animation.svg | 2 +- _examples/paragraph/customized/animation.svg | 2 +- _examples/paragraph/demo/animation.svg | 2 +- _examples/prefix/demo/animation.svg | 2 +- _examples/progressbar/demo/animation.svg | 2 +- _examples/section/demo/animation.svg | 2 +- _examples/spinner/demo/animation.svg | 2 +- _examples/style/demo/animation.svg | 2 +- _examples/table/demo/animation.svg | 2 +- _examples/theme/demo/animation.svg | 2 +- _examples/tree/demo/animation.svg | 2 +- docs/README.md | 2722 ++++++++++++++++- 19 files changed, 7921 insertions(+), 277 deletions(-) diff --git a/README.md b/README.md index 88cd51f65..3f7a273bf 100644 --- a/README.md +++ b/README.md @@ -254,6 +254,134 @@ func main() {
+### 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) @@ -355,57 +483,2455 @@ 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!") +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() } -``` - -
- -### bigtext/demo +func installingPseudoList() { + pterm.DefaultSection.Println("Installing pseudo programs") -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bigtext/demo/animation.svg) + 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() +} -SHOW SOURCE +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. -```go -package main + 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) +} -import "github.com/pterm/pterm" +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 main() { - // Print a large text with the LetterStyle from the standard theme. - // Useful for title screens. - pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString("PTerm")).Render() +func pseudoApplicationHeader() *pterm.TextPrinter { + return pterm.DefaultHeader.WithBackgroundStyle(pterm.NewStyle(pterm.BgLightBlue)).WithMargin(10).Println( + "Pseudo Application created with PTerm") +} - // Print a large text with differently colored letters. +func introScreen() { pterm.DefaultBigText.WithLetters( - pterm.NewLettersFromStringWithStyle("P", pterm.NewStyle(pterm.FgCyan)), + pterm.NewLettersFromStringWithStyle("P", pterm.NewStyle(pterm.FgLightCyan)), 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() + 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 } ```
-### box/demo +### coloring/fade-colors -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/box/demo/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-colors/animation.svg)
@@ -414,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/customized +### coloring/fade-multiple-colors -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/customized/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-multiple-colors/animation.svg)
@@ -447,58 +2974,44 @@ func main() { package main import ( + "strings" + "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 + 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. -import "github.com/pterm/pterm" + 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]) + } -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() + // Print info. + pterm.Info.Println(fadeInfo) - // Convert a text to a list and print it. - pterm.NewBulletListFromString(`0 - 1 - 2 - 3`, " ").Render() + // 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!") + } } ```
-### center/demo +### coloring/override-default-printers -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/center/demo/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/override-default-printers/animation.svg)
@@ -510,13 +3023,17 @@ 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:") + // Print default error. + pterm.Error.Println("This is the default Error") - // Generate BigLetters - s, _ := pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString("PTerm")).Srender() - pterm.DefaultCenter.Println(s) // Print BigLetters with the default CenterPrinter + // Customize default error. + pterm.Error.Prefix = pterm.Prefix{ + Text: "OVERRIDE", + Style: pterm.NewStyle(pterm.BgCyan, pterm.FgRed), + } - pterm.DefaultCenter.WithCenterEachLineSeparately().Println("This text is centered!\nBut each line is\ncentered\nseparately") + // Print new default error. + pterm.Error.Println("This is the default Error after the prefix was overridden") } ``` @@ -1362,6 +3879,37 @@ func main() {
+### 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) diff --git a/_examples/README.md b/_examples/README.md index b50e345a9..f5cac288a 100644 --- a/_examples/README.md +++ b/_examples/README.md @@ -77,6 +77,134 @@ func main() { +### 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) @@ -178,57 +306,2455 @@ 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!") +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() } -``` - -
- -### bigtext/demo +func installingPseudoList() { + pterm.DefaultSection.Println("Installing pseudo programs") -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bigtext/demo/animation.svg) + 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() +} -SHOW SOURCE +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. -```go -package main + 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) +} -import "github.com/pterm/pterm" +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 main() { - // Print a large text with the LetterStyle from the standard theme. - // Useful for title screens. - pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString("PTerm")).Render() +func pseudoApplicationHeader() *pterm.TextPrinter { + return pterm.DefaultHeader.WithBackgroundStyle(pterm.NewStyle(pterm.BgLightBlue)).WithMargin(10).Println( + "Pseudo Application created with PTerm") +} - // Print a large text with differently colored letters. +func introScreen() { pterm.DefaultBigText.WithLetters( - pterm.NewLettersFromStringWithStyle("P", pterm.NewStyle(pterm.FgCyan)), + pterm.NewLettersFromStringWithStyle("P", pterm.NewStyle(pterm.FgLightCyan)), 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() + 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 } ```
-### box/demo +### coloring/fade-colors -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/box/demo/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-colors/animation.svg)
@@ -237,30 +2763,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/customized +### coloring/fade-multiple-colors -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/customized/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-multiple-colors/animation.svg)
@@ -270,58 +2797,44 @@ func main() { package main import ( + "strings" + "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 + 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. -import "github.com/pterm/pterm" + 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]) + } -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() + // Print info. + pterm.Info.Println(fadeInfo) - // Convert a text to a list and print it. - pterm.NewBulletListFromString(`0 - 1 - 2 - 3`, " ").Render() + // 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!") + } } ```
-### center/demo +### coloring/override-default-printers -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/center/demo/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/override-default-printers/animation.svg)
@@ -333,13 +2846,17 @@ 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:") + // Print default error. + pterm.Error.Println("This is the default Error") - // Generate BigLetters - s, _ := pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString("PTerm")).Srender() - pterm.DefaultCenter.Println(s) // Print BigLetters with the default CenterPrinter + // Customize default error. + pterm.Error.Prefix = pterm.Prefix{ + Text: "OVERRIDE", + Style: pterm.NewStyle(pterm.BgCyan, pterm.FgRed), + } - pterm.DefaultCenter.WithCenterEachLineSeparately().Println("This text is centered!\nBut each line is\ncentered\nseparately") + // Print new default error. + pterm.Error.Println("This is the default Error after the prefix was overridden") } ``` @@ -1185,6 +3702,37 @@ func main() {
+### 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) diff --git a/_examples/coloring/fade-multiple-colors/animation.svg b/_examples/coloring/fade-multiple-colors/animation.svg index 11add53be..466f9f795 100644 --- a/_examples/coloring/fade-multiple-colors/animation.svg +++ b/_examples/coloring/fade-multiple-colors/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(185,69,255);white-space:pre}.g{fill:rgb(231,23,255);white-space:pre}.h{fill:rgb(255,0,231);white-space:pre}.i{fill:rgb(255,0,185);white-space:pre}.j{fill:rgb(255,0,139);white-space:pre}.k{fill:rgb(255,0,92);white-space:pre}.l{fill:rgb(255,0,46);white-space:pre}.m{fill:rgb(255,0,0);white-space:pre}.n{fill:rgb(208,46,0);white-space:pre}.o{fill:rgb(162,92,0);white-space:pre}.p{fill:rgb(115,139,0);white-space:pre}.q{fill:rgb(69,185,0);white-space:pre}.r{fill:rgb(23,231,0);white-space:pre}.s{fill:rgb(23,255,23);white-space:pre}.t{fill:rgb(69,255,69);white-space:pre}.u{fill:rgb(115,255,115);white-space:pre}.v{fill:rgb(162,255,162);white-space:pre}.w{fill:rgb(208,255,208);white-space:pre}.x{fill:transparent}.z{animation-duration:6.57556s;animation-iteration-count:infinite;animation-name:y;animation-timing-function:steps(1,end)}.A{fill:rgb(102,194,205)}.B{white-space:pre}.C{fill:rgb(0,255,255);white-space:pre}.D{fill:rgb(4,250,255);white-space:pre}.E{fill:rgb(8,246,255);white-space:pre}.F{fill:rgb(17,237,255);white-space:pre}.G{fill:rgb(21,233,255);white-space:pre}.H{fill:rgb(26,228,255);white-space:pre}.I{fill:rgb(30,224,255);white-space:pre}.J{fill:rgb(35,219,255);white-space:pre}.K{fill:rgb(39,215,255);white-space:pre}.L{fill:rgb(48,206,255);white-space:pre}.M{fill:rgb(52,202,255);white-space:pre}.N{fill:rgb(57,197,255);white-space:pre}.O{fill:rgb(61,193,255);white-space:pre}.P{fill:rgb(70,184,255);white-space:pre}.Q{fill:rgb(74,180,255);white-space:pre}.R{fill:rgb(79,175,255);white-space:pre}.S{fill:rgb(83,171,255);white-space:pre}.T{fill:rgb(92,162,255);white-space:pre}.U{fill:rgb(96,158,255);white-space:pre}.V{fill:rgb(105,149,255);white-space:pre}.W{fill:rgb(109,145,255);white-space:pre}.X{fill:rgb(114,140,255);white-space:pre}.Y{fill:rgb(118,136,255);white-space:pre}.Z{fill:rgb(123,131,255);white-space:pre}.aa{fill:rgb(127,127,255);white-space:pre}.ab{fill:rgb(131,123,255);white-space:pre}.ac{fill:rgb(136,118,255);white-space:pre}.ad{fill:rgb(140,114,255);white-space:pre}.ae{fill:rgb(149,105,255);white-space:pre}.af{fill:rgb(153,101,255);white-space:pre}.ag{fill:rgb(158,96,255);white-space:pre}.ah{fill:rgb(162,92,255);white-space:pre}.ai{fill:rgb(167,87,255);white-space:pre}.aj{fill:rgb(175,79,255);white-space:pre}.ak{fill:rgb(180,74,255);white-space:pre}.al{fill:rgb(184,70,255);white-space:pre}.am{fill:rgb(189,65,255);white-space:pre}.an{fill:rgb(193,61,255);white-space:pre}.ao{fill:rgb(197,57,255);white-space:pre}.ap{fill:rgb(202,52,255);white-space:pre}.aq{fill:rgb(211,43,255);white-space:pre}.ar{fill:rgb(215,39,255);white-space:pre}.as{fill:rgb(219,35,255);white-space:pre}.at{fill:rgb(224,30,255);white-space:pre}.au{fill:rgb(228,26,255);white-space:pre}.av{fill:rgb(233,21,255);white-space:pre}.aw{fill:rgb(237,17,255);white-space:pre}.ax{fill:rgb(241,13,255);white-space:pre}.ay{fill:rgb(246,8,255);white-space:pre}.az{fill:rgb(250,4,255);white-space:pre}.aA{fill:rgb(46,208,255);white-space:pre}.aB{fill:rgb(139,115,255);white-space:pre}.aC{fill:rgb(160,160,160);white-space:pre}@keyframes y{0%{transform:translateX(-0px)}24%{transform:translateX(-252px)}24%{transform:translateX(-504px)}24%{transform:translateX(-756px)}100%{transform:translateX(-1008px)}}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 +}.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(185,69,255);white-space:pre}.g{fill:rgb(231,23,255);white-space:pre}.h{fill:rgb(255,0,231);white-space:pre}.i{fill:rgb(255,0,185);white-space:pre}.j{fill:rgb(255,0,139);white-space:pre}.k{fill:rgb(255,0,92);white-space:pre}.l{fill:rgb(255,0,46);white-space:pre}.m{fill:rgb(255,0,0);white-space:pre}.n{fill:rgb(208,46,0);white-space:pre}.o{fill:rgb(162,92,0);white-space:pre}.p{fill:rgb(115,139,0);white-space:pre}.q{fill:rgb(69,185,0);white-space:pre}.r{fill:rgb(23,231,0);white-space:pre}.s{fill:rgb(23,255,23);white-space:pre}.t{fill:rgb(69,255,69);white-space:pre}.u{fill:rgb(115,255,115);white-space:pre}.v{fill:rgb(162,255,162);white-space:pre}.w{fill:rgb(208,255,208);white-space:pre}.x{fill:transparent}.z{animation-duration:6.84205s;animation-iteration-count:infinite;animation-name:y;animation-timing-function:steps(1,end)}.A{fill:rgb(102,194,205)}.B{white-space:pre}.C{fill:rgb(0,255,255);white-space:pre}.D{fill:rgb(4,250,255);white-space:pre}.E{fill:rgb(8,246,255);white-space:pre}.F{fill:rgb(17,237,255);white-space:pre}.G{fill:rgb(21,233,255);white-space:pre}.H{fill:rgb(26,228,255);white-space:pre}.I{fill:rgb(30,224,255);white-space:pre}.J{fill:rgb(35,219,255);white-space:pre}.K{fill:rgb(39,215,255);white-space:pre}.L{fill:rgb(48,206,255);white-space:pre}.M{fill:rgb(52,202,255);white-space:pre}.N{fill:rgb(57,197,255);white-space:pre}.O{fill:rgb(61,193,255);white-space:pre}.P{fill:rgb(70,184,255);white-space:pre}.Q{fill:rgb(74,180,255);white-space:pre}.R{fill:rgb(79,175,255);white-space:pre}.S{fill:rgb(83,171,255);white-space:pre}.T{fill:rgb(92,162,255);white-space:pre}.U{fill:rgb(96,158,255);white-space:pre}.V{fill:rgb(105,149,255);white-space:pre}.W{fill:rgb(109,145,255);white-space:pre}.X{fill:rgb(114,140,255);white-space:pre}.Y{fill:rgb(118,136,255);white-space:pre}.Z{fill:rgb(123,131,255);white-space:pre}.aa{fill:rgb(127,127,255);white-space:pre}.ab{fill:rgb(131,123,255);white-space:pre}.ac{fill:rgb(136,118,255);white-space:pre}.ad{fill:rgb(140,114,255);white-space:pre}.ae{fill:rgb(149,105,255);white-space:pre}.af{fill:rgb(153,101,255);white-space:pre}.ag{fill:rgb(158,96,255);white-space:pre}.ah{fill:rgb(162,92,255);white-space:pre}.ai{fill:rgb(167,87,255);white-space:pre}.aj{fill:rgb(175,79,255);white-space:pre}.ak{fill:rgb(180,74,255);white-space:pre}.al{fill:rgb(184,70,255);white-space:pre}.am{fill:rgb(189,65,255);white-space:pre}.an{fill:rgb(193,61,255);white-space:pre}.ao{fill:rgb(197,57,255);white-space:pre}.ap{fill:rgb(202,52,255);white-space:pre}.aq{fill:rgb(211,43,255);white-space:pre}.ar{fill:rgb(215,39,255);white-space:pre}.as{fill:rgb(219,35,255);white-space:pre}.at{fill:rgb(224,30,255);white-space:pre}.au{fill:rgb(228,26,255);white-space:pre}.av{fill:rgb(233,21,255);white-space:pre}.aw{fill:rgb(237,17,255);white-space:pre}.ax{fill:rgb(241,13,255);white-space:pre}.ay{fill:rgb(246,8,255);white-space:pre}.az{fill:rgb(250,4,255);white-space:pre}.aA{fill:rgb(46,208,255);white-space:pre}.aB{fill:rgb(139,115,255);white-space:pre}.aC{fill:rgb(160,160,160);white-space:pre}@keyframes y{0%{transform:translateX(-0px)}26.9%{transform:translateX(-252px)}26.9%{transform:translateX(-504px)}26.9%{transform:translateX(-756px)}100%{transform:translateX(-1008px)}}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/coloring/override-default-printers/animation.svg b/_examples/coloring/override-default-printers/animation.svg index 6a5ac261e..cf5ecce62 100644 --- a/_examples/coloring/override-default-printers/animation.svg +++ b/_examples/coloring/override-default-printers/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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.586955s;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)}24.1%{transform:translateX(-252px)}100%{transform:translateX(-504px)}} 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/coloring/print-color-rgb/animation.svg b/_examples/coloring/print-color-rgb/animation.svg index e4724f81f..7e7a55ae4 100644 --- a/_examples/coloring/print-color-rgb/animation.svg +++ b/_examples/coloring/print-color-rgb/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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.710528s;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)}25.5%{transform:translateX(-252px)}100%{transform:translateX(-504px)}}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/demo/demo/animation.svg b/_examples/demo/demo/animation.svg index 427ba5bcc..b109d53ff 100644 --- a/_examples/demo/demo/animation.svg +++ b/_examples/demo/demo/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(126,231,233);white-space:pre}.g{fill:rgb(234,89,246);white-space:pre}.h{fill:rgb(115,190,243)}.i{fill:rgb(160,160,160);white-space:pre}.j{fill:rgb(255,255,255);font-weight:bold;white-space:pre}.k{fill:rgb(102,194,205)}.l{white-space:pre}.m{fill:rgb(124,255,0);white-space:pre}.n{fill:rgb(255,255,255);white-space:pre}.o{fill:rgb(255,241,0);font-weight:bold;white-space:pre}.p{fill:rgb(168,204,140)}.q{fill:rgb(104,104,104);white-space:pre}.r{fill:rgb(0,198,255);white-space:pre}.s{fill:rgb(63,191,0);white-space:pre}.t{fill:rgb(219,171,121)}.u{fill:rgb(255,241,0);white-space:pre}.v{fill:rgb(21,233,0);white-space:pre}.w{fill:rgb(127,253,127);white-space:pre}.x{fill:rgb(243,86,86);white-space:pre}.y{fill:rgb(0,255,255);white-space:pre}.z{fill:rgb(2,252,255);white-space:pre}.A{fill:rgb(8,246,255);white-space:pre}.B{fill:rgb(11,243,255);white-space:pre}.C{fill:rgb(14,240,255);white-space:pre}.D{fill:rgb(17,237,255);white-space:pre}.E{fill:rgb(22,232,255);white-space:pre}.F{fill:rgb(25,229,255);white-space:pre}.G{fill:rgb(28,226,255);white-space:pre}.H{fill:rgb(31,223,255);white-space:pre}.I{fill:rgb(34,220,255);white-space:pre}.J{fill:rgb(37,217,255);white-space:pre}.K{fill:rgb(40,214,255);white-space:pre}.L{fill:rgb(42,212,255);white-space:pre}.M{fill:rgb(48,206,255);white-space:pre}.N{fill:rgb(51,203,255);white-space:pre}.O{fill:rgb(54,200,255);white-space:pre}.P{fill:rgb(60,194,255);white-space:pre}.Q{fill:rgb(63,191,255);white-space:pre}.R{fill:rgb(65,189,255);white-space:pre}.S{fill:rgb(68,186,255);white-space:pre}.T{fill:rgb(71,183,255);white-space:pre}.U{fill:rgb(74,180,255);white-space:pre}.V{fill:rgb(77,177,255);white-space:pre}.W{fill:rgb(80,174,255);white-space:pre}.X{fill:rgb(83,171,255);white-space:pre}.Y{fill:rgb(88,166,255);white-space:pre}.Z{fill:rgb(91,163,255);white-space:pre}.aa{fill:rgb(94,160,255);white-space:pre}.ab{fill:rgb(97,157,255);white-space:pre}.ac{fill:rgb(100,154,255);white-space:pre}.ad{fill:rgb(103,151,255);white-space:pre}.ae{fill:rgb(106,148,255);white-space:pre}.af{fill:rgb(108,146,255);white-space:pre}.ag{fill:rgb(114,140,255);white-space:pre}.ah{fill:rgb(117,137,255);white-space:pre}.ai{fill:rgb(120,134,255);white-space:pre}.aj{fill:rgb(126,128,255);white-space:pre}.ak{fill:rgb(128,126,255);white-space:pre}.al{fill:rgb(131,123,255);white-space:pre}.am{fill:rgb(137,117,255);white-space:pre}.an{fill:rgb(140,114,255);white-space:pre}.ao{fill:rgb(143,111,255);white-space:pre}.ap{fill:rgb(148,106,255);white-space:pre}.aq{fill:rgb(151,103,255);white-space:pre}.ar{fill:rgb(154,100,255);white-space:pre}.as{fill:rgb(160,94,255);white-space:pre}.at{fill:rgb(163,91,255);white-space:pre}.au{fill:rgb(166,88,255);white-space:pre}.av{fill:rgb(169,85,255);white-space:pre}.aw{fill:rgb(171,83,255);white-space:pre}.ax{fill:rgb(174,80,255);white-space:pre}.ay{fill:rgb(177,77,255);white-space:pre}.az{fill:rgb(183,71,255);white-space:pre}.aA{fill:rgb(186,68,255);white-space:pre}.aB{fill:rgb(189,65,255);white-space:pre}.aC{fill:rgb(194,60,255);white-space:pre}.aD{fill:rgb(197,57,255);white-space:pre}.aE{fill:rgb(200,54,255);white-space:pre}.aF{fill:rgb(206,48,255);white-space:pre}.aG{fill:rgb(209,45,255);white-space:pre}.aH{fill:rgb(212,42,255);white-space:pre}.aI{fill:rgb(214,40,255);white-space:pre}.aJ{fill:rgb(220,34,255);white-space:pre}.aK{fill:rgb(223,31,255);white-space:pre}.aL{fill:rgb(226,28,255);white-space:pre}.aM{fill:rgb(229,25,255);white-space:pre}.aN{fill:rgb(234,20,255);white-space:pre}.aO{fill:rgb(237,17,255);white-space:pre}.aP{fill:rgb(240,14,255);white-space:pre}.aQ{fill:rgb(243,11,255);white-space:pre}.aR{fill:rgb(249,5,255);white-space:pre}.aS{fill:rgb(252,2,255);white-space:pre}.aT{fill:transparent}.aV{animation-duration:39.799434s;animation-iteration-count:infinite;animation-name:aU;animation-timing-function:steps(1,end)}.aW{fill:rgb(255,0,0);white-space:pre}.aX{fill:rgb(233,21,0);white-space:pre}.aY{fill:rgb(212,42,0);white-space:pre}.aZ{fill:rgb(191,63,0);white-space:pre}.ba{fill:rgb(170,85,0);white-space:pre}.bb{fill:rgb(148,106,0);white-space:pre}.bc{fill:rgb(127,127,0);white-space:pre}.bd{fill:rgb(106,148,0);white-space:pre}.be{fill:rgb(85,170,0);white-space:pre}.bf{fill:rgb(42,212,0);white-space:pre}@keyframes aU{0%{transform:translateX(-0px)}4.44%{transform:translateX(-252px)}4.44%{transform:translateX(-504px)}4.45%{transform:translateX(-756px)}4.95%{transform:translateX(-1008px)}5.45%{transform:translateX(-1260px)}5.95%{transform:translateX(-1512px)}6.46%{transform:translateX(-1764px)}6.96%{transform:translateX(-2016px)}6.96%{transform:translateX(-2268px)}7.47%{transform:translateX(-2520px)}7.97%{transform:translateX(-2772px)}8.47%{transform:translateX(-3024px)}8.98%{transform:translateX(-3276px)}9.47%{transform:translateX(-3528px)}9.48%{transform:translateX(-3780px)}9.98%{transform:translateX(-4032px)}10.49%{transform:translateX(-4284px)}10.99%{transform:translateX(-4536px)}11.5%{transform:translateX(-4788px)}11.99%{transform:translateX(-5040px)}12%{transform:translateX(-5292px)}12.5%{transform:translateX(-5544px)}13.01%{transform:translateX(-5796px)}13.51%{transform:translateX(-6048px)}14.02%{transform:translateX(-6300px)}14.5%{transform:translateX(-6552px)}14.52%{transform:translateX(-6804px)}15.02%{transform:translateX(-7056px)}15.53%{transform:translateX(-7308px)}16.03%{transform:translateX(-7560px)}16.53%{transform:translateX(-7812px)}17.02%{transform:translateX(-8064px)}17.04%{transform:translateX(-8316px)}17.54%{transform:translateX(-8568px)}18.05%{transform:translateX(-8820px)}18.55%{transform:translateX(-9072px)}19.05%{transform:translateX(-9324px)}19.53%{transform:translateX(-9576px)}19.56%{transform:translateX(-9828px)}20.06%{transform:translateX(-10080px)}20.56%{transform:translateX(-10332px)}21.07%{transform:translateX(-10584px)}21.57%{transform:translateX(-10836px)}22.04%{transform:translateX(-11088px)}22.08%{transform:translateX(-11340px)}22.58%{transform:translateX(-11592px)}23.08%{transform:translateX(-11844px)}23.59%{transform:translateX(-12096px)}24.09%{transform:translateX(-12348px)}24.56%{transform:translateX(-12600px)}24.59%{transform:translateX(-12852px)}25.1%{transform:translateX(-13104px)}25.6%{transform:translateX(-13356px)}26.11%{transform:translateX(-13608px)}26.61%{transform:translateX(-13860px)}27.07%{transform:translateX(-14112px)}27.11%{transform:translateX(-14364px)}27.62%{transform:translateX(-14616px)}28.12%{transform:translateX(-14868px)}28.62%{transform:translateX(-15120px)}29.13%{transform:translateX(-15372px)}29.58%{transform:translateX(-15624px)}29.63%{transform:translateX(-15876px)}30.14%{transform:translateX(-16128px)}30.64%{transform:translateX(-16380px)}31.14%{transform:translateX(-16632px)}31.65%{transform:translateX(-16884px)}32.1%{transform:translateX(-17136px)}32.15%{transform:translateX(-17388px)}32.65%{transform:translateX(-17640px)}33.16%{transform:translateX(-17892px)}33.66%{transform:translateX(-18144px)}34.17%{transform:translateX(-18396px)}34.61%{transform:translateX(-18648px)}34.67%{transform:translateX(-18900px)}35.17%{transform:translateX(-19152px)}35.68%{transform:translateX(-19404px)}36.18%{transform:translateX(-19656px)}36.68%{transform:translateX(-19908px)}37.13%{transform:translateX(-20160px)}37.19%{transform:translateX(-20412px)}37.69%{transform:translateX(-20664px)}38.2%{transform:translateX(-20916px)}38.7%{transform:translateX(-21168px)}39.2%{transform:translateX(-21420px)}39.64%{transform:translateX(-21672px)}39.64%{transform:translateX(-21924px)}39.71%{transform:translateX(-22176px)}40.21%{transform:translateX(-22428px)}40.71%{transform:translateX(-22680px)}41.22%{transform:translateX(-22932px)}41.72%{transform:translateX(-23184px)}42.15%{transform:translateX(-23436px)}42.15%{transform:translateX(-23688px)}44.67%{transform:translateX(-23940px)}44.67%{transform:translateX(-24192px)}44.67%{transform:translateX(-24444px)}45.93%{transform:translateX(-24696px)}45.93%{transform:translateX(-24948px)}47.19%{transform:translateX(-25200px)}47.19%{transform:translateX(-25452px)}48.44%{transform:translateX(-25704px)}48.44%{transform:translateX(-25956px)}49.7%{transform:translateX(-26208px)}49.7%{transform:translateX(-26460px)}50.96%{transform:translateX(-26712px)}50.96%{transform:translateX(-26964px)}52.22%{transform:translateX(-27216px)}52.22%{transform:translateX(-27468px)}53.48%{transform:translateX(-27720px)}53.48%{transform:translateX(-27972px)}54.74%{transform:translateX(-28224px)}54.74%{transform:translateX(-28476px)}56%{transform:translateX(-28728px)}56%{transform:translateX(-28980px)}57.26%{transform:translateX(-29232px)}57.26%{transform:translateX(-29484px)}58.51%{transform:translateX(-29736px)}58.51%{transform:translateX(-29988px)}59.77%{transform:translateX(-30240px)}64.8%{transform:translateX(-30492px)}64.8%{transform:translateX(-30744px)}64.8%{transform:translateX(-30996px)}64.8%{transform:translateX(-31248px)}74.86%{transform:translateX(-31500px)}74.86%{transform:translateX(-31752px)}74.86%{transform:translateX(-32004px)}74.86%{transform:translateX(-32256px)}84.92%{transform:translateX(-32508px)}84.92%{transform:translateX(-32760px)}84.92%{transform:translateX(-33012px)}84.92%{transform:translateX(-33264px)}87.44%{transform:translateX(-33516px)}100%{transform:translateX(-33768px)}}███████████████████████████████████████████████████████████████████████████████████████████████████████████████████ PTDP - PTerm Demo Program INFO ThisanimationwasgeneratedwiththelatestversionofPTerm! PTermworksonnearlyeveryterminalandoperatingsystem. It'ssupereasytouse! Ifyouwant,youcancustomizeeverything:) Youcanseethecodeofthisdemointhe./_examples/demodirectory. Thisdemowasupdatedat:21Apr2022-01:45:20CESTWaitingfor15seconds...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-intellijInstallingpseudo-minecraft[9/12]███████████████████████████░░░░░░░░░75%|5s WARNING Couldnotinstallpseudo-minecraft Thecompanypolicyforbidsgames. SUCCESS Installingpseudo-scoop SUCCESS Installingpseudo-chocolateyInstallingpseudo-chocolatey[11/12]███████████████████████████████░░░92%|6s##ProgramInstallReportProgramName|Status|Sizepseudo-excel|pass|195mbpseudo-photoshop|pass|53mbpseudo-chrome|pass|180mbpseudo-outlook|pass|36mbpseudo-explorer|pass|88mbpseudo-dops|pass|73mbpseudo-git|pass|138mbpseudo-vsc|pass|127mbpseudo-intellij|pass|176mbpseudo-minecraft|fail|0mbpseudo-scoop|pass|65mbpseudo-chocolatey|pass|136mb#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:)#BulletListPrinterGoodbyeHaveaniceday!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[3/12]██████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░25%|2sInstallingpseudo-outlook[4/12]█████████████░░░░░░░░░░░░░░░░░░░░░░░░░33%|2sInstallingpseudo-explorer[5/12]████████████████░░░░░░░░░░░░░░░░░░░░░42%|2sInstallingpseudo-dops[6/12]█████████████████████░░░░░░░░░░░░░░░░░░░░50%|3sInstallingpseudo-git[7/12]████████████████████████░░░░░░░░░░░░░░░░░░58%|3sInstallingpseudo-vsc[8/12]████████████████████████████░░░░░░░░░░░░░░67%|4sInstallingpseudo-intellij[9/12]████████████████████████████░░░░░░░░░75%|4sInstallingpseudo-scoop[10/12]████████████████████████████████░░░░░░░83%|5spseudo-outlook|pass|pse└─┬C:├── INFO IfyourterminalhasTrueColorsupp YoucRestartinganimation... \ 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(126,231,233);white-space:pre}.g{fill:rgb(234,89,246);white-space:pre}.h{fill:rgb(115,190,243)}.i{fill:rgb(160,160,160);white-space:pre}.j{fill:rgb(255,255,255);font-weight:bold;white-space:pre}.k{fill:rgb(102,194,205)}.l{white-space:pre}.m{fill:rgb(124,255,0);white-space:pre}.n{fill:rgb(255,255,255);white-space:pre}.o{fill:rgb(255,241,0);font-weight:bold;white-space:pre}.p{fill:rgb(168,204,140)}.q{fill:rgb(219,171,121)}.r{fill:rgb(255,241,0);white-space:pre}.s{fill:rgb(104,104,104);white-space:pre}.t{fill:rgb(0,198,255);white-space:pre}.u{fill:rgb(21,233,0);white-space:pre}.v{fill:rgb(127,253,127);white-space:pre}.w{fill:rgb(243,86,86);white-space:pre}.x{fill:rgb(0,255,255);white-space:pre}.y{fill:rgb(2,252,255);white-space:pre}.z{fill:rgb(8,246,255);white-space:pre}.A{fill:rgb(11,243,255);white-space:pre}.B{fill:rgb(14,240,255);white-space:pre}.C{fill:rgb(17,237,255);white-space:pre}.D{fill:rgb(22,232,255);white-space:pre}.E{fill:rgb(25,229,255);white-space:pre}.F{fill:rgb(28,226,255);white-space:pre}.G{fill:rgb(31,223,255);white-space:pre}.H{fill:rgb(34,220,255);white-space:pre}.I{fill:rgb(37,217,255);white-space:pre}.J{fill:rgb(40,214,255);white-space:pre}.K{fill:rgb(42,212,255);white-space:pre}.L{fill:rgb(48,206,255);white-space:pre}.M{fill:rgb(51,203,255);white-space:pre}.N{fill:rgb(54,200,255);white-space:pre}.O{fill:rgb(60,194,255);white-space:pre}.P{fill:rgb(63,191,255);white-space:pre}.Q{fill:rgb(65,189,255);white-space:pre}.R{fill:rgb(68,186,255);white-space:pre}.S{fill:rgb(71,183,255);white-space:pre}.T{fill:rgb(74,180,255);white-space:pre}.U{fill:rgb(77,177,255);white-space:pre}.V{fill:rgb(80,174,255);white-space:pre}.W{fill:rgb(83,171,255);white-space:pre}.X{fill:rgb(88,166,255);white-space:pre}.Y{fill:rgb(91,163,255);white-space:pre}.Z{fill:rgb(94,160,255);white-space:pre}.aa{fill:rgb(97,157,255);white-space:pre}.ab{fill:rgb(100,154,255);white-space:pre}.ac{fill:rgb(103,151,255);white-space:pre}.ad{fill:rgb(106,148,255);white-space:pre}.ae{fill:rgb(108,146,255);white-space:pre}.af{fill:rgb(114,140,255);white-space:pre}.ag{fill:rgb(117,137,255);white-space:pre}.ah{fill:rgb(120,134,255);white-space:pre}.ai{fill:rgb(126,128,255);white-space:pre}.aj{fill:rgb(128,126,255);white-space:pre}.ak{fill:rgb(131,123,255);white-space:pre}.al{fill:rgb(137,117,255);white-space:pre}.am{fill:rgb(140,114,255);white-space:pre}.an{fill:rgb(143,111,255);white-space:pre}.ao{fill:rgb(148,106,255);white-space:pre}.ap{fill:rgb(151,103,255);white-space:pre}.aq{fill:rgb(154,100,255);white-space:pre}.ar{fill:rgb(160,94,255);white-space:pre}.as{fill:rgb(163,91,255);white-space:pre}.at{fill:rgb(166,88,255);white-space:pre}.au{fill:rgb(169,85,255);white-space:pre}.av{fill:rgb(171,83,255);white-space:pre}.aw{fill:rgb(174,80,255);white-space:pre}.ax{fill:rgb(177,77,255);white-space:pre}.ay{fill:rgb(183,71,255);white-space:pre}.az{fill:rgb(186,68,255);white-space:pre}.aA{fill:rgb(189,65,255);white-space:pre}.aB{fill:rgb(194,60,255);white-space:pre}.aC{fill:rgb(197,57,255);white-space:pre}.aD{fill:rgb(200,54,255);white-space:pre}.aE{fill:rgb(206,48,255);white-space:pre}.aF{fill:rgb(209,45,255);white-space:pre}.aG{fill:rgb(212,42,255);white-space:pre}.aH{fill:rgb(214,40,255);white-space:pre}.aI{fill:rgb(220,34,255);white-space:pre}.aJ{fill:rgb(223,31,255);white-space:pre}.aK{fill:rgb(226,28,255);white-space:pre}.aL{fill:rgb(229,25,255);white-space:pre}.aM{fill:rgb(234,20,255);white-space:pre}.aN{fill:rgb(237,17,255);white-space:pre}.aO{fill:rgb(240,14,255);white-space:pre}.aP{fill:rgb(243,11,255);white-space:pre}.aQ{fill:rgb(249,5,255);white-space:pre}.aR{fill:rgb(252,2,255);white-space:pre}.aS{fill:transparent}.aU{animation-duration:39.843383s;animation-iteration-count:infinite;animation-name:aT;animation-timing-function:steps(1,end)}.aV{fill:rgb(255,0,0);white-space:pre}.aW{fill:rgb(233,21,0);white-space:pre}.aX{fill:rgb(212,42,0);white-space:pre}.aY{fill:rgb(191,63,0);white-space:pre}.aZ{fill:rgb(170,85,0);white-space:pre}.ba{fill:rgb(148,106,0);white-space:pre}.bb{fill:rgb(127,127,0);white-space:pre}.bc{fill:rgb(106,148,0);white-space:pre}.bd{fill:rgb(85,170,0);white-space:pre}.be{fill:rgb(63,191,0);white-space:pre}.bf{fill:rgb(42,212,0);white-space:pre}@keyframes aT{0%{transform:translateX(-0px)}4.55%{transform:translateX(-252px)}4.55%{transform:translateX(-504px)}4.55%{transform:translateX(-756px)}5.06%{transform:translateX(-1008px)}5.56%{transform:translateX(-1260px)}6.06%{transform:translateX(-1512px)}6.57%{transform:translateX(-1764px)}7.06%{transform:translateX(-2016px)}7.07%{transform:translateX(-2268px)}7.57%{transform:translateX(-2520px)}8.08%{transform:translateX(-2772px)}8.58%{transform:translateX(-3024px)}9.08%{transform:translateX(-3276px)}9.58%{transform:translateX(-3528px)}9.59%{transform:translateX(-3780px)}10.09%{transform:translateX(-4032px)}10.59%{transform:translateX(-4284px)}11.1%{transform:translateX(-4536px)}11.6%{transform:translateX(-4788px)}12.09%{transform:translateX(-5040px)}12.1%{transform:translateX(-5292px)}12.61%{transform:translateX(-5544px)}13.11%{transform:translateX(-5796px)}13.61%{transform:translateX(-6048px)}14.11%{transform:translateX(-6300px)}14.6%{transform:translateX(-6552px)}14.62%{transform:translateX(-6804px)}15.12%{transform:translateX(-7056px)}15.62%{transform:translateX(-7308px)}16.13%{transform:translateX(-7560px)}16.63%{transform:translateX(-7812px)}17.11%{transform:translateX(-8064px)}17.13%{transform:translateX(-8316px)}17.64%{transform:translateX(-8568px)}18.14%{transform:translateX(-8820px)}18.64%{transform:translateX(-9072px)}19.15%{transform:translateX(-9324px)}19.62%{transform:translateX(-9576px)}19.65%{transform:translateX(-9828px)}20.15%{transform:translateX(-10080px)}20.66%{transform:translateX(-10332px)}21.16%{transform:translateX(-10584px)}21.66%{transform:translateX(-10836px)}22.13%{transform:translateX(-11088px)}22.17%{transform:translateX(-11340px)}22.67%{transform:translateX(-11592px)}23.17%{transform:translateX(-11844px)}23.68%{transform:translateX(-12096px)}24.18%{transform:translateX(-12348px)}24.64%{transform:translateX(-12600px)}24.68%{transform:translateX(-12852px)}25.19%{transform:translateX(-13104px)}25.69%{transform:translateX(-13356px)}26.19%{transform:translateX(-13608px)}26.69%{transform:translateX(-13860px)}27.15%{transform:translateX(-14112px)}27.2%{transform:translateX(-14364px)}27.7%{transform:translateX(-14616px)}28.2%{transform:translateX(-14868px)}28.71%{transform:translateX(-15120px)}29.21%{transform:translateX(-15372px)}29.66%{transform:translateX(-15624px)}29.71%{transform:translateX(-15876px)}30.22%{transform:translateX(-16128px)}30.72%{transform:translateX(-16380px)}31.22%{transform:translateX(-16632px)}31.73%{transform:translateX(-16884px)}32.17%{transform:translateX(-17136px)}32.23%{transform:translateX(-17388px)}32.73%{transform:translateX(-17640px)}33.24%{transform:translateX(-17892px)}33.74%{transform:translateX(-18144px)}34.24%{transform:translateX(-18396px)}34.69%{transform:translateX(-18648px)}34.75%{transform:translateX(-18900px)}35.25%{transform:translateX(-19152px)}35.75%{transform:translateX(-19404px)}36.26%{transform:translateX(-19656px)}36.76%{transform:translateX(-19908px)}37.2%{transform:translateX(-20160px)}37.26%{transform:translateX(-20412px)}37.77%{transform:translateX(-20664px)}38.27%{transform:translateX(-20916px)}38.77%{transform:translateX(-21168px)}39.28%{transform:translateX(-21420px)}39.71%{transform:translateX(-21672px)}39.78%{transform:translateX(-21924px)}40.28%{transform:translateX(-22176px)}40.79%{transform:translateX(-22428px)}41.29%{transform:translateX(-22680px)}41.79%{transform:translateX(-22932px)}42.22%{transform:translateX(-23184px)}42.22%{transform:translateX(-23436px)}44.73%{transform:translateX(-23688px)}44.73%{transform:translateX(-23940px)}44.73%{transform:translateX(-24192px)}45.99%{transform:translateX(-24444px)}45.99%{transform:translateX(-24696px)}47.25%{transform:translateX(-24948px)}47.25%{transform:translateX(-25200px)}48.5%{transform:translateX(-25452px)}48.5%{transform:translateX(-25704px)}49.76%{transform:translateX(-25956px)}49.76%{transform:translateX(-26208px)}51.02%{transform:translateX(-26460px)}51.02%{transform:translateX(-26712px)}52.27%{transform:translateX(-26964px)}52.28%{transform:translateX(-27216px)}53.53%{transform:translateX(-27468px)}53.53%{transform:translateX(-27720px)}54.79%{transform:translateX(-27972px)}54.79%{transform:translateX(-28224px)}56.05%{transform:translateX(-28476px)}56.05%{transform:translateX(-28728px)}57.3%{transform:translateX(-28980px)}57.3%{transform:translateX(-29232px)}58.56%{transform:translateX(-29484px)}58.56%{transform:translateX(-29736px)}59.82%{transform:translateX(-29988px)}64.84%{transform:translateX(-30240px)}64.84%{transform:translateX(-30492px)}64.84%{transform:translateX(-30744px)}64.84%{transform:translateX(-30996px)}74.89%{transform:translateX(-31248px)}74.89%{transform:translateX(-31500px)}74.89%{transform:translateX(-31752px)}74.89%{transform:translateX(-32004px)}84.94%{transform:translateX(-32256px)}84.94%{transform:translateX(-32508px)}84.94%{transform:translateX(-32760px)}84.94%{transform:translateX(-33012px)}87.45%{transform:translateX(-33264px)}100%{transform:translateX(-33516px)}}███████████████████████████████████████████████████████████████████████████████████████████████████████████████████ PTDP - PTerm Demo Program INFO ThisanimationwasgeneratedwiththelatestversionofPTerm! PTermworksonnearlyeveryterminalandoperatingsystem. It'ssupereasytouse! Ifyouwant,youcancustomizeeverything:) Youcanseethecodeofthisdemointhe./_examples/demodirectory. Thisdemowasupdatedat:21Apr2022-01:56:04CESTWaitingfor15seconds...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:)#BulletListPrinterGoodbyeHaveaniceday!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/header-custom/demo/animation.svg b/_examples/header-custom/demo/animation.svg index f6d10ba31..172c4618a 100644 --- a/_examples/header-custom/demo/animation.svg +++ b/_examples/header-custom/demo/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(102,194,205)}.g{fill:rgb(160,160,160);white-space:pre}.h{white-space:pre}.i{fill:rgb(232,131,136)}.j{fill:transparent}.l{animation-duration:6.641452s;animation-iteration-count:infinite;animation-name:k;animation-timing-function:steps(1,end)}@keyframes k{0%{transform:translateX(-0px)}24.7%{transform:translateX(-252px)}100%{transform:translateX(-504px)}} This is a custom header! This is a custom header! 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(102,194,205)}.g{fill:rgb(160,160,160);white-space:pre}.h{white-space:pre}.i{fill:rgb(232,131,136)}.j{fill:transparent}.l{animation-duration:6.6039200000000005s;animation-iteration-count:infinite;animation-name:k;animation-timing-function:steps(1,end)}@keyframes k{0%{transform:translateX(-0px)}24.3%{transform:translateX(-252px)}100%{transform:translateX(-504px)}} This is a custom header! This is a custom header! Restartinganimation... \ No newline at end of file diff --git a/_examples/panel/demo/animation.svg b/_examples/panel/demo/animation.svg index 4f5355862..c980c1e40 100644 --- a/_examples/panel/demo/animation.svg +++ b/_examples/panel/demo/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(111,119,131)}.h{fill:rgb(255,255,255);font-weight:bold;white-space:pre}.i{fill:rgb(255,0,4);white-space:pre}.j{fill:transparent}.l{animation-duration:6.434106s;animation-iteration-count:infinite;animation-name:k;animation-timing-function:steps(1,end)}@keyframes k{0%{transform:translateX(-0px)}22.3%{transform:translateX(-252px)}100%{transform:translateX(-504px)}}Thisisthefirstpanel This Hello, World! panel containsmultiplelinesThisisanotherThisisthesecondpanelpanellinewithanewlineRestartinganimation... \ 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(111,119,131)}.h{fill:rgb(255,255,255);font-weight:bold;white-space:pre}.i{fill:rgb(255,0,4);white-space:pre}.j{fill:transparent}.l{animation-duration:6.829499s;animation-iteration-count:infinite;animation-name:k;animation-timing-function:steps(1,end)}@keyframes k{0%{transform:translateX(-0px)}26.8%{transform:translateX(-252px)}100%{transform:translateX(-504px)}}Thisisthefirstpanel This Hello, World! panel containsmultiplelinesThisisanotherThisisthesecondpanelpanellinewithanewlineRestartinganimation... \ No newline at end of file diff --git a/_examples/paragraph/customized/animation.svg b/_examples/paragraph/customized/animation.svg index 85c1aa568..cdf51f0c6 100644 --- a/_examples/paragraph/customized/animation.svg +++ b/_examples/paragraph/customized/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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:transparent}.i{animation-duration:6.630381s;animation-iteration-count:infinite;animation-name:h;animation-timing-function:steps(1,end)}@keyframes h{0%{transform:translateX(-0px)}24.6%{transform:translateX(-252px)}100%{transform:translateX(-504px)}}Thisisacustomparagraphprinter.Asyoucansee,nowordsareseparated,butthetextissplitatthespaces.Thisisusefulforcontinuoustextofallkinds.Youcanmanuallychangethelinewidthifyouwantto.Loremipsumdolorsitamet,consetetursadipscingelitr,seddiamnonumyeirmodtemporinviduntutlaboreetdoloremagnaaliquyamThistextiswrittenwiththedefaultPrintln()function.Nointelligentsplittinghere.Loremipsumdolorsitamet,consetetursadipscingelitr,seddiamnonumyeirmodtemporinviduntutlaboreetdoloremagnaaliquyamRestartinganimation... \ 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:transparent}.i{animation-duration:6.874116s;animation-iteration-count:infinite;animation-name:h;animation-timing-function:steps(1,end)}@keyframes h{0%{transform:translateX(-0px)}27.3%{transform:translateX(-252px)}100%{transform:translateX(-504px)}}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/demo/animation.svg b/_examples/paragraph/demo/animation.svg index 6ee2e95db..fa23567e4 100644 --- a/_examples/paragraph/demo/animation.svg +++ b/_examples/paragraph/demo/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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:transparent}.i{animation-duration:6.593332s;animation-iteration-count:infinite;animation-name:h;animation-timing-function:steps(1,end)}@keyframes h{0%{transform:translateX(-0px)}24.2%{transform:translateX(-252px)}100%{transform:translateX(-504px)}}Thisisthedefaultparagraphprinter.Asyoucansee,nowordsareseparated,butthetextissplitatthespaces.Thisisusefulforcontinuoustextofallkinds.Youcanmanuallychangethelinewidthifyouwantto.Loremipsumdolorsitamet,consetetursadipscingelitr,seddiamnonumyeirmodtemporinviduntutlaboreetdoloremagnaaliquyamThistextiswrittenwiththedefaultPrintln()function.Nointelligentsplittinghere.Loremipsumdolorsitamet,consetetursadipscingelitr,seddiamnonumyeirmodtemporinviduntutlaboreetdoloremagnaaliquyamRestartinganimation... \ 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:transparent}.i{animation-duration:6.875153s;animation-iteration-count:infinite;animation-name:h;animation-timing-function:steps(1,end)}@keyframes h{0%{transform:translateX(-0px)}27.3%{transform:translateX(-252px)}100%{transform:translateX(-504px)}}Thisisthedefaultparagraphprinter.Asyoucansee,nowordsareseparated,butthetextissplitatthespaces.Thisisusefulforcontinuoustextofallkinds.Youcanmanuallychangethelinewidthifyouwantto.Loremipsumdolorsitamet,consetetursadipscingelitr,seddiamnonumyeirmodtemporinviduntutlaboreetdoloremagnaaliquyamThistextiswrittenwiththedefaultPrintln()function.Nointelligentsplittinghere.Loremipsumdolorsitamet,consetetursadipscingelitr,seddiamnonumyeirmodtemporinviduntutlaboreetdoloremagnaaliquyamRestartinganimation... \ No newline at end of file diff --git a/_examples/prefix/demo/animation.svg b/_examples/prefix/demo/animation.svg index 1e5178d5e..566e28b75 100644 --- a/_examples/prefix/demo/animation.svg +++ b/_examples/prefix/demo/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(111,119,131)}.g{white-space:pre}.h{fill:rgb(104,104,104);white-space:pre}.i{fill:rgb(102,194,205)}.j{fill:rgb(126,231,233);white-space:pre}.k{fill:rgb(168,204,140)}.l{fill:rgb(124,255,0);white-space:pre}.m{fill:rgb(219,171,121)}.n{fill:rgb(255,241,0);white-space:pre}.o{fill:rgb(232,131,136)}.p{fill:rgb(243,86,86);white-space:pre}.q{fill:transparent}.s{animation-duration:6.349075s;animation-iteration-count:infinite;animation-name:r;animation-timing-function:steps(1,end)}.t{fill:rgb(160,160,160);white-space:pre}@keyframes r{0%{transform:translateX(-0px)}21.2%{transform:translateX(-252px)}21.2%{transform:translateX(-504px)}100%{transform:translateX(-756px)}} 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 +}.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(111,119,131)}.g{white-space:pre}.h{fill:rgb(104,104,104);white-space:pre}.i{fill:rgb(102,194,205)}.j{fill:rgb(126,231,233);white-space:pre}.k{fill:rgb(168,204,140)}.l{fill:rgb(124,255,0);white-space:pre}.m{fill:rgb(219,171,121)}.n{fill:rgb(255,241,0);white-space:pre}.o{fill:rgb(232,131,136)}.p{fill:rgb(243,86,86);white-space:pre}.q{fill:transparent}.s{animation-duration:6.832378s;animation-iteration-count:infinite;animation-name:r;animation-timing-function:steps(1,end)}.t{fill:rgb(160,160,160);white-space:pre}@keyframes r{0%{transform:translateX(-0px)}26.8%{transform:translateX(-252px)}26.8%{transform:translateX(-504px)}100%{transform:translateX(-756px)}} 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/progressbar/demo/animation.svg b/_examples/progressbar/demo/animation.svg index 4bd1215e5..305fdb169 100644 --- a/_examples/progressbar/demo/animation.svg +++ b/_examples/progressbar/demo/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(168,204,140)}.g{white-space:pre}.h{fill:rgb(124,255,0);white-space:pre}.i{fill:rgb(126,231,233);white-space:pre}.j{fill:rgb(104,104,104);white-space:pre}.k{fill:rgb(255,255,255);white-space:pre}.l{fill:rgb(0,198,255);white-space:pre}.m{fill:rgb(0,255,0);white-space:pre}.n{fill:rgb(160,160,160);white-space:pre}.o{fill:transparent}.q{animation-duration:10.389614s;animation-iteration-count:infinite;animation-name:p;animation-timing-function:steps(1,end)}.r{fill:rgb(255,0,0);white-space:pre}.s{fill:rgb(233,21,0);white-space:pre}.t{fill:rgb(212,42,0);white-space:pre}.u{fill:rgb(191,63,0);white-space:pre}.v{fill:rgb(170,85,0);white-space:pre}.w{fill:rgb(148,106,0);white-space:pre}.x{fill:rgb(127,127,0);white-space:pre}.y{fill:rgb(106,148,0);white-space:pre}.z{fill:rgb(85,170,0);white-space:pre}.A{fill:rgb(63,191,0);white-space:pre}.B{fill:rgb(42,212,0);white-space:pre}.C{fill:rgb(21,233,0);white-space:pre}@keyframes p{0%{transform:translateX(-0px)}14.7%{transform:translateX(-252px)}14.7%{transform:translateX(-504px)}18.1%{transform:translateX(-756px)}18.1%{transform:translateX(-1008px)}21.5%{transform:translateX(-1260px)}21.5%{transform:translateX(-1512px)}24.9%{transform:translateX(-1764px)}24.9%{transform:translateX(-2016px)}28.2%{transform:translateX(-2268px)}28.2%{transform:translateX(-2520px)}31.6%{transform:translateX(-2772px)}31.6%{transform:translateX(-3024px)}35%{transform:translateX(-3276px)}35%{transform:translateX(-3528px)}38.4%{transform:translateX(-3780px)}38.4%{transform:translateX(-4032px)}41.7%{transform:translateX(-4284px)}41.7%{transform:translateX(-4536px)}45.1%{transform:translateX(-4788px)}45.1%{transform:translateX(-5040px)}48.5%{transform:translateX(-5292px)}48.5%{transform:translateX(-5544px)}51.9%{transform:translateX(-5796px)}51.9%{transform:translateX(-6048px)}100%{transform:translateX(-6300px)}} 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[2/12]███████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░17%|1sDownloadingpseudo-chrome[3/12]██████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░25%|1sDownloadingpseudo-outlook[4/12]█████████████░░░░░░░░░░░░░░░░░░░░░░░░33%|1sDownloadingpseudo-explorer[5/12]███████████████░░░░░░░░░░░░░░░░░░░░░42%|1sDownloadingpseudo-dops[5/12]█████████████████░░░░░░░░░░░░░░░░░░░░░░░42%|2sDownloadingpseudo-dops[6/12]████████████████████░░░░░░░░░░░░░░░░░░░░50%|2sDownloadingpseudo-git[7/12]████████████████████████░░░░░░░░░░░░░░░░░58%|2sDownloadingpseudo-vsc[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 +}.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(168,204,140)}.g{white-space:pre}.h{fill:rgb(124,255,0);white-space:pre}.i{fill:rgb(126,231,233);white-space:pre}.j{fill:rgb(104,104,104);white-space:pre}.k{fill:rgb(255,255,255);white-space:pre}.l{fill:rgb(0,198,255);white-space:pre}.m{fill:rgb(0,255,0);white-space:pre}.n{fill:rgb(160,160,160);white-space:pre}.o{fill:transparent}.q{animation-duration:10.616887s;animation-iteration-count:infinite;animation-name:p;animation-timing-function:steps(1,end)}.r{fill:rgb(255,0,0);white-space:pre}.s{fill:rgb(233,21,0);white-space:pre}.t{fill:rgb(212,42,0);white-space:pre}.u{fill:rgb(191,63,0);white-space:pre}.v{fill:rgb(170,85,0);white-space:pre}.w{fill:rgb(148,106,0);white-space:pre}.x{fill:rgb(127,127,0);white-space:pre}.y{fill:rgb(106,148,0);white-space:pre}.z{fill:rgb(85,170,0);white-space:pre}.A{fill:rgb(63,191,0);white-space:pre}.B{fill:rgb(42,212,0);white-space:pre}.C{fill:rgb(21,233,0);white-space:pre}@keyframes p{0%{transform:translateX(-0px)}16.6%{transform:translateX(-252px)}16.6%{transform:translateX(-504px)}19.9%{transform:translateX(-756px)}19.9%{transform:translateX(-1008px)}23.2%{transform:translateX(-1260px)}23.2%{transform:translateX(-1512px)}26.5%{transform:translateX(-1764px)}26.5%{transform:translateX(-2016px)}29.8%{transform:translateX(-2268px)}29.8%{transform:translateX(-2520px)}33.1%{transform:translateX(-2772px)}33.1%{transform:translateX(-3024px)}36.4%{transform:translateX(-3276px)}36.4%{transform:translateX(-3528px)}39.7%{transform:translateX(-3780px)}39.7%{transform:translateX(-4032px)}43%{transform:translateX(-4284px)}43%{transform:translateX(-4536px)}46.3%{transform:translateX(-4788px)}46.3%{transform:translateX(-5040px)}49.6%{transform:translateX(-5292px)}49.6%{transform:translateX(-5544px)}52.9%{transform:translateX(-5796px)}52.9%{transform:translateX(-6048px)}100%{transform:translateX(-6300px)}} 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/section/demo/animation.svg b/_examples/section/demo/animation.svg index 1cf2c528d..381f26664 100644 --- a/_examples/section/demo/animation.svg +++ b/_examples/section/demo/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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.5947949999999995s;animation-iteration-count:infinite;animation-name:l;animation-timing-function:steps(1,end)}@keyframes l{0%{transform:translateX(-0px)}24.2%{transform:translateX(-252px)}24.2%{transform:translateX(-504px)}100%{transform:translateX(-756px)}}#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/spinner/demo/animation.svg b/_examples/spinner/demo/animation.svg index eaf9ac47b..d2ad0350e 100644 --- a/_examples/spinner/demo/animation.svg +++ b/_examples/spinner/demo/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(126,231,233);white-space:pre}.g{fill:rgb(255,255,255);white-space:pre}.h{fill:rgb(104,104,104);white-space:pre}.i{fill:rgb(168,204,140)}.j{white-space:pre}.k{fill:rgb(124,255,0);white-space:pre}.l{fill:rgb(219,171,121)}.m{fill:rgb(255,241,0);white-space:pre}.n{fill:rgb(232,131,136)}.o{fill:rgb(243,86,86);white-space:pre}.p{fill:transparent}.r{animation-duration:15.590879s;animation-iteration-count:infinite;animation-name:q;animation-timing-function:steps(1,end)}.s{fill:rgb(160,160,160);white-space:pre}@keyframes q{0%{transform:translateX(-0px)}10.2%{transform:translateX(-252px)}11.5%{transform:translateX(-504px)}12.8%{transform:translateX(-756px)}14%{transform:translateX(-1008px)}15.3%{transform:translateX(-1260px)}16.6%{transform:translateX(-1512px)}17.9%{transform:translateX(-1764px)}19.2%{transform:translateX(-2016px)}20.5%{transform:translateX(-2268px)}21.8%{transform:translateX(-2520px)}23%{transform:translateX(-2772px)}23%{transform:translateX(-3024px)}24.3%{transform:translateX(-3276px)}25.6%{transform:translateX(-3528px)}26.9%{transform:translateX(-3780px)}28.2%{transform:translateX(-4032px)}29.4%{transform:translateX(-4284px)}30.7%{transform:translateX(-4536px)}32%{transform:translateX(-4788px)}33.3%{transform:translateX(-5040px)}34.6%{transform:translateX(-5292px)}35.8%{transform:translateX(-5544px)}35.9%{transform:translateX(-5796px)}37.1%{transform:translateX(-6048px)}38.4%{transform:translateX(-6300px)}39.7%{transform:translateX(-6552px)}41%{transform:translateX(-6804px)}42.3%{transform:translateX(-7056px)}43.6%{transform:translateX(-7308px)}44.9%{transform:translateX(-7560px)}46.1%{transform:translateX(-7812px)}47.4%{transform:translateX(-8064px)}48.7%{transform:translateX(-8316px)}48.7%{transform:translateX(-8568px)}50%{transform:translateX(-8820px)}51.3%{transform:translateX(-9072px)}52.5%{transform:translateX(-9324px)}53.8%{transform:translateX(-9576px)}55.1%{transform:translateX(-9828px)}55.1%{transform:translateX(-10080px)}56.4%{transform:translateX(-10332px)}57.7%{transform:translateX(-10584px)}59%{transform:translateX(-10836px)}60.3%{transform:translateX(-11088px)}61.5%{transform:translateX(-11340px)}61.5%{transform:translateX(-11592px)}62.8%{transform:translateX(-11844px)}64.1%{transform:translateX(-12096px)}65.4%{transform:translateX(-12348px)}66.7%{transform:translateX(-12600px)}67.9%{transform:translateX(-12852px)}100%{transform:translateX(-13104px)}}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'sreallymuchIt'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 +}.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(126,231,233);white-space:pre}.g{fill:rgb(255,255,255);white-space:pre}.h{fill:rgb(104,104,104);white-space:pre}.i{fill:rgb(168,204,140)}.j{white-space:pre}.k{fill:rgb(124,255,0);white-space:pre}.l{fill:rgb(219,171,121)}.m{fill:rgb(255,241,0);white-space:pre}.n{fill:rgb(232,131,136)}.o{fill:rgb(243,86,86);white-space:pre}.p{fill:transparent}.r{animation-duration:15.782215s;animation-iteration-count:infinite;animation-name:q;animation-timing-function:steps(1,end)}.s{fill:rgb(160,160,160);white-space:pre}@keyframes q{0%{transform:translateX(-0px)}11.3%{transform:translateX(-252px)}12.5%{transform:translateX(-504px)}13.8%{transform:translateX(-756px)}15.1%{transform:translateX(-1008px)}16.4%{transform:translateX(-1260px)}17.6%{transform:translateX(-1512px)}18.9%{transform:translateX(-1764px)}20.2%{transform:translateX(-2016px)}21.4%{transform:translateX(-2268px)}22.7%{transform:translateX(-2520px)}23.9%{transform:translateX(-2772px)}23.9%{transform:translateX(-3024px)}25.2%{transform:translateX(-3276px)}26.5%{transform:translateX(-3528px)}27.8%{transform:translateX(-3780px)}29%{transform:translateX(-4032px)}30.3%{transform:translateX(-4284px)}31.6%{transform:translateX(-4536px)}32.8%{transform:translateX(-4788px)}34.1%{transform:translateX(-5040px)}35.4%{transform:translateX(-5292px)}36.6%{transform:translateX(-5544px)}36.6%{transform:translateX(-5796px)}37.9%{transform:translateX(-6048px)}39.2%{transform:translateX(-6300px)}40.4%{transform:translateX(-6552px)}41.7%{transform:translateX(-6804px)}43%{transform:translateX(-7056px)}44.2%{transform:translateX(-7308px)}45.5%{transform:translateX(-7560px)}46.8%{transform:translateX(-7812px)}48.1%{transform:translateX(-8064px)}49.3%{transform:translateX(-8316px)}49.3%{transform:translateX(-8568px)}49.3%{transform:translateX(-8820px)}50.6%{transform:translateX(-9072px)}51.8%{transform:translateX(-9324px)}53.1%{transform:translateX(-9576px)}54.4%{transform:translateX(-9828px)}55.6%{transform:translateX(-10080px)}55.7%{transform:translateX(-10332px)}56.9%{transform:translateX(-10584px)}58.2%{transform:translateX(-10836px)}59.5%{transform:translateX(-11088px)}60.7%{transform:translateX(-11340px)}62%{transform:translateX(-11592px)}62%{transform:translateX(-11844px)}62%{transform:translateX(-12096px)}63.3%{transform:translateX(-12348px)}64.5%{transform:translateX(-12600px)}65.8%{transform:translateX(-12852px)}67.1%{transform:translateX(-13104px)}68.3%{transform:translateX(-13356px)}100%{transform:translateX(-13608px)}}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'sreallymuchIt'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/style/demo/animation.svg b/_examples/style/demo/animation.svg index 40928f086..d5b3e5378 100644 --- a/_examples/style/demo/animation.svg +++ b/_examples/style/demo/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(111,119,131)}.g{fill:rgb(126,231,233);font-weight:bold;white-space:pre}.h{fill:rgb(185,191,202)}.i{fill:rgb(127,253,127);white-space:pre}.j{fill:transparent}.l{animation-duration:6.5854680000000005s;animation-iteration-count:infinite;animation-name:k;animation-timing-function:steps(1,end)}.m{fill:rgb(160,160,160);white-space:pre}@keyframes k{0%{transform:translateX(-0px)}24.1%{transform:translateX(-252px)}100%{transform:translateX(-504px)}}Hello, World!Hello, World!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(111,119,131)}.g{fill:rgb(126,231,233);font-weight:bold;white-space:pre}.h{fill:rgb(185,191,202)}.i{fill:rgb(127,253,127);white-space:pre}.j{fill:transparent}.l{animation-duration:6.798081s;animation-iteration-count:infinite;animation-name:k;animation-timing-function:steps(1,end)}.m{fill:rgb(160,160,160);white-space:pre}@keyframes k{0%{transform:translateX(-0px)}26.4%{transform:translateX(-252px)}100%{transform:translateX(-504px)}}Hello, World!Hello, World!Restartinganimation... \ No newline at end of file diff --git a/_examples/table/demo/animation.svg b/_examples/table/demo/animation.svg index 74d2d3a74..c1d22eac2 100644 --- a/_examples/table/demo/animation.svg +++ b/_examples/table/demo/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(126,231,233);white-space:pre}.g{fill:rgb(104,104,104);white-space:pre}.h{fill:rgb(160,160,160);white-space:pre}.i{fill:transparent}.k{animation-duration:6.776144s;animation-iteration-count:infinite;animation-name:j;animation-timing-function:steps(1,end)}@keyframes j{0%{transform:translateX(-0px)}26.2%{transform:translateX(-252px)}26.2%{transform:translateX(-504px)}100%{transform:translateX(-756px)}}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 +}.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(126,231,233);white-space:pre}.g{fill:rgb(104,104,104);white-space:pre}.h{fill:rgb(160,160,160);white-space:pre}.i{fill:transparent}.k{animation-duration:6.90234s;animation-iteration-count:infinite;animation-name:j;animation-timing-function:steps(1,end)}@keyframes j{0%{transform:translateX(-0px)}27.6%{transform:translateX(-252px)}27.6%{transform:translateX(-504px)}100%{transform:translateX(-756px)}}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/theme/demo/animation.svg b/_examples/theme/demo/animation.svg index f9128a8b4..f732c324f 100644 --- a/_examples/theme/demo/animation.svg +++ b/_examples/theme/demo/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(102,194,205)}.g{white-space:pre}.h{fill:rgb(126,231,233);white-space:pre}.i{fill:rgb(0,198,255);white-space:pre}.j{fill:rgb(234,89,246);white-space:pre}.k{fill:rgb(255,241,0);font-weight:bold;white-space:pre}.l{fill:rgb(124,255,0);white-space:pre}.m{fill:rgb(168,204,140)}.n{fill:rgb(255,241,0);white-space:pre}.o{fill:rgb(219,171,121)}.p{fill:rgb(243,86,86);white-space:pre}.q{fill:rgb(232,131,136)}.r{fill:rgb(160,160,160);white-space:pre}.s{fill:rgb(111,119,131)}.t{fill:rgb(255,255,255);white-space:pre}.u{fill:rgb(104,104,104);white-space:pre}.v{fill:rgb(255,255,255);font-weight:bold;white-space:pre}.w{fill:transparent}.y{animation-duration:15.870953s;animation-iteration-count:infinite;animation-name:x;animation-timing-function:steps(1,end)}@keyframes x{0%{transform:translateX(-0px)}10.1%{transform:translateX(-252px)}11.7%{transform:translateX(-504px)}13.3%{transform:translateX(-756px)}14.8%{transform:translateX(-1008px)}16.4%{transform:translateX(-1260px)}18%{transform:translateX(-1512px)}19.6%{transform:translateX(-1764px)}21.1%{transform:translateX(-2016px)}22.7%{transform:translateX(-2268px)}24.3%{transform:translateX(-2520px)}25.9%{transform:translateX(-2772px)}27.5%{transform:translateX(-3024px)}29%{transform:translateX(-3276px)}30.6%{transform:translateX(-3528px)}32.2%{transform:translateX(-3780px)}33.8%{transform:translateX(-4032px)}35.4%{transform:translateX(-4284px)}36.9%{transform:translateX(-4536px)}38.5%{transform:translateX(-4788px)}40.1%{transform:translateX(-5040px)}41.7%{transform:translateX(-5292px)}43.2%{transform:translateX(-5544px)}44.8%{transform:translateX(-5796px)}46.4%{transform:translateX(-6048px)}48%{transform:translateX(-6300px)}49.6%{transform:translateX(-6552px)}51.1%{transform:translateX(-6804px)}52.7%{transform:translateX(-7056px)}54.3%{transform:translateX(-7308px)}55.9%{transform:translateX(-7560px)}57.4%{transform:translateX(-7812px)}59%{transform:translateX(-8064px)}60.6%{transform:translateX(-8316px)}62.2%{transform:translateX(-8568px)}63.8%{transform:translateX(-8820px)}65.3%{transform:translateX(-9072px)}66.9%{transform:translateX(-9324px)}68.5%{transform:translateX(-9576px)}100%{transform:translateX(-9828px)}} INFO Thesearethedefaultthemestyles. Youcanmodifythemeasilytoyourpersonalpreference, orcreatenewthemesfromscratch:)PrimaryStyleSecondaryStyleHighlightStyleInfoMessageStyleInfoPrefixStyleSuccessMessageStyleSuccessPrefixStyleWarningMessageStyleWarningPrefixStyleErrorMessageStyleErrorPrefixStyleFatalMessageStyleFatalPrefixStyleDescriptionMessageStyleDescriptionPrefixStyleScopeStyleProgressbarBarStyleProgressbarTitleStyleHeaderTextStyleHeaderBackgroundStyleSpinnerStyleSpinnerTextStyleTimerStyleTableStyleTableHeaderStyleTableSeparatorStyleSectionStyleBulletListTextStyleBulletListBulletStyleTreeStyleTreeTextStyleLetterStyleDebugMessageStyleDebugPrefixStyleBoxStyleBoxTextStyleBarLabelStyleBarStyleRestartinganimation... \ 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(102,194,205)}.g{white-space:pre}.h{fill:rgb(126,231,233);white-space:pre}.i{fill:rgb(0,198,255);white-space:pre}.j{fill:rgb(234,89,246);white-space:pre}.k{fill:rgb(255,241,0);font-weight:bold;white-space:pre}.l{fill:rgb(124,255,0);white-space:pre}.m{fill:rgb(168,204,140)}.n{fill:rgb(255,241,0);white-space:pre}.o{fill:rgb(219,171,121)}.p{fill:rgb(243,86,86);white-space:pre}.q{fill:rgb(232,131,136)}.r{fill:rgb(160,160,160);white-space:pre}.s{fill:rgb(111,119,131)}.t{fill:rgb(255,255,255);white-space:pre}.u{fill:rgb(104,104,104);white-space:pre}.v{fill:rgb(255,255,255);font-weight:bold;white-space:pre}.w{fill:transparent}.y{animation-duration:16.049057s;animation-iteration-count:infinite;animation-name:x;animation-timing-function:steps(1,end)}@keyframes x{0%{transform:translateX(-0px)}11.1%{transform:translateX(-252px)}12.7%{transform:translateX(-504px)}14.2%{transform:translateX(-756px)}15.8%{transform:translateX(-1008px)}17.3%{transform:translateX(-1260px)}18.9%{transform:translateX(-1512px)}20.5%{transform:translateX(-1764px)}22%{transform:translateX(-2016px)}23.6%{transform:translateX(-2268px)}25.1%{transform:translateX(-2520px)}26.7%{transform:translateX(-2772px)}28.3%{transform:translateX(-3024px)}29.8%{transform:translateX(-3276px)}31.4%{transform:translateX(-3528px)}33%{transform:translateX(-3780px)}34.5%{transform:translateX(-4032px)}36.1%{transform:translateX(-4284px)}37.6%{transform:translateX(-4536px)}39.2%{transform:translateX(-4788px)}40.8%{transform:translateX(-5040px)}42.3%{transform:translateX(-5292px)}43.9%{transform:translateX(-5544px)}45.4%{transform:translateX(-5796px)}47%{transform:translateX(-6048px)}48.6%{transform:translateX(-6300px)}50.1%{transform:translateX(-6552px)}51.7%{transform:translateX(-6804px)}53.2%{transform:translateX(-7056px)}54.8%{transform:translateX(-7308px)}56.4%{transform:translateX(-7560px)}57.9%{transform:translateX(-7812px)}59.5%{transform:translateX(-8064px)}61%{transform:translateX(-8316px)}62.6%{transform:translateX(-8568px)}64.2%{transform:translateX(-8820px)}65.7%{transform:translateX(-9072px)}67.3%{transform:translateX(-9324px)}68.8%{transform:translateX(-9576px)}100%{transform:translateX(-9828px)}} INFO Thesearethedefaultthemestyles. Youcanmodifythemeasilytoyourpersonalpreference, orcreatenewthemesfromscratch:)PrimaryStyleSecondaryStyleHighlightStyleInfoMessageStyleInfoPrefixStyleSuccessMessageStyleSuccessPrefixStyleWarningMessageStyleWarningPrefixStyleErrorMessageStyleErrorPrefixStyleFatalMessageStyleFatalPrefixStyleDescriptionMessageStyleDescriptionPrefixStyleScopeStyleProgressbarBarStyleProgressbarTitleStyleHeaderTextStyleHeaderBackgroundStyleSpinnerStyleSpinnerTextStyleTimerStyleTableStyleTableHeaderStyleTableSeparatorStyleSectionStyleBulletListTextStyleBulletListBulletStyleTreeStyleTreeTextStyleLetterStyleDebugMessageStyleDebugPrefixStyleBoxStyleBoxTextStyleBarLabelStyleBarStyleRestartinganimation... \ No newline at end of file diff --git a/_examples/tree/demo/animation.svg b/_examples/tree/demo/animation.svg index 13f4917e6..829a73ce0 100644 --- a/_examples/tree/demo/animation.svg +++ b/_examples/tree/demo/animation.svg @@ -7,4 +7,4 @@ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji' !important; -}.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(104,104,104);white-space:pre}.g{fill:rgb(160,160,160);white-space:pre}.h{fill:transparent}.j{animation-duration:6.673437s;animation-iteration-count:infinite;animation-name:i;animation-timing-function:steps(1,end)}@keyframes i{0%{transform:translateX(-0px)}25.1%{transform:translateX(-252px)}25.1%{transform:translateX(-504px)}25.1%{transform:translateX(-756px)}100%{transform:translateX(-1008px)}}├─┬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 +}.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(104,104,104);white-space:pre}.g{fill:rgb(160,160,160);white-space:pre}.h{fill:transparent}.j{animation-duration:6.875354s;animation-iteration-count:infinite;animation-name:i;animation-timing-function:steps(1,end)}@keyframes i{0%{transform:translateX(-0px)}27.3%{transform:translateX(-252px)}27.3%{transform:translateX(-504px)}27.3%{transform:translateX(-756px)}100%{transform:translateX(-1008px)}}├─┬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/docs/README.md b/docs/README.md index 88cd51f65..3f7a273bf 100644 --- a/docs/README.md +++ b/docs/README.md @@ -254,6 +254,134 @@ func main() { +### 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) @@ -355,57 +483,2455 @@ 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!") +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() } -``` - -
- -### bigtext/demo +func installingPseudoList() { + pterm.DefaultSection.Println("Installing pseudo programs") -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bigtext/demo/animation.svg) + 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() +} -SHOW SOURCE +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. -```go -package main + 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) +} -import "github.com/pterm/pterm" +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 main() { - // Print a large text with the LetterStyle from the standard theme. - // Useful for title screens. - pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString("PTerm")).Render() +func pseudoApplicationHeader() *pterm.TextPrinter { + return pterm.DefaultHeader.WithBackgroundStyle(pterm.NewStyle(pterm.BgLightBlue)).WithMargin(10).Println( + "Pseudo Application created with PTerm") +} - // Print a large text with differently colored letters. +func introScreen() { pterm.DefaultBigText.WithLetters( - pterm.NewLettersFromStringWithStyle("P", pterm.NewStyle(pterm.FgCyan)), + pterm.NewLettersFromStringWithStyle("P", pterm.NewStyle(pterm.FgLightCyan)), 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() + 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 } ```
-### box/demo +### coloring/fade-colors -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/box/demo/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-colors/animation.svg)
@@ -414,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/customized +### coloring/fade-multiple-colors -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/bulletlist/customized/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-multiple-colors/animation.svg)
@@ -447,58 +2974,44 @@ func main() { package main import ( + "strings" + "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 + 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. -import "github.com/pterm/pterm" + 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]) + } -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() + // Print info. + pterm.Info.Println(fadeInfo) - // Convert a text to a list and print it. - pterm.NewBulletListFromString(`0 - 1 - 2 - 3`, " ").Render() + // 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!") + } } ```
-### center/demo +### coloring/override-default-printers -![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/center/demo/animation.svg) +![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/override-default-printers/animation.svg)
@@ -510,13 +3023,17 @@ 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:") + // Print default error. + pterm.Error.Println("This is the default Error") - // Generate BigLetters - s, _ := pterm.DefaultBigText.WithLetters(pterm.NewLettersFromString("PTerm")).Srender() - pterm.DefaultCenter.Println(s) // Print BigLetters with the default CenterPrinter + // Customize default error. + pterm.Error.Prefix = pterm.Prefix{ + Text: "OVERRIDE", + Style: pterm.NewStyle(pterm.BgCyan, pterm.FgRed), + } - pterm.DefaultCenter.WithCenterEachLineSeparately().Println("This text is centered!\nBut each line is\ncentered\nseparately") + // Print new default error. + pterm.Error.Println("This is the default Error after the prefix was overridden") } ``` @@ -1362,6 +3879,37 @@ func main() {
+### 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) From 1691dd4aab72f838a07a0562e7b39245f87727c2 Mon Sep 17 00:00:00 2001 From: MarvinJWendt Date: Thu, 21 Apr 2022 02:01:25 +0200 Subject: [PATCH 7/7] fixed linting --- ci/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/main.go b/ci/main.go index 49f3b28ca..ff069cd3c 100644 --- a/ci/main.go +++ b/ci/main.go @@ -72,7 +72,7 @@ func main() { } log.Output(3, "### Generating examples README") - examplesReadme, err := os.ReadFile("./_examples/README.md") + examplesReadme, _ := os.ReadFile("./_examples/README.md") examplesReadmeContent := string(examplesReadme) examplesReadmeContent = writeBetween("examples", examplesReadmeContent, "\n"+readmeExamples+"\n") os.WriteFile("./_examples/README.md", []byte(examplesReadmeContent), 0600)