func NewForm(fields []*Field) (*Form, error) { form := (*Form)(C.new_form((**C.FIELD)(void(&fields[0])))) if form == nil { return nil, FormsError{"NewForm failed"} } return form, nil }
// NewForm returns a new form object using the fields array supplied as // an argument func NewForm(fields []*Field) (Form, error) { if fields[len(fields)-1] != nil { fields = append(fields, nil) } form, err := C.new_form((**C.FIELD)(unsafe.Pointer(&fields[0]))) return Form{form}, ncursesError(err) }
func NewForm(fields []*Field) (*Form, error) { f := make([]*C.FIELD, 0, len(fields)) for _, value := range fields { f = append(f, value.field) } form := C.new_form(&f[0]) if form == nil { return nil, errors.New("NewForm failed") } return &Form{form}, nil }
// NewForm returns a new form object using the fields array supplied as // an argument func NewForm(fields []*Field) (Form, error) { cfields := make([]*C.FIELD, len(fields)+1) for index, field := range fields { cfields[index] = field.field } cfields[len(fields)] = nil var form *C.FORM var err error form, err = C.new_form((**C.FIELD)(&cfields[0])) return Form{form}, ncursesError(err) }