示例#1
0
文件: form.go 项目: zozor/gocurse
func (f *Form) SetFields(fields []*Field) error {
	fs := make([]*C.FIELD, 0, len(fields))
	for _, value := range fields {
		fs = append(fs, value.field)
	}
	return geterror(C.set_form_fields(f.form, &fs[0]))
}
示例#2
0
// SetFields overwrites the current fields for the Form with new ones.
// It is important to make sure all prior fields have been freed otherwise
// this action will result in a memory leak
func (f *Form) SetFields(fields []*Field) error {
	//cfields := make([]*C.FIELD, len(fields)+1)
	//for index, field := range fields {
	//cfields[index] = field.field
	//}
	//cfields[len(fields)] = nil
	err := C.set_form_fields(f.form, (**C.FIELD)(unsafe.Pointer(&fields[0])))
	return ncursesError(syscall.Errno(err))
}
示例#3
0
// SetFields overwrites the current fields for the Form with new ones.
// It is important to make sure all prior fields have been freed otherwise
// this action will result in a memory leak
func (f *Form) SetFields(fields []*Field) error {
	cfields := make([]*C.FIELD, len(fields)+1)
	for index, field := range fields {
		cfields[index] = field.field
	}
	cfields[len(fields)] = nil
	err := C.set_form_fields(f.form, (**C.FIELD)(&cfields[0]))
	return ncursesError(syscall.Errno(err))
}
示例#4
0
文件: forms.go 项目: mpatraw/gocurse
func (form *Form) SetFields(fields []*Field) bool {
	return isOk(C.set_form_fields((*C.FORM)(form), (**C.FIELD)(void(&fields[0]))))
}