Class: Curses::Form
- Inherits:
-
Data
- Object
- Data
- Curses::Form
- Defined in:
- ext/curses/curses.c
Instance Method Summary collapse
-
#driver(command) ⇒ Object
call-seq: driver(command).
-
#initialize(fields) ⇒ Object
constructor
call-seq: new(fields).
-
#post ⇒ Object
call-seq: post.
-
#scale ⇒ Object
call-seq: scale.
-
#set_sub(win) ⇒ Object
call-seq: set_sub=(win).
-
#set_win(win) ⇒ Object
call-seq: set_win=(win).
-
#unpost ⇒ Object
call-seq: unpost.
Constructor Details
#initialize(fields) ⇒ Object
call-seq:
new(fields)
Construct a new Curses::Form.
4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 |
# File 'ext/curses/curses.c', line 4224
static VALUE
form_initialize(VALUE obj, VALUE fields)
{
struct formdata *formp;
FIELD **form_fields;
int i;
Check_Type(fields, T_ARRAY);
curses_init_screen();
TypedData_Get_Struct(obj, struct formdata, &formdata_type, formp);
if (formp->form) {
rb_raise(rb_eRuntimeError, "already initialized form");
}
formp->fields = rb_ary_new();
form_fields = ALLOC_N(FIELD *, RARRAY_LEN(fields) + 1);
for (i = 0; i < RARRAY_LEN(fields); i++) {
VALUE field = RARRAY_AREF(fields, i);
struct fielddata *fieldp;
GetFIELD(field, fieldp);
form_fields[i] = fieldp->field;
rb_ary_push(formp->fields, field);
}
form_fields[RARRAY_LEN(fields)] = NULL;
formp->form = new_form(form_fields);
if (formp->form == NULL) {
check_curses_error(errno);
}
return obj;
}
|
Instance Method Details
#driver(command) ⇒ Object
call-seq:
driver(command)
Perform the command on the form.
4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 |
# File 'ext/curses/curses.c', line 4306
static VALUE
form_driver_m(VALUE obj, VALUE command)
{
struct formdata *formp;
int error, c;
GetFORM(obj, formp);
if (FIXNUM_P(command)) {
c = NUM2INT(command);
}
else {
ID id_ord;
StringValue(command);
CONST_ID(id_ord, "ord");
c = NUM2INT(rb_funcall(command, id_ord, 0));
}
#ifdef HAVE_FORM_DRIVER_W
error = form_driver_w(formp->form,
FIXNUM_P(command) ? KEY_CODE_YES : OK,
c);
#else
error = form_driver(formp->form, c);
#endif
check_curses_error(error);
return obj;
}
|
#post ⇒ Object
call-seq:
post
Post the form.
4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 |
# File 'ext/curses/curses.c', line 4264
static VALUE
form_post(VALUE obj)
{
struct formdata *formp;
int error;
GetFORM(obj, formp);
error = post_form(formp->form);
check_curses_error(error);
return obj;
}
|
#scale ⇒ Object
call-seq:
scale
Return the minimum rows and columns required for the subwindow of the form.
4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 |
# File 'ext/curses/curses.c', line 4383
static VALUE
form_scale(VALUE obj)
{
struct formdata *formp;
int error, rows, columns;
GetFORM(obj, formp);
error = scale_form(formp->form, &rows, &columns);
check_curses_error(error);
return rb_assoc_new(INT2NUM(rows), INT2NUM(columns));
}
|
#set_sub(win) ⇒ Object
call-seq:
set_sub=(win)
Set the subwindow of the form.
4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 |
# File 'ext/curses/curses.c', line 4363
static VALUE
form_set_sub(VALUE obj, VALUE win)
{
struct formdata *formp;
struct windata *winp;
GetFORM(obj, formp);
GetWINDOW(win, winp);
set_form_sub(formp->form, winp->window);
return win;
}
|
#set_win(win) ⇒ Object
call-seq:
set_win=(win)
Set the window of the form.
4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 |
# File 'ext/curses/curses.c', line 4343
static VALUE
form_set_win(VALUE obj, VALUE win)
{
struct formdata *formp;
struct windata *winp;
GetFORM(obj, formp);
GetWINDOW(win, winp);
set_form_win(formp->form, winp->window);
return win;
}
|
#unpost ⇒ Object
call-seq:
unpost
Unpost the form.
4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 |
# File 'ext/curses/curses.c', line 4285
static VALUE
form_unpost(VALUE obj)
{
struct formdata *formp;
int error;
GetFORM(obj, formp);
error = unpost_form(formp->form);
check_curses_error(error);
return obj;
}
|