package name renaming
This commit is contained in:
parent
ecd6344269
commit
ee2b2ab3e2
|
@ -1,4 +1,4 @@
|
||||||
package widgets
|
package component
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/sqshq/sampler/config"
|
"github.com/sqshq/sampler/config"
|
|
@ -1,9 +1,9 @@
|
||||||
package widgets
|
package component
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/sqshq/sampler/component/runchart"
|
||||||
"github.com/sqshq/sampler/config"
|
"github.com/sqshq/sampler/config"
|
||||||
"github.com/sqshq/sampler/console"
|
"github.com/sqshq/sampler/console"
|
||||||
"github.com/sqshq/sampler/widgets/runchart"
|
|
||||||
ui "github.com/sqshq/termui"
|
ui "github.com/sqshq/termui"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package widgets
|
package component
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/sqshq/sampler/config"
|
"github.com/sqshq/sampler/config"
|
|
@ -2,9 +2,9 @@ package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/sqshq/sampler/component/asciibox"
|
||||||
"github.com/sqshq/sampler/console"
|
"github.com/sqshq/sampler/console"
|
||||||
"github.com/sqshq/sampler/data"
|
"github.com/sqshq/sampler/data"
|
||||||
"github.com/sqshq/sampler/widgets/asciibox"
|
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/sqshq/sampler/component/asciibox"
|
||||||
"github.com/sqshq/sampler/console"
|
"github.com/sqshq/sampler/console"
|
||||||
"github.com/sqshq/sampler/widgets/asciibox"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultRefreshRateMs = 1000
|
defaultRefreshRateMs = 200
|
||||||
defaultScale = 1
|
defaultScale = 1
|
||||||
defaultTheme = console.ThemeDark
|
defaultTheme = console.ThemeDark
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
package event
|
package event
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/sqshq/sampler/component"
|
||||||
"github.com/sqshq/sampler/config"
|
"github.com/sqshq/sampler/config"
|
||||||
"github.com/sqshq/sampler/console"
|
"github.com/sqshq/sampler/console"
|
||||||
"github.com/sqshq/sampler/widgets"
|
|
||||||
ui "github.com/sqshq/termui"
|
ui "github.com/sqshq/termui"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
refreshRateToRenderRateRatio = 0.8
|
refreshRateToRenderRateRatio = 0.6
|
||||||
)
|
)
|
||||||
|
|
||||||
type Handler struct {
|
type Handler struct {
|
||||||
layout *widgets.Layout
|
layout *component.Layout
|
||||||
renderTicker *time.Ticker
|
renderTicker *time.Ticker
|
||||||
consoleEvents <-chan ui.Event
|
consoleEvents <-chan ui.Event
|
||||||
renderRate time.Duration
|
renderRate time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHandler(layout *widgets.Layout) Handler {
|
func NewHandler(layout *component.Layout) Handler {
|
||||||
renderRate := calcMinRenderRate(layout)
|
renderRate := calcMinRenderRate(layout)
|
||||||
return Handler{
|
return Handler{
|
||||||
layout: layout,
|
layout: layout,
|
||||||
|
@ -58,13 +58,13 @@ func (h *Handler) HandleEvents() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) handleModeChange(m widgets.Mode) {
|
func (h *Handler) handleModeChange(m component.Mode) {
|
||||||
|
|
||||||
// render mode change before switching the tickers
|
// render change before switching the tickers
|
||||||
ui.Render(h.layout)
|
ui.Render(h.layout)
|
||||||
h.renderTicker.Stop()
|
h.renderTicker.Stop()
|
||||||
|
|
||||||
if m == widgets.ModeDefault {
|
if m == component.ModeDefault {
|
||||||
h.renderTicker = time.NewTicker(h.renderRate)
|
h.renderTicker = time.NewTicker(h.renderRate)
|
||||||
} else {
|
} else {
|
||||||
h.renderTicker = time.NewTicker(console.MinRenderInterval)
|
h.renderTicker = time.NewTicker(console.MinRenderInterval)
|
||||||
|
@ -80,7 +80,7 @@ func (h *Handler) handleExit() {
|
||||||
config.Update(settings)
|
config.Update(settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
func calcMinRenderRate(layout *widgets.Layout) time.Duration {
|
func calcMinRenderRate(layout *component.Layout) time.Duration {
|
||||||
|
|
||||||
minRefreshRateMs := layout.Components[0].RefreshRateMs
|
minRefreshRateMs := layout.Components[0].RefreshRateMs
|
||||||
for _, c := range layout.Components {
|
for _, c := range layout.Components {
|
||||||
|
|
10
main.go
10
main.go
|
@ -1,14 +1,14 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/sqshq/sampler/component"
|
||||||
|
"github.com/sqshq/sampler/component/asciibox"
|
||||||
|
"github.com/sqshq/sampler/component/barchart"
|
||||||
|
"github.com/sqshq/sampler/component/runchart"
|
||||||
"github.com/sqshq/sampler/config"
|
"github.com/sqshq/sampler/config"
|
||||||
"github.com/sqshq/sampler/console"
|
"github.com/sqshq/sampler/console"
|
||||||
"github.com/sqshq/sampler/data"
|
"github.com/sqshq/sampler/data"
|
||||||
"github.com/sqshq/sampler/event"
|
"github.com/sqshq/sampler/event"
|
||||||
"github.com/sqshq/sampler/widgets"
|
|
||||||
"github.com/sqshq/sampler/widgets/asciibox"
|
|
||||||
"github.com/sqshq/sampler/widgets/barchart"
|
|
||||||
"github.com/sqshq/sampler/widgets/runchart"
|
|
||||||
ui "github.com/sqshq/termui"
|
ui "github.com/sqshq/termui"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ func main() {
|
||||||
defer csl.Close()
|
defer csl.Close()
|
||||||
|
|
||||||
width, height := ui.TerminalDimensions()
|
width, height := ui.TerminalDimensions()
|
||||||
layout := widgets.NewLayout(width, height, widgets.NewMenu())
|
layout := component.NewLayout(width, height, component.NewMenu())
|
||||||
|
|
||||||
for _, c := range cfg.RunCharts {
|
for _, c := range cfg.RunCharts {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue