form_wrap.c in ncursesw-0.9.2 vs form_wrap.c in ncursesw-1.2.4.1
- old
+ new
@@ -4,11 +4,11 @@
* Prognosoft Inc. <http://www.prognosoft.biz>
* Copyright 2004
*
* Changes:
* (C) 2004 Tobias Peters
- * (C) 2005 Tobias Herzke
+ * (C) 2005 2009 Tobias Herzke
*
* This module is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
@@ -392,11 +392,11 @@
/*
* Form creation/destruction functions
*/
static VALUE rbncurs_m_new_form(VALUE dummy, VALUE rb_field_array)
{
- long n = RARRAY_LEN(rb_field_array);
+ long n = rbncurs_array_length(rb_field_array);
/* Will ncurses free this array? If not, must do it after calling free_form(). */
FIELD** fields = ALLOC_N(FIELD*, (n+1));
long i;
for (i=0; i<n; i++){
fields[i] = get_field(rb_ary_entry(rb_field_array, i));
@@ -616,11 +616,11 @@
if (ftype == TYPE_ENUM) {
if (argc != 4) {
rb_raise(rb_eArgError, "TYPE_ENUM requires three additional arguments");
}
else {
- int n = RARRAY_LEN(arg3);
+ int n = rbncurs_array_length(arg3);
/* Will ncurses free this array of strings in free_field()? */
char** list = ALLOC_N(char*, n+1);
int i;
for (i = 0; i < n; i++) {
list[i] = STR2CSTR(rb_ary_entry(arg3, (long)i));
@@ -775,11 +775,11 @@
/*
* form_field
*/
static VALUE rbncurs_c_set_form_fields(VALUE rb_form, VALUE rb_field_array) {
- long n = RARRAY_LEN(rb_field_array);
+ long n = rbncurs_array_length(rb_field_array);
/* If ncurses does not free memory used by the previous array of strings, */
/* we will have to do it now. */
FIELD** fields = ALLOC_N(FIELD*, (n+1));
long i;
FORM* form = NULL;
@@ -1123,15 +1123,15 @@
/* Compare number of arguments in Ruby Proc with that of set_field_type */
if (proc != Qnil) {
VALUE argc = rb_funcall(proc, rb_intern("arity"),0);
VALUE args = get_proc(field, FIELDTYPE_ARGS);
if (args != Qnil) {
- if (NUM2INT(argc)-1 != RARRAY_LEN(args)) {
+ if (NUM2INT(argc)-1 != rbncurs_array_length(args)) {
char msg[500];
snprintf(msg, 500, "The validation functions for this field type need %d additional arguments.",NUM2INT(argc)-1);
msg[499]=0;
- rb_raise(rb_eArgError, "%s", msg);
+ rb_raise(rb_eArgError, msg);
}
}
}
/* field will be the only argument in field_check/char_check callback */
/* and will be used to locate the appropriate Ruby Proc */
@@ -1256,24 +1256,24 @@
FORM_SNG_FUNC(current_field,1);
FORM_SNG_FUNC(data_ahead,1);
FORM_SNG_FUNC(data_behind,1);
FORM_SNG_FUNC(dup_field,3);
- FORM_SNG_FUNC(dynamic_field_info,3);
+ FORM_SNG_FUNC(dynamic_field_info,4);
FORM_SNG_FUNC(field_arg,1);
- FORM_SNG_FUNC(field_back,2);
+ FORM_SNG_FUNC(field_back,1);
FORM_SNG_FUNC(field_buffer,2);
FORM_SNG_FUNC(field_count,1);
- FORM_SNG_FUNC(field_fore,2);
+ FORM_SNG_FUNC(field_fore,1);
FORM_SNG_FUNC(field_index,1);
FORM_SNG_FUNC(field_info,7);
FORM_SNG_FUNC(field_init,1);
FORM_SNG_FUNC(field_just,1);
FORM_SNG_FUNC(field_opts,1);
FORM_SNG_FUNC(field_opts_off,2);
FORM_SNG_FUNC(field_opts_on,2);
- FORM_SNG_FUNC(field_pad,2);
+ FORM_SNG_FUNC(field_pad,1);
FORM_SNG_FUNC(field_status,1);
FORM_SNG_FUNC(field_term,1);
FORM_SNG_FUNC(field_type,1);
/* FORM_SNG_FUNC(field_userptr,1); */
FORM_SNG_FUNC(form_driver,2);
@@ -1347,94 +1347,94 @@
rb_iv_set(mForm, "@forms_hash", rb_hash_new());
cFORM = rb_define_class_under(mForm, "FORM", rb_cObject);
rb_define_singleton_method(cFORM, "new",
(&rbncurs_m_new_form),
1);
- RB_CLASS_METH(cFORM, current_field,0);
- RB_CLASS_METH(cFORM, data_ahead,0);
- RB_CLASS_METH(cFORM, data_behind,0);
- RB_CLASS_METH(cFORM, dup_field,2);
- RB_CLASS_METH(cFORM, field_count,0);
- RB_CLASS_METH(cFORM, field_init,0);
- RB_CLASS_METH(cFORM, field_term,0);
- RB_CLASS_METH(cFORM, form_driver,1);
- RB_CLASS_METH(cFORM, form_fields,0);
- RB_CLASS_METH(cFORM, form_init,0);
- RB_CLASS_METH(cFORM, form_opts,0);
- RB_CLASS_METH(cFORM, form_opts_off,1);
- RB_CLASS_METH(cFORM, form_opts_on,1);
- RB_CLASS_METH(cFORM, form_page,0);
- RB_CLASS_METH(cFORM, form_sub,0);
- RB_CLASS_METH(cFORM, form_term,0);
- /* RB_CLASS_METH(cFORM, form_userptr,0); */
- RB_CLASS_METH(cFORM, form_win,0);
- RB_CLASS_METH(cFORM, free_form,0);
- RB_CLASS_METH(cFORM, pos_form_cursor,0);
- RB_CLASS_METH(cFORM, post_form,0);
- RB_CLASS_METH(cFORM, scale_form,2);
- RB_CLASS_METH(cFORM, set_current_field,1);
- RB_CLASS_METH(cFORM, set_field_init,1);
- RB_CLASS_METH(cFORM, set_field_term,1);
- RB_CLASS_METH(cFORM, set_form_fields,1);
- RB_CLASS_METH(cFORM, set_form_init,1);
- RB_CLASS_METH(cFORM, set_form_opts,1);
- RB_CLASS_METH(cFORM, set_form_page,1);
- RB_CLASS_METH(cFORM, set_form_sub,1);
- RB_CLASS_METH(cFORM, set_form_term,1);
- /* RB_CLASS_METH(cFORM, set_form_userptr,1); */
- RB_CLASS_METH(cFORM, set_form_win,1);
- RB_CLASS_METH(cFORM, unpost_form,0);
+ RB_CLASS_METH(cFORM, NULL, current_field,0);
+ RB_CLASS_METH(cFORM, NULL, data_ahead,0);
+ RB_CLASS_METH(cFORM, NULL, data_behind,0);
+ RB_CLASS_METH(cFORM, NULL, dup_field,2);
+ RB_CLASS_METH(cFORM, NULL, field_count,0);
+ RB_CLASS_METH(cFORM, NULL, field_init,0);
+ RB_CLASS_METH(cFORM, NULL, field_term,0);
+ RB_CLASS_METH(cFORM, "driver", form_driver,1);
+ RB_CLASS_METH(cFORM, "fields", form_fields,0);
+ RB_CLASS_METH(cFORM, "init", form_init,0);
+ RB_CLASS_METH(cFORM, "opts", form_opts,0);
+ RB_CLASS_METH(cFORM, "opts_off", form_opts_off,1);
+ RB_CLASS_METH(cFORM, "opts_on", form_opts_on,1);
+ RB_CLASS_METH(cFORM, "page", form_page,0);
+ RB_CLASS_METH(cFORM, "sub", form_sub,0);
+ RB_CLASS_METH(cFORM, "term", form_term,0);
+ /* RB_CLASS_METH(cFORM, "userptr", form_userptr,0); */
+ RB_CLASS_METH(cFORM, "win", form_win,0);
+ RB_CLASS_METH(cFORM, "free", free_form,0);
+ RB_CLASS_METH(cFORM, "pos_cursor", pos_form_cursor,0);
+ RB_CLASS_METH(cFORM, "post", post_form,0);
+ RB_CLASS_METH(cFORM, "scale", scale_form,2);
+ RB_CLASS_METH(cFORM, "current_field=", set_current_field,1);
+ RB_CLASS_METH(cFORM, "field_init=", set_field_init,1);
+ RB_CLASS_METH(cFORM, "field_term=", set_field_term,1);
+ RB_CLASS_METH(cFORM, "fields=", set_form_fields,1);
+ RB_CLASS_METH(cFORM, "init=", set_form_init,1);
+ RB_CLASS_METH(cFORM, "opts=", set_form_opts,1);
+ RB_CLASS_METH(cFORM, "page=", set_form_page,1);
+ RB_CLASS_METH(cFORM, "sub=", set_form_sub,1);
+ RB_CLASS_METH(cFORM, "term=", set_form_term,1);
+ /* RB_CLASS_METH(cFORM, "userptr=", set_form_userptr,1); */
+ RB_CLASS_METH(cFORM, "win=", set_form_win,1);
+ RB_CLASS_METH(cFORM, "unpost", unpost_form,0);
/* Fields */
rb_iv_set(mForm, "@fields_hash", rb_hash_new());
cFIELD = rb_define_class_under(mForm, "FIELD", rb_cObject);
rb_define_singleton_method(cFIELD, "new",
(&rbncurs_m_new_field),
6);
- RB_CLASS_METH(cFIELD, dup_field,2);
- RB_CLASS_METH(cFIELD, dynamic_field_info,2);
- RB_CLASS_METH(cFIELD, field_arg,0);
- RB_CLASS_METH(cFIELD, field_back,1);
- RB_CLASS_METH(cFIELD, field_buffer,1);
- RB_CLASS_METH(cFIELD, field_fore,1);
- RB_CLASS_METH(cFIELD, field_index,0);
- RB_CLASS_METH(cFIELD, field_info,6);
- RB_CLASS_METH(cFIELD, field_just,0);
- RB_CLASS_METH(cFIELD, field_opts,0);
- RB_CLASS_METH(cFIELD, field_opts_off,1);
- RB_CLASS_METH(cFIELD, field_opts_on,1);
- RB_CLASS_METH(cFIELD, field_pad,1);
- RB_CLASS_METH(cFIELD, field_status,0);
- RB_CLASS_METH(cFIELD, field_type,0);
- /* RB_CLASS_METH(cFIELD, field_userptr,0); */
- RB_CLASS_METH(cFIELD, free_field,0);
- RB_CLASS_METH(cFIELD, link_field,2);
- RB_CLASS_METH(cFIELD, move_field,2);
- RB_CLASS_METH(cFIELD, new_page,0);
- RB_CLASS_METH(cFIELD, set_field_back,1);
- RB_CLASS_METH(cFIELD, set_field_buffer,2);
- RB_CLASS_METH(cFIELD, set_field_fore,1);
- RB_CLASS_METH(cFIELD, set_field_just,1);
- RB_CLASS_METH(cFIELD, set_field_opts,1);
- RB_CLASS_METH(cFIELD, set_field_pad,1);
- RB_CLASS_METH(cFIELD, set_field_status,1);
- RB_CLASS_METH(cFIELD, set_field_type,-1);
- /* RB_CLASS_METH(cFIELD, set_field_userptr,1); */
- RB_CLASS_METH(cFIELD, set_max_field,1);
- RB_CLASS_METH(cFIELD, set_new_page,1);
+ RB_CLASS_METH(cFIELD, "dup", dup_field,2);
+ RB_CLASS_METH(cFIELD, "dynamic_info", dynamic_field_info,3);
+ RB_CLASS_METH(cFIELD, "arg", field_arg,0);
+ RB_CLASS_METH(cFIELD, "back", field_back,1);
+ RB_CLASS_METH(cFIELD, "buffer", field_buffer,1);
+ RB_CLASS_METH(cFIELD, "fore", field_fore,1);
+ RB_CLASS_METH(cFIELD, "index", field_index,0);
+ RB_CLASS_METH(cFIELD, "info", field_info,6);
+ RB_CLASS_METH(cFIELD, "just", field_just,0);
+ RB_CLASS_METH(cFIELD, "opts", field_opts,0);
+ RB_CLASS_METH(cFIELD, "opts_off", field_opts_off,1);
+ RB_CLASS_METH(cFIELD, "opts_on", field_opts_on,1);
+ RB_CLASS_METH(cFIELD, "pad", field_pad,1);
+ RB_CLASS_METH(cFIELD, "status", field_status,0);
+ RB_CLASS_METH(cFIELD, "type", field_type,0);
+ /* RB_CLASS_METH(cFIELD, "userptr", field_userptr,0); */
+ RB_CLASS_METH(cFIELD, "free", free_field,0);
+ RB_CLASS_METH(cFIELD, "link", link_field,2);
+ RB_CLASS_METH(cFIELD, "move", move_field,2);
+ RB_CLASS_METH(cFIELD, NULL, new_page,0);
+ RB_CLASS_METH(cFIELD, "back=", set_field_back,1);
+ RB_CLASS_METH(cFIELD, "set_buffer", set_field_buffer,2);
+ RB_CLASS_METH(cFIELD, "fore=", set_field_fore,1);
+ RB_CLASS_METH(cFIELD, "just=", set_field_just,1);
+ RB_CLASS_METH(cFIELD, "opts=", set_field_opts,1);
+ RB_CLASS_METH(cFIELD, "pad=", set_field_pad,1);
+ RB_CLASS_METH(cFIELD, "status=", set_field_status,1);
+ RB_CLASS_METH(cFIELD, "set_type", set_field_type,-1);
+ /* RB_CLASS_METH(cFIELD, "userptr=", set_field_userptr,1); */
+ RB_CLASS_METH(cFIELD, "max_field=", set_max_field,1);
+ RB_CLASS_METH(cFIELD, "new_page=", set_new_page,1);
/* Field types */
rb_iv_set(mForm, "@fieldtypes_hash", rb_hash_new());
cFIELDTYPE = rb_define_class_under(mForm, "FIELDTYPE", rb_cObject);
rb_define_singleton_method(cFIELDTYPE, "new",
(&rbncurs_m_new_fieldtype),
2);
- RB_CLASS_METH(cFIELDTYPE, free_fieldtype,0);
- RB_CLASS_METH(cFIELDTYPE, link_fieldtype,1);
- RB_CLASS_METH(cFIELDTYPE, set_fieldtype_choice,2);
+ RB_CLASS_METH(cFIELDTYPE, "free", free_fieldtype,0);
+ RB_CLASS_METH(cFIELDTYPE, "link", link_fieldtype,1);
+ RB_CLASS_METH(cFIELDTYPE, "set_choice", set_fieldtype_choice,2);
/* Create predefined types */
rb_define_const(mForm, "TYPE_ALNUM", wrap_fieldtype(TYPE_ALNUM));
rb_define_const(mForm, "TYPE_ALPHA", wrap_fieldtype(TYPE_ALPHA));
rb_define_const(mForm, "TYPE_ENUM", wrap_fieldtype(TYPE_ENUM));