示例#1
0
func (runner *appRunner) layout(g *gocui.Gui) error {
	maxX, maxY := g.Size()

	view, _ := g.SetView("mainControls", -1, -1, maxX/2, maxY)
	_, originY := view.Origin()
	_, cursorY := view.Cursor()

	view.Clear()
	runner.mainControlLines = 0
	runner.highlightedTexter = nil

	if g.CurrentView() == nil {
		g.SetCurrentView("mainControls")
	}
	view.Highlight = g.CurrentView() == view

	runner.rootTexter.TextMain(func(label, line string, texter ViewModelNodeTexter) {
		paddedLabel := fmt.Sprintf("%20s", label)
		fmt.Fprintf(view, "%s %v\n", paddedLabel[len(paddedLabel)-20:len(paddedLabel)], line)
		if (originY + cursorY) == runner.mainControlLines {
			runner.highlightedTexter = texter
		}
		runner.mainControlLines++
	})

	return nil
}
示例#2
0
文件: demo2.go 项目: balu-/gocui
func nextView(g *gocui.Gui, v *gocui.View) error {
	currentView := g.CurrentView()
	if currentView == nil || currentView.Name() == "side" {
		return g.SetCurrentView("main")
	}
	return g.SetCurrentView("side")
}
示例#3
0
文件: ui.go 项目: garry415/goax
func nextView(g *gocui.Gui, v *gocui.View) error {
	currentView := g.CurrentView()
	if currentView == nil || currentView.Name() == "contacts" {
		return g.SetCurrentView("input")
	}
	return g.SetCurrentView("contacts")
}
示例#4
0
func nextView(g *gocui.Gui, v *gocui.View) error {
	g.Cursor = false
	v.Highlight = false
	log.Println("nextView: " + v.Name())
	var err error
	switch v.Name() {
	case "channels":
		err = g.SetCurrentView("input")
		g.Cursor = true
	case "input":
		err = g.SetCurrentView("channels")
		g.CurrentView().Highlight = true
	}
	//	g.Flush()
	return err
}
示例#5
0
文件: tui.go 项目: Rompei/vuls
func nextSummary(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		// cursor to summary
		if err := g.SetCurrentView("summary"); err != nil {
			return err
		}
		// move next line
		if err := cursorDown(g, g.CurrentView()); err != nil {
			return err
		}
		// cursor to detail
		if err := g.SetCurrentView("detail"); err != nil {
			return err
		}
	}
	return nil
}