Class: Curses::Field
- Inherits:
-
Object
- Object
- Curses::Field
- Defined in:
- ext/curses/curses.c
Instance Method Summary collapse
-
#back ⇒ Object
call-seq: back.
-
#back=(attr) ⇒ Object
call-seq: set_back(attr).
-
#buffer(buf) ⇒ Object
call-seq: buffer(buf).
- #dynamic_height ⇒ Object
- #dynamic_width ⇒ Object
-
#fore ⇒ Object
call-seq: fore.
-
#fore=(attr) ⇒ Object
call-seq: set_fore(attr).
- #height ⇒ Object
-
#initialize(height, width, toprow, leftcol, offscreen, nbuffers) ⇒ Object
constructor
call-seq: new(height, width, toprow, leftcol, offscreen, nbuffers).
- #leftcol ⇒ Object
- #max ⇒ Object
- #max=(max) ⇒ Object
- #nbuffers ⇒ Object
- #offscreen ⇒ Object
-
#opts ⇒ Object
call-seq: opts.
-
#opts_off(opts) ⇒ Object
call-seq: opts_off(opts).
-
#opts_on(opts) ⇒ Object
call-seq: opts_on(opts).
-
#set_back(attr) ⇒ Object
call-seq: set_back(attr).
-
#set_buffer(buf, value) ⇒ Object
call-seq: set_buffer(buf, value).
-
#set_fore(attr) ⇒ Object
call-seq: set_fore(attr).
- #set_max(max) ⇒ Object
- #set_type(*args) ⇒ Object
- #toprow ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(height, width, toprow, leftcol, offscreen, nbuffers) ⇒ Object
call-seq:
new(height, width, toprow, leftcol, offscreen, nbuffers)
Construct a new Curses::Field.
4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 |
# File 'ext/curses/curses.c', line 4185 static VALUE field_initialize(VALUE obj, VALUE height, VALUE width, VALUE toprow, VALUE leftcol, VALUE offscreen, VALUE nbuffers) { struct fielddata *fieldp; curses_init_screen(Qnil); TypedData_Get_Struct(obj, struct fielddata, &fielddata_type, fieldp); if (fieldp->field) { rb_raise(rb_eRuntimeError, "already initialized field"); } fieldp->field = new_field(NUM2INT(height), NUM2INT(width), NUM2INT(toprow), NUM2INT(leftcol), NUM2INT(offscreen), NUM2INT(nbuffers)); if (fieldp->field == NULL) { check_curses_error(errno); } return obj; } |
Instance Method Details
#back ⇒ Object
call-seq:
back
Get the background attribute of the field.
4308 4309 4310 4311 4312 4313 4314 4315 |
# File 'ext/curses/curses.c', line 4308 static VALUE field_get_back(VALUE obj) { struct fielddata *fieldp; GetFIELD(obj, fieldp); return CHTYPE2NUM(field_back(fieldp->field)); } |
#back=(attr) ⇒ Object
call-seq:
set_back(attr)
Set the background attribute of the field.
4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 |
# File 'ext/curses/curses.c', line 4289 static VALUE field_set_back(VALUE obj, VALUE attr) { struct fielddata *fieldp; GetFIELD(obj, fieldp); set_field_back(fieldp->field, NUM2CHTYPE(attr)); return attr; } |
#buffer(buf) ⇒ Object
call-seq:
buffer(buf)
Get the numbered buffer of the field.
4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 |
# File 'ext/curses/curses.c', line 4234 static VALUE field_buffer_m(VALUE obj, VALUE buf) { struct fielddata *fieldp; char *s; GetFIELD(obj, fieldp); s = field_buffer(fieldp->field, NUM2INT(buf)); return rb_external_str_new_with_enc(s, strlen(s), terminal_encoding); } |
#dynamic_height ⇒ Object
4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 |
# File 'ext/curses/curses.c', line 4444 static VALUE field_dynamic_height(VALUE obj) { struct fielddata *fieldp; int error, val; GetFIELD(obj, fieldp); error = dynamic_field_info(fieldp->field, &val, NULL, NULL); check_curses_error(error); return INT2NUM(val); } |
#dynamic_width ⇒ Object
4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 |
# File 'ext/curses/curses.c', line 4456 static VALUE field_dynamic_width(VALUE obj) { struct fielddata *fieldp; int error, val; GetFIELD(obj, fieldp); error = dynamic_field_info(fieldp->field, NULL, &val, NULL); check_curses_error(error); return INT2NUM(val); } |
#fore ⇒ Object
call-seq:
fore
Get the foreground attribute of the field.
4272 4273 4274 4275 4276 4277 4278 4279 |
# File 'ext/curses/curses.c', line 4272 static VALUE field_get_fore(VALUE obj) { struct fielddata *fieldp; GetFIELD(obj, fieldp); return CHTYPE2NUM(field_fore(fieldp->field)); } |
#fore=(attr) ⇒ Object
call-seq:
set_fore(attr)
Set the foreground attribute of the field.
4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 |
# File 'ext/curses/curses.c', line 4253 static VALUE field_set_fore(VALUE obj, VALUE attr) { struct fielddata *fieldp; GetFIELD(obj, fieldp); set_field_fore(fieldp->field, NUM2CHTYPE(attr)); return attr; } |
#height ⇒ Object
4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 |
# File 'ext/curses/curses.c', line 4372 static VALUE field_height(VALUE obj) { struct fielddata *fieldp; int error, val; GetFIELD(obj, fieldp); error = field_info(fieldp->field, &val, NULL, NULL, NULL, NULL, NULL); check_curses_error(error); return INT2NUM(val); } |
#leftcol ⇒ Object
4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 |
# File 'ext/curses/curses.c', line 4408 static VALUE field_leftcol(VALUE obj) { struct fielddata *fieldp; int error, val; GetFIELD(obj, fieldp); error = field_info(fieldp->field, NULL, NULL, NULL, &val, NULL, NULL); check_curses_error(error); return INT2NUM(val); } |
#max ⇒ Object
4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 |
# File 'ext/curses/curses.c', line 4468 static VALUE field_max(VALUE obj) { struct fielddata *fieldp; int error, val; GetFIELD(obj, fieldp); error = dynamic_field_info(fieldp->field, NULL, NULL, &val); check_curses_error(error); return INT2NUM(val); } |
#max=(max) ⇒ Object
4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 |
# File 'ext/curses/curses.c', line 4480 static VALUE field_set_max(VALUE obj, VALUE max) { struct fielddata *fieldp; int error; GetFIELD(obj, fieldp); error = set_max_field(fieldp->field, NUM2INT(max)); check_curses_error(error); return max; } |
#nbuffers ⇒ Object
4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 |
# File 'ext/curses/curses.c', line 4432 static VALUE field_nbuffers(VALUE obj) { struct fielddata *fieldp; int error, val; GetFIELD(obj, fieldp); error = field_info(fieldp->field, NULL, NULL, NULL, NULL, NULL, &val); check_curses_error(error); return INT2NUM(val); } |
#offscreen ⇒ Object
4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 |
# File 'ext/curses/curses.c', line 4420 static VALUE field_offscreen(VALUE obj) { struct fielddata *fieldp; int error, val; GetFIELD(obj, fieldp); error = field_info(fieldp->field, NULL, NULL, NULL, NULL, &val, NULL); check_curses_error(error); return INT2NUM(val); } |
#opts ⇒ Object
call-seq:
opts
Get the current option bits.
4363 4364 4365 4366 4367 4368 4369 4370 |
# File 'ext/curses/curses.c', line 4363 static VALUE field_opts_m(VALUE obj) { struct fielddata *fieldp; GetFIELD(obj, fieldp); return INT2NUM(field_opts(fieldp->field)); } |
#opts_off(opts) ⇒ Object
call-seq:
opts_off(opts)
Turn off the given option bits.
4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 |
# File 'ext/curses/curses.c', line 4344 static VALUE field_opts_off_m(VALUE obj, VALUE opts) { struct fielddata *fieldp; GetFIELD(obj, fieldp); field_opts_off(fieldp->field, NUM2INT(opts)); return opts; } |
#opts_on(opts) ⇒ Object
call-seq:
opts_on(opts)
Turn on the given option bits.
4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 |
# File 'ext/curses/curses.c', line 4325 static VALUE field_opts_on_m(VALUE obj, VALUE opts) { struct fielddata *fieldp; GetFIELD(obj, fieldp); field_opts_on(fieldp->field, NUM2INT(opts)); return opts; } |
#set_back(attr) ⇒ Object
call-seq:
set_back(attr)
Set the background attribute of the field.
4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 |
# File 'ext/curses/curses.c', line 4289 static VALUE field_set_back(VALUE obj, VALUE attr) { struct fielddata *fieldp; GetFIELD(obj, fieldp); set_field_back(fieldp->field, NUM2CHTYPE(attr)); return attr; } |
#set_buffer(buf, value) ⇒ Object
call-seq:
set_buffer(buf, value)
Set the numbered buffer of the field.
4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 |
# File 'ext/curses/curses.c', line 4214 static VALUE field_set_buffer(VALUE obj, VALUE buf, VALUE value) { struct fielddata *fieldp; GetFIELD(obj, fieldp); value = rb_str_export_to_enc(value, terminal_encoding); set_field_buffer(fieldp->field, NUM2INT(buf), StringValueCStr(value)); return obj; } |
#set_fore(attr) ⇒ Object
call-seq:
set_fore(attr)
Set the foreground attribute of the field.
4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 |
# File 'ext/curses/curses.c', line 4253 static VALUE field_set_fore(VALUE obj, VALUE attr) { struct fielddata *fieldp; GetFIELD(obj, fieldp); set_field_fore(fieldp->field, NUM2CHTYPE(attr)); return attr; } |
#set_max(max) ⇒ Object
4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 |
# File 'ext/curses/curses.c', line 4480 static VALUE field_set_max(VALUE obj, VALUE max) { struct fielddata *fieldp; int error; GetFIELD(obj, fieldp); error = set_max_field(fieldp->field, NUM2INT(max)); check_curses_error(error); return max; } |
#set_type(*args) ⇒ Object
4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 |
# File 'ext/curses/curses.c', line 4499 static VALUE field_set_type(int argc, VALUE *argv, VALUE obj) { struct fielddata *fieldp; VALUE type; int type_code; int error; if (argc < 1) { rb_raise(rb_eArgError, "wrong number of arguments (given %d, expected 1)", argc); } type_code = NUM2INT(argv[0]); GetFIELD(obj, fieldp); switch (type_code) { case TYPE_CODE_ALPHA: { VALUE width; rb_scan_args(argc, argv, "11", &type, &width); error = set_field_type(fieldp->field, TYPE_ALPHA, NIL_P(width) ? 0 : NUM2INT(width)); } break; case TYPE_CODE_ALNUM: { VALUE width; rb_scan_args(argc, argv, "11", &type, &width); error = set_field_type(fieldp->field, TYPE_ALNUM, NIL_P(width) ? 0 : NUM2INT(width)); } break; #if 0 case TYPE_CODE_ENUM: { /* TODO: consider how valuelist should be allocated? */ } break; #endif case TYPE_CODE_INTEGER: { VALUE padding, vmin, vmax; rb_scan_args(argc, argv, "13", &type, &padding, &vmin, &vmax); error = set_field_type(fieldp->field, TYPE_INTEGER, NIL_P(padding) ? 0 : NUM2INT(padding), NIL_P(vmin) ? INT_MIN : NUM2INT(vmin), NIL_P(vmax) ? INT_MAX : NUM2INT(vmax)); } break; case TYPE_CODE_NUMERIC: { VALUE padding, vmin, vmax; rb_scan_args(argc, argv, "13", &type, &padding, &vmin, &vmax); error = set_field_type(fieldp->field, TYPE_INTEGER, NIL_P(padding) ? 0 : NUM2INT(padding), NIL_P(vmin) ? INT_MIN : NUM2INT(vmin), NIL_P(vmax) ? INT_MAX : NUM2INT(vmax)); } break; #if 0 case TYPE_CODE_REGEXP: { /* TODO: consider how regexp should be allocated? */ } break; #endif default: rb_raise(rb_eArgError, "unknwon type: %d", type_code); break; } check_curses_error(error); return obj; } |
#toprow ⇒ Object
4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 |
# File 'ext/curses/curses.c', line 4396 static VALUE field_toprow(VALUE obj) { struct fielddata *fieldp; int error, val; GetFIELD(obj, fieldp); error = field_info(fieldp->field, NULL, NULL, &val, NULL, NULL, NULL); check_curses_error(error); return INT2NUM(val); } |
#width ⇒ Object
4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 |
# File 'ext/curses/curses.c', line 4384 static VALUE field_width(VALUE obj) { struct fielddata *fieldp; int error, val; GetFIELD(obj, fieldp); error = field_info(fieldp->field, NULL, &val, NULL, NULL, NULL, NULL); check_curses_error(error); return INT2NUM(val); } |