added asciibox component type

This commit is contained in:
sqshq 2019-02-17 18:00:00 -05:00
parent bd3ed07a5b
commit 8bdaccf58f
14 changed files with 3314 additions and 34 deletions

924
asset/font/3d.flf Normal file
View File

@ -0,0 +1,924 @@
flf2a$ 9 6 30 1 5
larry3d.flf by Larry Gelberg (larryg@avs.com)
(stolen liberally from Juan Car's puffy.flf)
tweaked by Glenn Chappell <ggc@uiuc.edu>
Version 1.2 2/24/94
$@
$@
$@
$@
$@
$@
$@
$@
@@
__ @
/\ \ @
\ \ \ @
\ \ \ @
\ \_\ @
\/\_\@
\/_/@
@
@@
__ __ @
/\ \\ \ @
\ \_\\_\ @
\/_//_/$ @
$ $ @
$ $@
@
@
@@
__ __ @
_\ \\ \__ @
/\__ _ _\ @
\/_L\ \\ \L_ @
/\_ _ _\@
\/_/\_\\_\/@
\/_//_/ @
@
@@
__ @
/\ \_ @
\/'__`\ @
/\ \_\_\ @
\ \____ \ @
\/\ \_\ \@
\ `\_ _/@
`\_/\_\@
\/_/@@
__ __ @
/\_\ / / @
\/_/ / / @
/ / @
/ / __ @
/_/ /\_\@
/_/ \/_/@
@
@@
____ @
/| _ \ @
|/\ | @
\// __`\/\ @
/| \L> <_@
| \_____/\/@
\/____/\/ @
@
@@
__ @
/\ \ @
\ \/$ @
\/ $ @
$ $ @
$ $@
@
@
@@
_ @
/' \ @
/\ ,/' @
\ \ \ @
\ \ `\ @
\ `\__\@
`\/_/ @
@
@@
__ @
/\ `\ @
\`\ \ @
`\`\ \ @
`\/' \@
/\__/@
\/_/ @
@
@@
__ @
_\ \ _ @
/\_` ' \ @
\/_> <_ @
/\_, ,_\@
\/_/\_\/@
\/_/ @
@
@@
__ @
/\ \ @
\_\ \___ @
/\___ __\@
\/__/\ \_/@
\ \_\ @
\/_/ @
@
@@
@
@
@
@
__ @
/\ \@
\ \/@
\/ @
@@
@
@
@
_______ @
/\______\@
\/______/@
@
@
@@
@
@
@
@
__ @
/\_\@
\/_/@
@
@@
__@
/ /@
/ / @
/ / @
/ / @
/_/ @
/_/ @
@
@@
__ @
/'__`\ @
/\ \/\ \ @
\ \ \ \ \ @
\ \ \_\ \ @
\ \____/ @
\/___/ @
@
@@
_ @
/' \ @
/\_, \ @
\/_/\ \ @
\ \ \ @
\ \_\ @
\/_/ @
@
@@
___ @
/'___`\ @
/\_\ /\ \ @
\/_/// /__ @
// /_\ \@
/\______/@
\/_____/ @
@
@@
__ @
/'__`\ @
/\_\L\ \ @
\/_/_\_<_ @
/\ \L\ \ @
\ \____/ @
\/___/ @
@
@@
__ __ @
/\ \\ \ @
\ \ \\ \ @
\ \ \\ \_ @
\ \__ ,_\@
\/_/\_\/@
\/_/ @
@
@@
______ @
/\ ___\ @
\ \ \__/ @
\ \___``\ @
\/\ \L\ \@
\ \____/@
\/___/ @
@
@@
____ @
/'___\ @
/\ \__/ @
\ \ _``\ @
\ \ \L\ \ @
\ \____/ @
\/___/ @
@
@@
________ @
/\_____ \ @
\/___//'/' @
/' /' @
/' /' @
/\_/ @
\// @
@
@@
__ @
/'_ `\ @
/\ \L\ \ @
\/_> _ <_ @
/\ \L\ \ @
\ \____/ @
\/___/ @
@
@@
__ @
/'_ `\ @
/\ \L\ \ @
\ \___, \ @
\/__,/\ \ @
\ \_\@
\/_/@
@
@@
@
@
__ @
/\_\ @
\/_/_ @
/\_\@
\/_/@
@
@@
@
@
__ @
/\_\ @
\/_/_ @
/\ \@
\ \/@
\/ @
@@
___ @
/ / @
/ / @
/< < @
\ `\ `\ @
`\ `\_|@
`\// @
@
@@
@
_______ @
/\______\ @
\/______/_ @
/\______\@
\/______/@
@
@
@@
__ @
/\ `\ @
\ `\ `\ @
`\ > >@
/ / @
/\_/ @
\// @
@
@@
_ @
/'_`\ @
/\_\/\`\@
\/_//'/'@
/\_\ @
\/\_\@
\/_/@
@
@@
@
__ @
/'_`\_ @
/'/'_` \ @
/\ \ \L\ \ @
\ \ `\__,_\@
\ `\_____\@
`\/_____/@
@@
______ @
/\ _ \ @
\ \ \L\ \ @
\ \ __ \ @
\ \ \/\ \ @
\ \_\ \_\@
\/_/\/_/@
@
@@
____ @
/\ _`\ @
\ \ \L\ \ @
\ \ _ <' @
\ \ \L\ \@
\ \____/@
\/___/ @
@
@@
____ @
/\ _`\ @
\ \ \/\_\ @
\ \ \/_/_ @
\ \ \L\ \@
\ \____/@
\/___/ @
@
@@
____ @
/\ _`\ @
\ \ \/\ \ @
\ \ \ \ \ @
\ \ \_\ \@
\ \____/@
\/___/ @
@
@@
____ @
/\ _`\ @
\ \ \L\_\ @
\ \ _\L @
\ \ \L\ \@
\ \____/@
\/___/ @
@
@@
____ @
/\ _`\ @
\ \ \L\_\@
\ \ _\/@
\ \ \/ @
\ \_\ @
\/_/ @
@
@@
____ @
/\ _`\ @
\ \ \L\_\ @
\ \ \L_L @
\ \ \/, \@
\ \____/@
\/___/ @
@
@@
__ __ @
/\ \/\ \ @
\ \ \_\ \ @
\ \ _ \ @
\ \ \ \ \ @
\ \_\ \_\@
\/_/\/_/@
@
@@
______ @
/\__ _\ @
\/_/\ \/ @
\ \ \ @
\_\ \__ @
/\_____\@
\/_____/@
@
@@
_____ @
/\___ \ @
\/__/\ \ @
_\ \ \ @
/\ \_\ \@
\ \____/@
\/___/ @
@
@@
__ __ @
/\ \/\ \ @
\ \ \/'/' @
\ \ , < @
\ \ \\`\ @
\ \_\ \_\@
\/_/\/_/@
@
@@
__ @
/\ \ @
\ \ \ @
\ \ \ __ @
\ \ \L\ \@
\ \____/@
\/___/ @
@
@@
@
/'\_/`\ @
/\ \ @
\ \ \__\ \ @
\ \ \_/\ \ @
\ \_\\ \_\@
\/_/ \/_/@
@
@@
__ __ @
/\ \/\ \ @
\ \ `\\ \ @
\ \ , ` \ @
\ \ \`\ \ @
\ \_\ \_\@
\/_/\/_/@
@
@@
_____ @
/\ __`\ @
\ \ \/\ \ @
\ \ \ \ \ @
\ \ \_\ \ @
\ \_____\@
\/_____/@
@
@@
____ @
/\ _`\ @
\ \ \L\ \@
\ \ ,__/@
\ \ \/ @
\ \_\ @
\/_/ @
@
@@
_____ @
/\ __`\ @
\ \ \/\ \ @
\ \ \ \ \ @
\ \ \\'\\ @
\ \___\_\@
\/__//_/@
@
@@
____ @
/\ _`\ @
\ \ \L\ \ @
\ \ , / @
\ \ \\ \ @
\ \_\ \_\@
\/_/\/ /@
@
@@
____ @
/\ _`\ @
\ \,\L\_\ @
\/_\__ \ @
/\ \L\ \ @
\ `\____\@
\/_____/@
@
@@
______ @
/\__ _\ @
\/_/\ \/ @
\ \ \ @
\ \ \ @
\ \_\@
\/_/@
@
@@
__ __ @
/\ \/\ \ @
\ \ \ \ \ @
\ \ \ \ \ @
\ \ \_\ \ @
\ \_____\@
\/_____/@
@
@@
__ __ @
/\ \/\ \ @
\ \ \ \ \ @
\ \ \ \ \ @
\ \ \_/ \@
\ `\___/@
`\/__/ @
@
@@
__ __ @
/\ \ __/\ \ @
\ \ \/\ \ \ \ @
\ \ \ \ \ \ \ @
\ \ \_/ \_\ \@
\ `\___x___/@
'\/__//__/ @
@
@@
__ __ @
/\ \ /\ \ @
\ `\`\/'/' @
`\/ > < @
\/'/\`\ @
/\_\\ \_\@
\/_/ \/_/@
@
@@
__ __ @
/\ \ /\ \@
\ `\`\\/'/@
`\ `\ /' @
`\ \ \ @
\ \_\@
\/_/@
@
@@
________ @
/\_____ \ @
\/____//'/' @
//'/' @
//'/'___ @
/\_______\@
\/_______/@
@
@@
____ @
/\ _\ @
\ \ \/ @
\ \ \ @
\ \ \_ @
\ \___\@
\/___/@
@
@@
__ @
/\ `\ @
\`\ `\ @
`\`\ `\ @
`\`\ `\ @
`\`\__\@
`\/__/@
@
@@
____ @
/\__ \ @
\/_/\ \ @
\ \ \ @
\_\ \ @
/\___\@
\/___/@
@
@@
__ @
/ `\ @
/\_/\_\ @
\//\// $ @
$ $ @
$ $@
@
@
@@
@
@
@
@
@
$ $ @
$_______ @
/\______\@
\/______/@@
__ @
/\ \ @
\ \\$ @
\// $ @
$ $ @
$ $@
@
@
@@
@
@
__ @
/'__`\ @
/\ \L\.\_ @
\ \__/.\_\@
\/__/\/_/@
@
@@
__ @
/\ \ @
\ \ \____ @
\ \ '__`\ @
\ \ \L\ \@
\ \_,__/@
\/___/ @
@
@@
@
@
___ @
/'___\ @
/\ \__/ @
\ \____\@
\/____/@
@
@@
__ @
/\ \ @
\_\ \ @
/'_` \ @
/\ \L\ \ @
\ \___,_\@
\/__,_ /@
@
@@
@
@
__ @
/'__`\ @
/\ __/ @
\ \____\@
\/____/@
@
@@
___ @
/'___\ @
/\ \__/ @
\ \ ,__\@
\ \ \_/@
\ \_\ @
\/_/ @
@
@@
@
@
__ @
/'_ `\ @
/\ \L\ \ @
\ \____ \ @
\/___L\ \@
/\____/@
\_/__/ @@
__ @
/\ \ @
\ \ \___ @
\ \ _ `\ @
\ \ \ \ \ @
\ \_\ \_\@
\/_/\/_/@
@
@@
@
__ @
/\_\ @
\/\ \ @
\ \ \ @
\ \_\@
\/_/@
@
@@
@
__ @
/\_\ @
\/\ \ @
\ \ \ @
_\ \ \ @
/\ \_\ \@
\ \____/@
\/___/ @@
__ @
/\ \ @
\ \ \/'\ @
\ \ , < @
\ \ \\`\ @
\ \_\ \_\@
\/_/\/_/@
@
@@
___ @
/\_ \ @
\//\ \ @
\ \ \ @
\_\ \_ @
/\____\@
\/____/@
@
@@
@
@
___ ___ @
/' __` __`\ @
/\ \/\ \/\ \ @
\ \_\ \_\ \_\@
\/_/\/_/\/_/@
@
@@
@
@
___ @
/' _ `\ @
/\ \/\ \ @
\ \_\ \_\@
\/_/\/_/@
@
@@
@
@
___ @
/ __`\ @
/\ \L\ \@
\ \____/@
\/___/ @
@
@@
@
@
_____ @
/\ '__`\ @
\ \ \L\ \@
\ \ ,__/@
\ \ \/ @
\ \_\ @
\/_/ @@
@
@
__ @
/'__`\ @
/\ \L\ \ @
\ \___, \ @
\/___/\ \ @
\ \_\@
\/_/@@
@
@
_ __ @
/\`'__\@
\ \ \/ @
\ \_\ @
\/_/ @
@
@@
@
@
____ @
/',__\ @
/\__, `\@
\/\____/@
\/___/ @
@
@@
__ @
/\ \__ @
\ \ ,_\ @
\ \ \/ @
\ \ \_ @
\ \__\@
\/__/@
@
@@
@
@
__ __ @
/\ \/\ \ @
\ \ \_\ \@
\ \____/@
\/___/ @
@
@@
@
@
__ __ @
/\ \/\ \ @
\ \ \_/ |@
\ \___/ @
\/__/ @
@
@@
@
@
__ __ __ @
/\ \/\ \/\ \ @
\ \ \_/ \_/ \@
\ \___x___/'@
\/__//__/ @
@
@@
@
@
__ _ @
/\ \/'\ @
\/> </ @
/\_/\_\@
\//\/_/@
@
@@
@
@
__ __ @
/\ \/\ \ @
\ \ \_\ \ @
\/`____ \ @
`/___/> \@
/\___/@
\/__/ @@
@
@
____ @
/\_ ,`\ @
\/_/ /_ @
/\____\@
\/____/@
@
@@
_ @
/' \@
\ ,/'@
<' \ @
< \ `\ @
\`\__\@
\/__/@
@
@@
__ @
/\ \ @
\ \ \ @
\ \ \ @
\ \ \ @
\ \ \ @
\ \ \ @
\ \_\@
\/_/@@
__ @
/\ `\ @
\`\ \ @
\ \ `>@
//' \ @
/\__/' @
\/_/ @
@
@ @
_ _ @
/' \/' \ @
/\_/\__//$ @
\//\/__/ $ @
$ $@
@
@
@
@@
__ __ @
/\_\/\_\ @
\/\ _ \ @
\ \ \L\ \ @
\ \ __ \ @
\ \_\/\_\@
\/_/\/_/@
@
@@
__ __ @
/\_\/\_\ @
\/\ __ \ @
\ \ \/\ \ @
\ \ \_\ \ @
\ \_____\@
\/_____/@
@
@ @
__ __ @
/\_\/\_\ @
\/\ \/\ \ @
\ \ \ \ \ @
\ \ \_\ \ @
\ \_____\@
\/_____/@
@
@ @
__ __ @
/\_\/\_\ @
\/_/\/_/_ @
/'_` \ @
/\ \L\ \ @
\ `\__,_\@
`\/_,__/@
@
@@
__ __ @
/\_\/\_\ @
\/_/\/_/ @
/'_`\ @
/\ \L\ \@
\ `\___/@
`\/__/ @
@
@@
__ __ @
/\_\ \_\ @
\/_/\/_/_ @
/\ \/\ \ @
\ \ \_\ \@
\ `\___/@
`\/__/ @
@
@@
______ @
/\ __ \ @
\ \ \/\ \ @
\ \ \<_<_ @
\ \ \ \ \@
\ \ \\_/@
\ \_\/ @
\/_/ @
@@

2227
asset/font/flat.flf Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +1,26 @@
runcharts:
- title: SEARCH ENGINE RESPONSE TIME (sec)
precision: 3
position:
w: 0
h: 0
size:
w: 30
h: 20
w: 50
h: 14
precision: 3
items:
- label: GOOGLE
script: curl -o /dev/null -s -w '%{time_total}' https://www.google.com
- label: YAHOO
script: curl -o /dev/null -s -w '%{time_total}' https://search.yahoo.com
- label: YANDEX
script: curl -o /dev/null -s -w '%{time_total}' https://yandex.com
- label: BING
script: curl -o /dev/null -s -w '%{time_total}' https://www.bing.com
- label: DDGO
script: curl -o /dev/null -s -w '%{time_total}' https://duckduckgo.com
- title: SEARCH ENGINE RESPONSE TIME 2 (sec)
refresh-rate-ms: 5000
position:
w: 0
h: 20
h: 14
size:
w: 15
w: 17
h: 10
legend:
enabled: true
@ -38,11 +34,29 @@ runcharts:
script: curl -o /dev/null -s -w '%{time_total}' https://www.bing.com
- title: MONGO COLLECTIONS COUNT
position:
w: 15
h: 20
w: 17
h: 14
size:
w: 15
w: 17
h: 10
items:
- label: POSTS
script: mongo --quiet --host=localhost blog --eval "db.getCollection('post').find({}).size()"
asciiboxes:
- title: COUNT
position:
w: 34
h: 14
size:
w: 16
h: 4
script: date +%r
- title: MODE
position:
w: 34
h: 18
size:
w: 16
h: 6
script: date +%r
font: 3d

View File

@ -4,6 +4,7 @@ import (
"fmt"
"github.com/sqshq/sampler/console"
"github.com/sqshq/sampler/data"
"github.com/sqshq/sampler/widgets/asciibox"
"gopkg.in/yaml.v2"
"io/ioutil"
"log"
@ -13,12 +14,12 @@ import (
type Config struct {
Theme *console.Theme `yaml:"theme,omitempty"`
RunCharts []RunChartConfig `yaml:"runcharts,omitempty"`
AsciiBoxes []AsciiBoxConfig `yaml:"asciiboxes,omitempty"`
}
type ComponentConfig struct {
Title string `yaml:"title"`
RefreshRateMs *int `yaml:"refresh-rate-ms,omitempty"`
Precision *int `yaml:"precision,omitempty"`
Position Position `yaml:"position"`
Size Size `yaml:"size"`
}
@ -26,9 +27,16 @@ type ComponentConfig struct {
type RunChartConfig struct {
ComponentConfig `yaml:",inline"`
Legend *LegendConfig `yaml:"legend,omitempty"`
Precision *int `yaml:"precision,omitempty"`
Items []data.Item `yaml:"items"`
}
type AsciiBoxConfig struct {
ComponentConfig `yaml:",inline"`
data.Item `yaml:",inline"`
Font *asciibox.AsciiFont `yaml:"font,omitempty"`
}
type LegendConfig struct {
Enabled bool `yaml:"enabled"`
Details bool `yaml:"details"`
@ -49,6 +57,8 @@ type ComponentType rune
const (
TypeRunChart ComponentType = 0
TypeBarChart ComponentType = 1
TypeTextBox ComponentType = 2
TypeAsciiBox ComponentType = 3
)
type ComponentSettings struct {
@ -91,6 +101,12 @@ func (c *Config) findComponent(componentType ComponentType, componentTitle strin
return &c.RunCharts[i].ComponentConfig
}
}
case TypeAsciiBox:
for i, component := range c.AsciiBoxes {
if component.Title == componentTitle {
return &c.AsciiBoxes[i].ComponentConfig
}
}
}
panic(fmt.Sprintf(

View File

@ -2,10 +2,11 @@ package config
import (
"github.com/sqshq/sampler/console"
"github.com/sqshq/sampler/widgets/asciibox"
)
const (
defaultRefreshRateMs = 300
defaultRefreshRateMs = 1000
defaultPrecision = 1
defaultTheme = console.ThemeDark
)
@ -38,6 +39,26 @@ func (c *Config) setDefaultValues() {
}
c.RunCharts[i] = chart
}
for i, box := range c.AsciiBoxes {
if box.RefreshRateMs == nil {
r := defaultRefreshRateMs
box.RefreshRateMs = &r
}
if box.Label == nil {
label := string(i)
box.Label = &label
}
if box.Font == nil {
font := asciibox.AsciiFontFlat
box.Font = &font
}
if box.Color == nil {
color := console.ColorWhite
box.Color = &color
}
c.AsciiBoxes[i] = box
}
}
func (c *Config) setDefaultLayout() {

View File

@ -7,7 +7,7 @@ import (
)
type Item struct {
Label string `yaml:"label"`
Label *string `yaml:"label,omitempty"`
Script string `yaml:"script"`
Color *ui.Color `yaml:"color,omitempty"`
}

View File

@ -25,14 +25,7 @@ func NewSampler(consumer Consumer, item Item, rateMs int) Sampler {
}
func (self *Sampler) sample() {
value, err := self.item.nextValue()
sample := Sample{
Value: value,
Error: err,
Label: self.item.Label,
}
sample := Sample{Value: value, Error: err, Label: *self.item.Label}
self.consumer.ConsumeSample(sample)
}

1
go.mod
View File

@ -4,6 +4,7 @@ require (
github.com/hajimehoshi/go-mp3 v0.1.1
github.com/hajimehoshi/oto v0.1.1
github.com/mattn/go-runewidth v0.0.4 // indirect
github.com/mbndr/figlet4go v0.0.0-20170909125910-47ded4d17030
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/sqshq/termui v0.0.0-20190125032456-731556c09f2c
gopkg.in/yaml.v2 v2.2.2

2
go.sum
View File

@ -11,6 +11,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
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=
github.com/mbndr/figlet4go v0.0.0-20170909125910-47ded4d17030 h1:TSUoxTASZ3DmI7VDNX7/cbGlwz0OCp9RW07tUDnx3TQ=
github.com/mbndr/figlet4go v0.0.0-20170909125910-47ded4d17030/go.mod h1:QzTGLGoOqLHUBK8/EZ0v4Fa4CdyXmdyRwCHcl0YbeO4=
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4=
github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=

View File

@ -6,6 +6,7 @@ import (
"github.com/sqshq/sampler/data"
"github.com/sqshq/sampler/event"
"github.com/sqshq/sampler/widgets"
"github.com/sqshq/sampler/widgets/asciibox"
"github.com/sqshq/sampler/widgets/runchart"
ui "github.com/sqshq/termui"
"time"
@ -28,11 +29,17 @@ func main() {
layout.AddComponent(chart, c.Title, c.Position, c.Size, config.TypeRunChart)
for _, item := range c.Items {
chart.AddLine(item.Label, *item.Color)
chart.AddLine(*item.Label, *item.Color)
data.NewSampler(chart, item, *c.RefreshRateMs)
}
}
for _, a := range cfg.AsciiBoxes {
box := asciibox.NewAsciiBox(a.Title, *a.Font, *a.Item.Color)
layout.AddComponent(box, a.Title, a.Position, a.Size, config.TypeAsciiBox)
data.NewSampler(box, a.Item, *a.RefreshRateMs)
}
handler := event.Handler{
Layout: layout,
RenderEvents: time.NewTicker(console.RenderRate).C,

View File

@ -0,0 +1,69 @@
package asciibox
import (
fl "github.com/mbndr/figlet4go"
"github.com/sqshq/sampler/data"
ui "github.com/sqshq/termui"
"image"
)
type AsciiBox struct {
ui.Block
text string
ascii string
style ui.Style
render *fl.AsciiRender
options *fl.RenderOptions
}
type AsciiFont string
const (
AsciiFontFlat AsciiFont = "flat"
AsciiFont3D AsciiFont = "3d"
)
func NewAsciiBox(title string, font AsciiFont, color ui.Color) *AsciiBox {
block := *ui.NewBlock()
block.Title = title
render := fl.NewAsciiRender()
err := render.LoadFont("asset/")
if err != nil {
panic("Can't load fonts: " + err.Error())
}
options := fl.NewRenderOptions()
options.FontName = string(font)
return &AsciiBox{
Block: block,
style: ui.NewStyle(color),
render: render,
options: options,
}
}
func (a *AsciiBox) ConsumeSample(sample data.Sample) {
a.text = sample.Value
a.ascii, _ = a.render.RenderOpts(sample.Value, a.options)
}
func (a *AsciiBox) Draw(buffer *ui.Buffer) {
buffer.Fill(ui.NewCell(' ', ui.NewStyle(ui.ColorBlack)), a.GetRect())
a.Block.Draw(buffer)
point := a.Inner.Min
cells := ui.ParseText(a.ascii, a.style)
for i := 0; i < len(cells) && point.Y < a.Inner.Max.Y; i++ {
if cells[i].Rune == '\n' {
point = image.Pt(a.Inner.Min.X, point.Y+1)
} else if point.In(a.Inner) {
buffer.SetCell(cells[i], point)
point = point.Add(image.Pt(1, 0))
}
}
}

View File

@ -27,7 +27,7 @@ const (
)
const (
columnsCount = 30
columnsCount = 50
rowsCount = 30
)

View File

@ -70,6 +70,9 @@ func (m *Menu) up() {
break
}
}
if m.option == MenuOptionPinpoint && m.component.Type != config.TypeRunChart {
m.up()
}
}
func (m *Menu) down() {
@ -79,6 +82,9 @@ func (m *Menu) down() {
break
}
}
if m.option == MenuOptionPinpoint && m.component.Type != config.TypeRunChart {
m.down()
}
}
func (m *Menu) moveOrResize() {
@ -92,11 +98,8 @@ func (m *Menu) Draw(buffer *ui.Buffer) {
}
m.updateDimensions()
buffer.Fill(
ui.NewCell(' ', ui.NewStyle(ui.ColorBlack)),
m.GetRect(),
)
buffer.Fill(ui.NewCell(' ', ui.NewStyle(ui.ColorBlack)), m.GetRect())
m.drawInnerBorder(buffer)
switch m.mode {
case MenuModeHighlight:
@ -107,7 +110,6 @@ func (m *Menu) Draw(buffer *ui.Buffer) {
m.renderOptions(buffer)
}
m.drawInnerBorder(buffer)
m.Block.Draw(buffer)
}

View File

@ -107,5 +107,9 @@ func getDiffWithPreviousValue(line TimeLine) float64 {
}
func getCurrentValue(line TimeLine) float64 {
if len(line.points) == 0 {
return 0
} else {
return line.points[len(line.points)-1].value
}
}