1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
### box/demo

<details>
<summary>SHOW SOURCE</summary>
```go
package main
import "github.com/pterm/pterm"
func main() {
// Print an informational message.
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")
// Create three panels with text, some of them with titles.
// The panels are created using the DefaultBox style.
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.")
// Combine the panels into a layout using the DefaultPanel style.
// The layout is a 2D grid, with each row being an array of panels.
// In this case, the first row contains panel1 and panel2, and the second row contains only panel3.
panels, _ := pterm.DefaultPanel.WithPanels(pterm.Panels{
{{Data: panel1}, {Data: panel2}},
{{Data: panel3}},
}).Srender()
// Print the panels layout inside a box with a title.
// The box is created using the DefaultBox style, with the title positioned at the bottom right.
pterm.DefaultBox.WithTitle("Lorem Ipsum").WithTitleBottomRight().WithRightPadding(0).WithBottomPadding(0).Println(panels)
}
```
</details>
### box/custom-padding

<details>
<summary>SHOW SOURCE</summary>
```go
package main
import "github.com/pterm/pterm"
func main() {
// Create a default box with custom padding options and print "Hello, World!" inside it.
pterm.DefaultBox.WithRightPadding(10).WithLeftPadding(10).WithTopPadding(2).WithBottomPadding(2).Println("Hello, World!")
}
```
</details>
### box/default

<details>
<summary>SHOW SOURCE</summary>
```go
package main
import "github.com/pterm/pterm"
func main() {
// Create a default box with PTerm and print a message in it.
// The DefaultBox.Println method automatically starts, prints the message, and stops the box.
pterm.DefaultBox.Println("Hello, World!")
}
```
</details>
### box/title

<details>
<summary>SHOW SOURCE</summary>
```go
package main
import "github.com/pterm/pterm"
func main() {
// Create a default box with specified padding
paddedBox := pterm.DefaultBox.WithLeftPadding(4).WithRightPadding(4).WithTopPadding(1).WithBottomPadding(1)
// Define a title for the box
title := pterm.LightRed("I'm a box!")
// Create boxes with the title positioned differently and containing different content
box1 := paddedBox.WithTitle(title).Sprint("Hello, World!\n 1") // Title at default position (top left)
box2 := paddedBox.WithTitle(title).WithTitleTopCenter().Sprint("Hello, World!\n 2") // Title at top center
box3 := paddedBox.WithTitle(title).WithTitleTopRight().Sprint("Hello, World!\n 3") // Title at top right
box4 := paddedBox.WithTitle(title).WithTitleBottomRight().Sprint("Hello, World!\n 4") // Title at bottom right
box5 := paddedBox.WithTitle(title).WithTitleBottomCenter().Sprint("Hello, World!\n 5") // Title at bottom center
box6 := paddedBox.WithTitle(title).WithTitleBottomLeft().Sprint("Hello, World!\n 6") // Title at bottom left
box7 := paddedBox.WithTitle(title).WithTitleTopLeft().Sprint("Hello, World!\n 7") // Title at top left
// Render the boxes in a panel layout
pterm.DefaultPanel.WithPanels([][]pterm.Panel{
{{box1}, {box2}, {box3}},
{{box4}, {box5}, {box6}},
{{box7}},
}).Render()
}
```
</details>
|