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.



3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
# File 'ext/curses/curses.c', line 3402

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



3434
3435
3436
3437
3438
3439
3440
3441
3442
# File 'ext/curses/curses.c', line 3434

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



3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
# File 'ext/curses/curses.c', line 3455

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



3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
# File 'ext/curses/curses.c', line 3444

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.



3534
3535
3536
3537
3538
3539
3540
3541
# File 'ext/curses/curses.c', line 3534

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.



3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
# File 'ext/curses/curses.c', line 3514

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.



3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
# File 'ext/curses/curses.c', line 3494

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.



3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
# File 'ext/curses/curses.c', line 3474

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