Esempio n. 1
0
//cursorDown moves the cursor down one position. When reaching the bottom, windows the text
func (c *CUI) cursorDown(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx, cy+1); err != nil {
			ox, oy := v.Origin()
			if err := v.SetOrigin(ox, oy+1); err != nil {
				return err
			}
		}
	}
	return nil
}
Esempio n. 2
0
//cursorUp moves the cursor up one position. When reaching the top, windows the text
func (c *CUI) cursorUp(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		ox, oy := v.Origin()
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx, cy-1); err != nil && oy > 0 {
			if err := v.SetOrigin(ox, oy-1); err != nil {
				return err
			}
		}
	}
	return nil
}
Esempio n. 3
0
//getCursorListPos returns the position of selection in the given view
func (c *CUI) getCursorListPos(g *gocui.Gui, v *gocui.View) (y int) {
	_, oy := v.Origin()
	_, cy := v.Cursor()
	y = oy + cy
	return
}