Class: Curses::Form
- Inherits:
-
Object
- Object
- 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.
4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 |
# File 'ext/curses/curses.c', line 4641 static VALUE form_initialize(VALUE obj, VALUE fields) { struct formdata *formp; FIELD **form_fields; int i; Check_Type(fields, T_ARRAY); curses_init_screen(Qnil); 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.
4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 |
# File 'ext/curses/curses.c', line 4723 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.
4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 |
# File 'ext/curses/curses.c', line 4681 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.
4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 |
# File 'ext/curses/curses.c', line 4800 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.
4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 |
# File 'ext/curses/curses.c', line 4780 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.
4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 |
# File 'ext/curses/curses.c', line 4760 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.
4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 |
# File 'ext/curses/curses.c', line 4702 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; } |