/
deprecated.go
79 lines (67 loc) · 2.35 KB
/
deprecated.go
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
package pterm
import (
"strings"
"github.com/pterm/pterm/internal"
)
// NewLettersFromString creates a Letters object from a string, which is prefilled with the LetterStyle from ThemeDefault.
// You can override the ThemeDefault LetterStyle if you want to.
//
// Deprecated: use putils.NewLettersFromString instead.
func NewLettersFromString(text string) Letters {
return NewLettersFromStringWithStyle(text, &ThemeDefault.LetterStyle)
}
// NewLettersFromStringWithStyle creates a Letters object from a string and applies a Style to it.
//
// Deprecated: use putils.NewLettersFromStringWithStyle instead.
func NewLettersFromStringWithStyle(text string, style *Style) Letters {
s := strings.Split(text, "")
l := Letters{}
for _, s2 := range s {
l = append(l, Letter{
String: s2,
Style: style,
})
}
return l
}
// NewLettersFromStringWithRGB creates a Letters object from a string and applies an RGB color to it (overwrites style).
//
// Deprecated: use putils.NewLettersFromStringWithRGB instead.
func NewLettersFromStringWithRGB(text string, rgb RGB) Letters {
s := strings.Split(text, "")
l := Letters{}
for _, s2 := range s {
l = append(l, Letter{
String: s2,
Style: &Style{},
RGB: rgb,
})
}
return l
}
// NewBulletListFromStrings returns a BulletListPrinter with Text using the NewTreeListItemFromString method.
//
// Deprecated: use putils.NewBulletListFromStrings instead.
func NewBulletListFromStrings(s []string, padding string) BulletListPrinter {
var lis []BulletListItem
for _, line := range s {
lis = append(lis, NewBulletListItemFromString(line, padding))
}
return *DefaultBulletList.WithItems(lis)
}
// NewBulletListItemFromString returns a BulletListItem with a Text. The padding is counted in the Text to define the Level of the ListItem.
//
// Deprecated: use putils.NewBulletListItemFromString instead.
func NewBulletListItemFromString(text string, padding string) BulletListItem {
s, l := internal.RemoveAndCountPrefix(text, padding)
return BulletListItem{
Level: l,
Text: s,
}
}
// NewBulletListFromString returns a BulletListPrinter with Text using the NewTreeListItemFromString method, splitting after return (\n).
//
// Deprecated: use putils.NewBulletListFromString instead.
func NewBulletListFromString(s string, padding string) BulletListPrinter {
return NewBulletListFromStrings(strings.Split(s, "\n"), padding)
}