Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2fd7960
commit 76ec959
Showing
77 changed files
with
1,088 additions
and
1,084 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# PTerm Examples | ||
|
||
> This directory contains examples of using the PTerm library. | ||
40 changes: 20 additions & 20 deletions
40
_examples/print-basic-text/README.md → _examples/basictext/demo/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +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!") | ||
} | ||
|
||
``` | ||
# 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!") | ||
} | ||
|
||
``` |
File renamed without changes
File renamed without changes.
42 changes: 21 additions & 21 deletions
42
_examples/bulletlist-custom/README.md → _examples/bulletlist/customized/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +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() | ||
} | ||
|
||
``` | ||
# 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() | ||
} | ||
|
||
``` |
File renamed without changes
File renamed without changes.
40 changes: 20 additions & 20 deletions
40
_examples/center/README.md → _examples/center/demo/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +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") | ||
} | ||
|
||
``` | ||
# 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") | ||
} | ||
|
||
``` |
File renamed without changes
File renamed without changes.
68 changes: 34 additions & 34 deletions
68
_examples/print-with-color/README.md → _examples/coloring/demo/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +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") | ||
} | ||
|
||
``` | ||
# 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") | ||
} | ||
|
||
``` |
File renamed without changes
File renamed without changes.
Oops, something went wrong.