migrate to termui v3

This commit is contained in:
sqshq 2019-03-13 23:01:44 -04:00
parent ff24a2d64e
commit e68977b393
20 changed files with 41 additions and 28 deletions

View File

@ -2,9 +2,9 @@ package component
import (
"fmt"
ui "github.com/gizak/termui/v3"
"github.com/sqshq/sampler/console"
"github.com/sqshq/sampler/data"
ui "github.com/sqshq/termui"
"image"
"strings"
)
@ -49,7 +49,7 @@ func (a *Alerter) RenderAlert(buffer *ui.Buffer, area image.Rectangle) {
width = area.Dx()
}
cells := ui.WrapCells(ui.ParseText(fmt.Sprintf("%s\n%s\n",
cells := ui.WrapCells(ui.ParseStyles(fmt.Sprintf("%s\n%s\n",
strings.ToUpper(a.alert.Title), a.alert.Text), ui.NewStyle(console.ColorWhite)), uint(width))
var lines []string

View File

@ -1,12 +1,12 @@
package asciibox
import (
ui "github.com/gizak/termui/v3"
fl "github.com/mbndr/figlet4go"
"github.com/sqshq/sampler/asset"
"github.com/sqshq/sampler/component"
"github.com/sqshq/sampler/config"
"github.com/sqshq/sampler/data"
ui "github.com/sqshq/termui"
"image"
)
@ -71,7 +71,7 @@ func (a *AsciiBox) Draw(buffer *ui.Buffer) {
a.Block.Draw(buffer)
point := a.Inner.Min
cells := ui.ParseText(a.ascii, a.style)
cells := ui.ParseStyles(a.ascii, a.style)
for i := 0; i < len(cells) && point.Y < a.Inner.Max.Y; i++ {
if cells[i].Rune == '\n' {

View File

@ -2,11 +2,11 @@ package barchart
import (
"fmt"
ui "github.com/gizak/termui/v3"
rw "github.com/mattn/go-runewidth"
"github.com/sqshq/sampler/component"
"github.com/sqshq/sampler/console"
"github.com/sqshq/sampler/data"
ui "github.com/sqshq/termui"
"image"
"math"
"strconv"

View File

@ -1,8 +1,8 @@
package component
import (
ui "github.com/gizak/termui/v3"
"github.com/sqshq/sampler/config"
ui "github.com/sqshq/termui"
)
type Component struct {

View File

@ -2,10 +2,10 @@ package gauge
import (
"fmt"
ui "github.com/gizak/termui/v3"
"github.com/sqshq/sampler/component"
"github.com/sqshq/sampler/console"
"github.com/sqshq/sampler/data"
ui "github.com/sqshq/termui"
"image"
"math"
"strconv"

View File

@ -1,11 +1,11 @@
package layout
import (
ui "github.com/gizak/termui/v3"
"github.com/sqshq/sampler/component"
"github.com/sqshq/sampler/component/runchart"
"github.com/sqshq/sampler/config"
"github.com/sqshq/sampler/console"
ui "github.com/sqshq/termui"
"image"
"math"
)

View File

@ -1,9 +1,9 @@
package component
import (
ui "github.com/gizak/termui/v3"
"github.com/sqshq/sampler/config"
"github.com/sqshq/sampler/console"
ui "github.com/sqshq/termui"
"image"
)

View File

@ -1,8 +1,8 @@
package runchart
import (
ui "github.com/gizak/termui/v3"
"github.com/sqshq/sampler/console"
ui "github.com/sqshq/termui"
"image"
"math"
"time"

View File

@ -2,8 +2,8 @@ package runchart
import (
"fmt"
ui "github.com/gizak/termui/v3"
"github.com/sqshq/sampler/console"
ui "github.com/sqshq/termui"
"image"
"math"
)

View File

@ -12,7 +12,7 @@ import (
"sync"
"time"
ui "github.com/sqshq/termui"
ui "github.com/gizak/termui/v3"
)
const (
@ -257,7 +257,7 @@ func (c *RunChart) renderLines(buffer *ui.Buffer, drawArea image.Rectangle) {
previousPoint = xPoint[xOrder[i-1]]
}
canvas.Line(
canvas.SetLine(
braillePoint(previousPoint),
braillePoint(currentPoint),
line.color,

View File

@ -2,8 +2,8 @@ package component
import (
"fmt"
ui "github.com/gizak/termui/v3"
"github.com/sqshq/sampler/console"
ui "github.com/sqshq/termui"
"image"
)

View File

@ -1,8 +1,8 @@
package config
import (
ui "github.com/gizak/termui/v3"
"github.com/sqshq/sampler/console"
ui "github.com/sqshq/termui"
)
type ComponentType rune

View File

@ -2,7 +2,7 @@ package console
import (
"fmt"
ui "github.com/sqshq/termui"
ui "github.com/gizak/termui/v3"
"log"
"time"
)

View File

@ -2,7 +2,7 @@ package console
import (
"fmt"
ui "github.com/sqshq/termui"
ui "github.com/gizak/termui/v3"
)
type Theme string

View File

@ -1,6 +1,6 @@
package data
import ui "github.com/sqshq/termui"
import ui "github.com/gizak/termui/v3"
type Consumer struct {
SampleChannel chan Sample

View File

@ -1,8 +1,8 @@
package data
import (
ui "github.com/gizak/termui/v3"
"github.com/sqshq/sampler/config"
ui "github.com/sqshq/termui"
"os/exec"
"strings"
)

View File

@ -1,10 +1,10 @@
package event
import (
ui "github.com/gizak/termui/v3"
"github.com/sqshq/sampler/component/layout"
"github.com/sqshq/sampler/config"
"github.com/sqshq/sampler/console"
ui "github.com/sqshq/termui"
"time"
)

5
go.mod
View File

@ -1,11 +1,14 @@
module github.com/sqshq/sampler
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gizak/termui/v3 v3.0.0
github.com/hajimehoshi/go-mp3 v0.1.1
github.com/hajimehoshi/oto v0.1.1
github.com/maruel/panicparse v1.1.1 // indirect
github.com/mattn/go-runewidth v0.0.4
github.com/mbndr/figlet4go v0.0.0-20190224160619-d6cef5b186ea
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/sqshq/termui v0.0.0-20190125032456-731556c09f2c
github.com/stretchr/testify v1.3.0 // indirect
gopkg.in/yaml.v2 v2.2.2
)

22
go.sum
View File

@ -1,4 +1,12 @@
github.com/google/pprof v0.0.0-20190109223431-e84dfd68c163/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/cjbassi/drawille-go v0.0.0-20190126131713-27dc511fe6fd h1:XtfPmj9tQRilnrEmI1HjQhxXWRhEM+m8CACtaMJE/kM=
github.com/cjbassi/drawille-go v0.0.0-20190126131713-27dc511fe6fd/go.mod h1:vjcQJUZJYD3MeVGhtZXSMnCHfUNZxsyYzJt90eCYxK4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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/gizak/termui v2.3.0+incompatible h1:S8wJoNumYfc/rR5UezUM4HsPEo3RJh0LKdiuDWQpjqw=
github.com/gizak/termui v2.3.0+incompatible/go.mod h1:PkJoWUt/zacQKysNfQtcw1RW+eK2SxkieVBtl+4ovLA=
github.com/gizak/termui/v3 v3.0.0 h1:NYTUG6ig/sJK05O5FyhWemwlVPO8ilNpvS/PgRtrKAE=
github.com/gizak/termui/v3 v3.0.0/go.mod h1:uinu2dMdtMI+FTIdEFUJQT5y+KShnhQRshvPblXq3lY=
github.com/gopherjs/gopherjs v0.0.0-20180628210949-0892b62f0d9f h1:FDM3EtwZLyhW48YRiyqjivNlNZjAObv4xt4NnJaU+NQ=
github.com/gopherjs/gopherjs v0.0.0-20180628210949-0892b62f0d9f/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gopherjs/gopherwasm v0.1.1 h1:R/3+SfgCFStiql6ICfyfke1WtpglfjIvTEBux8R1euc=
@ -7,7 +15,8 @@ github.com/hajimehoshi/go-mp3 v0.1.1 h1:Y33fAdTma70fkrxnc9u50Uq0lV6eZ+bkAlssdMmC
github.com/hajimehoshi/go-mp3 v0.1.1/go.mod h1:4i+c5pDNKDrxl1iu9iG90/+fhP37lio6gNhjCx9WBJw=
github.com/hajimehoshi/oto v0.1.1 h1:EG+WxxeAfde1mI0adhLYvGbKgDCxm7bCTd6g+JIA6vI=
github.com/hajimehoshi/oto v0.1.1/go.mod h1:hUiLWeBQnbDu4pZsAhOnGqMI1ZGibS6e2qhQdfpwz04=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/maruel/panicparse v1.1.1 h1:k62YPcEoLncEEpjMt92GtG5ugb8WL/510Ys3/h5IkRc=
github.com/maruel/panicparse v1.1.1/go.mod h1:nty42YY5QByNC5MM7q/nj938VbgPU7avs45z6NClpxI=
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
@ -18,11 +27,12 @@ github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9
github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d h1:x3S6kxmy49zXVVyhcnrFqxvNVCBPb2KZ9hV2RBdS840=
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ=
github.com/sqshq/termui v0.0.0-20190125032456-731556c09f2c h1:BBEmIcD4UhAHDVWi3PVuA5TxVTZxcjmYzmdvhWkPfvE=
github.com/sqshq/termui v0.0.0-20190125032456-731556c09f2c/go.mod h1:puWaguPLLYPPKabYPVhZ8sDNe0nKSMiKWRfLVaaX8Zs=
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/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
golang.org/x/arch v0.0.0-20181203225421-5a4828bb7045/go.mod h1:cYlCBUl1MsqxdiKgmc4uh7TxZfWSFLOGSRR090WDxt8=
golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/sys v0.0.0-20190116161447-11f53e031339/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
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.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=

View File

@ -1,6 +1,7 @@
package main
import (
ui "github.com/gizak/termui/v3"
"github.com/sqshq/sampler/asset"
"github.com/sqshq/sampler/component"
"github.com/sqshq/sampler/component/asciibox"
@ -12,7 +13,6 @@ import (
"github.com/sqshq/sampler/console"
"github.com/sqshq/sampler/data"
"github.com/sqshq/sampler/event"
ui "github.com/sqshq/termui"
)
func main() {