Class: Curses::Item

Inherits:
Data
  • 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.



3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
# File 'ext/curses/curses.c', line 3088

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



3120
3121
3122
3123
3124
3125
3126
3127
3128
# File 'ext/curses/curses.c', line 3120

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



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

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



3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
# File 'ext/curses/curses.c', line 3130

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.



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

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.



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

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.



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

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.



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

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