multiple cosmetic improvements

This commit is contained in:
sqshq 2019-06-02 20:53:15 -04:00
parent a736560c71
commit d107621830
6 changed files with 12 additions and 26 deletions

View File

@ -8,7 +8,7 @@ import (
"time"
)
const DefaultValueLength = 4
const defaultValueLength = 4
type ChartGrid struct {
timeRange TimeRange
@ -30,7 +30,7 @@ func (c *RunChart) newChartGrid() ChartGrid {
valueExtrema: getLocalExtrema(c.lines, timeRange),
linesCount: linesCount,
maxTimeWidth: c.Inner.Max.X,
minTimeWidth: 0,
minTimeWidth: defaultValueLength,
}
}
@ -145,23 +145,3 @@ func getLocalExtrema(items []TimeLine, timeRange TimeRange) ValueExtrema {
func (r *TimeRange) isInRange(time time.Time) bool {
return time.After(r.min) && time.Before(r.max)
}
//func (c *RunChart) getMaxValueLength() int {
//
// maxValueLength := -1
//
// for _, line := range c.lines {
// for _, point := range line.points {
// l := len(util.FormatValue(point.value, c.scale))
// if l > maxValueLength {
// maxValueLength = l
// }
// }
// }
//
// if maxValueLength < 0 {
// return DefaultValueLength
// }
//
// return maxValueLength
//}

View File

@ -137,9 +137,9 @@ func (c *RunChart) Draw(buffer *ui.Buffer) {
c.Inner.Max.X, c.Inner.Max.Y-xAxisLabelsHeight-1,
)
c.renderAxes(buffer)
c.renderLines(buffer, drawArea)
c.renderLegend(buffer, drawArea)
c.renderAxes(buffer)
component.RenderAlert(c.alert, c.Rectangle, buffer)
c.mutex.Unlock()
}

View File

@ -6,6 +6,7 @@ import (
"fmt"
ui "github.com/gizak/termui/v3"
"github.com/kr/pty"
"github.com/lunixbochs/vtclean"
"github.com/sqshq/sampler/config"
"io"
"os"
@ -84,7 +85,9 @@ func (i *Item) executeCmd(variables []string, script string) (string, error) {
return "", err
}
return string(output), nil
result := vtclean.Clean(string(output), false)
return result, nil
}
func (i *Item) initInteractiveShell(variables []string) error {
@ -151,7 +154,7 @@ await:
for {
select {
case output := <-i.interactiveShell.Channel:
o := cleanupOutput(output)
o := vtclean.Clean(output, false)
if len(o) > 0 && !strings.Contains(o, i.sampleScript) {
builder.WriteString(o)
builder.WriteString("\n")

View File

@ -29,7 +29,7 @@ func NewSampler(consumer *Consumer, items []*Item, triggers []*Trigger, options
go func() {
for ; true; <-ticker.C {
for _, item := range sampler.items {
sampler.sample(item, options)
go sampler.sample(item, options)
}
}
}()

1
go.mod
View File

@ -6,6 +6,7 @@ require (
github.com/hajimehoshi/oto v0.1.1
github.com/jessevdk/go-flags v1.4.0
github.com/kr/pty v1.1.4
github.com/lunixbochs/vtclean v1.0.0
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

2
go.sum
View File

@ -14,6 +14,8 @@ github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGAR
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/kr/pty v1.1.4 h1:5Myjjh3JY/NaAi4IsUbHADytDyl1VE1Y9PXDlL+P/VQ=
github.com/kr/pty v1.1.4/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/lunixbochs/vtclean v1.0.0 h1:xu2sLAri4lGiovBDQKxl5mrXyESr3gUr5m5SM5+LVb8=
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
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=