From a40cc50f3f133a02175e65e0b9f791fedec693ce Mon Sep 17 00:00:00 2001 From: sqshq Date: Sun, 24 Feb 2019 19:37:57 -0500 Subject: [PATCH] positioning adjustments --- component/layout.go | 18 +++++++++--------- config.yml | 40 ++++++++++++++++++++-------------------- config/config.go | 2 +- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/component/layout.go b/component/layout.go index a6200f5..5ec2550 100644 --- a/component/layout.go +++ b/component/layout.go @@ -29,15 +29,16 @@ const ( ) const ( - columnsCount = 50 - rowsCount = 30 + columnsCount = 60 + rowsCount = 40 + statusbarHeight = 1 ) func NewLayout(width, height int, statusline *StatusBar, menu *Menu) *Layout { block := *ui.NewBlock() block.SetRect(0, 0, width, height) - statusline.SetRect(0, height-1, width, height) + statusline.SetRect(0, height-statusbarHeight, width, height) return &Layout{ Block: block, @@ -119,7 +120,6 @@ func (l *Layout) HandleConsoleEvent(e string) { switch l.mode { case ModeDefault: l.changeMode(ModeComponentSelect) - l.selection = 0 l.menu.highlight(l.getComponent(l.selection)) case ModeChartPinpoint: chart := l.getSelectedComponent().Drawable.(*runchart.RunChart) @@ -138,7 +138,6 @@ func (l *Layout) HandleConsoleEvent(e string) { switch l.mode { case ModeDefault: l.changeMode(ModeComponentSelect) - l.selection = 0 l.menu.highlight(l.getComponent(l.selection)) case ModeChartPinpoint: chart := l.getSelectedComponent().Drawable.(*runchart.RunChart) @@ -157,7 +156,6 @@ func (l *Layout) HandleConsoleEvent(e string) { switch l.mode { case ModeDefault: l.changeMode(ModeComponentSelect) - l.selection = 0 l.menu.highlight(l.getComponent(l.selection)) case ModeComponentSelect: if l.selection > 0 { @@ -175,7 +173,6 @@ func (l *Layout) HandleConsoleEvent(e string) { switch l.mode { case ModeDefault: l.changeMode(ModeComponentSelect) - l.selection = 0 l.menu.highlight(l.getComponent(l.selection)) case ModeComponentSelect: if l.selection < len(l.Components)-1 { @@ -194,7 +191,6 @@ func (l *Layout) HandleConsoleEvent(e string) { func (l *Layout) ChangeDimensions(width, height int) { l.SetRect(0, 0, width, height) - l.statusbar.SetRect(0, height-1, width, height) } // TODO func to get prev/next component navigating left/right/top/bottom @@ -209,7 +205,7 @@ func (l *Layout) getSelectedComponent() *Component { func (l *Layout) Draw(buffer *ui.Buffer) { columnWidth := float64(l.GetRect().Dx()) / columnsCount - rowHeight := float64(l.GetRect().Dy()) / rowsCount + rowHeight := float64(l.GetRect().Dy()-statusbarHeight) / rowsCount for _, component := range l.Components { @@ -222,6 +218,10 @@ func (l *Layout) Draw(buffer *ui.Buffer) { component.Drawable.Draw(buffer) } + l.statusbar.SetRect( + 0, l.GetRect().Dy()-statusbarHeight, + l.GetRect().Dx(), l.GetRect().Dy()) + l.menu.Draw(buffer) l.statusbar.Draw(buffer) } diff --git a/config.yml b/config.yml index 6d87a8e..0e7f931 100644 --- a/config.yml +++ b/config.yml @@ -4,8 +4,8 @@ runcharts: w: 0 h: 0 size: - w: 34 - h: 14 + w: 40 + h: 18 scale: 3 items: - label: GOOGLE @@ -17,11 +17,11 @@ runcharts: - title: SEARCH ENGINE RESPONSE TIME 2 (sec) refresh-rate-ms: 5000 position: - w: 34 + w: 40 h: 0 size: - w: 16 - h: 14 + w: 20 + h: 18 legend: enabled: true details: false @@ -34,11 +34,11 @@ runcharts: script: curl -o /dev/null -s -w '%{time_total}' https://www.bing.com - title: MONGO COLLECTIONS COUNT position: - w: 17 - h: 14 + w: 21 + h: 18 size: - w: 17 - h: 10 + w: 19 + h: 13 scale: 0 items: - label: ACTIVE @@ -50,10 +50,10 @@ barcharts: refresh-rate-ms: 1000 position: w: 0 - h: 14 + h: 18 size: - w: 17 - h: 10 + w: 21 + h: 13 scale: 0 items: - label: NEW @@ -69,18 +69,18 @@ barcharts: asciiboxes: - title: LOCAL TIME position: - w: 34 - h: 14 + w: 40 + h: 18 size: - w: 16 - h: 4 + w: 20 + h: 6 script: date +%r - title: UTC TIME position: - w: 34 - h: 18 + w: 40 + h: 24 size: - w: 16 - h: 6 + w: 20 + h: 7 script: env TZ=UTC date +%r font: 3d diff --git a/config/config.go b/config/config.go index cc48b3e..c1f388a 100644 --- a/config/config.go +++ b/config/config.go @@ -156,7 +156,7 @@ func saveFile(config *Config) { log.Fatalf("Can't marshal config file: %v", err) } - err = ioutil.WriteFile("config.yml", file, 0644) + err = ioutil.WriteFile(os.Args[1], file, 0644) if err != nil { log.Fatalf("Can't save config file: %v", err) }