Skip to content

Commit 654f7d6

Browse files
committed
add module rivo.tview
1 parent 3cfbe55 commit 654f7d6

File tree

6 files changed

+105
-1
lines changed

6 files changed

+105
-1
lines changed

modules/rivo.tview/demo/demo.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package demo
2+
3+
import (
4+
"github.com/gdamore/tcell/v2"
5+
"github.com/rivo/tview"
6+
"math/rand"
7+
)
8+
9+
func QuickStart() {
10+
box := tview.NewBox().SetBorder(true).SetTitle("Hello, world!")
11+
if err := tview.NewApplication().SetRoot(box, true).Run(); err != nil {
12+
panic(err)
13+
}
14+
}
15+
16+
func Box() {
17+
box := tview.NewBox().
18+
SetBorder(true).
19+
SetBorderAttributes(tcell.AttrBold).
20+
SetTitle("A [red]c[yellow]o[green]l[darkcyan]o[blue]r[darkmagenta]f[red]u[yellow]l[white] [black:red]c[:yellow]o[:green]l[:darkcyan]o[:blue]r[:darkmagenta]f[:red]u[:yellow]l[white:] [::bu]title")
21+
if err := tview.NewApplication().SetRoot(box, true).Run(); err != nil {
22+
panic(err)
23+
}
24+
}
25+
26+
func Button() {
27+
app := tview.NewApplication()
28+
button := tview.NewButton("Hit Enter to close").SetSelectedFunc(func() {
29+
app.Stop()
30+
})
31+
button.SetBorder(true).SetRect(0, 0, 22, 3)
32+
if err := app.SetRoot(button, false).EnableMouse(true).Run(); err != nil {
33+
panic(err)
34+
}
35+
}
36+
37+
func Checkbox() {
38+
app := tview.NewApplication()
39+
checkbox := tview.NewCheckbox().SetLabel("Hit Enter to check box: ")
40+
checkbox.SetChangedFunc(func(checked bool) {
41+
checkbox.SetBackgroundColor([]tcell.Color{tcell.ColorSkyblue, tcell.ColorBlueViolet, tcell.ColorPink}[rand.Intn(3)])
42+
})
43+
if err := app.SetRoot(checkbox, true).EnableMouse(true).Run(); err != nil {
44+
panic(err)
45+
}
46+
}

modules/rivo.tview/go.mod

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module rivo.tview
2+
3+
go 1.17
4+
5+
require github.com/rivo/tview v0.0.0-20210909154944-f7430b878d17
6+
7+
require (
8+
github.com/gdamore/encoding v1.0.0 // indirect
9+
github.com/gdamore/tcell/v2 v2.4.1-0.20210905002822-f057f0a857a1 // indirect
10+
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
11+
github.com/mattn/go-runewidth v0.0.13 // indirect
12+
github.com/rivo/uniseg v0.2.0 // indirect
13+
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2 // indirect
14+
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect
15+
golang.org/x/text v0.3.6 // indirect
16+
)

modules/rivo.tview/go.sum

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
2+
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
3+
github.com/gdamore/tcell/v2 v2.4.1-0.20210905002822-f057f0a857a1 h1:QqwPZCwh/k1uYqq6uXSb9TRDhTkfQbO80v8zhnIe5zM=
4+
github.com/gdamore/tcell/v2 v2.4.1-0.20210905002822-f057f0a857a1/go.mod h1:Az6Jt+M5idSED2YPGtwnfJV0kXohgdCBPmHGSYc1r04=
5+
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
6+
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
7+
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
8+
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
9+
github.com/rivo/tview v0.0.0-20210909154944-f7430b878d17 h1:Hvt6NxqL7PhMn3SpabVqp8bFkf8xR3tzXYbMFF0z0DI=
10+
github.com/rivo/tview v0.0.0-20210909154944-f7430b878d17/go.mod h1:WIfMkQNY+oq/mWwtsjOYHIZBuwthioY2srOmljJkTnk=
11+
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
12+
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
13+
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
14+
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2 h1:46ULzRKLh1CwgRq2dC5SlBzEqqNCi8rreOZnNrbqcIY=
15+
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
16+
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
17+
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE=
18+
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
19+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
20+
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
21+
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
22+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

modules/rivo.tview/main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package main
2+
3+
import "rivo.tview/demo"
4+
5+
func main() {
6+
//go demo.Box()
7+
//demo.Button()
8+
9+
demo.Checkbox()
10+
}

modules/rivo.tview/main_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package main_test
2+
3+
import (
4+
"rivo.tview/demo"
5+
"testing"
6+
)
7+
8+
func TestQuickStart(t *testing.T) {
9+
demo.QuickStart()
10+
}

submodules/godotenv

0 commit comments

Comments
 (0)