positioning adjustments

This commit is contained in:
sqshq 2019-02-24 19:37:57 -05:00
parent 68acb63715
commit a40cc50f3f
3 changed files with 30 additions and 30 deletions

View File

@ -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)
}

View File

@ -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

View File

@ -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)
}