class Curses::Item
Public Class Methods
new(name, description)
click to toggle source
Construct a new Curses::Item.
static VALUE
item_initialize(VALUE obj, VALUE name, VALUE description)
{
struct itemdata *itemp;
curses_init_screen(Qnil);
TypedData_Get_Struct(obj, struct itemdata, &itemdata_type, itemp);
if (itemp->item) {
rb_raise(rb_eRuntimeError, "already initialized item");
}
name = rb_str_export_to_enc(name, terminal_encoding);
description = rb_str_export_to_enc(description, terminal_encoding);
itemp->item = new_item(StringValueCStr(name),
StringValueCStr(description));
if (itemp->item == NULL) {
check_curses_error(errno);
}
return obj;
}
Public Instance Methods
==(p1)
click to toggle source
static VALUE
item_eq(VALUE obj, VALUE other)
{
struct itemdata *item1, *item2;
GetITEM(obj, item1);
GetITEM(other, item2);
return item1->item == item2->item ? Qtrue : Qfalse;
}
description()
click to toggle source
static VALUE
item_description_m(VALUE obj)
{
struct itemdata *itemp;
const char *desc;
GetITEM(obj, itemp);
desc = item_description(itemp->item);
return rb_external_str_new_with_enc(desc, strlen(desc), terminal_encoding);
}
name()
click to toggle source
static VALUE
item_name_m(VALUE obj)
{
struct itemdata *itemp;
const char *name;
GetITEM(obj, itemp);
name = item_name(itemp->item);
return rb_external_str_new_with_enc(name, strlen(name), terminal_encoding);
}
opts
click to toggle source
Get the current option bits of the item.
static VALUE
item_opts_m(VALUE obj, VALUE opts)
{
struct itemdata *itemp;
GetITEM(obj, itemp);
return INT2NUM(item_opts(itemp->item));
}
opts_off(opts)
click to toggle source
Turn off the option bits of the item.
static VALUE
item_opts_off_m(VALUE obj, VALUE opts)
{
struct itemdata *itemp;
int error;
GetITEM(obj, itemp);
error = item_opts_off(itemp->item, NUM2INT(opts));
check_curses_error(error);
return obj;
}
opts_on(opts)
click to toggle source
Turn on the option bits of the item.
static VALUE
item_opts_on_m(VALUE obj, VALUE opts)
{
struct itemdata *itemp;
int error;
GetITEM(obj, itemp);
error = item_opts_on(itemp->item, NUM2INT(opts));
check_curses_error(error);
return obj;
}
set_opts(opts)
click to toggle source
Set the option bits of the item.
static VALUE
item_set_opts(VALUE obj, VALUE opts)
{
struct itemdata *itemp;
int error;
GetITEM(obj, itemp);
error = set_item_opts(itemp->item, NUM2INT(opts));
check_curses_error(error);
return obj;
}