Class: Curses::Item
- Inherits:
-
Data
- Object
- Data
- Curses::Item
- Defined in:
- ext/curses/curses.c
Instance Method Summary collapse
- #==(other) ⇒ Object
- #description ⇒ Object
-
#initialize(name, description) ⇒ Object
constructor
call-seq: new(name, description).
- #name ⇒ Object
-
#opts(opts) ⇒ Object
call-seq: opts.
-
#opts_off(opts) ⇒ Object
call-seq: opts_off(opts).
-
#opts_on(opts) ⇒ Object
call-seq: opts_on(opts).
-
#set_opts(opts) ⇒ Object
call-seq: set_opts(opts).
Constructor Details
#initialize(name, description) ⇒ Object
call-seq:
new(name, description)
Construct a new Curses::Item.
3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 |
# File 'ext/curses/curses.c', line 3092
static VALUE
item_initialize(VALUE obj, VALUE name, VALUE description)
{
struct itemdata *itemp;
curses_init_screen();
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;
}
|
Instance Method Details
#==(other) ⇒ Object
3124 3125 3126 3127 3128 3129 3130 3131 3132 |
# File 'ext/curses/curses.c', line 3124
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 ⇒ Object
3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 |
# File 'ext/curses/curses.c', line 3145
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 ⇒ Object
3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 |
# File 'ext/curses/curses.c', line 3134
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(opts) ⇒ Object
call-seq:
opts
Get the current option bits of the item.
3224 3225 3226 3227 3228 3229 3230 3231 |
# File 'ext/curses/curses.c', line 3224
static VALUE
item_opts_m(VALUE obj, VALUE opts)
{
struct itemdata *itemp;
GetITEM(obj, itemp);
return INT2NUM(item_opts(itemp->item));
}
|
#opts_off(opts) ⇒ Object
call-seq:
opts_off(opts)
Turn off the option bits of the item.
3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 |
# File 'ext/curses/curses.c', line 3204
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) ⇒ Object
call-seq:
opts_on(opts)
Turn on the option bits of the item.
3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 |
# File 'ext/curses/curses.c', line 3184
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) ⇒ Object
call-seq:
set_opts(opts)
Set the option bits of the item.
3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 |
# File 'ext/curses/curses.c', line 3164
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;
}
|