예제 #1
0
파일: forms.go 프로젝트: mpatraw/gocurse
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
}
예제 #2
0
파일: form.go 프로젝트: trotha01/goncurses
// 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)
}
예제 #3
0
파일: form.go 프로젝트: zozor/gocurse
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
}
예제 #4
0
// 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)
}