Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error when using REQ_LEFT #53

Closed
kallerosenbaum opened this issue Aug 19, 2020 · 0 comments · Fixed by #54
Closed

Compilation error when using REQ_LEFT #53

kallerosenbaum opened this issue Aug 19, 2020 · 0 comments · Fixed by #54
Labels

Comments

@kallerosenbaum
Copy link

I'm running into problems using REQ_LEFT.

The following code doesn't compile:

package main

import (
	gc "github.com/rthornton128/goncurses"
)

func main() {
	menuWin, _ := gc.Init()

	gc.Raw(true)
	gc.Echo(false)
	menuWin.Keypad(true)
	gc.Cursor(0)

	menuWin.Keypad(true)
	itemPos, _ := gc.NewItem("YES", "")
	itemNeg, _ := gc.NewItem("NO","")

	choices := []*gc.MenuItem {itemNeg, itemPos}
	menu, _ := gc.NewMenu(choices)
	menu.SetWindow(menuWin)
	height, width := dimensions(menuWin)
	menu.SubWindow(menuWin.Derived(height, width, 0, 0))

	menu.Format(1, 2)
	menu.Post()

	menuWin.Refresh()

	var key gc.Key
	for ; ; key = menuWin.GetChar(){
		switch key {
		case gc.KEY_RIGHT:
			menu.Driver(gc.REQ_RIGHT) // Works
		case gc.KEY_LEFT:
			menu.Driver(gc.REQ_LEFT) // Compilation error
		}
	}

	gc.End()
}

func dimensions(w *gc.Window) (height int, width int) {
	y, x := w.YX()
	maxy, maxx := w.MaxYX()
	height = maxy - y
	width = maxx - x
	return
}

Compilation error:

$ go build req_left.go 
# command-line-arguments
./req_left.go:36:15: cannot use goncurses.REQ_LEFT (type goncurses.MenuDriverReq) as type int in argument to menu.Driver

However if I change REQ_LEFT to REQ_RIGHT it does compile.

$ go version
go version go1.13.8 linux/amd64

goncurses version seems to be v0.0.0-20200419155752-a72cfe131f63 according to my go.mod file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants