示例#1
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
}
示例#2
0
func toggleCmdMode(g *gocui.Gui, v *gocui.View) error {
	var nv string

	tv, err := g.View("tubes")
	if err != nil {
		return err
	}

	if !cmdMode {
		cmdMode = true
		g.Cursor = true
		nv = "menu"

		//Clear the tube list and set autoscroll for command responses
		tv.Clear()
		tv.Autoscroll = true

		PrintLine(tv, fmt.Sprintf("Running commands on %s:\n", cTubes.Selected))
	} else {
		cmdMode = false
		g.Cursor = false
		nv = "tubes"

		//Reset the view origin and disable autoscroll
		tv.SetOrigin(0, 0)
		tv.Autoscroll = false

		//Reload the tube list
		if err := reloadTubes(g); err != nil {
			return err
		}
	}

	if err := reloadMenu(g); err != nil {
		return err
	}

	return g.SetCurrentView(nv)
}
示例#3
0
文件: active.go 项目: jmptrader/gocui
func nextView(g *gocui.Gui, v *gocui.View) error {
	nextIndex := (active + 1) % len(viewArr)
	name := viewArr[nextIndex]

	out, err := g.View("v2")
	if err != nil {
		return err
	}
	fmt.Fprintln(out, "Going from view "+v.Name()+" to "+name)

	if _, err := setCurrentViewOnTop(g, name); err != nil {
		return err
	}

	if nextIndex == 0 || nextIndex == 3 {
		g.Cursor = true
	} else {
		g.Cursor = false
	}

	active = nextIndex
	return nil
}