Skip to content

Commit

Permalink
chore: update examples to remove deprecated Copy()
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed May 1, 2024
1 parent 387f2d7 commit 0d3715f
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 22 deletions.
6 changes: 5 additions & 1 deletion examples/go.mod
Expand Up @@ -19,11 +19,15 @@ require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/caarlos0/sshmarshal v0.1.0 // indirect
github.com/charmbracelet/keygen v0.3.0 // indirect
github.com/charmbracelet/x/exp/term v0.0.0-20240425164147-ba2a9512b05f // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/sys v0.19.0 // indirect
)
11 changes: 11 additions & 0 deletions examples/go.sum
Expand Up @@ -18,11 +18,15 @@ github.com/charmbracelet/keygen v0.3.0 h1:mXpsQcH7DDlST5TddmXNXjS0L7ECk4/kLQYyBc
github.com/charmbracelet/keygen v0.3.0/go.mod h1:1ukgO8806O25lUZ5s0IrNur+RlwTBERlezdgW71F5rM=
github.com/charmbracelet/wish v0.5.0 h1:FkkdNBFqrLABR1ciNrAL2KCxoyWfKhXnIGZw6GfAtPg=
github.com/charmbracelet/wish v0.5.0/go.mod h1:5GAn5SrDSZ7cgKjnC+3kDmiIo7I6k4/AYiRzC4+tpCk=
github.com/charmbracelet/x/exp/term v0.0.0-20240425164147-ba2a9512b05f h1:1BXkZqDueTOBECyDoFGRi0xMYgjJ6vvoPIkWyKOwzTc=
github.com/charmbracelet/x/exp/term v0.0.0-20240425164147-ba2a9512b05f/go.mod h1:yQqGHmheaQfkqiJWjklPHVAq1dKbk8uGbcoS/lcKCJ0=
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/gliderlabs/ssh v0.3.4 h1:+AXBtim7MTKaLVPgvE+3mhewYRawNLTd+jEEz/wExZw=
Expand Down Expand Up @@ -61,6 +65,8 @@ github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b/go.mod h1:fQuZ0gauxyBcmsdE3ZT4NasjaRdxmbCS0jRHsrWu3Ho=
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
github.com/muesli/termenv v0.11.1-0.20220212125758-44cd13922739/go.mod h1:Bd5NYQ7pd+SrtBSrSNoBBmXlcY8+Xj4BMJgh8qcZrvs=
Expand All @@ -82,6 +88,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down Expand Up @@ -116,13 +124,16 @@ golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210422114643-f5beecf764ed/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
Expand Down
22 changes: 11 additions & 11 deletions examples/layout/main.go
Expand Up @@ -68,9 +68,9 @@ var (
BorderForeground(highlight).
Padding(0, 1)

activeTab = tab.Copy().Border(activeTabBorder, true)
activeTab = tab.Border(activeTabBorder, true)

tabGap = tab.Copy().
tabGap = tab.
BorderTop(false).
BorderLeft(false).
BorderRight(false)
Expand Down Expand Up @@ -109,7 +109,7 @@ var (
Padding(0, 3).
MarginTop(1)

activeButtonStyle = buttonStyle.Copy().
activeButtonStyle = buttonStyle.
Foreground(lipgloss.Color("#FFF7DB")).
Background(lipgloss.Color("#F25D94")).
MarginRight(2).
Expand Down Expand Up @@ -173,13 +173,13 @@ var (
Padding(0, 1).
MarginRight(1)

encodingStyle = statusNugget.Copy().
encodingStyle = statusNugget.
Background(lipgloss.Color("#A550DF")).
Align(lipgloss.Right)

statusText = lipgloss.NewStyle().Inherit(statusBarStyle)

fishCakeStyle = statusNugget.Copy().Background(lipgloss.Color("#6124DF"))
fishCakeStyle = statusNugget.Background(lipgloss.Color("#6124DF"))

// Page.

Expand Down Expand Up @@ -215,7 +215,7 @@ func main() {
for i, v := range colors {
const offset = 2
c := lipgloss.Color(v[0])
fmt.Fprint(&title, titleStyle.Copy().MarginLeft(i*offset).Background(c))
fmt.Fprint(&title, titleStyle.MarginLeft(i*offset).Background(c))
if i < len(colors)-1 {
title.WriteRune('\n')
}
Expand Down Expand Up @@ -276,7 +276,7 @@ func main() {
listItem("Pomelo"),
),
),
list.Copy().Width(columnWidth).Render(
list.Width(columnWidth).Render(
lipgloss.JoinVertical(lipgloss.Left,
listHeader("Actual Lip Gloss Vendors"),
listItem("Glossier"),
Expand All @@ -300,9 +300,9 @@ func main() {

doc.WriteString(lipgloss.JoinHorizontal(
lipgloss.Top,
historyStyle.Copy().Align(lipgloss.Right).Render(historyA),
historyStyle.Copy().Align(lipgloss.Center).Render(historyB),
historyStyle.Copy().MarginRight(0).Render(historyC),
historyStyle.Align(lipgloss.Right).Render(historyA),
historyStyle.Align(lipgloss.Center).Render(historyB),
historyStyle.MarginRight(0).Render(historyC),
))

doc.WriteString("\n\n")
Expand All @@ -315,7 +315,7 @@ func main() {
statusKey := statusStyle.Render("STATUS")
encoding := encodingStyle.Render("UTF-8")
fishCake := fishCakeStyle.Render("🍥 Fish Cake")
statusVal := statusText.Copy().
statusVal := statusText.
Width(width - w(statusKey) - w(encoding) - w(fishCake)).
Render("Ravishing")

Expand Down
2 changes: 1 addition & 1 deletion examples/ssh/main.go
Expand Up @@ -161,7 +161,7 @@ func handler(next ssh.Handler) ssh.Handler {
styles.gray,
)

fmt.Fprintf(&str, "%s %t %s\n\n", styles.bold.Copy().UnsetString().Render("Has dark background?"),
fmt.Fprintf(&str, "%s %t %s\n\n", styles.bold.UnsetString().Render("Has dark background?"),
renderer.HasDarkBackground(),
renderer.Output().BackgroundColor())

Expand Down
8 changes: 4 additions & 4 deletions examples/table/languages/main.go
Expand Up @@ -23,9 +23,9 @@ func main() {
// CellStyle is the base lipgloss style used for the table rows.
CellStyle = re.NewStyle().Padding(0, 1).Width(14)
// OddRowStyle is the lipgloss style used for odd-numbered table rows.
OddRowStyle = CellStyle.Copy().Foreground(gray)
OddRowStyle = CellStyle.Foreground(gray)
// EvenRowStyle is the lipgloss style used for even-numbered table rows.
EvenRowStyle = CellStyle.Copy().Foreground(lightGray)
EvenRowStyle = CellStyle.Foreground(lightGray)
// BorderStyle is the lipgloss style used for the table border.
BorderStyle = lipgloss.NewStyle().Foreground(purple)
)
Expand Down Expand Up @@ -55,12 +55,12 @@ func main() {

// Make the second column a little wider.
if col == 1 {
style = style.Copy().Width(22)
style = style.Width(22)
}

// Arabic is a right-to-left language, so right align the text.
if row < len(rows) && rows[row-1][0] == "Arabic" && col != 0 {
style = style.Copy().Align(lipgloss.Right)
style = style.Align(lipgloss.Right)
}

return style
Expand Down
10 changes: 5 additions & 5 deletions examples/table/pokemon/main.go
Expand Up @@ -12,8 +12,8 @@ import (
func main() {
re := lipgloss.NewRenderer(os.Stdout)
baseStyle := re.NewStyle().Padding(0, 1)
headerStyle := baseStyle.Copy().Foreground(lipgloss.Color("252")).Bold(true)
selectedStyle := baseStyle.Copy().Foreground(lipgloss.Color("#01BE85")).Background(lipgloss.Color("#00432F"))
headerStyle := baseStyle.Foreground(lipgloss.Color("252")).Bold(true)
selectedStyle := baseStyle.Foreground(lipgloss.Color("#01BE85")).Background(lipgloss.Color("#00432F"))
typeColors := map[string]lipgloss.Color{
"Bug": lipgloss.Color("#D7FF87"),
"Electric": lipgloss.Color("#FDFF90"),
Expand Down Expand Up @@ -101,13 +101,13 @@ func main() {
}

color := c[fmt.Sprint(data[row-1][col])]
return baseStyle.Copy().Foreground(color)
return baseStyle.Foreground(color)
}

if even {
return baseStyle.Copy().Foreground(lipgloss.Color("245"))
return baseStyle.Foreground(lipgloss.Color("245"))
}
return baseStyle.Copy().Foreground(lipgloss.Color("252"))
return baseStyle.Foreground(lipgloss.Color("252"))
})
fmt.Println(t)
}

0 comments on commit 0d3715f

Please sign in to comment.