예제 #1
0
파일: test.go 프로젝트: zozor/gocurse
func main() {
	window, err := gocurse.Initscr()
	if err != nil {
		gocurse.Endwin()
		return
	}
	window.Refresh()
	fmt.Println(window.Getch())

	gocurse.Endwin()
}
예제 #2
0
파일: sample.go 프로젝트: zozor/gocurse
func main() {
	//setup
	window, err := gocurse.Initscr()
	if err != nil {
		fmt.Println(err)
		gocurse.Endwin()
		return
	}
	defer gocurse.Endwin()

	window.Clear()

	gocurse.Noecho()
	gocurse.Cbreak()

	window.Keypad(true)

	if err := gocurse.StartColor(); err != nil {
		fmt.Println(err)
		return
	}

	//color setup
	gocurse.SetColorPair(1, gocurse.COLOR_RED, gocurse.COLOR_BLACK)

	x, y := 10, 10

	for {

		inp := window.Getch()
		fmt.Println(inp)

		switch inp {
		case 'q':
			return
		case gocurse.KEY_LEFT:
			x--
		case gocurse.KEY_RIGHT:
			x++
		case gocurse.KEY_UP:
			y--
		case gocurse.KEY_DOWN:
			y++
		}

		window.Clear()
		window.Addch(x, y, '@', gocurse.GetColorPair(1))
		window.Refresh()
	}
}