コード例 #1
0
ファイル: statsdtop.go プロジェクト: kgilmer/statsdtop
func layout(g *gocui.Gui) error {
	maxX, maxY := g.Size()
	columnX := maxX / 3

	g.BgColor = gocui.ColorWhite
	g.FgColor = gocui.ColorBlack
	g.RenderFrames = false

	if v, err := g.SetView("status", -1, -1, maxX, 1); err != nil {
		if err != gocui.ErrorUnkView {
			return err
		}
		v.FgColor = gocui.ColorWhite
		v.BgColor = gocui.ColorBlack
	}

	if v, err := g.SetView("counterHeader", -1, 0, columnX, maxY); err != nil {
		if err != gocui.ErrorUnkView {
			return err
		}
		v.FgColor = gocui.ColorWhite
		v.BgColor = gocui.ColorBlue
		fmt.Fprintf(v, "Counters")
	}
	if _, err := g.SetView("counters", -1, 1, columnX, maxY); err != nil {
		if err != gocui.ErrorUnkView {
			return err
		}
	}

	if v, err := g.SetView("gaugeHeader", columnX, 0, columnX*2, maxY); err != nil {
		if err != gocui.ErrorUnkView {
			return err
		}
		v.FgColor = gocui.ColorWhite
		v.BgColor = gocui.ColorCyan
		fmt.Fprintf(v, "Gauges")
	}
	if _, err := g.SetView("gauges", columnX, 1, columnX*2, maxY); err != nil {
		if err != gocui.ErrorUnkView {
			return err
		}
	}

	if v, err := g.SetView("timerHeader", columnX*2, 0, maxX-1, maxY); err != nil {
		if err != gocui.ErrorUnkView {
			return err
		}
		v.FgColor = gocui.ColorWhite
		v.BgColor = gocui.ColorMagenta
		fmt.Fprintf(v, "Timers")
	}
	if _, err := g.SetView("timers", (columnX * 2), 1, maxX-1, maxY); err != nil {
		if err != gocui.ErrorUnkView {
			return err
		}
	}

	return nil
}