Skip to content

Commit

Permalink
Merge branch 'master' into issue-460-proposal_live_update_elapsed_tim…
Browse files Browse the repository at this point in the history
…e_for_progressbar
  • Loading branch information
KarolosLykos committed May 2, 2023
2 parents 4df1c2a + 45c6eda commit 1d4fac6
Show file tree
Hide file tree
Showing 77 changed files with 943 additions and 65 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
<a name="unreleased"></a>
## [Unreleased]

### Features
- **rgb:** added RGBStyle

### Test
- **rgb:** added RGBStyle tests

### Code Refactoring
- **rgb:** removed 'GetValues' for 'RGBStyle'


<a name="v0.12.59"></a>
## [v0.12.59] - 2023-04-15
### Features
- add optional mask to InteractiveTextInputPrinter

Expand Down Expand Up @@ -1156,7 +1168,8 @@ removed `Header` and put it's content directly into `HeaderPrinter`
- initial commit


[Unreleased]: https://github.com/pterm/pterm/compare/v0.12.58...HEAD
[Unreleased]: https://github.com/pterm/pterm/compare/v0.12.59...HEAD
[v0.12.59]: https://github.com/pterm/pterm/compare/v0.12.58...v0.12.59
[v0.12.58]: https://github.com/pterm/pterm/compare/v0.12.57...v0.12.58
[v0.12.57]: https://github.com/pterm/pterm/compare/v0.12.56...v0.12.57
[v0.12.56]: https://github.com/pterm/pterm/compare/v0.12.55...v0.12.56
Expand Down
114 changes: 114 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,87 @@ func main() {

</details>

### coloring/fade-colors-rgb-style

![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-colors-rgb-style/animation.svg)

<details>

<summary>SHOW SOURCE</summary>

```go
package main

import (
"strings"

"github.com/pterm/pterm"
)

func main() {
white := pterm.NewRGB(255, 255, 255) // This RGB value is used as the gradients start point.
grey := pterm.NewRGB(128, 128, 128) // This RGB value is used as the gradients start point.
black := pterm.NewRGB(0, 0, 0) // This RGB value is used as the gradients start point.
red := pterm.NewRGB(255, 0, 0) // This RGB value is used as the gradients start point.
purple := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients start point.
green := pterm.NewRGB(0, 255, 0) // This RGB value is used as the gradients start 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.
for i := 0; i < len(str); i++ {
// Append faded letter to info string.
fadeInfo += pterm.NewRGBStyle(white.Fade(0, float32(len(str)), float32(i), purple), grey.Fade(0, float32(len(str)), float32(i), black)).Sprint(strs[i])
}

pterm.Info.Println(fadeInfo)

str = "The background and foreground colors can be customized individually."
strs = strings.Split(str, "")
var fade2 string // String which will be used to print info.
for i := 0; i < len(str); i++ {
// Append faded letter to info string.
fade2 += pterm.NewRGBStyle(black, purple.Fade(0, float32(len(str)), float32(i), red)).Sprint(strs[i])
}

pterm.Println(fade2)

str = "Styles can also be applied. For example: Bold or Italic."
strs = strings.Split(str, "")
var fade3 string // String which will be used to print.

bold := 0
boldStr := strings.Split("Bold", "")
italic := 0
italicStr := strings.Split("Italic", "")

for i := 0; i < len(str); i++ {
// Append faded letter to info string.
s := pterm.NewRGBStyle(white.Fade(0, float32(len(str)), float32(i), green), red.Fade(0, float32(len(str)), float32(i), black))

// if the next letters are "Bold", then add the style "Bold".
// else if the next letters are "Italic", then add the style "Italic".
if bold < len(boldStr) && i+len(boldStr) <= len(strs) {
if strings.Join(strs[i:i+len(boldStr)-bold], "") == strings.Join(boldStr[bold:], "") {
s = s.AddOptions(pterm.Bold)
bold++
}
} else if italic < len(italicStr) && i+len(italicStr)-italic < len(strs) {
if strings.Join(strs[i:i+len(italicStr)-italic], "") == strings.Join(italicStr[italic:], "") {
s = s.AddOptions(pterm.Italic)
italic++
}
}
fade3 += s.Sprint(strs[i])
}

pterm.Println(fade3)
}

```

</details>

### coloring/fade-multiple-colors

![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-multiple-colors/animation.svg)
Expand Down Expand Up @@ -1179,6 +1260,39 @@ func main() {

</details>

### coloring/print-color-rgb-style

![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/print-color-rgb-style/animation.svg)

<details>

<summary>SHOW SOURCE</summary>

```go
package main

import (
"github.com/pterm/pterm"
)

func main() {
foregroundRGB := pterm.RGB{R: 187, G: 80, B: 0}
backgroundRGB := pterm.RGB{R: 0, G: 50, B: 123}

// Print string with a custom foreground and background RGB color.
pterm.NewRGBStyle(foregroundRGB, backgroundRGB).Println("This text is not styled.")

// Print string with a custom foreground and background RGB color and style bold.
pterm.NewRGBStyle(foregroundRGB, backgroundRGB).AddOptions(pterm.Bold).Println("This text is bold.")

// Print string with a custom foreground and background RGB color and style italic.
pterm.NewRGBStyle(foregroundRGB, backgroundRGB).AddOptions(pterm.Italic).Println("This text is italic.")
}

```

</details>

### demo/demo

![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/demo/demo/animation.svg)
Expand Down
114 changes: 114 additions & 0 deletions _examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,87 @@ func main() {

</details>

### coloring/fade-colors-rgb-style

![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-colors-rgb-style/animation.svg)

<details>

<summary>SHOW SOURCE</summary>

```go
package main

import (
"strings"

"github.com/pterm/pterm"
)

func main() {
white := pterm.NewRGB(255, 255, 255) // This RGB value is used as the gradients start point.
grey := pterm.NewRGB(128, 128, 128) // This RGB value is used as the gradients start point.
black := pterm.NewRGB(0, 0, 0) // This RGB value is used as the gradients start point.
red := pterm.NewRGB(255, 0, 0) // This RGB value is used as the gradients start point.
purple := pterm.NewRGB(255, 0, 255) // This RGB value is used as the gradients start point.
green := pterm.NewRGB(0, 255, 0) // This RGB value is used as the gradients start 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.
for i := 0; i < len(str); i++ {
// Append faded letter to info string.
fadeInfo += pterm.NewRGBStyle(white.Fade(0, float32(len(str)), float32(i), purple), grey.Fade(0, float32(len(str)), float32(i), black)).Sprint(strs[i])
}

pterm.Info.Println(fadeInfo)

str = "The background and foreground colors can be customized individually."
strs = strings.Split(str, "")
var fade2 string // String which will be used to print info.
for i := 0; i < len(str); i++ {
// Append faded letter to info string.
fade2 += pterm.NewRGBStyle(black, purple.Fade(0, float32(len(str)), float32(i), red)).Sprint(strs[i])
}

pterm.Println(fade2)

str = "Styles can also be applied. For example: Bold or Italic."
strs = strings.Split(str, "")
var fade3 string // String which will be used to print.

bold := 0
boldStr := strings.Split("Bold", "")
italic := 0
italicStr := strings.Split("Italic", "")

for i := 0; i < len(str); i++ {
// Append faded letter to info string.
s := pterm.NewRGBStyle(white.Fade(0, float32(len(str)), float32(i), green), red.Fade(0, float32(len(str)), float32(i), black))

// if the next letters are "Bold", then add the style "Bold".
// else if the next letters are "Italic", then add the style "Italic".
if bold < len(boldStr) && i+len(boldStr) <= len(strs) {
if strings.Join(strs[i:i+len(boldStr)-bold], "") == strings.Join(boldStr[bold:], "") {
s = s.AddOptions(pterm.Bold)
bold++
}
} else if italic < len(italicStr) && i+len(italicStr)-italic < len(strs) {
if strings.Join(strs[i:i+len(italicStr)-italic], "") == strings.Join(italicStr[italic:], "") {
s = s.AddOptions(pterm.Italic)
italic++
}
}
fade3 += s.Sprint(strs[i])
}

pterm.Println(fade3)
}

```

</details>

### coloring/fade-multiple-colors

![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/fade-multiple-colors/animation.svg)
Expand Down Expand Up @@ -1056,6 +1137,39 @@ func main() {

</details>

### coloring/print-color-rgb-style

![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/coloring/print-color-rgb-style/animation.svg)

<details>

<summary>SHOW SOURCE</summary>

```go
package main

import (
"github.com/pterm/pterm"
)

func main() {
foregroundRGB := pterm.RGB{R: 187, G: 80, B: 0}
backgroundRGB := pterm.RGB{R: 0, G: 50, B: 123}

// Print string with a custom foreground and background RGB color.
pterm.NewRGBStyle(foregroundRGB, backgroundRGB).Println("This text is not styled.")

// Print string with a custom foreground and background RGB color and style bold.
pterm.NewRGBStyle(foregroundRGB, backgroundRGB).AddOptions(pterm.Bold).Println("This text is bold.")

// Print string with a custom foreground and background RGB color and style italic.
pterm.NewRGBStyle(foregroundRGB, backgroundRGB).AddOptions(pterm.Italic).Println("This text is italic.")
}

```

</details>

### demo/demo

![Animation](https://raw.githubusercontent.com/pterm/pterm/master/_examples/demo/demo/animation.svg)
Expand Down
2 changes: 1 addition & 1 deletion _examples/area/center/animation.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1d4fac6

Please sign in to comment.