1
0
Эх сурвалжийг харах

Pushed project to bubbletea v2

arianagiroux 1 долоо хоног өмнө
parent
commit
7d2859a1fd
6 өөрчлөгдсөн 98 нэмэгдсэн , 172 устгасан
  1. 1 1
      Readme.md
  2. 3 5
      cmd/pingo.go
  3. 15 19
      go.mod
  4. 36 43
      go.sum
  5. 43 37
      tui.go
  6. 0 67
      tui_test.go

+ 1 - 1
Readme.md

@@ -46,7 +46,7 @@ additionally, see `bin/` for additional pre-compiled binaries
 
 [bt]: https://github.com/charmbracelet/bubbletea
 [lg]: https://github.com/charmbracelet/lipgloss
-[bbl]: https://github.com/charmbracelet/bubbles
+[bbl]: charm.land/bubbles/v2
 [ntc]: https://github.com/NimbleMarkets/ntcharts
 [wish]: https://github.com/charmbracelet/wish
 

+ 3 - 5
cmd/pingo.go

@@ -16,7 +16,7 @@ import (
 	"pingo"
 	"time"
 
-	tea "github.com/charmbracelet/bubbletea"
+	tea "charm.land/bubbletea/v2"
 )
 
 func main() {
@@ -34,10 +34,8 @@ func main() {
 		hosts, time.Duration(*speed), *chartHeight,
 	)
 
-	p := tea.NewProgram(model,
-		tea.WithAltScreen(), // use the full size of the terminal in its "alternate screen buffer"
-		// tea.WithMouseCellMotion(), // turn on mouse support so we can track the mouse wheel
-	)
+	p := tea.NewProgram(model) // tea.WithAltScreen(), // use the full size of the terminal in its "alternate screen buffer"
+	// tea.WithMouseCellMotion(), // turn on mouse support so we can track the mouse wheel
 
 	if _, err := p.Run(); err != nil {
 		fmt.Printf("Alas, there's been an error: %v", err)

+ 15 - 19
go.mod

@@ -3,33 +3,29 @@ module pingo
 go 1.25.6
 
 require (
-	github.com/NimbleMarkets/ntcharts v0.4.0
-	github.com/charmbracelet/bubbles v0.20.0
-	github.com/charmbracelet/bubbletea v1.3.10
-	github.com/charmbracelet/lipgloss v1.1.0
+	charm.land/bubbles/v2 v2.0.0
+	charm.land/bubbletea/v2 v2.0.1
+	charm.land/lipgloss/v2 v2.0.0
 	github.com/stretchr/testify v1.11.1
 )
 
 require (
-	github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
-	github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
-	github.com/charmbracelet/x/ansi v0.10.1 // indirect
-	github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
-	github.com/charmbracelet/x/term v0.2.1 // indirect
+	github.com/charmbracelet/colorprofile v0.4.2 // indirect
+	github.com/charmbracelet/ultraviolet v0.0.0-20260205113103-524a6607adb8 // indirect
+	github.com/charmbracelet/x/ansi v0.11.6 // indirect
+	github.com/charmbracelet/x/term v0.2.2 // indirect
+	github.com/charmbracelet/x/termios v0.1.1 // indirect
+	github.com/charmbracelet/x/windows v0.2.2 // indirect
+	github.com/clipperhouse/displaywidth v0.11.0 // indirect
+	github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
 	github.com/davecgh/go-spew v1.1.1 // indirect
-	github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
-	github.com/lrstanley/bubblezone v0.0.0-20240914071701-b48c55a5e78e // indirect
-	github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
-	github.com/mattn/go-isatty v0.0.20 // indirect
-	github.com/mattn/go-localereader v0.0.1 // indirect
-	github.com/mattn/go-runewidth v0.0.16 // indirect
-	github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
+	github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
+	github.com/mattn/go-runewidth v0.0.20 // indirect
 	github.com/muesli/cancelreader v0.2.2 // indirect
-	github.com/muesli/termenv v0.16.0 // indirect
 	github.com/pmezard/go-difflib v1.0.0 // indirect
 	github.com/rivo/uniseg v0.4.7 // indirect
 	github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
-	golang.org/x/sys v0.36.0 // indirect
-	golang.org/x/text v0.20.0 // indirect
+	golang.org/x/sync v0.19.0 // indirect
+	golang.org/x/sys v0.41.0 // indirect
 	gopkg.in/yaml.v3 v3.0.1 // indirect
 )

+ 36 - 43
go.sum

@@ -1,58 +1,51 @@
-github.com/NimbleMarkets/ntcharts v0.4.0 h1:BtrER5o6s3xMAebhSDQZpdFdfVMGMpV4Qz8lD+Qiw5g=
-github.com/NimbleMarkets/ntcharts v0.4.0/go.mod h1:zVeRqYkh2n59YPe1bflaSL4O2aD2ZemNmrbdEqZ70hk=
-github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
-github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
-github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE=
-github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU=
-github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw=
-github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4=
-github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs=
-github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk=
-github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
-github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
-github.com/charmbracelet/x/ansi v0.10.1 h1:rL3Koar5XvX0pHGfovN03f5cxLbCF2YvLeyz7D2jVDQ=
-github.com/charmbracelet/x/ansi v0.10.1/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE=
-github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0GVL4jeHEwG5YOXDmi86oYw2yuYUGqz6a8sLwg0X8=
-github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
-github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
-github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
+charm.land/bubbles/v2 v2.0.0 h1:tE3eK/pHjmtrDiRdoC9uGNLgpopOd8fjhEe31B/ai5s=
+charm.land/bubbles/v2 v2.0.0/go.mod h1:rCHoleP2XhU8um45NTuOWBPNVHxnkXKTiZqcclL/qOI=
+charm.land/bubbletea/v2 v2.0.1 h1:B8e9zzK7x9JJ+XvHGF4xnYu9Xa0E0y0MyggY6dbaCfQ=
+charm.land/bubbletea/v2 v2.0.1/go.mod h1:3LRff2U4WIYXy7MTxfbAQ+AdfM3D8Xuvz2wbsOD9OHQ=
+charm.land/lipgloss/v2 v2.0.0 h1:sd8N/B3x892oiOjFfBQdXBQp3cAkvjGaU5TvVZC3ivo=
+charm.land/lipgloss/v2 v2.0.0/go.mod h1:w6SnmsBFBmEFBodiEDurGS/sdUY/u1+v72DqUzc6J14=
+github.com/aymanbagabas/go-udiff v0.4.0 h1:TKnLPh7IbnizJIBKFWa9mKayRUBQ9Kh1BPCk6w2PnYM=
+github.com/aymanbagabas/go-udiff v0.4.0/go.mod h1:0L9PGwj20lrtmEMeyw4WKJ/TMyDtvAoK9bf2u/mNo3w=
+github.com/charmbracelet/colorprofile v0.4.2 h1:BdSNuMjRbotnxHSfxy+PCSa4xAmz7szw70ktAtWRYrY=
+github.com/charmbracelet/colorprofile v0.4.2/go.mod h1:0rTi81QpwDElInthtrQ6Ni7cG0sDtwAd4C4le060fT8=
+github.com/charmbracelet/ultraviolet v0.0.0-20260205113103-524a6607adb8 h1:eyFRbAmexyt43hVfeyBofiGSEmJ7krjLOYt/9CF5NKA=
+github.com/charmbracelet/ultraviolet v0.0.0-20260205113103-524a6607adb8/go.mod h1:SQpCTRNBtzJkwku5ye4S3HEuthAlGy2n9VXZnWkEW98=
+github.com/charmbracelet/x/ansi v0.11.6 h1:GhV21SiDz/45W9AnV2R61xZMRri5NlLnl6CVF7ihZW8=
+github.com/charmbracelet/x/ansi v0.11.6/go.mod h1:2JNYLgQUsyqaiLovhU2Rv/pb8r6ydXKS3NIttu3VGZQ=
+github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f h1:pk6gmGpCE7F3FcjaOEKYriCvpmIN4+6OS/RD0vm4uIA=
+github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f/go.mod h1:IfZAMTHB6XkZSeXUqriemErjAWCCzT0LwjKFYCZyw0I=
+github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk=
+github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI=
+github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY=
+github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo=
+github.com/charmbracelet/x/windows v0.2.2 h1:IofanmuvaxnKHuV04sC0eBy/smG6kIKrWG2/jYn2GuM=
+github.com/charmbracelet/x/windows v0.2.2/go.mod h1:/8XtdKZzedat74NQFn0NGlGL4soHB0YQZrETF96h75k=
+github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSEFgwIwO+UVM8=
+github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0=
+github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk=
+github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
 github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-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/lrstanley/bubblezone v0.0.0-20240914071701-b48c55a5e78e h1:OLwZ8xVaeVrru0xyeuOX+fne0gQTFEGlzfNjipCbxlU=
-github.com/lrstanley/bubblezone v0.0.0-20240914071701-b48c55a5e78e/go.mod h1:NQ34EGeu8FAYGBMDzwhfNJL8YQYoWZP5xYJPRDAwN3E=
-github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
-github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
-github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
-github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
-github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
-github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
-github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
-github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
-github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
-github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
+github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag=
+github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
+github.com/mattn/go-runewidth v0.0.20 h1:WcT52H91ZUAwy8+HUkdM3THM6gXqXuLJi9O3rjcQQaQ=
+github.com/mattn/go-runewidth v0.0.20/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
 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/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
-github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
 github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
 github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
 github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
 github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
 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=
-golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E=
-golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
-golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
-golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
-golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
-golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
+golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
+golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
+golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
+golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
+golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
+golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

+ 43 - 37
tui.go

@@ -7,10 +7,9 @@ import (
 	"slices"
 	"time"
 
-	"github.com/NimbleMarkets/ntcharts/linechart/streamlinechart"
-	"github.com/charmbracelet/bubbles/viewport"
-	tea "github.com/charmbracelet/bubbletea"
-	"github.com/charmbracelet/lipgloss"
+	"charm.land/bubbles/v2/viewport"
+	tea "charm.land/bubbletea/v2"
+	"charm.land/lipgloss/v2"
 )
 
 // Style Defintions
@@ -55,7 +54,6 @@ type Model struct {
 
 func InitialModel(addresses []string, speed time.Duration, chartHeight int) Model {
 	var model Model
-	model.viewport = viewport.New(0, 0)
 	model.viewport.MouseWheelEnabled = true
 	model.UpdateSpeed = speed
 	model.ChartHeight = chartHeight
@@ -87,37 +85,38 @@ func (m Model) content() string {
 	output := "\n"
 	for _, address := range m.Addresses {
 		if len(address.results) == 0 {
-			output = output + fmt.Sprintf("\n%s\tloading...", headerStyle.Render(address.Address))
-		} else if m.viewport.Width != 0 && m.viewport.Height != 0 {
+			output = output + fmt.Sprintf("%s\tloading...", headerStyle.Render(address.Address))
+
+		} else if m.viewport.Width() != 0 && m.viewport.Height() != 0 {
 			if slices.Contains(address.results, -1) {
-				output = output + fmt.Sprintf("\n%s",
-					blockStyle.Render(headerStyle.Render(
-						fmt.Sprintf("%s\t%s",
-							secondaryColor.Render(address.Address),
-							infoStyle.Render("(connection unstable)"),
-						),
-					)))
+				output = output + blockStyle.Render(headerStyle.Render(
+					fmt.Sprintf("\n%s\t%s",
+						secondaryColor.Render(address.Address),
+						infoStyle.Render("(connection unstable)"),
+					),
+				))
 			} else {
 				output = output + fmt.Sprintf("\n%s",
 					blockStyle.Render(headerStyle.Render(address.Address)))
 			}
 
 			// Linechart
-			viewportHeight := m.viewport.Height - 4
-			var slc streamlinechart.Model
-			if m.ChartHeight == 0 && len(m.Addresses) == 1 {
-				slc = streamlinechart.New(m.width, viewportHeight)
-			} else if m.ChartHeight == 0 && len(m.Addresses) > 1 {
-				slc = streamlinechart.New(m.width, viewportHeight-5)
-			} else {
-				slc = streamlinechart.New(m.width, m.ChartHeight)
-			}
-
-			for _, v := range address.results {
-				slc.Push(v)
-			}
-			slc.Draw()
-			output = output + blockStyle.Render(fmt.Sprintf("\n%s\n", slc.View()))
+			// viewportHeight := m.viewport.Height() - 4
+			// var slc streamlinechart.Model
+			// if m.ChartHeight == 0 && len(m.Addresses) == 1 {
+			// 	slc = streamlinechart.New(m.width, viewportHeight)
+			// } else if m.ChartHeight == 0 && len(m.Addresses) > 1 {
+			// 	slc = streamlinechart.New(m.width, viewportHeight-5)
+			// } else {
+			// 	slc = streamlinechart.New(m.width, m.ChartHeight)
+			// }
+
+			// for _, v := range address.results {
+			// 	slc.Push(v)
+			// }
+			// slc.Draw()
+			// output = output + blockStyle.Render(fmt.Sprintf("\n%s\n", slc.View()))
+			output = output + blockStyle.Render(fmt.Sprintf("\n%f", address.Last()))
 		}
 	}
 
@@ -136,17 +135,19 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 			address.max_results = m.width
 			m.Addresses[i] = address
 		}
-		m.viewport.Height = msg.Height - 4
-		m.viewport.Width = msg.Width
+		m.viewport.SetHeight(msg.Height - 4)
+		m.viewport.SetWidth(msg.Width)
 		m.viewport.YPosition = 1
 
-	case tea.KeyMsg:
+	case tea.KeyPressMsg:
 		if k := msg.String(); k == "j" { // scroll down
-			m.viewport.LineDown(8)
+			m.viewport.ScrollDown(1)
 		} else if k == "k" { // scroll up
-			m.viewport.LineUp(8)
+			m.viewport.ScrollUp(1)
 		} else {
-			return m, tea.Quit
+			if k == "ctrl+c" {
+				cmds = append(cmds, tea.Quit)
+			}
 		}
 
 	case tickMsg:
@@ -165,7 +166,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 	return m, tea.Batch(cmds...)
 }
 
-func (m Model) View() string {
+func (m Model) View() tea.View {
 	var headerStyle = lipgloss.NewStyle().
 		Width(m.width).
 		Align(lipgloss.Center).
@@ -180,7 +181,12 @@ func (m Model) View() string {
 
 	header := headerStyle.Render("pingo v0")
 	footer := footerStyle.Render("\nj/k: down/up\t|\tq/ctrl-c/esc: quit\n")
-	return fmt.Sprintf("\n%s\n%s\n%s", header, m.viewport.View(), footer)
+	content := fmt.Sprintf("\n%s\n%s\n%s", header, m.viewport.View(), footer)
+
+	var v tea.View
+	v.SetContent(content)
+	v.AltScreen = true
+	return v
 }
 
 // Returns a batched set of tea.Cmd functions for each address.

+ 0 - 67
tui_test.go

@@ -1,67 +0,0 @@
-package pingo
-
-import (
-	"testing"
-	"time"
-
-	tea "github.com/charmbracelet/bubbletea"
-	"github.com/stretchr/testify/assert"
-)
-
-func Test_InitialModel(t *testing.T) {
-	model := InitialModel([]string{"test"}, time.Duration(time.Second*1), 10)
-
-	assert.True(t, len(model.Addresses) == 1)
-	assert.True(t, model.viewport.Width == 0)
-	assert.Equal(t, model.UpdateSpeed, time.Duration(time.Second*1))
-	assert.Equal(t, model.ChartHeight, 10)
-}
-
-func Test_Model_Init(t *testing.T) {
-	testModel := Model{}
-	result := testModel.Init()
-	assert.IsType(t, new(tea.Cmd), &result)
-
-	result2 := result()
-	assert.IsType(t, new(tea.Msg), &result2)
-
-	_, ok := result2.(tickMsg)
-	assert.True(t, ok)
-}
-
-func Test_Model_Update_window_resize(t *testing.T) {
-	testMsg := tea.WindowSizeMsg{Width: 10, Height: 10}
-	model := tea.Model(InitialModel([]string{"test"}, time.Duration(time.Second*1), 10))
-	assert.Equal(t, 0, model.(Model).width)
-	assert.Equal(t, 0, model.(Model).viewport.YPosition)
-	assert.Equal(t, 1, len(model.(Model).Addresses))
-	assert.Equal(t, 80, model.(Model).Addresses[0].max_results)
-
-	model, _ = model.Update(testMsg)
-	assert.Equal(t, 10, model.(Model).width)
-	assert.Equal(t, 10, model.(Model).viewport.Width)
-	assert.Equal(t, 6, model.(Model).viewport.Height)
-	assert.Equal(t, 1, model.(Model).viewport.YPosition)
-	assert.Equal(t, 10, model.(Model).Addresses[0].max_results)
-}
-
-func Test_Model_Update_keymsg_j(t *testing.T) {
-	t.Skip()
-	testKey := tea.Key{Type: tea.KeyRunes, Runes: []rune{'j'}}
-	testMsg := tea.KeyMsg(testKey)
-	model := tea.Model(InitialModel([]string{"127.0.0.1", "127.0.0.1"}, time.Duration(time.Second*1), 0))
-	scrollPercent := model.(Model).viewport.ScrollPercent()
-	var msgs []tea.Msg
-	var cmd tea.Cmd
-	model, cmd = model.Update(tea.WindowSizeMsg{Width: 100, Height: 2000})
-	if cmd != nil {
-		msgs = append(msgs, cmd())
-	}
-	msgs = append(msgs, testMsg)
-	model, _ = model.Update(msgs)
-	assert.NotEqual(t, scrollPercent, model.(Model).viewport.ScrollPercent())
-}
-
-func Test_Model_View(t *testing.T)    {}
-func Test_Model_content(t *testing.T) {}
-func Test_Model_Poll(t *testing.T)    {}