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.
4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 |
# File 'ext/curses/curses.c', line 4052
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.
4175 4176 4177 4178 4179 4180 4181 4182 |
# File 'ext/curses/curses.c', line 4175
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.
4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 |
# File 'ext/curses/curses.c', line 4156
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.
4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 |
# File 'ext/curses/curses.c', line 4101
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
4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 |
# File 'ext/curses/curses.c', line 4311
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
4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 |
# File 'ext/curses/curses.c', line 4323
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.
4139 4140 4141 4142 4143 4144 4145 4146 |
# File 'ext/curses/curses.c', line 4139
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.
4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 |
# File 'ext/curses/curses.c', line 4120
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
4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 |
# File 'ext/curses/curses.c', line 4239
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
4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 |
# File 'ext/curses/curses.c', line 4275
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
4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 |
# File 'ext/curses/curses.c', line 4335
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
4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 |
# File 'ext/curses/curses.c', line 4347
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
4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 |
# File 'ext/curses/curses.c', line 4299
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
4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 |
# File 'ext/curses/curses.c', line 4287
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.
4230 4231 4232 4233 4234 4235 4236 4237 |
# File 'ext/curses/curses.c', line 4230
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.
4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 |
# File 'ext/curses/curses.c', line 4211
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.
4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 |
# File 'ext/curses/curses.c', line 4192
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.
4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 |
# File 'ext/curses/curses.c', line 4156
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.
4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 |
# File 'ext/curses/curses.c', line 4081
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.
4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 |
# File 'ext/curses/curses.c', line 4120
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
4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 |
# File 'ext/curses/curses.c', line 4347
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
4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 |
# File 'ext/curses/curses.c', line 4366
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
4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 |
# File 'ext/curses/curses.c', line 4263
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
4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 |
# File 'ext/curses/curses.c', line 4251
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);
}
|