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.



3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
# File 'ext/curses/curses.c', line 3122

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



3154
3155
3156
3157
3158
3159
3160
3161
3162
# File 'ext/curses/curses.c', line 3154

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



3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
# File 'ext/curses/curses.c', line 3175

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



3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
# File 'ext/curses/curses.c', line 3164

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

#optsObject

call-seq:

opts

Get the current option bits of the item.



3254
3255
3256
3257
3258
3259
3260
3261
# File 'ext/curses/curses.c', line 3254

static VALUE
item_opts_m(VALUE obj)
{
    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.



3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
# File 'ext/curses/curses.c', line 3234

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.



3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
# File 'ext/curses/curses.c', line 3214

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.



3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
# File 'ext/curses/curses.c', line 3194

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