Exemple #1
0
//selectAction shows information about the action that is selected in the ActionListView
func (c *CUI) selectAction(g *gocui.Gui, v *gocui.View) error {
	c.selectedCommand = c.getCursorListPos(g, v)

	if c.selectedCommand > len(c.cmdList)-1 {
		return nil
	}

	var l string
	var t string
	//Load the message from the commandList
	l = c.cmdList[c.selectedCommand].Message.ChildrenText()
	t = c.cmdList[c.selectedCommand].Message.Message

	maxX, maxY := g.Size()
	if v, err := g.SetView("ActionViewTitle", maxX/2-30, maxY/3-2, maxX/2+30, maxY/3); err != nil {
		if err != gocui.ErrorUnkView {
			return err
		}
		fmt.Fprintln(v, t)
	}
	if v, err := g.SetView("ActionView", maxX/2-30, maxY/3, maxX/2+30, 2*maxY/3); err != nil {
		if err != gocui.ErrorUnkView {
			return err
		}
		v.Wrap = true
		fmt.Fprintln(v, l)
		if err := g.SetCurrentView("ActionView"); err != nil {
			return err
		}
	}
	err := c.printActionHelp(g)
	return err
}