Class: Curses::Item

Inherits:
Object
  • Object
show all
Defined in:
ext/curses/curses.c

Instance Method Summary collapse

Constructor Details

#initialize(name, description) ⇒ Object

call-seq:

new(name, description)

Construct a new Curses::Item.


3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
# File 'ext/curses/curses.c', line 3108

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;
}

Instance Method Details

#==(other) ⇒ Object


3140
3141
3142
3143
3144
3145
3146
3147
3148
# File 'ext/curses/curses.c', line 3140

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;
}

#descriptionObject


3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
# File 'ext/curses/curses.c', line 3161

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);
}

#nameObject


3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
# File 'ext/curses/curses.c', line 3150

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.


3240
3241
3242
3243
3244
3245
3246
3247
# File 'ext/curses/curses.c', line 3240

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.


3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
# File 'ext/curses/curses.c', line 3220

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.


3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
# File 'ext/curses/curses.c', line 3200

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.


3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
# File 'ext/curses/curses.c', line 3180

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;
}