Esempio n. 1
0
// GetString reads at most 'n' characters entered by the user from the Window.
// Attempts to enter greater than 'n' characters will elicit a 'beep'
func (w *Window) GetString(n int) (string, error) {
	cstr := make([]C.char, n)
	if C.wgetnstr(w.win, (*C.char)(&cstr[0]), C.int(n)) == C.ERR {
		return "", errors.New("Failed to retrieve string from input stream")
	}
	return C.GoString(&cstr[0]), nil
}
Esempio n. 2
0
func (win *Window) Getnstr(length int) (string, error) {
	buf := make([]byte, length)
	r := C.wgetnstr((*C.WINDOW)(win), (*C.char)(unsafe.Pointer(&buf[0])), C.int(length))
	if r == C.ERR {
		return string(buf), CursesError{"wgetnstr failed"}
	}
	return string(buf), nil
}
Esempio n. 3
0
func (w *Window) Getstr() (string, error) {
	var buffer [1024]C.char
	if C.wgetnstr(w.win, &buffer[0], 1024) == ERR {
		return "", Error
	}

	s := C.GoString(&buffer[0])
	return s, nil
}