rubysl-curses 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 479a6a30a2387c020f20b86d3ca3fe635447671b
4
- data.tar.gz: 832e85d87af5bb831b49a3e4ab497fcddf5598df
5
- SHA512:
6
- metadata.gz: ca116304af1d590e23b831b0c921e636c7f1c123de46d89ea673ba20ee147827a608606fb2d07b8248a1c9177fcdca901a655781bb533fc9d7239edd7cd575d9
7
- data.tar.gz: 991b9a2cb5a29ebf9fc53a626acfdfdf739a1b6ee003a5cd40687f5ae84546817be7e029878e2264af09fdad3fec0b57a2a1436dfaa32054fe454141a85c9af8
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Yjg5YjE1NTI2ZDJkOGIzM2MxMWQwMjEyNjQ3YTlkZGM2NGM2MjUzMA==
5
+ data.tar.gz: !binary |-
6
+ ODM3MDExYTA2ZDkzZjRlNDhkOGIwY2EwYjM0ZTBkNmViN2M0NTBkYw==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ OTI2ZGQyY2I1ZjI0NjAyZmE5ZmNjZDU2MzUxNjU4NTM0ZmUyODE2YzgyNjFi
10
+ ODU1ZDUzOWM1OGJlOTE0YmQwYTU5ZjY5OWQ1YTFlZmNiODE5YzlkYTMxNTgx
11
+ Nzk5OTQ5ODliMjM5YjE2YmY0N2RjZjk3OWMxYzZmMDRlZTAzMGM=
12
+ data.tar.gz: !binary |-
13
+ MTk0MmZhYzAwZDhlM2ExMTBmYmNlYTRiMzA2ODBhNWI1OGRhMzRiMzIxZjRl
14
+ MGMyYjE2OGY2NzlkZDlhOWY0NWI1NTU0NzZiMmU2OGM4ZmRjYjUzMGFkMzNj
15
+ MGY4YmFkZTRjNzkzYzA0YzUyZDM5NjY3ZDkwZTU1NzhkMjgwMzk=
data/.gitignore CHANGED
@@ -15,4 +15,3 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
- .rbx
data/.travis.yml CHANGED
@@ -1,8 +1,7 @@
1
1
  language: ruby
2
- before_install:
3
- - gem update --system
4
- - gem --version
5
- - gem install rubysl-bundler
6
- script: bundle exec mspec spec
2
+ env:
3
+ - RUBYLIB=lib
4
+ script: bundle exec mspec
7
5
  rvm:
8
- - rbx-nightly-18mode
6
+ - 1.9.3
7
+ - rbx-nightly-19mode
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # RubySL::Curses
1
+ # Rubysl::Curses
2
2
 
3
3
  TODO: Write a gem description
4
4
 
@@ -24,6 +24,6 @@ TODO: Write usage instructions here
24
24
 
25
25
  1. Fork it
26
26
  2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Added some feature'`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
28
  4. Push to the branch (`git push origin my-new-feature`)
29
29
  5. Create new Pull Request
data/Rakefile CHANGED
@@ -1,2 +1 @@
1
- #!/usr/bin/env rake
2
1
  require "bundler/gem_tasks"
@@ -1,8 +1,8 @@
1
1
  /* -*- C -*-
2
- * $Id: curses.c 25899 2009-11-24 07:02:04Z shyouhei $
2
+ * $Id: curses.c 42241 2013-07-29 13:25:46Z zzak $
3
3
  *
4
4
  * ext/curses/curses.c
5
- *
5
+ *
6
6
  * by MAEDA Shugo (ender@pic-internet.or.jp)
7
7
  * modified by Yukihiro Matsumoto (matz@netlab.co.jp),
8
8
  * Toki Yoshinori,
@@ -11,10 +11,14 @@
11
11
  *
12
12
  * maintainers:
13
13
  * - Takaaki Tateishi (ttate@kt.jaist.ac.jp)
14
+ *
15
+ * documentation:
16
+ * - Vincent Batts (vbatts@hashbangbash.com)
14
17
  */
15
18
 
16
19
  #include "ruby.h"
17
- #include "rubyio.h"
20
+ #include "ruby/io.h"
21
+ #include "ruby/thread.h"
18
22
 
19
23
  #if defined(HAVE_NCURSES_H)
20
24
  # include <ncurses.h>
@@ -54,12 +58,13 @@
54
58
  # define USE_MOUSE 1
55
59
  #endif
56
60
 
57
- #define NUM2CH NUM2LONG
58
- #define CH2FIX LONG2FIX
61
+ #define NUM2CH NUM2CHR
62
+ #define CH2FIX CHR2FIX
59
63
 
60
64
  static VALUE mCurses;
61
65
  static VALUE mKey;
62
66
  static VALUE cWindow;
67
+ static VALUE cPad;
63
68
  #ifdef USE_MOUSE
64
69
  static VALUE cMouseEvent;
65
70
  #endif
@@ -70,14 +75,12 @@ struct windata {
70
75
  WINDOW *window;
71
76
  };
72
77
 
73
- #define CHECK(c) c
74
-
75
- static VALUE window_attroff();
76
- static VALUE window_attron();
77
- static VALUE window_attrset();
78
+ static VALUE window_attroff(VALUE obj, VALUE attrs);
79
+ static VALUE window_attron(VALUE obj, VALUE attrs);
80
+ static VALUE window_attrset(VALUE obj, VALUE attrs);
78
81
 
79
82
  static void
80
- no_window()
83
+ no_window(void)
81
84
  {
82
85
  rb_raise(rb_eRuntimeError, "already closed window");
83
86
  }
@@ -85,23 +88,36 @@ no_window()
85
88
  #define GetWINDOW(obj, winp) do {\
86
89
  if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4)\
87
90
  rb_raise(rb_eSecurityError, "Insecure: operation on untainted window");\
88
- Data_Get_Struct(obj, struct windata, winp);\
89
- if (winp->window == 0) no_window();\
91
+ TypedData_Get_Struct((obj), struct windata, &windata_type, (winp));\
92
+ if ((winp)->window == 0) no_window();\
90
93
  } while (0)
91
94
 
92
95
  static void
93
- free_window(winp)
94
- struct windata *winp;
96
+ window_free(void *p)
95
97
  {
98
+ struct windata *winp = p;
96
99
  if (winp->window && winp->window != stdscr) delwin(winp->window);
97
100
  winp->window = 0;
98
- free(winp);
101
+ xfree(winp);
99
102
  }
100
103
 
104
+ static size_t
105
+ window_memsize(const void *p)
106
+ {
107
+ const struct windata *winp = p;
108
+ size_t size = sizeof(*winp);
109
+ if (!winp) return 0;
110
+ if (winp->window && winp->window != stdscr) size += sizeof(winp->window);
111
+ return size;
112
+ }
113
+
114
+ static const rb_data_type_t windata_type = {
115
+ "windata",
116
+ {0, window_free, window_memsize,}
117
+ };
118
+
101
119
  static VALUE
102
- prep_window(class, window)
103
- VALUE class;
104
- WINDOW *window;
120
+ prep_window(VALUE class, WINDOW *window)
105
121
  {
106
122
  VALUE obj;
107
123
  struct windata *winp;
@@ -111,19 +127,24 @@ prep_window(class, window)
111
127
  }
112
128
 
113
129
  obj = rb_obj_alloc(class);
114
- Data_Get_Struct(obj, struct windata, winp);
130
+ TypedData_Get_Struct(obj, struct windata, &windata_type, winp);
115
131
  winp->window = window;
116
-
117
- return obj;
132
+
133
+ return obj;
118
134
  }
119
135
 
120
136
  /*-------------------------- module Curses --------------------------*/
121
137
 
122
- /* def init_screen */
138
+ /*
139
+ * Document-method: Curses.init_screen
140
+ *
141
+ * Initialize a standard screen
142
+ *
143
+ * see also Curses.stdscr
144
+ */
123
145
  static VALUE
124
- curses_init_screen()
146
+ curses_init_screen(void)
125
147
  {
126
- rb_secure(4);
127
148
  if (rb_stdscr) return rb_stdscr;
128
149
  initscr();
129
150
  if (stdscr == 0) {
@@ -134,12 +155,33 @@ curses_init_screen()
134
155
  return rb_stdscr;
135
156
  }
136
157
 
137
- /* def stdscr */
158
+ /*
159
+ * Document-method: Curses.stdscr
160
+ *
161
+ * The Standard Screen.
162
+ *
163
+ * Upon initializing curses, a default window called stdscr,
164
+ * which is the size of the terminal screen, is created.
165
+ *
166
+ * Many curses functions use this window.
167
+ */
138
168
  #define curses_stdscr curses_init_screen
139
169
 
140
- /* def close_screen */
170
+ /*
171
+ * Document-method: Curses.close_screen
172
+ *
173
+ * A program should always call Curses.close_screen before exiting or
174
+ * escaping from curses mode temporarily. This routine
175
+ * restores tty modes, moves the cursor to the lower
176
+ * left-hand corner of the screen and resets the terminal
177
+ * into the proper non-visual mode.
178
+ *
179
+ * Calling Curses.refresh or Curses.doupdate after a temporary
180
+ * escape causes the program to resume visual mode.
181
+ *
182
+ */
141
183
  static VALUE
142
- curses_close_screen()
184
+ curses_close_screen(void)
143
185
  {
144
186
  curses_stdscr();
145
187
  #ifdef HAVE_ISENDWIN
@@ -150,6 +192,13 @@ curses_close_screen()
150
192
  return Qnil;
151
193
  }
152
194
 
195
+ /*
196
+ * This is no runtime method,
197
+ * but a function called before the proc ends
198
+ *
199
+ * Similar to Curses.close_screen, except that it also
200
+ * garbage collects/unregisters the Curses.stdscr
201
+ */
153
202
  static void
154
203
  curses_finalize(VALUE dummy)
155
204
  {
@@ -163,54 +212,79 @@ curses_finalize(VALUE dummy)
163
212
  rb_gc_unregister_address(&rb_stdscr);
164
213
  }
165
214
 
166
- /* def closed? */
215
+ #ifdef HAVE_ISENDWIN
216
+ /*
217
+ * Document-method: Curses.closed?
218
+ *
219
+ * Returns +true+ if the window/screen has been closed,
220
+ * without any subsequent Curses.refresh calls,
221
+ * returns +false+ otherwise.
222
+ */
167
223
  static VALUE
168
- curses_closed()
224
+ curses_closed(void)
169
225
  {
170
- #ifdef HAVE_ISENDWIN
171
226
  curses_stdscr();
172
227
  if (isendwin()) {
173
228
  return Qtrue;
174
229
  }
175
230
  return Qfalse;
231
+ }
176
232
  #else
177
- rb_notimplement();
233
+ #define curses_closed rb_f_notimplement
178
234
  #endif
179
- }
180
235
 
181
- /* def clear */
236
+ /*
237
+ * Document-method: Curses.clear
238
+ *
239
+ * Clears every position on the screen completely,
240
+ * so that a subsequent call by Curses.refresh for the screen/window
241
+ * will be repainted from scratch.
242
+ */
182
243
  static VALUE
183
- curses_clear(obj)
184
- VALUE obj;
244
+ curses_clear(VALUE obj)
185
245
  {
186
246
  curses_stdscr();
187
247
  wclear(stdscr);
188
248
  return Qnil;
189
249
  }
190
250
 
191
- /* def clrtoeol */
251
+ /*
252
+ * Document-method: Curses.clrtoeol
253
+ *
254
+ * Clears to the end of line, that the cursor is currently on.
255
+ */
192
256
  static VALUE
193
- curses_clrtoeol()
257
+ curses_clrtoeol(void)
194
258
  {
195
259
  curses_stdscr();
196
260
  clrtoeol();
197
261
  return Qnil;
198
262
  }
199
263
 
200
- /* def refresh */
264
+ /*
265
+ * Document-method: Curses.refresh
266
+ *
267
+ * Refreshes the windows and lines.
268
+ *
269
+ */
201
270
  static VALUE
202
- curses_refresh(obj)
203
- VALUE obj;
271
+ curses_refresh(VALUE obj)
204
272
  {
205
273
  curses_stdscr();
206
274
  refresh();
207
275
  return Qnil;
208
276
  }
209
277
 
210
- /* def doupdate */
278
+ /*
279
+ * Document-method: Curses.doupdate
280
+ *
281
+ * Refreshes the windows and lines.
282
+ *
283
+ * Curses.doupdate allows multiple updates with
284
+ * more efficiency than Curses.refresh alone.
285
+ */
211
286
  static VALUE
212
- curses_doupdate(obj)
213
- VALUE obj;
287
+ curses_doupdate(VALUE obj)
214
288
  {
215
289
  curses_stdscr();
216
290
  #ifdef HAVE_DOUPDATE
@@ -221,90 +295,164 @@ curses_doupdate(obj)
221
295
  return Qnil;
222
296
  }
223
297
 
224
- /* def echo */
298
+ /*
299
+ * Document-method: Curses.echo
300
+ *
301
+ * Enables characters typed by the user
302
+ * to be echoed by Curses.getch as they are typed.
303
+ */
225
304
  static VALUE
226
- curses_echo(obj)
227
- VALUE obj;
305
+ curses_echo(VALUE obj)
228
306
  {
229
307
  curses_stdscr();
230
308
  echo();
231
309
  return Qnil;
232
310
  }
233
311
 
234
- /* def noecho */
312
+ /*
313
+ * Document-method: Curses.noecho
314
+ *
315
+ * Disables characters typed by the user
316
+ * to be echoed by Curses.getch as they are typed.
317
+ */
235
318
  static VALUE
236
- curses_noecho(obj)
237
- VALUE obj;
319
+ curses_noecho(VALUE obj)
238
320
  {
239
321
  curses_stdscr();
240
322
  noecho();
241
323
  return Qnil;
242
324
  }
243
325
 
244
- /* def raw */
326
+ /*
327
+ * Document-method: Curses.raw
328
+ *
329
+ * Put the terminal into raw mode.
330
+ *
331
+ * Raw mode is similar to Curses.cbreak mode, in that characters typed
332
+ * are immediately passed through to the user program.
333
+ *
334
+ * The differences are that in raw mode, the interrupt, quit,
335
+ * suspend, and flow control characters are all passed through
336
+ * uninterpreted, instead of generating a signal. The behavior
337
+ * of the BREAK key depends on other bits in the tty driver
338
+ * that are not set by curses.
339
+ */
245
340
  static VALUE
246
- curses_raw(obj)
247
- VALUE obj;
341
+ curses_raw(VALUE obj)
248
342
  {
249
343
  curses_stdscr();
250
344
  raw();
251
345
  return Qnil;
252
346
  }
253
347
 
254
- /* def noraw */
348
+ /*
349
+ * Document-method: Curses.noraw
350
+ *
351
+ * Put the terminal out of raw mode.
352
+ *
353
+ * see Curses.raw for more detail
354
+ */
255
355
  static VALUE
256
- curses_noraw(obj)
257
- VALUE obj;
356
+ curses_noraw(VALUE obj)
258
357
  {
259
358
  curses_stdscr();
260
359
  noraw();
261
360
  return Qnil;
262
361
  }
263
362
 
264
- /* def cbreak */
363
+ /*
364
+ * Document-method: Curses.cbreak
365
+ *
366
+ * Put the terminal into cbreak mode.
367
+ *
368
+ * Normally, the tty driver buffers typed characters until
369
+ * a newline or carriage return is typed. The Curses.cbreak
370
+ * routine disables line buffering and erase/kill
371
+ * character-processing (interrupt and flow control characters
372
+ * are unaffected), making characters typed by the user
373
+ * immediately available to the program.
374
+ *
375
+ * The Curses.nocbreak routine returns the terminal to normal (cooked) mode.
376
+ *
377
+ * Initially the terminal may or may not be in cbreak mode,
378
+ * as the mode is inherited; therefore, a program should
379
+ * call Curses.cbreak or Curses.nocbreak explicitly.
380
+ * Most interactive programs using curses set the cbreak mode.
381
+ * Note that Curses.cbreak overrides Curses.raw.
382
+ *
383
+ * see also Curses.raw
384
+ */
265
385
  static VALUE
266
- curses_cbreak(obj)
267
- VALUE obj;
386
+ curses_cbreak(VALUE obj)
268
387
  {
269
388
  curses_stdscr();
270
389
  cbreak();
271
390
  return Qnil;
272
391
  }
273
392
 
274
- /* def nocbreak */
393
+ /*
394
+ * Document-method: Curses.nocbreak
395
+ *
396
+ * Put the terminal into normal mode (out of cbreak mode).
397
+ *
398
+ * See Curses.cbreak for more detail.
399
+ */
275
400
  static VALUE
276
- curses_nocbreak(obj)
277
- VALUE obj;
401
+ curses_nocbreak(VALUE obj)
278
402
  {
279
403
  curses_stdscr();
280
404
  nocbreak();
281
405
  return Qnil;
282
406
  }
283
407
 
284
- /* def nl */
408
+ /*
409
+ * Document-method: Curses.nl
410
+ *
411
+ * Enable the underlying display device to translate
412
+ * the return key into newline on input, and whether it
413
+ * translates newline into return and line-feed on output
414
+ * (in either case, the call Curses.addch('\n') does the
415
+ * equivalent of return and line feed on the virtual screen).
416
+ *
417
+ * Initially, these translations do occur. If you disable
418
+ * them using Curses.nonl, curses will be able to make better use
419
+ * of the line-feed capability, resulting in faster cursor
420
+ * motion. Also, curses will then be able to detect the return key.
421
+ */
285
422
  static VALUE
286
- curses_nl(obj)
287
- VALUE obj;
423
+ curses_nl(VALUE obj)
288
424
  {
289
425
  curses_stdscr();
290
426
  nl();
291
427
  return Qnil;
292
428
  }
293
429
 
294
- /* def nonl */
430
+ /*
431
+ * Document-method: Curses.nl
432
+ *
433
+ * Disable the underlying display device to translate
434
+ * the return key into newline on input
435
+ *
436
+ * See Curses.nl for more detail
437
+ */
295
438
  static VALUE
296
- curses_nonl(obj)
297
- VALUE obj;
439
+ curses_nonl(VALUE obj)
298
440
  {
299
441
  curses_stdscr();
300
442
  nonl();
301
443
  return Qnil;
302
444
  }
303
445
 
304
- /* def beep */
446
+ /*
447
+ * Document-method: Curses.beep
448
+ *
449
+ * Sounds an audible alarm on the terminal, if possible;
450
+ * otherwise it flashes the screen (visual bell).
451
+ *
452
+ * see also Curses.flash
453
+ */
305
454
  static VALUE
306
- curses_beep(obj)
307
- VALUE obj;
455
+ curses_beep(VALUE obj)
308
456
  {
309
457
  #ifdef HAVE_BEEP
310
458
  curses_stdscr();
@@ -313,10 +461,16 @@ curses_beep(obj)
313
461
  return Qnil;
314
462
  }
315
463
 
316
- /* def flash */
464
+ /*
465
+ * Document-method: Curses.flash
466
+ *
467
+ * Flashes the screen, for visual alarm on the terminal, if possible;
468
+ * otherwise it sounds the alert.
469
+ *
470
+ * see also Curses.beep
471
+ */
317
472
  static VALUE
318
- curses_flash(obj)
319
- VALUE obj;
473
+ curses_flash(VALUE obj)
320
474
  {
321
475
  #ifdef HAVE_FLASH
322
476
  curses_stdscr();
@@ -325,138 +479,246 @@ curses_flash(obj)
325
479
  return Qnil;
326
480
  }
327
481
 
328
- /* def ungetch */
329
- static VALUE
330
- curses_ungetch(obj, ch)
331
- VALUE obj;
332
- VALUE ch;
482
+ static int
483
+ curses_char(VALUE c)
333
484
  {
485
+ if (FIXNUM_P(c)) {
486
+ return NUM2INT(c);
487
+ }
488
+ else {
489
+ int cc;
490
+
491
+ StringValue(c);
492
+ if (RSTRING_LEN(c) == 0 || RSTRING_LEN(c) > 1) {
493
+ rb_raise(rb_eArgError, "string not corresponding a character");
494
+ }
495
+ cc = RSTRING_PTR(c)[0];
496
+ if (cc > 0x7f) {
497
+ rb_raise(rb_eArgError, "no multibyte string supported (yet)");
498
+ }
499
+ return cc;
500
+ }
501
+ }
502
+
334
503
  #ifdef HAVE_UNGETCH
504
+ /*
505
+ * Document-method: Curses.ungetch
506
+ * call-seq: ungetch(ch)
507
+ *
508
+ * Places +ch+ back onto the input queue to be returned by
509
+ * the next call to Curses.getch.
510
+ *
511
+ * There is just one input queue for all windows.
512
+ */
513
+ static VALUE
514
+ curses_ungetch(VALUE obj, VALUE ch)
515
+ {
516
+ int c = curses_char(ch);
335
517
  curses_stdscr();
336
- ungetch(NUM2INT(ch));
337
- #else
338
- rb_notimplement();
339
- #endif
518
+ ungetch(c);
340
519
  return Qnil;
341
520
  }
521
+ #else
522
+ #define curses_ungetch rb_f_notimplement
523
+ #endif
342
524
 
343
- /* def setpos(y, x) */
525
+ /*
526
+ * Document-method: Curses.setpos
527
+ * call-seq: setpos(y, x)
528
+ *
529
+ * A setter for the position of the cursor,
530
+ * using coordinates +x+ and +y+
531
+ *
532
+ */
344
533
  static VALUE
345
- curses_setpos(obj, y, x)
346
- VALUE obj;
347
- VALUE y;
348
- VALUE x;
534
+ curses_setpos(VALUE obj, VALUE y, VALUE x)
349
535
  {
350
536
  curses_stdscr();
351
537
  move(NUM2INT(y), NUM2INT(x));
352
538
  return Qnil;
353
539
  }
354
540
 
355
- /* def standout */
541
+ /*
542
+ * Document-method: Curses.standout
543
+ *
544
+ * Enables the best highlighting mode of the terminal.
545
+ *
546
+ * This is equivalent to Curses:Window.attron(A_STANDOUT)
547
+ *
548
+ * see also Curses::Window.attrset additional information
549
+ */
356
550
  static VALUE
357
- curses_standout(obj)
358
- VALUE obj;
551
+ curses_standout(VALUE obj)
359
552
  {
360
553
  curses_stdscr();
361
554
  standout();
362
555
  return Qnil;
363
556
  }
364
557
 
365
- /* def standend */
558
+ /*
559
+ * Document-method: Curses.standend
560
+ *
561
+ * Enables the Normal display (no highlight)
562
+ *
563
+ * This is equivalent to Curses.attron(A_NORMAL)
564
+ *
565
+ * see also Curses::Window.attrset for additional information.
566
+ */
366
567
  static VALUE
367
- curses_standend(obj)
368
- VALUE obj;
568
+ curses_standend(VALUE obj)
369
569
  {
370
570
  curses_stdscr();
371
571
  standend();
372
572
  return Qnil;
373
573
  }
374
574
 
375
- /* def inch */
575
+ /*
576
+ * Document-method: Curses.inch
577
+ *
578
+ * Returns the character at the current position.
579
+ */
376
580
  static VALUE
377
- curses_inch(obj)
378
- VALUE obj;
581
+ curses_inch(VALUE obj)
379
582
  {
380
583
  curses_stdscr();
381
584
  return CH2FIX(inch());
382
585
  }
383
586
 
384
- /* def addch(ch) */
587
+ /*
588
+ * Document-method: Curses.addch
589
+ * call-seq: addch(ch)
590
+ *
591
+ * Add a character +ch+, with attributes, then advance the cursor.
592
+ *
593
+ * see also the system manual for curs_addch(3)
594
+ */
385
595
  static VALUE
386
- curses_addch(obj, ch)
387
- VALUE obj;
388
- VALUE ch;
596
+ curses_addch(VALUE obj, VALUE ch)
389
597
  {
390
598
  curses_stdscr();
391
599
  addch(NUM2CH(ch));
392
600
  return Qnil;
393
601
  }
394
602
 
395
- /* def insch(ch) */
603
+ /*
604
+ * Document-method: Curses.insch
605
+ * call-seq: insch(ch)
606
+ *
607
+ * Insert a character +ch+, before the cursor.
608
+ *
609
+ */
396
610
  static VALUE
397
- curses_insch(obj, ch)
398
- VALUE obj;
399
- VALUE ch;
611
+ curses_insch(VALUE obj, VALUE ch)
400
612
  {
401
613
  curses_stdscr();
402
614
  insch(NUM2CH(ch));
403
615
  return Qnil;
404
616
  }
405
617
 
406
- /* def addstr(str) */
618
+ /*
619
+ * Document-method: Curses.addstr
620
+ * call-seq: addstr(str)
621
+ *
622
+ * add a string of characters +str+, to the window and advance cursor
623
+ *
624
+ */
407
625
  static VALUE
408
- curses_addstr(obj, str)
409
- VALUE obj;
410
- VALUE str;
626
+ curses_addstr(VALUE obj, VALUE str)
411
627
  {
628
+ StringValue(str);
629
+ str = rb_str_export_locale(str);
412
630
  curses_stdscr();
413
631
  if (!NIL_P(str)) {
414
- addstr(STR2CSTR(str));
632
+ addstr(StringValueCStr(str));
415
633
  }
416
634
  return Qnil;
417
635
  }
418
636
 
419
- /* def getch */
420
- static VALUE
421
- curses_getch(obj)
422
- VALUE obj;
637
+ static void *
638
+ getch_func(void *arg)
423
639
  {
424
- rb_read_check(stdin);
425
- curses_stdscr();
426
- return UINT2NUM(getch());
640
+ int *ip = (int *)arg;
641
+ *ip = getch();
642
+ return 0;
427
643
  }
428
644
 
429
- /* def getstr */
645
+ /*
646
+ * Document-method: Curses.getch
647
+ *
648
+ * Read and returns a character from the window.
649
+ *
650
+ * See Curses::Key to all the function KEY_* available
651
+ *
652
+ */
430
653
  static VALUE
431
- curses_getstr(obj)
432
- VALUE obj;
654
+ curses_getch(VALUE obj)
433
655
  {
434
- char rtn[1024]; /* This should be big enough.. I hope */
656
+ int c;
435
657
 
436
658
  curses_stdscr();
437
- rb_read_check(stdin);
659
+ rb_thread_call_without_gvl(getch_func, &c, RUBY_UBF_IO, 0);
660
+ if (c == EOF) return Qnil;
661
+ if (rb_isprint(c)) {
662
+ char ch = (char)c;
663
+
664
+ return rb_locale_str_new(&ch, 1);
665
+ }
666
+ return UINT2NUM(c);
667
+ }
668
+
669
+ /* This should be big enough.. I hope */
670
+ #define GETSTR_BUF_SIZE 1024
671
+
672
+ static void *
673
+ getstr_func(void *arg)
674
+ {
675
+ char *rtn = (char *)arg;
438
676
  #if defined(HAVE_GETNSTR)
439
- getnstr(rtn,1023);
677
+ getnstr(rtn,GETSTR_BUF_SIZE-1);
440
678
  #else
441
679
  getstr(rtn);
442
680
  #endif
443
- return rb_tainted_str_new2(rtn);
681
+ return 0;
444
682
  }
445
683
 
446
- /* def delch */
684
+ /*
685
+ * Document-method: Curses.getstr
686
+ *
687
+ * This is equivalent to a series f Curses::Window.getch calls
688
+ *
689
+ */
447
690
  static VALUE
448
- curses_delch(obj)
449
- VALUE obj;
691
+ curses_getstr(VALUE obj)
692
+ {
693
+ char rtn[GETSTR_BUF_SIZE];
694
+
695
+ curses_stdscr();
696
+ rb_thread_call_without_gvl(getstr_func, rtn, RUBY_UBF_IO, 0);
697
+ return rb_locale_str_new_cstr(rtn);
698
+ }
699
+
700
+ /*
701
+ * Document-method: Curses.delch
702
+ *
703
+ * Delete the character under the cursor
704
+ *
705
+ */
706
+ static VALUE
707
+ curses_delch(VALUE obj)
450
708
  {
451
709
  curses_stdscr();
452
710
  delch();
453
711
  return Qnil;
454
712
  }
455
713
 
456
- /* def delelteln */
714
+ /*
715
+ * Document-method: Curses.deleteln
716
+ *
717
+ * Delete the line under the cursor.
718
+ *
719
+ */
457
720
  static VALUE
458
- curses_deleteln(obj)
459
- VALUE obj;
721
+ curses_deleteln(VALUE obj)
460
722
  {
461
723
  curses_stdscr();
462
724
  #if defined(HAVE_DELETELN) || defined(deleteln)
@@ -465,10 +727,14 @@ curses_deleteln(obj)
465
727
  return Qnil;
466
728
  }
467
729
 
468
- /* def insertln */
730
+ /*
731
+ * Document-method: Curses.insertln
732
+ *
733
+ * Inserts a line above the cursor, and the bottom line is lost
734
+ *
735
+ */
469
736
  static VALUE
470
- curses_insertln(obj)
471
- VALUE obj;
737
+ curses_insertln(VALUE obj)
472
738
  {
473
739
  curses_stdscr();
474
740
  #if defined(HAVE_INSERTLN) || defined(insertln)
@@ -477,343 +743,755 @@ curses_insertln(obj)
477
743
  return Qnil;
478
744
  }
479
745
 
480
- /* def keyname */
746
+ /*
747
+ * Document-method: Curses.keyname
748
+ * call-seq: keyname(c)
749
+ *
750
+ * Returns the character string corresponding to key +c+
751
+ */
481
752
  static VALUE
482
- curses_keyname(obj, c)
483
- VALUE obj;
484
- VALUE c;
753
+ curses_keyname(VALUE obj, VALUE c)
485
754
  {
486
755
  #ifdef HAVE_KEYNAME
487
- const char *name;
756
+ int cc = curses_char(c);
757
+ const char *name;
488
758
 
489
- curses_stdscr();
490
- name = keyname(NUM2INT(c));
491
- if (name) {
492
- return rb_str_new2(name);
493
- } else {
494
- return Qnil;
495
- }
759
+ curses_stdscr();
760
+ name = keyname(cc);
761
+ if (name) {
762
+ return rb_str_new_cstr(name);
763
+ }
764
+ else {
765
+ return Qnil;
766
+ }
496
767
  #else
497
- return Qnil;
768
+ return Qnil;
498
769
  #endif
499
770
  }
500
771
 
772
+ /*
773
+ * Document-method: Curses.lines
774
+ *
775
+ * Returns the number of lines on the screen
776
+ */
501
777
  static VALUE
502
- curses_lines()
778
+ curses_lines(void)
503
779
  {
504
780
  return INT2FIX(LINES);
505
781
  }
506
782
 
783
+ /*
784
+ * Document-method: Curses.cols
785
+ *
786
+ * Returns the number of columns on the screen
787
+ */
507
788
  static VALUE
508
- curses_cols()
789
+ curses_cols(void)
509
790
  {
510
791
  return INT2FIX(COLS);
511
792
  }
512
793
 
794
+ /*
795
+ * Document-method: Curses.curs_set
796
+ * call-seq: curs_set(visibility)
797
+ *
798
+ * Sets Cursor Visibility.
799
+ * 0: invisible
800
+ * 1: visible
801
+ * 2: very visible
802
+ */
513
803
  static VALUE
514
804
  curses_curs_set(VALUE obj, VALUE visibility)
515
805
  {
516
806
  #ifdef HAVE_CURS_SET
517
- int n;
518
- curses_stdscr();
519
- return (n = curs_set(NUM2INT(visibility)) != ERR) ? INT2FIX(n) : Qnil;
807
+ int n;
808
+ curses_stdscr();
809
+ return (n = curs_set(NUM2INT(visibility)) != ERR) ? INT2FIX(n) : Qnil;
520
810
  #else
521
- return Qnil;
811
+ return Qnil;
522
812
  #endif
523
813
  }
524
814
 
815
+ /*
816
+ * Document-method: Curses.scrl
817
+ * call-seq: scrl(num)
818
+ *
819
+ * Scrolls the current window Fixnum +num+ lines.
820
+ * The current cursor position is not changed.
821
+ *
822
+ * For positive +num+, it scrolls up.
823
+ *
824
+ * For negative +num+, it scrolls down.
825
+ *
826
+ */
525
827
  static VALUE
526
828
  curses_scrl(VALUE obj, VALUE n)
527
829
  {
528
- /* may have to raise exception on ERR */
830
+ /* may have to raise exception on ERR */
529
831
  #ifdef HAVE_SCRL
530
- curses_stdscr();
531
- return (scrl(NUM2INT(n)) == OK) ? Qtrue : Qfalse;
832
+ curses_stdscr();
833
+ return (scrl(NUM2INT(n)) == OK) ? Qtrue : Qfalse;
532
834
  #else
533
- return Qfalse;
835
+ return Qfalse;
534
836
  #endif
535
837
  }
536
838
 
839
+ /*
840
+ * Document-method: Curses.setscrreg
841
+ *
842
+ * call-seq:
843
+ * setscrreg(top, bottom)
844
+ *
845
+ * Set a software scrolling region in a window.
846
+ * +top+ and +bottom+ are lines numbers of the margin.
847
+ *
848
+ * If this option and Curses.scrollok are enabled, an attempt to move off
849
+ * the bottom margin line causes all lines in the scrolling region
850
+ * to scroll one line in the direction of the first line.
851
+ * Only the text of the window is scrolled.
852
+ *
853
+ */
537
854
  static VALUE
538
855
  curses_setscrreg(VALUE obj, VALUE top, VALUE bottom)
539
856
  {
540
- /* may have to raise exception on ERR */
857
+ /* may have to raise exception on ERR */
541
858
  #ifdef HAVE_SETSCRREG
542
- curses_stdscr();
543
- return (setscrreg(NUM2INT(top), NUM2INT(bottom)) == OK) ? Qtrue : Qfalse;
859
+ curses_stdscr();
860
+ return (setscrreg(NUM2INT(top), NUM2INT(bottom)) == OK) ? Qtrue : Qfalse;
544
861
  #else
545
- return Qfalse;
862
+ return Qfalse;
546
863
  #endif
547
864
  }
548
865
 
866
+ /*
867
+ * Document-method: Curses.attroff
868
+ * call-seq: attroff(attrs)
869
+ *
870
+ * Turns on the named attributes +attrs+ without affecting any others.
871
+ *
872
+ * See also Curses::Window.attrset for additional information.
873
+ */
549
874
  static VALUE
550
875
  curses_attroff(VALUE obj, VALUE attrs)
551
876
  {
552
- curses_stdscr();
553
- return window_attroff(rb_stdscr,attrs);
554
- /* return INT2FIX(attroff(NUM2INT(attrs))); */
877
+ curses_stdscr();
878
+ return window_attroff(rb_stdscr,attrs);
879
+ /* return INT2FIX(attroff(NUM2INT(attrs))); */
555
880
  }
556
881
 
882
+ /*
883
+ * Document-method: Curses.attron
884
+ * call-seq: attron(attrs)
885
+ *
886
+ * Turns off the named attributes +attrs+
887
+ * without turning any other attributes on or off.
888
+ *
889
+ * See also Curses::Window.attrset for additional information.
890
+ */
557
891
  static VALUE
558
892
  curses_attron(VALUE obj, VALUE attrs)
559
893
  {
560
- curses_stdscr();
561
- return window_attron(rb_stdscr,attrs);
562
- /* return INT2FIX(attroff(NUM2INT(attrs))); */
894
+ curses_stdscr();
895
+ return window_attron(rb_stdscr,attrs);
896
+ /* return INT2FIX(attroff(NUM2INT(attrs))); */
563
897
  }
564
898
 
899
+ /*
900
+ * Document-method: Curses.attrset
901
+ * call-seq: attrset(attrs)
902
+ *
903
+ * Sets the current attributes of the given window to +attrs+.
904
+ *
905
+ * see also Curses::Window.attrset
906
+ *
907
+ */
565
908
  static VALUE
566
909
  curses_attrset(VALUE obj, VALUE attrs)
567
910
  {
568
- curses_stdscr();
569
- return window_attrset(rb_stdscr,attrs);
570
- /* return INT2FIX(attroff(NUM2INT(attrs))); */
911
+ curses_stdscr();
912
+ return window_attrset(rb_stdscr,attrs);
913
+ /* return INT2FIX(attroff(NUM2INT(attrs))); */
571
914
  }
572
915
 
916
+ /*
917
+ * Document-method: Curses.bkgdset
918
+ * call-seq: bkgdset(ch)
919
+ *
920
+ * Manipulate the background of the named window
921
+ * with character Integer +ch+
922
+ *
923
+ * The background becomes a property of the character
924
+ * and moves with the character through any scrolling
925
+ * and insert/delete line/character operations.
926
+ *
927
+ * see also the system manual for curs_bkgd(3)
928
+ */
573
929
  static VALUE
574
930
  curses_bkgdset(VALUE obj, VALUE ch)
575
931
  {
576
932
  #ifdef HAVE_BKGDSET
577
- curses_stdscr();
578
- bkgdset(NUM2CH(ch));
933
+ curses_stdscr();
934
+ bkgdset(NUM2CH(ch));
579
935
  #endif
580
- return Qnil;
936
+ return Qnil;
581
937
  }
582
938
 
939
+ /*
940
+ * call-seq: bkgd(ch)
941
+ *
942
+ * Window background manipulation routines.
943
+ *
944
+ * Set the background property of the current
945
+ * and then apply the character Integer +ch+ setting
946
+ * to every character position in that window.
947
+ *
948
+ * see also the system manual for curs_bkgd(3)
949
+ */
583
950
  static VALUE
584
951
  curses_bkgd(VALUE obj, VALUE ch)
585
952
  {
586
953
  #ifdef HAVE_BKGD
587
- curses_stdscr();
588
- return (bkgd(NUM2CH(ch)) == OK) ? Qtrue : Qfalse;
954
+ curses_stdscr();
955
+ return (bkgd(NUM2CH(ch)) == OK) ? Qtrue : Qfalse;
589
956
  #else
590
- return Qfalse;
957
+ return Qfalse;
591
958
  #endif
592
959
  }
593
960
 
961
+ #if defined(HAVE_USE_DEFAULT_COLORS)
962
+ /*
963
+ * tells the curses library to use terminal's default colors.
964
+ *
965
+ * see also the system manual for default_colors(3)
966
+ */
594
967
  static VALUE
595
- curses_resizeterm(VALUE obj, VALUE lin, VALUE col)
968
+ curses_use_default_colors(VALUE obj)
596
969
  {
597
- #if defined(HAVE_RESIZETERM)
598
- curses_stdscr();
599
- return (resizeterm(NUM2INT(lin),NUM2INT(col)) == OK) ? Qtrue : Qfalse;
970
+ curses_stdscr();
971
+ use_default_colors();
972
+ return Qnil;
973
+ }
600
974
  #else
601
- return Qnil;
975
+ #define curses_use_default_colors rb_f_notimplement
602
976
  #endif
603
- }
604
977
 
605
- #ifdef USE_COLOR
978
+ #if defined(HAVE_TABSIZE)
979
+ /*
980
+ * Document-method: Curses.TABSIZE=
981
+ * call-seq: TABSIZE=(value)
982
+ *
983
+ * Sets the TABSIZE to Integer +value+
984
+ */
606
985
  static VALUE
607
- curses_start_color(VALUE obj)
986
+ curses_tabsize_set(VALUE obj, VALUE val)
608
987
  {
609
- /* may have to raise exception on ERR */
610
- curses_stdscr();
611
- return (start_color() == OK) ? Qtrue : Qfalse;
988
+ TABSIZE = NUM2INT(val);
989
+ return INT2NUM(TABSIZE);
612
990
  }
991
+ #else
992
+ #define curses_tabsize_set rb_f_notimplement
993
+ #endif
613
994
 
995
+ #if defined(HAVE_TABSIZE)
996
+ /*
997
+ * Returns the number of positions in a tab.
998
+ */
614
999
  static VALUE
615
- curses_init_pair(VALUE obj, VALUE pair, VALUE f, VALUE b)
1000
+ curses_tabsize_get(VALUE ojb)
616
1001
  {
617
- /* may have to raise exception on ERR */
618
- curses_stdscr();
619
- return (init_pair(NUM2INT(pair),NUM2INT(f),NUM2INT(b)) == OK) ? Qtrue : Qfalse;
1002
+ return INT2NUM(TABSIZE);
620
1003
  }
1004
+ #else
1005
+ #define curses_tabsize_get rb_f_notimplement
1006
+ #endif
621
1007
 
1008
+ #if defined(HAVE_ESCDELAY)
1009
+ /*
1010
+ * call-seq: Curses.ESCDELAY=(value)
1011
+ *
1012
+ * Sets the ESCDELAY to Integer +value+
1013
+ */
622
1014
  static VALUE
623
- curses_init_color(VALUE obj, VALUE color, VALUE r, VALUE g, VALUE b)
1015
+ curses_escdelay_set(VALUE obj, VALUE val)
624
1016
  {
625
- /* may have to raise exception on ERR */
626
- curses_stdscr();
627
- return (init_color(NUM2INT(color),NUM2INT(r),
628
- NUM2INT(g),NUM2INT(b)) == OK) ? Qtrue : Qfalse;
1017
+ ESCDELAY = NUM2INT(val);
1018
+ return INT2NUM(ESCDELAY);
629
1019
  }
1020
+ #else
1021
+ #define curses_escdelay_set rb_f_notimplement
1022
+ #endif
630
1023
 
1024
+ #if defined(HAVE_ESCDELAY)
1025
+ /*
1026
+ * Returns the total time, in milliseconds, for which
1027
+ * curses will await a character sequence, e.g., a function key
1028
+ */
631
1029
  static VALUE
632
- curses_has_colors(VALUE obj)
1030
+ curses_escdelay_get(VALUE obj)
633
1031
  {
634
- curses_stdscr();
635
- return has_colors() ? Qtrue : Qfalse;
1032
+ return INT2NUM(ESCDELAY);
636
1033
  }
1034
+ #else
1035
+ #define curses_escdelay_get rb_f_notimplement
1036
+ #endif
1037
+
1038
+ /*
1039
+ * Document-method: Curses.resize
1040
+ * call-seq: resize(lines, cols)
1041
+ *
1042
+ * alias for Curses.resizeterm
1043
+ *
1044
+ */
637
1045
 
1046
+ /*
1047
+ * Document-method: Curses.resizeterm
1048
+ * call-seq: resizeterm(lines, cols)
1049
+ *
1050
+ * Resize the current term to Fixnum +lines+ and Fixnum +cols+
1051
+ *
1052
+ */
638
1053
  static VALUE
639
- curses_can_change_color(VALUE obj)
1054
+ curses_resizeterm(VALUE obj, VALUE lin, VALUE col)
640
1055
  {
641
- curses_stdscr();
642
- return can_change_color() ? Qtrue : Qfalse;
1056
+ #if defined(HAVE_RESIZETERM)
1057
+ curses_stdscr();
1058
+ return (resizeterm(NUM2INT(lin),NUM2INT(col)) == OK) ? Qtrue : Qfalse;
1059
+ #else
1060
+ return Qnil;
1061
+ #endif
1062
+ }
1063
+
1064
+ #ifdef USE_COLOR
1065
+ /*
1066
+ * Document-method: Curses.start_color
1067
+ *
1068
+ * Initializes the color attributes, for terminals that support it.
1069
+ *
1070
+ * This must be called, in order to use color attributes.
1071
+ * It is good practice to call it just after Curses.init_screen
1072
+ */
1073
+ static VALUE
1074
+ curses_start_color(VALUE obj)
1075
+ {
1076
+ /* may have to raise exception on ERR */
1077
+ curses_stdscr();
1078
+ return (start_color() == OK) ? Qtrue : Qfalse;
643
1079
  }
644
1080
 
1081
+ /*
1082
+ * Document-method: Curses.init_pair
1083
+ * call-seq: init_pair(pair, f, b)
1084
+ *
1085
+ * Changes the definition of a color-pair.
1086
+ *
1087
+ * It takes three arguments: the number of the color-pair to be changed +pair+,
1088
+ * the foreground color number +f+, and the background color number +b+.
1089
+ *
1090
+ * If the color-pair was previously initialized, the screen is
1091
+ * refreshed and all occurrences of that color-pair are changed
1092
+ * to the new definition.
1093
+ *
1094
+ */
1095
+ static VALUE
1096
+ curses_init_pair(VALUE obj, VALUE pair, VALUE f, VALUE b)
1097
+ {
1098
+ /* may have to raise exception on ERR */
1099
+ curses_stdscr();
1100
+ return (init_pair(NUM2INT(pair),NUM2INT(f),NUM2INT(b)) == OK) ? Qtrue : Qfalse;
1101
+ }
1102
+
1103
+ /*
1104
+ * Document-method: Curses.init_color
1105
+ * call-seq: init_color(color, r, g, b)
1106
+ *
1107
+ * Changes the definition of a color. It takes four arguments:
1108
+ * * the number of the color to be changed, +color+
1109
+ * * the amount of red, +r+
1110
+ * * the amount of green, +g+
1111
+ * * the amount of blue, +b+
1112
+ *
1113
+ * The value of the first argument must be between 0 and COLORS.
1114
+ * (See the section Colors for the default color index.) Each
1115
+ * of the last three arguments must be a value between 0 and 1000.
1116
+ * When Curses.init_color is used, all occurrences of that color
1117
+ * on the screen immediately change to the new definition.
1118
+ */
1119
+ static VALUE
1120
+ curses_init_color(VALUE obj, VALUE color, VALUE r, VALUE g, VALUE b)
1121
+ {
1122
+ /* may have to raise exception on ERR */
1123
+ curses_stdscr();
1124
+ return (init_color(NUM2INT(color),NUM2INT(r),
1125
+ NUM2INT(g),NUM2INT(b)) == OK) ? Qtrue : Qfalse;
1126
+ }
1127
+
1128
+ /*
1129
+ * Document-method: Curses.has_colors?
1130
+ *
1131
+ * Returns +true+ or +false+ depending on whether the terminal has color capabilities.
1132
+ */
1133
+ static VALUE
1134
+ curses_has_colors(VALUE obj)
1135
+ {
1136
+ curses_stdscr();
1137
+ return has_colors() ? Qtrue : Qfalse;
1138
+ }
1139
+
1140
+ /*
1141
+ * Document-method: Curses.can_change_color?
1142
+ *
1143
+ * Returns +true+ or +false+ depending on whether the terminal can change color attributes
1144
+ */
1145
+ static VALUE
1146
+ curses_can_change_color(VALUE obj)
1147
+ {
1148
+ curses_stdscr();
1149
+ return can_change_color() ? Qtrue : Qfalse;
1150
+ }
1151
+
1152
+ #if defined(HAVE_COLORS)
1153
+ /*
1154
+ * Document-method: Curses.color
1155
+ *
1156
+ * returns COLORS
1157
+ */
1158
+ static VALUE
1159
+ curses_colors(VALUE obj)
1160
+ {
1161
+ return INT2FIX(COLORS);
1162
+ }
1163
+ #else
1164
+ #define curses_colors rb_f_notimplement
1165
+ #endif
1166
+
1167
+ /*
1168
+ * Document-method: Curses.color_content
1169
+ * call-seq: color_content(color)
1170
+ *
1171
+ * Returns an 3 item Array of the RGB values in +color+
1172
+ */
645
1173
  static VALUE
646
1174
  curses_color_content(VALUE obj, VALUE color)
647
1175
  {
648
- short r,g,b;
1176
+ short r,g,b;
649
1177
 
650
- curses_stdscr();
651
- color_content(NUM2INT(color),&r,&g,&b);
652
- return rb_ary_new3(3,INT2FIX(r),INT2FIX(g),INT2FIX(b));
1178
+ curses_stdscr();
1179
+ color_content(NUM2INT(color),&r,&g,&b);
1180
+ return rb_ary_new3(3,INT2FIX(r),INT2FIX(g),INT2FIX(b));
653
1181
  }
654
1182
 
1183
+
1184
+ #if defined(HAVE_COLOR_PAIRS)
1185
+ /*
1186
+ * Document-method: Curses.color_pairs
1187
+ *
1188
+ * Returns the COLOR_PAIRS available, if the curses library supports it.
1189
+ */
1190
+ static VALUE
1191
+ curses_color_pairs(VALUE obj)
1192
+ {
1193
+ return INT2FIX(COLOR_PAIRS);
1194
+ }
1195
+ #else
1196
+ #define curses_color_pairs rb_f_notimplement
1197
+ #endif
1198
+
1199
+ /*
1200
+ * Document-method: Curses.pair_content
1201
+ * call-seq: pair_content(pair)
1202
+ *
1203
+ * Returns a 2 item Array, with the foreground and
1204
+ * background color, in +pair+
1205
+ */
655
1206
  static VALUE
656
1207
  curses_pair_content(VALUE obj, VALUE pair)
657
1208
  {
658
- short f,b;
1209
+ short f,b;
659
1210
 
660
- curses_stdscr();
661
- pair_content(NUM2INT(pair),&f,&b);
662
- return rb_ary_new3(2,INT2FIX(f),INT2FIX(b));
1211
+ curses_stdscr();
1212
+ pair_content(NUM2INT(pair),&f,&b);
1213
+ return rb_ary_new3(2,INT2FIX(f),INT2FIX(b));
663
1214
  }
664
1215
 
1216
+ /*
1217
+ * Document-method: Curses.color_pair
1218
+ * call-seq: color_pair(attrs)
1219
+ *
1220
+ * Sets the color pair attributes to +attrs+.
1221
+ *
1222
+ * This should be equivalent to Curses.attrset(COLOR_PAIR(+attrs+))
1223
+ *
1224
+ * TODO: validate that equivalency
1225
+ */
665
1226
  static VALUE
666
1227
  curses_color_pair(VALUE obj, VALUE attrs)
667
1228
  {
668
- return INT2FIX(COLOR_PAIR(NUM2INT(attrs)));
1229
+ return INT2FIX(COLOR_PAIR(NUM2INT(attrs)));
669
1230
  }
670
1231
 
1232
+ /*
1233
+ * Document-method: Curses.pair_number
1234
+ * call-seq: pair_number(attrs)
1235
+ *
1236
+ * Returns the Fixnum color pair number of attributes +attrs+.
1237
+ */
671
1238
  static VALUE
672
1239
  curses_pair_number(VALUE obj, VALUE attrs)
673
1240
  {
674
- curses_stdscr();
675
- return INT2FIX(PAIR_NUMBER(NUM2INT(attrs)));
1241
+ curses_stdscr();
1242
+ return INT2FIX(PAIR_NUMBER(NUM2LONG(attrs)));
676
1243
  }
677
1244
  #endif /* USE_COLOR */
678
1245
 
679
1246
  #ifdef USE_MOUSE
680
1247
  struct mousedata {
681
- MEVENT *mevent;
1248
+ MEVENT *mevent;
682
1249
  };
683
1250
 
684
1251
  static void
685
- no_mevent()
1252
+ no_mevent(void)
686
1253
  {
687
- rb_raise(rb_eRuntimeError, "no such mouse event");
1254
+ rb_raise(rb_eRuntimeError, "no such mouse event");
688
1255
  }
689
1256
 
690
1257
  #define GetMOUSE(obj, data) do {\
691
1258
  if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4)\
692
1259
  rb_raise(rb_eSecurityError, "Insecure: operation on untainted mouse");\
693
- Data_Get_Struct(obj, struct mousedata, data);\
694
- if (data->mevent == 0) no_mevent();\
1260
+ TypedData_Get_Struct((obj), struct mousedata, &mousedata_type, (data));\
1261
+ if ((data)->mevent == 0) no_mevent();\
695
1262
  } while (0)
696
1263
 
697
1264
  static void
698
- curses_mousedata_free(struct mousedata *mdata)
1265
+ curses_mousedata_free(void *p)
699
1266
  {
700
- if (mdata->mevent)
701
- free(mdata->mevent);
1267
+ struct mousedata *mdata = p;
1268
+ if (mdata->mevent)
1269
+ xfree(mdata->mevent);
702
1270
  }
703
1271
 
1272
+ static size_t
1273
+ curses_mousedata_memsize(const void *p)
1274
+ {
1275
+ const struct mousedata *mdata = p;
1276
+ size_t size = sizeof(*mdata);
1277
+ if (!mdata) return 0;
1278
+ if (mdata->mevent) size += sizeof(mdata->mevent);
1279
+ return size;
1280
+ }
1281
+
1282
+ static const rb_data_type_t mousedata_type = {
1283
+ "mousedata",
1284
+ {0, curses_mousedata_free, curses_mousedata_memsize,}
1285
+ };
1286
+
1287
+ /*
1288
+ * Document-method: Curses.getmouse
1289
+ *
1290
+ * Returns coordinates of the mouse.
1291
+ *
1292
+ * This will read and pop the mouse event data off the queue
1293
+ *
1294
+ * See the BUTTON*, ALL_MOUSE_EVENTS and REPORT_MOUSE_POSITION constants, to examine the mask of the event
1295
+ */
704
1296
  static VALUE
705
1297
  curses_getmouse(VALUE obj)
706
1298
  {
707
- struct mousedata *mdata;
708
- VALUE val;
1299
+ struct mousedata *mdata;
1300
+ VALUE val;
709
1301
 
710
- curses_stdscr();
711
- val = Data_Make_Struct(cMouseEvent,struct mousedata,
712
- 0,curses_mousedata_free,mdata);
713
- mdata->mevent = (MEVENT*)xmalloc(sizeof(MEVENT));
714
- return (getmouse(mdata->mevent) == OK) ? val : Qnil;
1302
+ curses_stdscr();
1303
+ val = TypedData_Make_Struct(cMouseEvent,struct mousedata,
1304
+ &mousedata_type,mdata);
1305
+ mdata->mevent = (MEVENT*)xmalloc(sizeof(MEVENT));
1306
+ return (getmouse(mdata->mevent) == OK) ? val : Qnil;
715
1307
  }
716
1308
 
1309
+ /*
1310
+ * Document-method: Curses.ungetmouse
1311
+ *
1312
+ * It pushes a KEY_MOUSE event onto the input queue, and associates with that
1313
+ * event the given state data and screen-relative character-cell coordinates.
1314
+ *
1315
+ * The Curses.ungetmouse function behaves analogously to Curses.ungetch.
1316
+ */
717
1317
  static VALUE
718
1318
  curses_ungetmouse(VALUE obj, VALUE mevent)
719
1319
  {
720
- struct mousedata *mdata;
1320
+ struct mousedata *mdata;
721
1321
 
722
- curses_stdscr();
723
- GetMOUSE(mevent,mdata);
724
- return (ungetmouse(mdata->mevent) == OK) ? Qtrue : Qfalse;
1322
+ curses_stdscr();
1323
+ GetMOUSE(mevent,mdata);
1324
+ return (ungetmouse(mdata->mevent) == OK) ? Qtrue : Qfalse;
725
1325
  }
726
1326
 
1327
+ /*
1328
+ * Document-method: Curses.mouseinterval
1329
+ * call-seq: mouseinterval(interval)
1330
+ *
1331
+ * The Curses.mouseinterval function sets the maximum time
1332
+ * (in thousands of a second) that can elapse between press
1333
+ * and release events for them to be recognized as a click.
1334
+ *
1335
+ * Use Curses.mouseinterval(0) to disable click resolution.
1336
+ * This function returns the previous interval value.
1337
+ *
1338
+ * Use Curses.mouseinterval(-1) to obtain the interval without
1339
+ * altering it.
1340
+ *
1341
+ * The default is one sixth of a second.
1342
+ */
727
1343
  static VALUE
728
1344
  curses_mouseinterval(VALUE obj, VALUE interval)
729
1345
  {
730
- curses_stdscr();
731
- return mouseinterval(NUM2INT(interval)) ? Qtrue : Qfalse;
1346
+ curses_stdscr();
1347
+ return mouseinterval(NUM2INT(interval)) ? Qtrue : Qfalse;
732
1348
  }
733
1349
 
1350
+ /*
1351
+ * Document-method: Curses.mousemask
1352
+ * call-seq: mousemask(mask)
1353
+ *
1354
+ * Returns the +mask+ of the reportable events
1355
+ */
734
1356
  static VALUE
735
1357
  curses_mousemask(VALUE obj, VALUE mask)
736
1358
  {
737
- curses_stdscr();
738
- return INT2NUM(mousemask(NUM2UINT(mask),NULL));
1359
+ curses_stdscr();
1360
+ return INT2NUM(mousemask(NUM2UINT(mask),NULL));
739
1361
  }
740
1362
 
741
1363
  #define DEFINE_MOUSE_GET_MEMBER(func_name,mem) \
742
1364
  static VALUE func_name (VALUE mouse) \
743
1365
  { \
744
- struct mousedata *mdata; \
745
- GetMOUSE(mouse, mdata); \
746
- return (UINT2NUM(mdata->mevent -> mem)); \
1366
+ struct mousedata *mdata; \
1367
+ GetMOUSE(mouse, mdata); \
1368
+ return (UINT2NUM(mdata->mevent -> mem)); \
747
1369
  }
748
1370
 
1371
+ /*
1372
+ * Document-method: Curses::MouseEvent.eid
1373
+ *
1374
+ * Returns the current mouse id
1375
+ */
749
1376
  DEFINE_MOUSE_GET_MEMBER(curs_mouse_id, id)
1377
+ /*
1378
+ * Document-method: Curses::MouseEvent.x
1379
+ *
1380
+ * Returns the current mouse's X coordinate
1381
+ */
750
1382
  DEFINE_MOUSE_GET_MEMBER(curs_mouse_x, x)
1383
+ /*
1384
+ * Document-method: Curses::MouseEvent.y
1385
+ *
1386
+ * Returns the current mouse's Y coordinate
1387
+ */
751
1388
  DEFINE_MOUSE_GET_MEMBER(curs_mouse_y, y)
1389
+ /*
1390
+ * Document-method: Curses::MouseEvent.z
1391
+ *
1392
+ * Returns the current mouse's Z coordinate
1393
+ */
752
1394
  DEFINE_MOUSE_GET_MEMBER(curs_mouse_z, z)
1395
+ /*
1396
+ * Document-method: Curses::MouseEvent.bstate
1397
+ *
1398
+ * Returns the current mouse's button state. Use this with the button state
1399
+ * constants to determine which buttons were pressed.
1400
+ */
753
1401
  DEFINE_MOUSE_GET_MEMBER(curs_mouse_bstate, bstate)
754
1402
  #undef define_curs_mouse_member
755
1403
  #endif /* USE_MOUSE */
756
1404
 
1405
+ #ifdef HAVE_TIMEOUT
1406
+ /*
1407
+ * Document-method: Curses.timeout=
1408
+ * call-seq: timeout=(delay)
1409
+ *
1410
+ * Sets block and non-blocking reads for the window.
1411
+ * - If delay is negative, blocking read is used (i.e., waits indefinitely for input).
1412
+ * - If delay is zero, then non-blocking read is used (i.e., read returns ERR if no input is waiting).
1413
+ * - If delay is positive, then read blocks for delay milliseconds, and returns ERR if there is still no input.
1414
+ *
1415
+ */
757
1416
  static VALUE
758
1417
  curses_timeout(VALUE obj, VALUE delay)
759
1418
  {
760
- #ifdef HAVE_TIMEOUT
761
- curses_stdscr();
762
- timeout(NUM2INT(delay));
763
- return Qnil;
1419
+ curses_stdscr();
1420
+ timeout(NUM2INT(delay));
1421
+ return Qnil;
1422
+ }
764
1423
  #else
765
- rb_notimplement();
1424
+ #define curses_timeout rb_f_notimplement
766
1425
  #endif
767
- }
768
1426
 
1427
+ #ifdef HAVE_DEF_PROG_MODE
1428
+ /*
1429
+ * Document-method: Curses.def_prog_mode
1430
+ *
1431
+ * Save the current terminal modes as the "program"
1432
+ * state for use by the Curses.reset_prog_mode
1433
+ *
1434
+ * This is done automatically by Curses.init_screen
1435
+ */
769
1436
  static VALUE
770
1437
  curses_def_prog_mode(VALUE obj)
771
1438
  {
772
- #ifdef HAVE_DEF_PROG_MODE
773
- curses_stdscr();
774
- return def_prog_mode() == OK ? Qtrue : Qfalse;
1439
+ curses_stdscr();
1440
+ return def_prog_mode() == OK ? Qtrue : Qfalse;
1441
+ }
775
1442
  #else
776
- rb_notimplement();
1443
+ #define curses_def_prog_mode rb_f_notimplement
777
1444
  #endif
778
- }
779
1445
 
1446
+ #ifdef HAVE_RESET_PROG_MODE
1447
+ /*
1448
+ * Document-method: Curses.reset_prog_mode
1449
+ *
1450
+ * Reset the current terminal modes to the saved state
1451
+ * by the Curses.def_prog_mode
1452
+ *
1453
+ * This is done automatically by Curses.close_screen
1454
+ */
780
1455
  static VALUE
781
1456
  curses_reset_prog_mode(VALUE obj)
782
1457
  {
783
- #ifdef HAVE_RESET_PROG_MODE
784
- curses_stdscr();
785
- return reset_prog_mode() == OK ? Qtrue : Qfalse;
1458
+ curses_stdscr();
1459
+ return reset_prog_mode() == OK ? Qtrue : Qfalse;
1460
+ }
786
1461
  #else
787
- rb_notimplement();
1462
+ #define curses_reset_prog_mode rb_f_notimplement
788
1463
  #endif
789
- }
790
1464
 
791
1465
  /*-------------------------- class Window --------------------------*/
792
1466
 
793
- /* def self.allocate */
1467
+ /* returns a Curses::Window object */
794
1468
  static VALUE
795
1469
  window_s_allocate(VALUE class)
796
1470
  {
797
1471
  struct windata *winp;
798
1472
 
799
- return Data_Make_Struct(class, struct windata, 0, free_window, winp);
1473
+ return TypedData_Make_Struct(class, struct windata, &windata_type, winp);
800
1474
  }
801
1475
 
802
- /* def initialize(h, w, top, left) */
1476
+ /*
1477
+ * Document-method: Curses::Window.new
1478
+ * call-seq: new(height, width, top, left)
1479
+ *
1480
+ * Construct a new Curses::Window with constraints of
1481
+ * +height+ lines, +width+ columns, begin at +top+ line, and begin +left+ most column.
1482
+ *
1483
+ * A new window using full screen is called as
1484
+ * Curses::Window.new(0,0,0,0)
1485
+ *
1486
+ */
803
1487
  static VALUE
804
- window_initialize(obj, h, w, top, left)
805
- VALUE obj;
806
- VALUE h;
807
- VALUE w;
808
- VALUE top;
809
- VALUE left;
1488
+ window_initialize(VALUE obj, VALUE h, VALUE w, VALUE top, VALUE left)
810
1489
  {
811
1490
  struct windata *winp;
812
1491
  WINDOW *window;
813
1492
 
814
- rb_secure(4);
815
1493
  curses_init_screen();
816
- Data_Get_Struct(obj, struct windata, winp);
1494
+ TypedData_Get_Struct(obj, struct windata, &windata_type, winp);
817
1495
  if (winp->window) delwin(winp->window);
818
1496
  window = newwin(NUM2INT(h), NUM2INT(w), NUM2INT(top), NUM2INT(left));
819
1497
  wclear(window);
@@ -822,14 +1500,16 @@ window_initialize(obj, h, w, top, left)
822
1500
  return obj;
823
1501
  }
824
1502
 
825
- /* def subwin(height, width, top, left) */
1503
+ /*
1504
+ * Document-method: Curses::Window.subwin
1505
+ * call-seq: subwin(height, width, top, left)
1506
+ *
1507
+ * Construct a new subwindow with constraints of
1508
+ * +height+ lines, +width+ columns, begin at +top+ line, and begin +left+ most column.
1509
+ *
1510
+ */
826
1511
  static VALUE
827
- window_subwin(obj, height, width, top, left)
828
- VALUE obj;
829
- VALUE height;
830
- VALUE width;
831
- VALUE top;
832
- VALUE left;
1512
+ window_subwin(VALUE obj, VALUE height, VALUE width, VALUE top, VALUE left)
833
1513
  {
834
1514
  struct windata *winp;
835
1515
  WINDOW *window;
@@ -847,13 +1527,16 @@ window_subwin(obj, height, width, top, left)
847
1527
  return win;
848
1528
  }
849
1529
 
850
- /* def close */
1530
+ /*
1531
+ * Document-method: Curses::Window.close
1532
+ *
1533
+ * Deletes the window, and frees the memory
1534
+ */
851
1535
  static VALUE
852
- window_close(obj)
853
- VALUE obj;
1536
+ window_close(VALUE obj)
854
1537
  {
855
1538
  struct windata *winp;
856
-
1539
+
857
1540
  GetWINDOW(obj, winp);
858
1541
  delwin(winp->window);
859
1542
  winp->window = 0;
@@ -861,49 +1544,65 @@ window_close(obj)
861
1544
  return Qnil;
862
1545
  }
863
1546
 
864
- /* def clear */
1547
+ /*
1548
+ * Document-method: Curses::Window.clear
1549
+ *
1550
+ * Clear the window.
1551
+ */
865
1552
  static VALUE
866
- window_clear(obj)
867
- VALUE obj;
1553
+ window_clear(VALUE obj)
868
1554
  {
869
1555
  struct windata *winp;
870
-
1556
+
871
1557
  GetWINDOW(obj, winp);
872
1558
  wclear(winp->window);
873
-
1559
+
874
1560
  return Qnil;
875
1561
  }
876
1562
 
877
- /* def clrtoeol */
1563
+ /*
1564
+ * Document-method: Curses::Window.clrtoeol
1565
+ *
1566
+ * Clear the window to the end of line, that the cursor is currently on.
1567
+ */
878
1568
  static VALUE
879
- window_clrtoeol(obj)
880
- VALUE obj;
1569
+ window_clrtoeol(VALUE obj)
881
1570
  {
882
1571
  struct windata *winp;
883
-
1572
+
884
1573
  GetWINDOW(obj, winp);
885
1574
  wclrtoeol(winp->window);
886
-
1575
+
887
1576
  return Qnil;
888
1577
  }
889
1578
 
890
- /* def refresh */
1579
+ /*
1580
+ * Document-method: Curses::Window.refresh
1581
+ *
1582
+ * Refreshes the windows and lines.
1583
+ *
1584
+ */
891
1585
  static VALUE
892
- window_refresh(obj)
893
- VALUE obj;
1586
+ window_refresh(VALUE obj)
894
1587
  {
895
1588
  struct windata *winp;
896
-
1589
+
897
1590
  GetWINDOW(obj, winp);
898
1591
  wrefresh(winp->window);
899
-
1592
+
900
1593
  return Qnil;
901
1594
  }
902
1595
 
903
- /* def noutrefresh */
1596
+ /*
1597
+ * Document-method: Curses::Window.noutrefresh
1598
+ *
1599
+ * Refreshes the windows and lines.
1600
+ *
1601
+ * Curses::Window.noutrefresh allows multiple updates with
1602
+ * more efficiency than Curses::Window.refresh alone.
1603
+ */
904
1604
  static VALUE
905
- window_noutrefresh(obj)
906
- VALUE obj;
1605
+ window_noutrefresh(VALUE obj)
907
1606
  {
908
1607
  struct windata *winp;
909
1608
 
@@ -917,65 +1616,81 @@ window_noutrefresh(obj)
917
1616
  return Qnil;
918
1617
  }
919
1618
 
920
- /* def move(y, x) */
1619
+ /*
1620
+ * Document-method: Curses::Window.move
1621
+ * call-seq: move(y,x)
1622
+ *
1623
+ * Moves the window so that the upper left-hand corner is at position (+y+, +x+)
1624
+ */
921
1625
  static VALUE
922
- window_move(obj, y, x)
923
- VALUE obj;
924
- VALUE y;
925
- VALUE x;
1626
+ window_move(VALUE obj, VALUE y, VALUE x)
926
1627
  {
927
1628
  struct windata *winp;
928
-
1629
+
929
1630
  GetWINDOW(obj, winp);
930
1631
  mvwin(winp->window, NUM2INT(y), NUM2INT(x));
931
1632
 
932
1633
  return Qnil;
933
1634
  }
934
1635
 
935
- /* def setpos(y, x) */
1636
+ /*
1637
+ * Document-method: Curses::Window.setpos
1638
+ * call-seq: setpos(y, x)
1639
+ *
1640
+ * A setter for the position of the cursor
1641
+ * in the current window,
1642
+ * using coordinates +x+ and +y+
1643
+ *
1644
+ */
936
1645
  static VALUE
937
- window_setpos(obj, y, x)
938
- VALUE obj;
939
- VALUE y;
940
- VALUE x;
1646
+ window_setpos(VALUE obj, VALUE y, VALUE x)
941
1647
  {
942
1648
  struct windata *winp;
943
-
1649
+
944
1650
  GetWINDOW(obj, winp);
945
1651
  wmove(winp->window, NUM2INT(y), NUM2INT(x));
946
1652
  return Qnil;
947
1653
  }
948
1654
 
949
- /* def cury */
1655
+ /*
1656
+ * Document-method: Curses::Window.cury
1657
+ *
1658
+ * A getter for the current line (Y coord) of the window
1659
+ */
950
1660
  static VALUE
951
- window_cury(obj)
952
- VALUE obj;
1661
+ window_cury(VALUE obj)
953
1662
  {
954
1663
  struct windata *winp;
955
- int x, y;
1664
+ int RB_UNUSED_VAR(x), y;
956
1665
 
957
1666
  GetWINDOW(obj, winp);
958
1667
  getyx(winp->window, y, x);
959
1668
  return INT2FIX(y);
960
1669
  }
961
1670
 
962
- /* def curx */
1671
+ /*
1672
+ * Document-method: Curses::Window.curx
1673
+ *
1674
+ * A getter for the current column (X coord) of the window
1675
+ */
963
1676
  static VALUE
964
- window_curx(obj)
965
- VALUE obj;
1677
+ window_curx(VALUE obj)
966
1678
  {
967
1679
  struct windata *winp;
968
- int x, y;
1680
+ int x, RB_UNUSED_VAR(y);
969
1681
 
970
1682
  GetWINDOW(obj, winp);
971
1683
  getyx(winp->window, y, x);
972
1684
  return INT2FIX(x);
973
1685
  }
974
1686
 
975
- /* def maxy */
1687
+ /*
1688
+ * Document-method: Curses::Window.maxy
1689
+ *
1690
+ * A getter for the maximum lines for the window
1691
+ */
976
1692
  static VALUE
977
- window_maxy(obj)
978
- VALUE obj;
1693
+ window_maxy(VALUE obj)
979
1694
  {
980
1695
  struct windata *winp;
981
1696
 
@@ -993,10 +1708,13 @@ window_maxy(obj)
993
1708
  #endif
994
1709
  }
995
1710
 
996
- /* def maxx */
1711
+ /*
1712
+ * Document-method: Curses::Window.maxx
1713
+ *
1714
+ * A getter for the maximum columns for the window
1715
+ */
997
1716
  static VALUE
998
- window_maxx(obj)
999
- VALUE obj;
1717
+ window_maxx(VALUE obj)
1000
1718
  {
1001
1719
  struct windata *winp;
1002
1720
 
@@ -1014,47 +1732,61 @@ window_maxx(obj)
1014
1732
  #endif
1015
1733
  }
1016
1734
 
1017
- /* def begy */
1735
+ /*
1736
+ * Document-method: Curses::Window.begy
1737
+ *
1738
+ * A getter for the beginning line (Y coord) of the window
1739
+ */
1018
1740
  static VALUE
1019
- window_begy(obj)
1020
- VALUE obj;
1741
+ window_begy(VALUE obj)
1021
1742
  {
1022
1743
  struct windata *winp;
1023
- int x, y;
1744
+ int RB_UNUSED_VAR(x), y;
1024
1745
 
1025
1746
  GetWINDOW(obj, winp);
1026
1747
  #ifdef getbegyx
1027
1748
  getbegyx(winp->window, y, x);
1028
- return INT2FIX(y);
1029
1749
  #else
1030
- return INT2FIX(winp->window->_begy);
1750
+ y = winp->window->_begy;
1031
1751
  #endif
1752
+ return INT2FIX(y);
1032
1753
  }
1033
1754
 
1034
- /* def begx */
1755
+ /*
1756
+ * Document-method: Curses::Window.begx
1757
+ *
1758
+ * A getter for the beginning column (X coord) of the window
1759
+ */
1035
1760
  static VALUE
1036
- window_begx(obj)
1037
- VALUE obj;
1761
+ window_begx(VALUE obj)
1038
1762
  {
1039
1763
  struct windata *winp;
1040
- int x, y;
1764
+ int x, RB_UNUSED_VAR(y);
1041
1765
 
1042
1766
  GetWINDOW(obj, winp);
1043
1767
  #ifdef getbegyx
1044
1768
  getbegyx(winp->window, y, x);
1045
- return INT2FIX(x);
1046
1769
  #else
1047
- return INT2FIX(winp->window->_begx);
1770
+ x = winp->window->_begx;
1048
1771
  #endif
1772
+ return INT2FIX(x);
1049
1773
  }
1050
1774
 
1051
- /* def box(vert, hor) */
1775
+ /*
1776
+ * Document-method: Curses::Window.box
1777
+ * call-seq: box(vert, hor)
1778
+ *
1779
+ * set the characters to frame the window in.
1780
+ * The vertical +vert+ and horizontal +hor+ character.
1781
+ *
1782
+ * win = Curses::Window.new(5,5,5,5)
1783
+ * win.box(?|, ?-)
1784
+ *
1785
+ */
1052
1786
  static VALUE
1053
- window_box(argc, argv, self)
1054
- int argc;
1055
- VALUE argv[], self;
1787
+ window_box(int argc, VALUE *argv, VALUE self)
1056
1788
  {
1057
- struct windata *winp;
1789
+ struct windata *winp;
1058
1790
  VALUE vert, hor, corn;
1059
1791
 
1060
1792
  rb_scan_args(argc, argv, "21", &vert, &hor, &corn);
@@ -1063,423 +1795,894 @@ window_box(argc, argv, self)
1063
1795
  box(winp->window, NUM2CH(vert), NUM2CH(hor));
1064
1796
 
1065
1797
  if (!NIL_P(corn)) {
1066
- int cur_x, cur_y, x, y;
1067
- chtype c;
1068
-
1069
- c = NUM2CH(corn);
1070
- getyx(winp->window, cur_y, cur_x);
1071
- x = NUM2INT(window_maxx(self)) - 1;
1072
- y = NUM2INT(window_maxy(self)) - 1;
1073
- wmove(winp->window, 0, 0);
1074
- waddch(winp->window, c);
1075
- wmove(winp->window, y, 0);
1076
- waddch(winp->window, c);
1077
- wmove(winp->window, y, x);
1078
- waddch(winp->window, c);
1079
- wmove(winp->window, 0, x);
1080
- waddch(winp->window, c);
1081
- wmove(winp->window, cur_y, cur_x);
1798
+ int cur_x, cur_y, x, y;
1799
+ chtype c;
1800
+
1801
+ c = NUM2CH(corn);
1802
+ getyx(winp->window, cur_y, cur_x);
1803
+ x = NUM2INT(window_maxx(self)) - 1;
1804
+ y = NUM2INT(window_maxy(self)) - 1;
1805
+ wmove(winp->window, 0, 0);
1806
+ waddch(winp->window, c);
1807
+ wmove(winp->window, y, 0);
1808
+ waddch(winp->window, c);
1809
+ wmove(winp->window, y, x);
1810
+ waddch(winp->window, c);
1811
+ wmove(winp->window, 0, x);
1812
+ waddch(winp->window, c);
1813
+ wmove(winp->window, cur_y, cur_x);
1082
1814
  }
1083
-
1815
+
1084
1816
  return Qnil;
1085
1817
  }
1086
1818
 
1087
- /* def standout */
1819
+ /*
1820
+ * Document-method: Curses::Window.standout
1821
+ *
1822
+ * Enables the best highlighting mode of the terminal.
1823
+ *
1824
+ * This is equivalent to Curses::Window.attron(A_STANDOUT)
1825
+ *
1826
+ * see also Curses::Window.attrset
1827
+ */
1088
1828
  static VALUE
1089
- window_standout(obj)
1090
- VALUE obj;
1829
+ window_standout(VALUE obj)
1091
1830
  {
1092
1831
  struct windata *winp;
1093
-
1832
+
1094
1833
  GetWINDOW(obj, winp);
1095
1834
  wstandout(winp->window);
1096
1835
  return Qnil;
1097
1836
  }
1098
1837
 
1099
- /* def standend */
1838
+ /*
1839
+ * Document-method: Curses::Window.standend
1840
+ *
1841
+ * Enables the Normal display (no highlight)
1842
+ *
1843
+ * This is equivalent to Curses::Window.attron(A_NORMAL)
1844
+ *
1845
+ * see also Curses::Window.attrset
1846
+ */
1100
1847
  static VALUE
1101
- window_standend(obj)
1102
- VALUE obj;
1848
+ window_standend(VALUE obj)
1103
1849
  {
1104
1850
  struct windata *winp;
1105
-
1851
+
1106
1852
  GetWINDOW(obj, winp);
1107
1853
  wstandend(winp->window);
1108
1854
  return Qnil;
1109
1855
  }
1110
1856
 
1111
- /* def inch */
1857
+ /*
1858
+ * Document-method: Curses::Window.inch
1859
+ *
1860
+ * Returns the character at the current position of the window.
1861
+ */
1112
1862
  static VALUE
1113
- window_inch(obj)
1114
- VALUE obj;
1863
+ window_inch(VALUE obj)
1115
1864
  {
1116
1865
  struct windata *winp;
1117
-
1866
+
1118
1867
  GetWINDOW(obj, winp);
1119
1868
  return CH2FIX(winch(winp->window));
1120
1869
  }
1121
1870
 
1122
- /* def addch(ch) */
1871
+ /*
1872
+ * Document-method: Curses::Window.addch
1873
+ * call-seq: addch(ch)
1874
+ *
1875
+ * Add a character +ch+, with attributes, to the window, then advance the cursor.
1876
+ *
1877
+ * see also the system manual for curs_addch(3)
1878
+ */
1123
1879
  static VALUE
1124
- window_addch(obj, ch)
1125
- VALUE obj;
1126
- VALUE ch;
1880
+ window_addch(VALUE obj, VALUE ch)
1127
1881
  {
1128
1882
  struct windata *winp;
1129
-
1883
+
1130
1884
  GetWINDOW(obj, winp);
1131
1885
  waddch(winp->window, NUM2CH(ch));
1132
-
1886
+
1133
1887
  return Qnil;
1134
1888
  }
1135
1889
 
1136
- /* def insch(ch) */
1890
+ /*
1891
+ * Document-method: Curses::Window.insch
1892
+ * call-seq: insch(ch)
1893
+ *
1894
+ * Insert a character +ch+, before the cursor, in the current window
1895
+ *
1896
+ */
1137
1897
  static VALUE
1138
- window_insch(obj, ch)
1139
- VALUE obj;
1140
- VALUE ch;
1898
+ window_insch(VALUE obj, VALUE ch)
1141
1899
  {
1142
1900
  struct windata *winp;
1143
-
1901
+
1144
1902
  GetWINDOW(obj, winp);
1145
1903
  winsch(winp->window, NUM2CH(ch));
1146
-
1904
+
1147
1905
  return Qnil;
1148
1906
  }
1149
1907
 
1150
- /* def addstr(str) */
1908
+ /*
1909
+ * Document-method: Curses::Window.addstr
1910
+ * call-seq: addstr(str)
1911
+ *
1912
+ * add a string of characters +str+, to the window and advance cursor
1913
+ *
1914
+ */
1151
1915
  static VALUE
1152
- window_addstr(obj, str)
1153
- VALUE obj;
1154
- VALUE str;
1916
+ window_addstr(VALUE obj, VALUE str)
1155
1917
  {
1156
1918
  if (!NIL_P(str)) {
1157
1919
  struct windata *winp;
1158
1920
 
1921
+ StringValue(str);
1922
+ str = rb_str_export_locale(str);
1159
1923
  GetWINDOW(obj, winp);
1160
- waddstr(winp->window, STR2CSTR(str));
1924
+ waddstr(winp->window, StringValueCStr(str));
1161
1925
  }
1162
1926
  return Qnil;
1163
1927
  }
1164
1928
 
1165
- /* def <<(str) */
1929
+ /*
1930
+ * Document-method: Curses::Window.<<
1931
+ *
1932
+ * call-seq:
1933
+ * <<(str)
1934
+ *
1935
+ * Add String +str+ to the current string.
1936
+ *
1937
+ * See also Curses::Window.addstr
1938
+ */
1166
1939
  static VALUE
1167
- window_addstr2(obj, str)
1168
- VALUE obj;
1169
- VALUE str;
1940
+ window_addstr2(VALUE obj, VALUE str)
1170
1941
  {
1171
1942
  window_addstr(obj, str);
1172
1943
  return obj;
1173
1944
  }
1174
1945
 
1175
- /* def getch */
1176
- static VALUE
1177
- window_getch(obj)
1178
- VALUE obj;
1946
+ struct wgetch_arg {
1947
+ WINDOW *win;
1948
+ int c;
1949
+ };
1950
+
1951
+ static void *
1952
+ wgetch_func(void *_arg)
1179
1953
  {
1180
- struct windata *winp;
1181
-
1182
- rb_read_check(stdin);
1183
- GetWINDOW(obj, winp);
1184
- return UINT2NUM(wgetch(winp->window));
1954
+ struct wgetch_arg *arg = (struct wgetch_arg *)_arg;
1955
+ arg->c = wgetch(arg->win);
1956
+ return 0;
1185
1957
  }
1186
1958
 
1187
- /* def getstr */
1959
+ /*
1960
+ * Document-method: Curses::Window.getch
1961
+ *
1962
+ * Read and returns a character from the window.
1963
+ *
1964
+ * See Curses::Key to all the function KEY_* available
1965
+ *
1966
+ */
1188
1967
  static VALUE
1189
- window_getstr(obj)
1190
- VALUE obj;
1968
+ window_getch(VALUE obj)
1191
1969
  {
1192
1970
  struct windata *winp;
1193
- char rtn[1024]; /* This should be big enough.. I hope */
1194
-
1971
+ struct wgetch_arg arg;
1972
+ int c;
1973
+
1195
1974
  GetWINDOW(obj, winp);
1196
- rb_read_check(stdin);
1975
+ arg.win = winp->window;
1976
+ rb_thread_call_without_gvl(wgetch_func, (void *)&arg, RUBY_UBF_IO, 0);
1977
+ c = arg.c;
1978
+ if (c == EOF) return Qnil;
1979
+ if (rb_isprint(c)) {
1980
+ char ch = (char)c;
1981
+
1982
+ return rb_locale_str_new(&ch, 1);
1983
+ }
1984
+ return UINT2NUM(c);
1985
+ }
1986
+
1987
+ struct wgetstr_arg {
1988
+ WINDOW *win;
1989
+ char rtn[GETSTR_BUF_SIZE];
1990
+ };
1991
+
1992
+ static void *
1993
+ wgetstr_func(void *_arg)
1994
+ {
1995
+ struct wgetstr_arg *arg = (struct wgetstr_arg *)_arg;
1197
1996
  #if defined(HAVE_WGETNSTR)
1198
- wgetnstr(winp->window, rtn, 1023);
1997
+ wgetnstr(arg->win, arg->rtn, GETSTR_BUF_SIZE-1);
1199
1998
  #else
1200
- wgetstr(winp->window, rtn);
1999
+ wgetstr(arg->win, arg->rtn);
1201
2000
  #endif
1202
- return rb_tainted_str_new2(rtn);
2001
+ return 0;
1203
2002
  }
1204
2003
 
1205
- /* def delch */
2004
+ /*
2005
+ * Document-method: Curses::Window.getstr
2006
+ *
2007
+ * This is equivalent to a series f Curses::Window.getch calls
2008
+ *
2009
+ */
1206
2010
  static VALUE
1207
- window_delch(obj)
1208
- VALUE obj;
2011
+ window_getstr(VALUE obj)
1209
2012
  {
1210
2013
  struct windata *winp;
1211
-
2014
+ struct wgetstr_arg arg;
2015
+
2016
+ GetWINDOW(obj, winp);
2017
+ arg.win = winp->window;
2018
+ rb_thread_call_without_gvl(wgetstr_func, (void *)&arg, RUBY_UBF_IO, 0);
2019
+ return rb_locale_str_new_cstr(arg.rtn);
2020
+ }
2021
+
2022
+ /*
2023
+ * Document-method: Curses::Window.delch
2024
+ *
2025
+ * Delete the character under the cursor
2026
+ *
2027
+ */
2028
+ static VALUE
2029
+ window_delch(VALUE obj)
2030
+ {
2031
+ struct windata *winp;
2032
+
1212
2033
  GetWINDOW(obj, winp);
1213
2034
  wdelch(winp->window);
1214
2035
  return Qnil;
1215
2036
  }
1216
2037
 
1217
- /* def delelteln */
2038
+ /*
2039
+ * Document-method: Curses::Window.deleteln
2040
+ *
2041
+ * Delete the line under the cursor.
2042
+ *
2043
+ */
1218
2044
  static VALUE
1219
- window_deleteln(obj)
1220
- VALUE obj;
2045
+ window_deleteln(VALUE obj)
1221
2046
  {
1222
2047
  #if defined(HAVE_WDELETELN) || defined(wdeleteln)
1223
2048
  struct windata *winp;
1224
-
2049
+
1225
2050
  GetWINDOW(obj, winp);
1226
2051
  wdeleteln(winp->window);
1227
2052
  #endif
1228
2053
  return Qnil;
1229
2054
  }
1230
2055
 
1231
- /* def insertln */
2056
+ /*
2057
+ * Document-method: Curses::Window.insertln
2058
+ *
2059
+ * Inserts a line above the cursor, and the bottom line is lost
2060
+ *
2061
+ */
1232
2062
  static VALUE
1233
- window_insertln(obj)
1234
- VALUE obj;
2063
+ window_insertln(VALUE obj)
1235
2064
  {
1236
2065
  #if defined(HAVE_WINSERTLN) || defined(winsertln)
1237
2066
  struct windata *winp;
1238
-
2067
+
1239
2068
  GetWINDOW(obj, winp);
1240
2069
  winsertln(winp->window);
1241
2070
  #endif
1242
2071
  return Qnil;
1243
2072
  }
1244
2073
 
2074
+ /*
2075
+ * Document-method: Curses::Window.scrollok
2076
+ * call-seq: scrollok(bool)
2077
+ *
2078
+ * Controls what happens when the cursor of a window
2079
+ * is moved off the edge of the window or scrolling region,
2080
+ * either as a result of a newline action on the bottom line,
2081
+ * or typing the last character of the last line.
2082
+ *
2083
+ * If disabled, (+bool+ is false), the cursor is left on the bottom line.
2084
+ *
2085
+ * If enabled, (+bool+ is true), the window is scrolled up one line
2086
+ * (Note that to get the physical scrolling effect on the terminal,
2087
+ * it is also necessary to call Curses::Window.idlok)
2088
+ */
1245
2089
  static VALUE
1246
2090
  window_scrollok(VALUE obj, VALUE bf)
1247
2091
  {
1248
- struct windata *winp;
2092
+ struct windata *winp;
1249
2093
 
1250
- GetWINDOW(obj, winp);
1251
- scrollok(winp->window, RTEST(bf) ? TRUE : FALSE);
1252
- return Qnil;
2094
+ GetWINDOW(obj, winp);
2095
+ scrollok(winp->window, RTEST(bf) ? TRUE : FALSE);
2096
+ return Qnil;
1253
2097
  }
1254
2098
 
2099
+ /*
2100
+ * Document-method: Curses::Window.idlok
2101
+ * call-seq: idlok(bool)
2102
+ *
2103
+ * If +bool+ is +true+ curses considers using the hardware insert/delete
2104
+ * line feature of terminals so equipped.
2105
+ *
2106
+ * If +bool+ is +false+, disables use of line insertion and deletion.
2107
+ * This option should be enabled only if the application needs insert/delete
2108
+ * line, for example, for a screen editor.
2109
+ *
2110
+ * It is disabled by default because insert/delete line tends to be visually
2111
+ * annoying when used in applications where it is not really needed.
2112
+ * If insert/delete line cannot be used, curses redraws the changed portions of all lines.
2113
+ *
2114
+ */
1255
2115
  static VALUE
1256
2116
  window_idlok(VALUE obj, VALUE bf)
1257
2117
  {
1258
- struct windata *winp;
2118
+ struct windata *winp;
1259
2119
 
1260
- GetWINDOW(obj, winp);
1261
- idlok(winp->window, RTEST(bf) ? TRUE : FALSE);
1262
- return Qnil;
2120
+ GetWINDOW(obj, winp);
2121
+ idlok(winp->window, RTEST(bf) ? TRUE : FALSE);
2122
+ return Qnil;
1263
2123
  }
1264
2124
 
2125
+ /*
2126
+ * Document-method: Curses::Window.setscrreg
2127
+ * call-seq:
2128
+ * setscrreg(top, bottom)
2129
+ *
2130
+ * Set a software scrolling region in a window.
2131
+ * +top+ and +bottom+ are lines numbers of the margin.
2132
+ *
2133
+ * If this option and Curses::Window.scrollok are enabled, an attempt to move
2134
+ * off the bottom margin line causes all lines in the scrolling region to
2135
+ * scroll one line in the direction of the first line. Only the text of the
2136
+ * window is scrolled.
2137
+ *
2138
+ */
1265
2139
  static VALUE
1266
2140
  window_setscrreg(VALUE obj, VALUE top, VALUE bottom)
1267
2141
  {
1268
2142
  #ifdef HAVE_WSETSCRREG
1269
- struct windata *winp;
1270
- int res;
2143
+ struct windata *winp;
2144
+ int res;
1271
2145
 
1272
- GetWINDOW(obj, winp);
1273
- res = wsetscrreg(winp->window, NUM2INT(top), NUM2INT(bottom));
1274
- /* may have to raise exception on ERR */
1275
- return (res == OK) ? Qtrue : Qfalse;
2146
+ GetWINDOW(obj, winp);
2147
+ res = wsetscrreg(winp->window, NUM2INT(top), NUM2INT(bottom));
2148
+ /* may have to raise exception on ERR */
2149
+ return (res == OK) ? Qtrue : Qfalse;
1276
2150
  #else
1277
- return Qfalse;
2151
+ return Qfalse;
1278
2152
  #endif
1279
2153
  }
1280
2154
 
1281
2155
  #if defined(USE_COLOR) && defined(HAVE_WCOLOR_SET)
2156
+ /*
2157
+ * Document-method: Curses::Window.color_set
2158
+ * call-seq: color_set(col)
2159
+ *
2160
+ * Sets the current color of the given window to the
2161
+ * foreground/background combination described by the Fixnum +col+.
2162
+ */
1282
2163
  static VALUE
1283
- window_color_set(VALUE obj, VALUE col)
2164
+ window_color_set(VALUE obj, VALUE col)
1284
2165
  {
1285
- struct windata *winp;
1286
- int res;
2166
+ struct windata *winp;
2167
+ int res;
1287
2168
 
1288
- GetWINDOW(obj, winp);
1289
- res = wcolor_set(winp->window, NUM2INT(col), NULL);
1290
- return (res == OK) ? Qtrue : Qfalse;
2169
+ GetWINDOW(obj, winp);
2170
+ res = wcolor_set(winp->window, NUM2INT(col), NULL);
2171
+ return (res == OK) ? Qtrue : Qfalse;
1291
2172
  }
1292
- #endif /* USE_COLOR */
2173
+ #endif /* defined(USE_COLOR) && defined(HAVE_WCOLOR_SET) */
1293
2174
 
2175
+ /*
2176
+ * Document-method: Curses::Window.scroll
2177
+ *
2178
+ * Scrolls the current window up one line.
2179
+ */
1294
2180
  static VALUE
1295
2181
  window_scroll(VALUE obj)
1296
2182
  {
1297
- struct windata *winp;
2183
+ struct windata *winp;
1298
2184
 
1299
- GetWINDOW(obj, winp);
1300
- /* may have to raise exception on ERR */
1301
- return (scroll(winp->window) == OK) ? Qtrue : Qfalse;
2185
+ GetWINDOW(obj, winp);
2186
+ /* may have to raise exception on ERR */
2187
+ return (scroll(winp->window) == OK) ? Qtrue : Qfalse;
1302
2188
  }
1303
2189
 
2190
+ /*
2191
+ * Document-method: Curses::Window.scrl
2192
+ * call-seq: scrl(num)
2193
+ *
2194
+ * Scrolls the current window Fixnum +num+ lines.
2195
+ * The current cursor position is not changed.
2196
+ *
2197
+ * For positive +num+, it scrolls up.
2198
+ *
2199
+ * For negative +num+, it scrolls down.
2200
+ *
2201
+ */
1304
2202
  static VALUE
1305
2203
  window_scrl(VALUE obj, VALUE n)
1306
2204
  {
1307
2205
  #ifdef HAVE_WSCRL
1308
- struct windata *winp;
2206
+ struct windata *winp;
1309
2207
 
1310
- GetWINDOW(obj, winp);
1311
- /* may have to raise exception on ERR */
1312
- return (wscrl(winp->window,NUM2INT(n)) == OK) ? Qtrue : Qfalse;
2208
+ GetWINDOW(obj, winp);
2209
+ /* may have to raise exception on ERR */
2210
+ return (wscrl(winp->window,NUM2INT(n)) == OK) ? Qtrue : Qfalse;
1313
2211
  #else
1314
- return Qfalse;
2212
+ return Qfalse;
1315
2213
  #endif
1316
2214
  }
1317
2215
 
2216
+ /*
2217
+ * Document-method: Curses::Window.attroff
2218
+ * call-seq: attroff(attrs)
2219
+ *
2220
+ * Turns on the named attributes +attrs+ without affecting any others.
2221
+ *
2222
+ * See also Curses::Window.attrset
2223
+ */
1318
2224
  static VALUE
1319
2225
  window_attroff(VALUE obj, VALUE attrs)
1320
2226
  {
1321
2227
  #ifdef HAVE_WATTROFF
1322
- struct windata *winp;
2228
+ struct windata *winp;
1323
2229
 
1324
- GetWINDOW(obj,winp);
1325
- return INT2FIX(wattroff(winp->window,NUM2INT(attrs)));
2230
+ GetWINDOW(obj,winp);
2231
+ return INT2FIX(wattroff(winp->window,NUM2INT(attrs)));
1326
2232
  #else
1327
- return Qtrue;
2233
+ return Qtrue;
1328
2234
  #endif
1329
2235
  }
1330
2236
 
2237
+ /*
2238
+ * Document-method: Curses::Window.attron
2239
+ * call-seq: attron(attrs)
2240
+ *
2241
+ * Turns off the named attributes +attrs+
2242
+ * without turning any other attributes on or off.
2243
+ *
2244
+ * See also Curses::Window.attrset
2245
+ */
1331
2246
  static VALUE
1332
2247
  window_attron(VALUE obj, VALUE attrs)
1333
2248
  {
1334
2249
  #ifdef HAVE_WATTRON
1335
- struct windata *winp;
1336
- VALUE val;
1337
-
1338
- GetWINDOW(obj,winp);
1339
- val = INT2FIX(wattron(winp->window,NUM2INT(attrs)));
1340
- if( rb_block_given_p() ){
1341
- rb_yield(val);
1342
- wattroff(winp->window,NUM2INT(attrs));
1343
- return val;
1344
- }
1345
- else{
1346
- return val;
1347
- }
2250
+ struct windata *winp;
2251
+ VALUE val;
2252
+
2253
+ GetWINDOW(obj,winp);
2254
+ val = INT2FIX(wattron(winp->window,NUM2INT(attrs)));
2255
+ if (rb_block_given_p()) {
2256
+ rb_yield(val);
2257
+ wattroff(winp->window,NUM2INT(attrs));
2258
+ return val;
2259
+ }
2260
+ else{
2261
+ return val;
2262
+ }
1348
2263
  #else
1349
- return Qtrue;
2264
+ return Qtrue;
1350
2265
  #endif
1351
2266
  }
1352
2267
 
2268
+ /*
2269
+ * Document-method: Curses::Window.attrset
2270
+ * call-seq: attrset(attrs)
2271
+ *
2272
+ * Sets the current attributes of the given window to +attrs+.
2273
+ *
2274
+ * The following video attributes, defined in <curses.h>, can
2275
+ * be passed to the routines Curses::Window.attron, Curses::Window.attroff,
2276
+ * and Curses::Window.attrset, or OR'd with the characters passed to addch.
2277
+ * A_NORMAL Normal display (no highlight)
2278
+ * A_STANDOUT Best highlighting mode of the terminal.
2279
+ * A_UNDERLINE Underlining
2280
+ * A_REVERSE Reverse video
2281
+ * A_BLINK Blinking
2282
+ * A_DIM Half bright
2283
+ * A_BOLD Extra bright or bold
2284
+ * A_PROTECT Protected mode
2285
+ * A_INVIS Invisible or blank mode
2286
+ * A_ALTCHARSET Alternate character set
2287
+ * A_CHARTEXT Bit-mask to extract a character
2288
+ * COLOR_PAIR(n) Color-pair number n
2289
+ *
2290
+ * TODO: provide some examples here.
2291
+ *
2292
+ * see also system manual curs_attr(3)
2293
+ */
1353
2294
  static VALUE
1354
2295
  window_attrset(VALUE obj, VALUE attrs)
1355
2296
  {
1356
2297
  #ifdef HAVE_WATTRSET
1357
- struct windata *winp;
2298
+ struct windata *winp;
1358
2299
 
1359
- GetWINDOW(obj,winp);
1360
- return INT2FIX(wattrset(winp->window,NUM2INT(attrs)));
2300
+ GetWINDOW(obj,winp);
2301
+ return INT2FIX(wattrset(winp->window,NUM2INT(attrs)));
1361
2302
  #else
1362
- return Qtrue;
2303
+ return Qtrue;
1363
2304
  #endif
1364
2305
  }
1365
2306
 
2307
+ /*
2308
+ * Document-method: Curses::Window.bkgdset
2309
+ * call-seq: bkgdset(ch)
2310
+ *
2311
+ * Manipulate the background of the current window
2312
+ * with character Integer +ch+
2313
+ *
2314
+ * see also Curses.bkgdset
2315
+ */
1366
2316
  static VALUE
1367
2317
  window_bkgdset(VALUE obj, VALUE ch)
1368
2318
  {
1369
2319
  #ifdef HAVE_WBKGDSET
1370
- struct windata *winp;
2320
+ struct windata *winp;
1371
2321
 
1372
- GetWINDOW(obj,winp);
1373
- wbkgdset(winp->window, NUM2CH(ch));
2322
+ GetWINDOW(obj,winp);
2323
+ wbkgdset(winp->window, NUM2CH(ch));
1374
2324
  #endif
1375
- return Qnil;
2325
+ return Qnil;
1376
2326
  }
1377
2327
 
2328
+ /*
2329
+ * Document-method: Curses::Window.bkgd
2330
+ * call-seq: bkgd(ch)
2331
+ *
2332
+ * Set the background of the current window
2333
+ * and apply character Integer +ch+ to every character.
2334
+ *
2335
+ * see also Curses.bkgd
2336
+ */
1378
2337
  static VALUE
1379
2338
  window_bkgd(VALUE obj, VALUE ch)
1380
2339
  {
1381
2340
  #ifdef HAVE_WBKGD
1382
- struct windata *winp;
2341
+ struct windata *winp;
1383
2342
 
1384
- GetWINDOW(obj,winp);
1385
- return (wbkgd(winp->window, NUM2CH(ch)) == OK) ? Qtrue : Qfalse;
2343
+ GetWINDOW(obj,winp);
2344
+ return (wbkgd(winp->window, NUM2CH(ch)) == OK) ? Qtrue : Qfalse;
1386
2345
  #else
1387
- return Qfalse;
2346
+ return Qfalse;
1388
2347
  #endif
1389
2348
  }
1390
2349
 
2350
+ /*
2351
+ * Document-method: Curses::Window.getbkgd
2352
+ *
2353
+ * Returns an Integer (+ch+) for the character property in the current window.
2354
+ */
1391
2355
  static VALUE
1392
2356
  window_getbkgd(VALUE obj)
1393
2357
  {
1394
2358
  #ifdef HAVE_WGETBKGD
1395
- chtype c;
1396
- struct windata *winp;
2359
+ chtype c;
2360
+ struct windata *winp;
1397
2361
 
1398
- GetWINDOW(obj,winp);
1399
- return (c = getbkgd(winp->window) != ERR) ? CH2FIX(c) : Qnil;
2362
+ GetWINDOW(obj,winp);
2363
+ return (c = getbkgd(winp->window) != ERR) ? CH2FIX(c) : Qnil;
1400
2364
  #else
1401
- return Qnil;
2365
+ return Qnil;
1402
2366
  #endif
1403
2367
  }
1404
2368
 
2369
+ /*
2370
+ * Document-method: Curses::Window.resize
2371
+ * call-seq: resize(lines, cols)
2372
+ *
2373
+ * Resize the current window to Fixnum +lines+ and Fixnum +cols+
2374
+ *
2375
+ */
1405
2376
  static VALUE
1406
2377
  window_resize(VALUE obj, VALUE lin, VALUE col)
1407
2378
  {
1408
2379
  #if defined(HAVE_WRESIZE)
1409
- struct windata *winp;
2380
+ struct windata *winp;
1410
2381
 
1411
- GetWINDOW(obj,winp);
1412
- return wresize(winp->window, NUM2INT(lin), NUM2INT(col)) == OK ? Qtrue : Qfalse;
2382
+ GetWINDOW(obj,winp);
2383
+ return wresize(winp->window, NUM2INT(lin), NUM2INT(col)) == OK ? Qtrue : Qfalse;
1413
2384
  #else
1414
- return Qnil;
2385
+ return Qnil;
1415
2386
  #endif
1416
2387
  }
1417
2388
 
1418
2389
 
2390
+ #ifdef HAVE_KEYPAD
2391
+ /*
2392
+ * Document-method: Curses::Window.keypad=
2393
+ * call-seq:
2394
+ * keypad=(bool)
2395
+ *
2396
+ * See Curses::Window.keypad
2397
+ */
2398
+
2399
+ /*
2400
+ * Document-method: Curses::Window.keypad
2401
+ * call-seq:
2402
+ * keypad(bool)
2403
+ *
2404
+ * Enables the keypad of the user's terminal.
2405
+ *
2406
+ * If enabled (+bool+ is +true+), the user can press a function key
2407
+ * (such as an arrow key) and wgetch returns a single value representing
2408
+ * the function key, as in KEY_LEFT. If disabled (+bool+ is +false+),
2409
+ * curses does not treat function keys specially and the program has to
2410
+ * interpret the escape sequences itself. If the keypad in the terminal
2411
+ * can be turned on (made to transmit) and off (made to work locally),
2412
+ * turning on this option causes the terminal keypad to be turned on when
2413
+ * Curses::Window.getch is called.
2414
+ *
2415
+ * The default value for keypad is false.
2416
+ *
2417
+ */
1419
2418
  static VALUE
1420
2419
  window_keypad(VALUE obj, VALUE val)
1421
2420
  {
1422
- #ifdef HAVE_KEYPAD
1423
- struct windata *winp;
2421
+ struct windata *winp;
1424
2422
 
1425
- GetWINDOW(obj,winp);
1426
- /* keypad() of NetBSD's libcurses returns no value */
2423
+ GetWINDOW(obj,winp);
2424
+ /* keypad() of NetBSD's libcurses returns no value */
1427
2425
  #if defined(__NetBSD__) && !defined(NCURSES_VERSION)
1428
- keypad(winp->window,(RTEST(val) ? TRUE : FALSE));
1429
- return Qnil;
2426
+ keypad(winp->window,(RTEST(val) ? TRUE : FALSE));
2427
+ return Qnil;
1430
2428
  #else
1431
- /* may have to raise exception on ERR */
1432
- return (keypad(winp->window,RTEST(val) ? TRUE : FALSE)) == OK ?
1433
- Qtrue : Qfalse;
2429
+ /* may have to raise exception on ERR */
2430
+ return (keypad(winp->window,RTEST(val) ? TRUE : FALSE)) == OK ?
2431
+ Qtrue : Qfalse;
1434
2432
  #endif
1435
- #else
1436
- rb_notimplement();
1437
- #endif /* HAVE_KEYPAD */
1438
2433
  }
2434
+ #else
2435
+ #define window_keypad rb_f_notimplement
2436
+ #endif
1439
2437
 
2438
+ #ifdef HAVE_NODELAY
2439
+ /*
2440
+ * Document-method: Curses::Window.nodelay
2441
+ * call-seq:
2442
+ * window.nodelay = bool
2443
+ *
2444
+ * When in no-delay mode Curses::Window#getch is a non-blocking call. If no
2445
+ * input is ready #getch returns ERR.
2446
+ *
2447
+ * When in delay mode (+bool+ is +false+ which is the default),
2448
+ * Curses::Window#getch blocks until a key is pressed.
2449
+ *
2450
+ */
1440
2451
  static VALUE
1441
2452
  window_nodelay(VALUE obj, VALUE val)
1442
2453
  {
1443
- #ifdef HAVE_NODELAY
1444
- struct windata *winp;
1445
- GetWINDOW(obj,winp);
2454
+ struct windata *winp;
2455
+ GetWINDOW(obj,winp);
1446
2456
 
1447
- /* nodelay() of NetBSD's libcurses returns no value */
2457
+ /* nodelay() of NetBSD's libcurses returns no value */
1448
2458
  #if defined(__NetBSD__) && !defined(NCURSES_VERSION)
1449
- nodelay(winp->window, RTEST(val) ? TRUE : FALSE);
1450
- return Qnil;
2459
+ nodelay(winp->window, RTEST(val) ? TRUE : FALSE);
2460
+ return Qnil;
1451
2461
  #else
1452
- return nodelay(winp->window,RTEST(val) ? TRUE : FALSE) == OK ? Qtrue : Qfalse;
2462
+ return nodelay(winp->window,RTEST(val) ? TRUE : FALSE) == OK ? Qtrue : Qfalse;
1453
2463
  #endif
2464
+ }
1454
2465
  #else
1455
- rb_notimplement();
2466
+ #define window_nodelay rb_f_notimplement
1456
2467
  #endif
1457
- }
1458
2468
 
2469
+ #ifdef HAVE_WTIMEOUT
2470
+ /*
2471
+ * Document-method: Curses::Window.timeout=
2472
+ * call-seq: timeout=(delay)
2473
+ *
2474
+ * Sets block and non-blocking reads for the window.
2475
+ * - If delay is negative, blocking read is used (i.e., waits indefinitely for input).
2476
+ * - If delay is zero, then non-blocking read is used (i.e., read returns ERR if no input is waiting).
2477
+ * - If delay is positive, then read blocks for delay milliseconds, and returns ERR if there is still no input.
2478
+ *
2479
+ */
1459
2480
  static VALUE
1460
2481
  window_timeout(VALUE obj, VALUE delay)
1461
2482
  {
1462
- #ifdef HAVE_WTIMEOUT
1463
- struct windata *winp;
1464
- GetWINDOW(obj,winp);
2483
+ struct windata *winp;
2484
+ GetWINDOW(obj,winp);
2485
+
2486
+ wtimeout(winp->window,NUM2INT(delay));
2487
+ return Qnil;
2488
+ }
2489
+ #else
2490
+ #define window_timeout rb_f_notimplement
2491
+ #endif
2492
+
2493
+ /*--------------------------- class Pad ----------------------------*/
2494
+
2495
+ #ifdef HAVE_NEWPAD
2496
+ /*
2497
+ * Document-method: Curses::Pad.new
2498
+ *
2499
+ * call-seq:
2500
+ * new(height, width)
2501
+ *
2502
+ * Construct a new Curses::Pad with constraints of +height+ lines, +width+
2503
+ * columns
2504
+ *
2505
+ */
2506
+ static VALUE
2507
+ pad_initialize(VALUE obj, VALUE h, VALUE w)
2508
+ {
2509
+ struct windata *padp;
2510
+ WINDOW *window;
2511
+
2512
+ curses_init_screen();
2513
+ TypedData_Get_Struct(obj, struct windata, &windata_type, padp);
2514
+ if (padp->window) delwin(padp->window);
2515
+ window = newpad(NUM2INT(h), NUM2INT(w));
2516
+ wclear(window);
2517
+ padp->window = window;
2518
+
2519
+ return obj;
2520
+ }
1465
2521
 
1466
- wtimeout(winp->window,NUM2INT(delay));
1467
- return Qnil;
2522
+ #if 1
2523
+ #define pad_subpad window_subwin
1468
2524
  #else
1469
- rb_notimplement();
2525
+ /*
2526
+ * Document-method: Curses::Pad.subpad
2527
+ * call-seq:
2528
+ * subpad(height, width, begin_x, begin_y)
2529
+ *
2530
+ * Construct a new subpad with constraints of +height+ lines, +width+ columns,
2531
+ * begin at +begin_x+ line, and +begin_y+ columns on the pad.
2532
+ *
2533
+ */
2534
+ static VALUE
2535
+ pad_subpad(VALUE obj, VALUE height, VALUE width, VALUE begin_x, VALUE begin_y)
2536
+ {
2537
+ struct windata *padp;
2538
+ WINDOW *subpad;
2539
+ VALUE pad;
2540
+ int h, w, x, y;
2541
+
2542
+ h = NUM2INT(height);
2543
+ w = NUM2INT(width);
2544
+ x = NUM2INT(begin_x);
2545
+ y = NUM2INT(begin_y);
2546
+ GetWINDOW(obj, padp);
2547
+ subpad = subwin(padp->window, h, w, x, y);
2548
+ pad = prep_window(rb_obj_class(obj), subpad);
2549
+
2550
+ return pad;
2551
+ }
1470
2552
  #endif
2553
+
2554
+ /*
2555
+ * Document-method: Curses::Pad.refresh
2556
+ *
2557
+ * call-seq:
2558
+ * pad.refresh(pad_minrow, pad_mincol, screen_minrow, screen_mincol, screen_maxrow, screen_maxcol)
2559
+ *
2560
+ * Refreshes the pad. +pad_minrow+ and pad_mincol+ define the upper-left
2561
+ * corner of the rectangle to be displayed. +screen_minrow+, +screen_mincol+,
2562
+ * +screen_maxrow+, +screen_maxcol+ define the edges of the rectangle to be
2563
+ * displayed on the screen.
2564
+ *
2565
+ */
2566
+ static VALUE
2567
+ pad_refresh(VALUE obj, VALUE pminrow, VALUE pmincol, VALUE sminrow,
2568
+ VALUE smincol, VALUE smaxrow, VALUE smaxcol)
2569
+ {
2570
+ struct windata *padp;
2571
+ int pmr, pmc, smr, smc, sxr, sxc;
2572
+
2573
+ pmr = NUM2INT(pminrow);
2574
+ pmc = NUM2INT(pmincol);
2575
+ smr = NUM2INT(sminrow);
2576
+ smc = NUM2INT(smincol);
2577
+ sxr = NUM2INT(smaxrow);
2578
+ sxc = NUM2INT(smaxcol);
2579
+
2580
+ GetWINDOW(obj, padp);
2581
+ prefresh(padp->window, pmr, pmc, smr, smc, sxr, sxc);
2582
+
2583
+ return Qnil;
1471
2584
  }
1472
2585
 
2586
+ /*
2587
+ * Document-method: Curses::Pad.noutrefresh
2588
+ *
2589
+ * call-seq:
2590
+ * pad.noutrefresh(pad_minrow, pad_mincol, screen_minrow, screen_mincol, screen_maxrow, screen_maxcol)
2591
+ *
2592
+ * Refreshes the pad. +pad_minrow+ and pad_mincol+ define the upper-left
2593
+ * corner of the rectangle to be displayed. +screen_minrow+, +screen_mincol+,
2594
+ * +screen_maxrow+, +screen_maxcol+ define the edges of the rectangle to be
2595
+ * displayed on the screen.
2596
+ *
2597
+ */
2598
+ static VALUE
2599
+ pad_noutrefresh(VALUE obj, VALUE pminrow, VALUE pmincol, VALUE sminrow,
2600
+ VALUE smincol, VALUE smaxrow, VALUE smaxcol)
2601
+ {
2602
+ struct windata *padp;
2603
+ int pmr, pmc, smr, smc, sxr, sxc;
2604
+
2605
+ pmr = NUM2INT(pminrow);
2606
+ pmc = NUM2INT(pmincol);
2607
+ smr = NUM2INT(sminrow);
2608
+ smc = NUM2INT(smincol);
2609
+ sxr = NUM2INT(smaxrow);
2610
+ sxc = NUM2INT(smaxcol);
2611
+
2612
+ GetWINDOW(obj, padp);
2613
+ #ifdef HAVE_DOUPDATE
2614
+ pnoutrefresh(padp->window, pmr, pmc, smr, smc, sxr, sxc);
2615
+ #else
2616
+ prefresh(padp->window, pmr, pmc, smr, smc, sxr, sxc);
2617
+ #endif
2618
+
2619
+ return Qnil;
2620
+ }
2621
+ #endif /* HAVE_NEWPAD */
2622
+
1473
2623
  /*------------------------- Initialization -------------------------*/
2624
+
2625
+ /*
2626
+ * Document-module: Curses
2627
+ *
2628
+ * == Description
2629
+ * An implementation of the CRT screen handling and optimization library.
2630
+ *
2631
+ * == Structures and such
2632
+ *
2633
+ * === Classes
2634
+ *
2635
+ * * Curses::Window - class with the means to draw a window or box
2636
+ * * Curses::MouseEvent - class for collecting mouse events
2637
+ *
2638
+ * === Modules
2639
+ *
2640
+ * Curses:: The curses implementation
2641
+ * Curses::Key:: Collection of constants for keypress events
2642
+ *
2643
+ * == Examples
2644
+ *
2645
+ * * hello.rb
2646
+ * :include: sample/curses/hello.rb
2647
+ *
2648
+ *
2649
+ * * rain.rb
2650
+ * :include: sample/curses/rain.rb
2651
+ *
2652
+ *
2653
+ */
1474
2654
  void
1475
- Init_curses()
2655
+ Init_curses(void)
1476
2656
  {
1477
2657
  mCurses = rb_define_module("Curses");
2658
+
2659
+ /*
2660
+ * Document-module: Curses::Key
2661
+ *
2662
+ *
2663
+ * a container for the KEY_* values.
2664
+ *
2665
+ * See also system manual for getch(3)
2666
+ *
2667
+ */
1478
2668
  mKey = rb_define_module_under(mCurses, "Key");
1479
2669
 
1480
2670
  rb_gc_register_address(&rb_stdscr);
1481
2671
 
1482
2672
  #ifdef USE_MOUSE
2673
+ /*
2674
+ * Document-class: Curses::MouseEvent
2675
+ *
2676
+ * == Description
2677
+ *
2678
+ * Curses::MouseEvent
2679
+ *
2680
+ * == Example
2681
+ *
2682
+ * * mouse.rb
2683
+ * :include: sample/curses/mouse.rb
2684
+ *
2685
+ */
1483
2686
  cMouseEvent = rb_define_class_under(mCurses,"MouseEvent",rb_cObject);
1484
2687
  rb_undef_method(CLASS_OF(cMouseEvent),"new");
1485
2688
  rb_define_method(cMouseEvent, "eid", curs_mouse_id, 0);
@@ -1489,6 +2692,12 @@ Init_curses()
1489
2692
  rb_define_method(cMouseEvent, "bstate", curs_mouse_bstate, 0);
1490
2693
  #endif /* USE_MOUSE */
1491
2694
 
2695
+ rb_define_module_function(mCurses, "ESCDELAY=", curses_escdelay_set, 1);
2696
+ rb_define_module_function(mCurses, "ESCDELAY", curses_escdelay_get, 0);
2697
+ rb_define_module_function(mCurses, "TABSIZE", curses_tabsize_get, 0);
2698
+ rb_define_module_function(mCurses, "TABSIZE=", curses_tabsize_set, 1);
2699
+
2700
+ rb_define_module_function(mCurses, "use_default_colors", curses_use_default_colors, 0);
1492
2701
  rb_define_module_function(mCurses, "init_screen", curses_init_screen, 0);
1493
2702
  rb_define_module_function(mCurses, "close_screen", curses_close_screen, 0);
1494
2703
  rb_define_module_function(mCurses, "closed?", curses_closed, 0);
@@ -1503,8 +2712,8 @@ Init_curses()
1503
2712
  rb_define_module_function(mCurses, "noraw", curses_noraw, 0);
1504
2713
  rb_define_module_function(mCurses, "cbreak", curses_cbreak, 0);
1505
2714
  rb_define_module_function(mCurses, "nocbreak", curses_nocbreak, 0);
1506
- rb_define_alias(mCurses, "crmode", "cbreak");
1507
- rb_define_alias(mCurses, "nocrmode", "nocbreak");
2715
+ rb_define_module_function(mCurses, "crmode", curses_cbreak, 0);
2716
+ rb_define_module_function(mCurses, "nocrmode", curses_nocbreak, 0);
1508
2717
  rb_define_module_function(mCurses, "nl", curses_nl, 0);
1509
2718
  rb_define_module_function(mCurses, "nonl", curses_nonl, 0);
1510
2719
  rb_define_module_function(mCurses, "beep", curses_beep, 0);
@@ -1542,7 +2751,9 @@ Init_curses()
1542
2751
  rb_define_module_function(mCurses, "has_colors?", curses_has_colors, 0);
1543
2752
  rb_define_module_function(mCurses, "can_change_color?",
1544
2753
  curses_can_change_color, 0);
2754
+ rb_define_module_function(mCurses, "colors", curses_colors, 0);
1545
2755
  rb_define_module_function(mCurses, "color_content", curses_color_content, 1);
2756
+ rb_define_module_function(mCurses, "color_pairs", curses_color_pairs, 0);
1546
2757
  rb_define_module_function(mCurses, "pair_content", curses_pair_content, 1);
1547
2758
  rb_define_module_function(mCurses, "color_pair", curses_color_pair, 1);
1548
2759
  rb_define_module_function(mCurses, "pair_number", curses_pair_number, 1);
@@ -1558,6 +2769,66 @@ Init_curses()
1558
2769
  rb_define_module_function(mCurses, "def_prog_mode", curses_def_prog_mode, 0);
1559
2770
  rb_define_module_function(mCurses, "reset_prog_mode", curses_reset_prog_mode, 0);
1560
2771
 
2772
+ {
2773
+ VALUE version;
2774
+ #if defined(HAVE_FUNC_CURSES_VERSION)
2775
+ /* ncurses and PDcurses */
2776
+ version = rb_str_new2(curses_version());
2777
+ #elif defined(HAVE_VAR_CURSES_VERSION)
2778
+ /* SVR4 curses has an undocumented and undeclared variable, curses_version.
2779
+ * It contains a string, "SVR4". */
2780
+ RUBY_EXTERN char *curses_version;
2781
+ version = rb_sprintf("curses (%s)", curses_version);
2782
+ #else
2783
+ /* BSD curses, perhaps. NetBSD 5 still use it. */
2784
+ version = rb_str_new2("curses (unknown)");
2785
+ #endif
2786
+ /*
2787
+ * Identifies curses library version.
2788
+ *
2789
+ * - "ncurses 5.9.20110404"
2790
+ * - "PDCurses 3.4 - Public Domain 2008"
2791
+ * - "curses (SVR4)" (System V curses)
2792
+ * - "curses (unknown)" (The original BSD curses? NetBSD maybe.)
2793
+ *
2794
+ */
2795
+ rb_define_const(mCurses, "VERSION", version);
2796
+ }
2797
+
2798
+ /*
2799
+ * Document-class: Curses::Window
2800
+ *
2801
+ * == Description
2802
+ *
2803
+ * The means by which to create and manage frames or windows.
2804
+ * While there may be more than one window at a time, only one window
2805
+ * will receive input.
2806
+ *
2807
+ * == Usage
2808
+ *
2809
+ * require 'curses'
2810
+ *
2811
+ * Curses.init_screen()
2812
+ *
2813
+ * my_str = "LOOK! PONIES!"
2814
+ * bwin = Curses::Window.new( 10, (my_str.length + 10),
2815
+ * (Curses.lines - 10) / 2,
2816
+ * (Curses.cols - (my_str.length + 10)) / 2 )
2817
+ * bwin.box("\\", "/")
2818
+ * bwin.refresh
2819
+ * win = bwin.subwin( 6, my_str.length + 6,
2820
+ * (Curses.lines - 6) / 2,
2821
+ * (Curses.cols - (my_str.length + 6)) / 2 )
2822
+ * win.setpos(2,3)
2823
+ * win.addstr(my_str)
2824
+ * # or even
2825
+ * win << "\nORLY"
2826
+ * win << "\nYES!! " + my_str
2827
+ * win.refresh
2828
+ * win.getch
2829
+ * win.close
2830
+ *
2831
+ */
1561
2832
  cWindow = rb_define_class_under(mCurses, "Window", rb_cData);
1562
2833
  rb_define_alloc_func(cWindow, window_s_allocate);
1563
2834
  rb_define_method(cWindow, "initialize", window_initialize, 4);
@@ -1610,523 +2881,1448 @@ Init_curses()
1610
2881
  rb_define_method(cWindow, "nodelay=", window_nodelay, 1);
1611
2882
  rb_define_method(cWindow, "timeout=", window_timeout, 1);
1612
2883
 
2884
+ #ifdef HAVE_NEWPAD
2885
+ /*
2886
+ * Document-class: Curses::Pad
2887
+ *
2888
+ * == Description
2889
+ *
2890
+ * A Pad is like a Window but allows for scrolling of contents that cannot
2891
+ * fit on the screen. Pads do not refresh automatically, use Pad#refresh
2892
+ * or Pad#noutrefresh instead.
2893
+ *
2894
+ */
2895
+ cPad = rb_define_class_under(mCurses, "Pad", cWindow);
2896
+ /* inherits alloc_func from cWindow */
2897
+ rb_define_method(cPad, "initialize", pad_initialize, 2);
2898
+ rb_define_method(cPad, "subpad", pad_subpad, 4);
2899
+ rb_define_method(cPad, "refresh", pad_refresh, 6);
2900
+ rb_define_method(cPad, "noutrefresh", pad_noutrefresh, 6);
2901
+ rb_undef_method(cPad, "subwin");
2902
+ #endif
2903
+
1613
2904
  #define rb_curses_define_const(c) rb_define_const(mCurses,#c,UINT2NUM(c))
1614
2905
 
1615
2906
  #ifdef USE_COLOR
2907
+ /* Document-const: A_ATTRIBUTES
2908
+ *
2909
+ * Character attribute mask:
2910
+ * Bit-mask to extract attributes
2911
+ *
2912
+ * See Curses.inch or Curses::Window.inch
2913
+ */
1616
2914
  rb_curses_define_const(A_ATTRIBUTES);
1617
2915
  #ifdef A_NORMAL
2916
+ /* Document-const: A_NORMAL
2917
+ *
2918
+ * Attribute mask:
2919
+ * Normal display (no highlight)
2920
+ *
2921
+ * See Curses.attrset
2922
+ */
1618
2923
  rb_curses_define_const(A_NORMAL);
1619
2924
  #endif
2925
+ /* Document-const: A_STANDOUT
2926
+ *
2927
+ * Attribute mask:
2928
+ * Best highlighting mode of the terminal.
2929
+ *
2930
+ * See Curses.attrset
2931
+ */
1620
2932
  rb_curses_define_const(A_STANDOUT);
2933
+ /* Document-const: A_UNDERLINE
2934
+ *
2935
+ * Attribute mask:
2936
+ * Underlining
2937
+ *
2938
+ * See Curses.attrset
2939
+ */
1621
2940
  rb_curses_define_const(A_UNDERLINE);
2941
+ /* Document-const: A_REVERSE
2942
+ *
2943
+ * Attribute mask:
2944
+ * Reverse video
2945
+ *
2946
+ * See Curses.attrset
2947
+ */
1622
2948
  rb_curses_define_const(A_REVERSE);
2949
+ /* Document-const: A_BLINK
2950
+ *
2951
+ * Attribute mask:
2952
+ * Blinking
2953
+ *
2954
+ * See Curses.attrset
2955
+ */
1623
2956
  rb_curses_define_const(A_BLINK);
2957
+ /* Document-const: A_DIM
2958
+ *
2959
+ * Attribute mask:
2960
+ * Half bright
2961
+ *
2962
+ * See Curses.attrset
2963
+ */
1624
2964
  rb_curses_define_const(A_DIM);
2965
+ /* Document-const: A_BOLD
2966
+ *
2967
+ * Attribute mask:
2968
+ * Extra bright or bold
2969
+ *
2970
+ * See Curses.attrset
2971
+ */
1625
2972
  rb_curses_define_const(A_BOLD);
2973
+ /* Document-const: A_PROTECT
2974
+ *
2975
+ * Attribute mask:
2976
+ * Protected mode
2977
+ *
2978
+ * See Curses.attrset
2979
+ */
1626
2980
  rb_curses_define_const(A_PROTECT);
1627
2981
  #ifdef A_INVIS /* for NetBSD */
2982
+ /* Document-const: A_INVIS
2983
+ *
2984
+ * Attribute mask:
2985
+ * Invisible or blank mode
2986
+ *
2987
+ * See Curses.attrset
2988
+ */
1628
2989
  rb_curses_define_const(A_INVIS);
1629
2990
  #endif
2991
+ /* Document-const: A_ALTCHARSET
2992
+ *
2993
+ * Attribute mask:
2994
+ * Alternate character set
2995
+ *
2996
+ * See Curses.attrset
2997
+ */
1630
2998
  rb_curses_define_const(A_ALTCHARSET);
2999
+ /* Document-const: A_CHARTEXT
3000
+ *
3001
+ * Attribute mask:
3002
+ * Bit-mask to extract a character
3003
+ *
3004
+ * See Curses.attrset
3005
+ */
1631
3006
  rb_curses_define_const(A_CHARTEXT);
1632
3007
  #ifdef A_HORIZONTAL
3008
+ /* Document-const: A_HORIZONTAL
3009
+ *
3010
+ * Attribute mask:
3011
+ * horizontal highlight
3012
+ *
3013
+ * Check system curs_attr(3x) for support
3014
+ */
1633
3015
  rb_curses_define_const(A_HORIZONTAL);
1634
3016
  #endif
1635
3017
  #ifdef A_LEFT
3018
+ /* Document-const: A_LEFT
3019
+ *
3020
+ * Attribute mask:
3021
+ * left highlight
3022
+ *
3023
+ * Check system curs_attr(3x) for support
3024
+ */
1636
3025
  rb_curses_define_const(A_LEFT);
1637
3026
  #endif
1638
3027
  #ifdef A_LOW
3028
+ /* Document-const: A_LOW
3029
+ *
3030
+ * Attribute mask:
3031
+ * low highlight
3032
+ *
3033
+ * Check system curs_attr(3x) for support
3034
+ */
1639
3035
  rb_curses_define_const(A_LOW);
1640
3036
  #endif
1641
3037
  #ifdef A_RIGHT
3038
+ /* Document-const: A_RIGHT
3039
+ *
3040
+ * Attribute mask:
3041
+ * right highlight
3042
+ *
3043
+ * Check system curs_attr(3x) for support
3044
+ */
1642
3045
  rb_curses_define_const(A_RIGHT);
1643
3046
  #endif
1644
3047
  #ifdef A_TOP
3048
+ /* Document-const: A_TOP
3049
+ *
3050
+ * Attribute mask:
3051
+ * top highlight
3052
+ *
3053
+ * Check system curs_attr(3x) for support
3054
+ */
1645
3055
  rb_curses_define_const(A_TOP);
1646
3056
  #endif
1647
3057
  #ifdef A_VERTICAL
3058
+ /* Document-const: A_VERTICAL
3059
+ *
3060
+ * Attribute mask:
3061
+ * vertical highlight
3062
+ *
3063
+ * Check system curs_attr(3x) for support
3064
+ */
1648
3065
  rb_curses_define_const(A_VERTICAL);
1649
3066
  #endif
3067
+ /* Document-const: A_COLOR
3068
+ *
3069
+ * Character attribute mask:
3070
+ * Bit-mask to extract color-pair field information
3071
+ *
3072
+ * See Curses.inch or Curses::Window.inch
3073
+ */
1650
3074
  rb_curses_define_const(A_COLOR);
1651
3075
 
1652
3076
  #ifdef COLORS
3077
+ /*
3078
+ * Document-const: Curses::COLORS
3079
+ *
3080
+ * Number of the colors available
3081
+ */
1653
3082
  rb_curses_define_const(COLORS);
1654
3083
  #endif
3084
+ /*
3085
+ * Document-const: Curses::COLOR_BLACK
3086
+ *
3087
+ * Value of the color black
3088
+ */
1655
3089
  rb_curses_define_const(COLOR_BLACK);
3090
+ /*
3091
+ * Document-const: COLOR_RED
3092
+ *
3093
+ * Value of the color red
3094
+ */
1656
3095
  rb_curses_define_const(COLOR_RED);
3096
+ /*
3097
+ * Document-const: COLOR_GREEN
3098
+ *
3099
+ * Value of the color green
3100
+ */
1657
3101
  rb_curses_define_const(COLOR_GREEN);
3102
+ /*
3103
+ * Document-const: COLOR_YELLOW
3104
+ *
3105
+ * Value of the color yellow
3106
+ */
1658
3107
  rb_curses_define_const(COLOR_YELLOW);
3108
+ /*
3109
+ * Document-const: COLOR_BLUE
3110
+ *
3111
+ * Value of the color blue
3112
+ */
1659
3113
  rb_curses_define_const(COLOR_BLUE);
3114
+ /*
3115
+ * Document-const: COLOR_MAGENTA
3116
+ *
3117
+ * Value of the color magenta
3118
+ */
1660
3119
  rb_curses_define_const(COLOR_MAGENTA);
3120
+ /*
3121
+ * Document-const: COLOR_CYAN
3122
+ *
3123
+ * Value of the color cyan
3124
+ */
1661
3125
  rb_curses_define_const(COLOR_CYAN);
3126
+ /*
3127
+ * Document-const: COLOR_WHITE
3128
+ *
3129
+ * Value of the color white
3130
+ */
1662
3131
  rb_curses_define_const(COLOR_WHITE);
1663
3132
  #endif /* USE_COLOR */
1664
3133
  #ifdef USE_MOUSE
1665
3134
  #ifdef BUTTON1_PRESSED
3135
+ /* Document-const: BUTTON1_PRESSED
3136
+ *
3137
+ * Mouse event mask:
3138
+ * mouse button 1 down
3139
+ *
3140
+ * See Curses.getmouse
3141
+ */
1666
3142
  rb_curses_define_const(BUTTON1_PRESSED);
1667
3143
  #endif
1668
3144
  #ifdef BUTTON1_RELEASED
3145
+ /* Document-const: BUTTON1_RELEASED
3146
+ *
3147
+ * Mouse event mask:
3148
+ * mouse button 1 up
3149
+ *
3150
+ * See Curses.getmouse
3151
+ */
1669
3152
  rb_curses_define_const(BUTTON1_RELEASED);
1670
3153
  #endif
1671
3154
  #ifdef BUTTON1_CLICKED
3155
+ /* Document-const: BUTTON1_CLICKED
3156
+ *
3157
+ * Mouse event mask:
3158
+ * mouse button 1 clicked
3159
+ *
3160
+ * See Curses.getmouse
3161
+ */
1672
3162
  rb_curses_define_const(BUTTON1_CLICKED);
1673
3163
  #endif
1674
3164
  #ifdef BUTTON1_DOUBLE_CLICKED
3165
+ /* Document-const: BUTTON1_DOUBLE_CLICKED
3166
+ *
3167
+ * Mouse event mask:
3168
+ * mouse button 1 double clicked
3169
+ *
3170
+ * See Curses.getmouse
3171
+ */
1675
3172
  rb_curses_define_const(BUTTON1_DOUBLE_CLICKED);
1676
3173
  #endif
1677
3174
  #ifdef BUTTON1_TRIPLE_CLICKED
3175
+ /* Document-const: BUTTON1_TRIPLE_CLICKED
3176
+ *
3177
+ * Mouse event mask:
3178
+ * mouse button 1 triple clicked
3179
+ *
3180
+ * See Curses.getmouse
3181
+ */
1678
3182
  rb_curses_define_const(BUTTON1_TRIPLE_CLICKED);
1679
3183
  #endif
1680
3184
  #ifdef BUTTON2_PRESSED
3185
+ /* Document-const: BUTTON2_PRESSED
3186
+ *
3187
+ * Mouse event mask:
3188
+ * mouse button 2 down
3189
+ *
3190
+ * See Curses.getmouse
3191
+ */
1681
3192
  rb_curses_define_const(BUTTON2_PRESSED);
1682
3193
  #endif
1683
3194
  #ifdef BUTTON2_RELEASED
3195
+ /* Document-const: BUTTON2_RELEASED
3196
+ *
3197
+ * Mouse event mask:
3198
+ * mouse button 2 up
3199
+ *
3200
+ * See Curses.getmouse
3201
+ */
1684
3202
  rb_curses_define_const(BUTTON2_RELEASED);
1685
3203
  #endif
1686
3204
  #ifdef BUTTON2_CLICKED
3205
+ /* Document-const: BUTTON2_CLICKED
3206
+ *
3207
+ * Mouse event mask:
3208
+ * mouse button 2 clicked
3209
+ *
3210
+ * See Curses.getmouse
3211
+ */
1687
3212
  rb_curses_define_const(BUTTON2_CLICKED);
1688
3213
  #endif
1689
3214
  #ifdef BUTTON2_DOUBLE_CLICKED
3215
+ /* Document-const: BUTTON2_DOUBLE_CLICKED
3216
+ *
3217
+ * Mouse event mask:
3218
+ * mouse button 2 double clicked
3219
+ *
3220
+ * See Curses.getmouse
3221
+ */
1690
3222
  rb_curses_define_const(BUTTON2_DOUBLE_CLICKED);
1691
3223
  #endif
1692
3224
  #ifdef BUTTON2_TRIPLE_CLICKED
3225
+ /* Document-const: BUTTON2_TRIPLE_CLICKED
3226
+ *
3227
+ * Mouse event mask:
3228
+ * mouse button 2 triple clicked
3229
+ *
3230
+ * See Curses.getmouse
3231
+ */
1693
3232
  rb_curses_define_const(BUTTON2_TRIPLE_CLICKED);
1694
3233
  #endif
1695
3234
  #ifdef BUTTON3_PRESSED
3235
+ /* Document-const: BUTTON3_PRESSED
3236
+ *
3237
+ * Mouse event mask:
3238
+ * mouse button 3 down
3239
+ *
3240
+ * See Curses.getmouse
3241
+ */
1696
3242
  rb_curses_define_const(BUTTON3_PRESSED);
1697
3243
  #endif
1698
3244
  #ifdef BUTTON3_RELEASED
3245
+ /* Document-const: BUTTON3_RELEASED
3246
+ *
3247
+ * Mouse event mask:
3248
+ * mouse button 3 up
3249
+ *
3250
+ * See Curses.getmouse
3251
+ */
1699
3252
  rb_curses_define_const(BUTTON3_RELEASED);
1700
3253
  #endif
1701
3254
  #ifdef BUTTON3_CLICKED
3255
+ /* Document-const: BUTTON3_CLICKED
3256
+ *
3257
+ * Mouse event mask:
3258
+ * mouse button 3 clicked
3259
+ *
3260
+ * See Curses.getmouse
3261
+ */
1702
3262
  rb_curses_define_const(BUTTON3_CLICKED);
1703
3263
  #endif
1704
3264
  #ifdef BUTTON3_DOUBLE_CLICKED
3265
+ /* Document-const: BUTTON3_DOUBLE_CLICKED
3266
+ *
3267
+ * Mouse event mask:
3268
+ * mouse button 3 double clicked
3269
+ *
3270
+ * See Curses.getmouse
3271
+ */
1705
3272
  rb_curses_define_const(BUTTON3_DOUBLE_CLICKED);
1706
3273
  #endif
1707
3274
  #ifdef BUTTON3_TRIPLE_CLICKED
3275
+ /* Document-const: BUTTON3_TRIPLE_CLICKED
3276
+ *
3277
+ * Mouse event mask:
3278
+ * mouse button 3 triple clicked
3279
+ *
3280
+ * See Curses.getmouse
3281
+ */
1708
3282
  rb_curses_define_const(BUTTON3_TRIPLE_CLICKED);
1709
3283
  #endif
1710
3284
  #ifdef BUTTON4_PRESSED
3285
+ /* Document-const: BUTTON4_PRESSED
3286
+ *
3287
+ * Mouse event mask:
3288
+ * mouse button 4 down
3289
+ *
3290
+ * See Curses.getmouse
3291
+ */
1711
3292
  rb_curses_define_const(BUTTON4_PRESSED);
1712
3293
  #endif
1713
3294
  #ifdef BUTTON4_RELEASED
3295
+ /* Document-const: BUTTON4_RELEASED
3296
+ *
3297
+ * Mouse event mask:
3298
+ * mouse button 4 up
3299
+ *
3300
+ * See Curses.getmouse
3301
+ */
1714
3302
  rb_curses_define_const(BUTTON4_RELEASED);
1715
3303
  #endif
1716
3304
  #ifdef BUTTON4_CLICKED
3305
+ /* Document-const: BUTTON4_CLICKED
3306
+ *
3307
+ * Mouse event mask:
3308
+ * mouse button 4 clicked
3309
+ *
3310
+ * See Curses.getmouse
3311
+ */
1717
3312
  rb_curses_define_const(BUTTON4_CLICKED);
1718
3313
  #endif
1719
3314
  #ifdef BUTTON4_DOUBLE_CLICKED
3315
+ /* Document-const: BUTTON4_DOUBLE_CLICKED
3316
+ *
3317
+ * Mouse event mask:
3318
+ * mouse button 4 double clicked
3319
+ *
3320
+ * See Curses.getmouse
3321
+ */
1720
3322
  rb_curses_define_const(BUTTON4_DOUBLE_CLICKED);
1721
3323
  #endif
1722
3324
  #ifdef BUTTON4_TRIPLE_CLICKED
3325
+ /* Document-const: BUTTON4_TRIPLE_CLICKED
3326
+ *
3327
+ * Mouse event mask:
3328
+ * mouse button 4 triple clicked
3329
+ *
3330
+ * See Curses.getmouse
3331
+ */
1723
3332
  rb_curses_define_const(BUTTON4_TRIPLE_CLICKED);
1724
3333
  #endif
1725
3334
  #ifdef BUTTON_SHIFT
3335
+ /* Document-const: BUTTON_SHIFT
3336
+ *
3337
+ * Mouse event mask:
3338
+ * shift was down during button state change
3339
+ *
3340
+ * See Curses.getmouse
3341
+ */
1726
3342
  rb_curses_define_const(BUTTON_SHIFT);
1727
3343
  #endif
1728
3344
  #ifdef BUTTON_CTRL
3345
+ /* Document-const: BUTTON_CTRL
3346
+ *
3347
+ * Mouse event mask:
3348
+ * control was down during button state change
3349
+ *
3350
+ * See Curses.getmouse
3351
+ */
1729
3352
  rb_curses_define_const(BUTTON_CTRL);
1730
3353
  #endif
1731
3354
  #ifdef BUTTON_ALT
3355
+ /* Document-const: BUTTON_ALT
3356
+ *
3357
+ * Mouse event mask:
3358
+ * alt was down during button state change
3359
+ *
3360
+ * See Curses.getmouse
3361
+ */
1732
3362
  rb_curses_define_const(BUTTON_ALT);
1733
3363
  #endif
1734
3364
  #ifdef ALL_MOUSE_EVENTS
3365
+ /* Document-const: ALL_MOUSE_EVENTS
3366
+ *
3367
+ * Mouse event mask:
3368
+ * report all button state changes
3369
+ *
3370
+ * See Curses.getmouse
3371
+ */
1735
3372
  rb_curses_define_const(ALL_MOUSE_EVENTS);
1736
3373
  #endif
1737
3374
  #ifdef REPORT_MOUSE_POSITION
3375
+ /* Document-const: REPORT_MOUSE_POSITION
3376
+ *
3377
+ * Mouse event mask:
3378
+ * report mouse movement
3379
+ *
3380
+ * See Curses.getmouse
3381
+ */
1738
3382
  rb_curses_define_const(REPORT_MOUSE_POSITION);
1739
3383
  #endif
1740
3384
  #endif /* USE_MOUSE */
1741
3385
 
1742
3386
  #if defined(KEY_MOUSE) && defined(USE_MOUSE)
3387
+ /* Document-const: KEY_MOUSE
3388
+ * Mouse event read
3389
+ */
3390
+ /* Document-const: MOUSE
3391
+ * Mouse event read
3392
+ */
1743
3393
  rb_curses_define_const(KEY_MOUSE);
1744
3394
  rb_define_const(mKey, "MOUSE", INT2NUM(KEY_MOUSE));
1745
3395
  #endif
1746
3396
  #ifdef KEY_MIN
3397
+ /* Document-const: KEY_MIN
3398
+ * The minimum allowed curses key value.
3399
+ */
3400
+ /* Document-const: MIN
3401
+ * The minimum allowed curses key value.
3402
+ */
1747
3403
  rb_curses_define_const(KEY_MIN);
1748
3404
  rb_define_const(mKey, "MIN", INT2NUM(KEY_MIN));
1749
3405
  #endif
1750
3406
  #ifdef KEY_BREAK
3407
+ /* Document-const: KEY_BREAK
3408
+ * Break key
3409
+ */
3410
+ /* Document-const: BREAK
3411
+ * Break key
3412
+ */
1751
3413
  rb_curses_define_const(KEY_BREAK);
1752
3414
  rb_define_const(mKey, "BREAK", INT2NUM(KEY_BREAK));
1753
3415
  #endif
1754
3416
  #ifdef KEY_DOWN
3417
+ /* Document-const: KEY_DOWN
3418
+ * the down arrow key
3419
+ */
3420
+ /* Document-const: DOWN
3421
+ * the down arrow key
3422
+ */
1755
3423
  rb_curses_define_const(KEY_DOWN);
1756
3424
  rb_define_const(mKey, "DOWN", INT2NUM(KEY_DOWN));
1757
3425
  #endif
1758
3426
  #ifdef KEY_UP
3427
+ /* Document-const: KEY_UP
3428
+ * the up arrow key
3429
+ */
3430
+ /* Document-const: UP
3431
+ * the up arrow key
3432
+ */
1759
3433
  rb_curses_define_const(KEY_UP);
1760
3434
  rb_define_const(mKey, "UP", INT2NUM(KEY_UP));
1761
3435
  #endif
1762
3436
  #ifdef KEY_LEFT
3437
+ /* Document-const: KEY_LEFT
3438
+ * the left arrow key
3439
+ */
3440
+ /* Document-const: LEFT
3441
+ * the left arrow key
3442
+ */
1763
3443
  rb_curses_define_const(KEY_LEFT);
1764
3444
  rb_define_const(mKey, "LEFT", INT2NUM(KEY_LEFT));
1765
3445
  #endif
1766
3446
  #ifdef KEY_RIGHT
3447
+ /* Document-const: KEY_RIGHT
3448
+ * the right arrow key
3449
+ */
3450
+ /* Document-const: RIGHT
3451
+ * the right arrow key
3452
+ */
1767
3453
  rb_curses_define_const(KEY_RIGHT);
1768
3454
  rb_define_const(mKey, "RIGHT", INT2NUM(KEY_RIGHT));
1769
3455
  #endif
1770
3456
  #ifdef KEY_HOME
3457
+ /* Document-const: KEY_HOME
3458
+ * Home key (upward+left arrow)
3459
+ */
3460
+ /* Document-const: HOME
3461
+ * Home key (upward+left arrow)
3462
+ */
1771
3463
  rb_curses_define_const(KEY_HOME);
1772
3464
  rb_define_const(mKey, "HOME", INT2NUM(KEY_HOME));
1773
3465
  #endif
1774
3466
  #ifdef KEY_BACKSPACE
3467
+ /* Document-const: KEY_BACKSPACE
3468
+ * Backspace
3469
+ */
3470
+ /* Document-const: BACKSPACE
3471
+ * Backspace
3472
+ */
1775
3473
  rb_curses_define_const(KEY_BACKSPACE);
1776
3474
  rb_define_const(mKey, "BACKSPACE", INT2NUM(KEY_BACKSPACE));
1777
3475
  #endif
1778
3476
  #ifdef KEY_F
1779
3477
  /* KEY_F(n) : 0 <= n <= 63 */
1780
3478
  {
1781
- int i;
1782
- char c[8];
1783
- for( i=0; i<64; i++ ){
1784
- sprintf(c, "KEY_F%d", i);
1785
- rb_define_const(mCurses, c, INT2NUM(KEY_F(i)));
1786
- sprintf(c, "F%d", i);
1787
- rb_define_const(mKey, c, INT2NUM(KEY_F(i)));
1788
- }
3479
+ int i;
3480
+ char c[8];
3481
+ for (i=0; i<64; i++) {
3482
+ sprintf(c, "KEY_F%d", i);
3483
+ rb_define_const(mCurses, c, INT2NUM(KEY_F(i)));
3484
+ sprintf(c, "F%d", i);
3485
+ rb_define_const(mKey, c, INT2NUM(KEY_F(i)));
3486
+ }
1789
3487
  }
1790
3488
  #endif
1791
3489
  #ifdef KEY_DL
3490
+ /* Document-const: KEY_DL
3491
+ * Delete line
3492
+ */
3493
+ /* Document-const: DL
3494
+ * Delete line
3495
+ */
1792
3496
  rb_curses_define_const(KEY_DL);
1793
3497
  rb_define_const(mKey, "DL", INT2NUM(KEY_DL));
1794
3498
  #endif
1795
3499
  #ifdef KEY_IL
3500
+ /* Document-const: KEY_IL
3501
+ * Insert line
3502
+ */
3503
+ /* Document-const: IL
3504
+ * Insert line
3505
+ */
1796
3506
  rb_curses_define_const(KEY_IL);
1797
3507
  rb_define_const(mKey, "IL", INT2NUM(KEY_IL));
1798
3508
  #endif
1799
3509
  #ifdef KEY_DC
3510
+ /* Document-const: KEY_DC
3511
+ * Delete character
3512
+ */
3513
+ /* Document-const: DC
3514
+ * Delete character
3515
+ */
1800
3516
  rb_curses_define_const(KEY_DC);
1801
3517
  rb_define_const(mKey, "DC", INT2NUM(KEY_DC));
1802
3518
  #endif
1803
3519
  #ifdef KEY_IC
3520
+ /* Document-const: KEY_IC
3521
+ * Insert char or enter insert mode
3522
+ */
3523
+ /* Document-const: IC
3524
+ * Insert char or enter insert mode
3525
+ */
1804
3526
  rb_curses_define_const(KEY_IC);
1805
3527
  rb_define_const(mKey, "IC", INT2NUM(KEY_IC));
1806
3528
  #endif
1807
3529
  #ifdef KEY_EIC
3530
+ /* Document-const: KEY_EIC
3531
+ * Enter insert char mode
3532
+ */
3533
+ /* Document-const: EIC
3534
+ * Enter insert char mode
3535
+ */
1808
3536
  rb_curses_define_const(KEY_EIC);
1809
3537
  rb_define_const(mKey, "EIC", INT2NUM(KEY_EIC));
1810
3538
  #endif
1811
3539
  #ifdef KEY_CLEAR
3540
+ /* Document-const: KEY_CLEAR
3541
+ * Clear Screen
3542
+ */
3543
+ /* Document-const: CLEAR
3544
+ * Clear Screen
3545
+ */
1812
3546
  rb_curses_define_const(KEY_CLEAR);
1813
3547
  rb_define_const(mKey, "CLEAR", INT2NUM(KEY_CLEAR));
1814
3548
  #endif
1815
3549
  #ifdef KEY_EOS
3550
+ /* Document-const: KEY_EOS
3551
+ * Clear to end of screen
3552
+ */
3553
+ /* Document-const: EOS
3554
+ * Clear to end of screen
3555
+ */
1816
3556
  rb_curses_define_const(KEY_EOS);
1817
3557
  rb_define_const(mKey, "EOS", INT2NUM(KEY_EOS));
1818
3558
  #endif
1819
3559
  #ifdef KEY_EOL
3560
+ /* Document-const: KEY_EOL
3561
+ * Clear to end of line
3562
+ */
3563
+ /* Document-const: EOL
3564
+ * Clear to end of line
3565
+ */
1820
3566
  rb_curses_define_const(KEY_EOL);
1821
3567
  rb_define_const(mKey, "EOL", INT2NUM(KEY_EOL));
1822
3568
  #endif
1823
3569
  #ifdef KEY_SF
3570
+ /* Document-const: KEY_SF
3571
+ * Scroll 1 line forward
3572
+ */
3573
+ /* Document-const: SF
3574
+ * Scroll 1 line forward
3575
+ */
1824
3576
  rb_curses_define_const(KEY_SF);
1825
3577
  rb_define_const(mKey, "SF", INT2NUM(KEY_SF));
1826
3578
  #endif
1827
3579
  #ifdef KEY_SR
3580
+ /* Document-const: KEY_SR
3581
+ * Scroll 1 line backward (reverse)
3582
+ */
3583
+ /* Document-const: SR
3584
+ * Scroll 1 line backward (reverse)
3585
+ */
1828
3586
  rb_curses_define_const(KEY_SR);
1829
3587
  rb_define_const(mKey, "SR", INT2NUM(KEY_SR));
1830
3588
  #endif
1831
3589
  #ifdef KEY_NPAGE
3590
+ /* Document-const: KEY_NPAGE
3591
+ * Next page
3592
+ */
3593
+ /* Document-const: NPAGE
3594
+ * Next page
3595
+ */
1832
3596
  rb_curses_define_const(KEY_NPAGE);
1833
3597
  rb_define_const(mKey, "NPAGE", INT2NUM(KEY_NPAGE));
1834
3598
  #endif
1835
3599
  #ifdef KEY_PPAGE
3600
+ /* Document-const: KEY_PPAGE
3601
+ * Previous page
3602
+ */
3603
+ /* Document-const: PPAGE
3604
+ * Previous page
3605
+ */
1836
3606
  rb_curses_define_const(KEY_PPAGE);
1837
3607
  rb_define_const(mKey, "PPAGE", INT2NUM(KEY_PPAGE));
1838
3608
  #endif
1839
3609
  #ifdef KEY_STAB
3610
+ /* Document-const: KEY_STAB
3611
+ * Set tab
3612
+ */
3613
+ /* Document-const: STAB
3614
+ * Set tab
3615
+ */
1840
3616
  rb_curses_define_const(KEY_STAB);
1841
3617
  rb_define_const(mKey, "STAB", INT2NUM(KEY_STAB));
1842
3618
  #endif
1843
3619
  #ifdef KEY_CTAB
3620
+ /* Document-const: KEY_CTAB
3621
+ * Clear tab
3622
+ */
3623
+ /* Document-const: CTAB
3624
+ * Clear tab
3625
+ */
1844
3626
  rb_curses_define_const(KEY_CTAB);
1845
3627
  rb_define_const(mKey, "CTAB", INT2NUM(KEY_CTAB));
1846
3628
  #endif
1847
3629
  #ifdef KEY_CATAB
3630
+ /* Document-const: KEY_CATAB
3631
+ * Clear all tabs
3632
+ */
3633
+ /* Document-const: CATAB
3634
+ * Clear all tabs
3635
+ */
1848
3636
  rb_curses_define_const(KEY_CATAB);
1849
3637
  rb_define_const(mKey, "CATAB", INT2NUM(KEY_CATAB));
1850
3638
  #endif
1851
3639
  #ifdef KEY_ENTER
3640
+ /* Document-const: KEY_ENTER
3641
+ * Enter or send
3642
+ */
3643
+ /* Document-const: ENTER
3644
+ * Enter or send
3645
+ */
1852
3646
  rb_curses_define_const(KEY_ENTER);
1853
3647
  rb_define_const(mKey, "ENTER", INT2NUM(KEY_ENTER));
1854
3648
  #endif
1855
3649
  #ifdef KEY_SRESET
3650
+ /* Document-const: KEY_SRESET
3651
+ * Soft (partial) reset
3652
+ */
3653
+ /* Document-const: SRESET
3654
+ * Soft (partial) reset
3655
+ */
1856
3656
  rb_curses_define_const(KEY_SRESET);
1857
3657
  rb_define_const(mKey, "SRESET", INT2NUM(KEY_SRESET));
1858
3658
  #endif
1859
3659
  #ifdef KEY_RESET
3660
+ /* Document-const: KEY_RESET
3661
+ * Reset or hard reset
3662
+ */
3663
+ /* Document-const: RESET
3664
+ * Reset or hard reset
3665
+ */
1860
3666
  rb_curses_define_const(KEY_RESET);
1861
3667
  rb_define_const(mKey, "RESET", INT2NUM(KEY_RESET));
1862
3668
  #endif
1863
3669
  #ifdef KEY_PRINT
3670
+ /* Document-const: KEY_PRINT
3671
+ * Print or copy
3672
+ */
3673
+ /* Document-const: PRINT
3674
+ * Print or copy
3675
+ */
1864
3676
  rb_curses_define_const(KEY_PRINT);
1865
3677
  rb_define_const(mKey, "PRINT", INT2NUM(KEY_PRINT));
1866
3678
  #endif
1867
3679
  #ifdef KEY_LL
3680
+ /* Document-const: KEY_LL
3681
+ * Home down or bottom (lower left)
3682
+ */
3683
+ /* Document-const: LL
3684
+ * Home down or bottom (lower left)
3685
+ */
1868
3686
  rb_curses_define_const(KEY_LL);
1869
3687
  rb_define_const(mKey, "LL", INT2NUM(KEY_LL));
1870
3688
  #endif
1871
3689
  #ifdef KEY_A1
3690
+ /* Document-const: KEY_A1
3691
+ * Upper left of keypad
3692
+ */
3693
+ /* Document-const: A1
3694
+ * Upper left of keypad
3695
+ */
1872
3696
  rb_curses_define_const(KEY_A1);
1873
3697
  rb_define_const(mKey, "A1", INT2NUM(KEY_A1));
1874
3698
  #endif
1875
3699
  #ifdef KEY_A3
3700
+ /* Document-const: KEY_A3
3701
+ * Upper right of keypad
3702
+ */
3703
+ /* Document-const: A3
3704
+ * Upper right of keypad
3705
+ */
1876
3706
  rb_curses_define_const(KEY_A3);
1877
3707
  rb_define_const(mKey, "A3", INT2NUM(KEY_A3));
1878
3708
  #endif
1879
3709
  #ifdef KEY_B2
3710
+ /* Document-const: KEY_B2
3711
+ * Center of keypad
3712
+ */
3713
+ /* Document-const: B2
3714
+ * Center of keypad
3715
+ */
1880
3716
  rb_curses_define_const(KEY_B2);
1881
3717
  rb_define_const(mKey, "B2", INT2NUM(KEY_B2));
1882
3718
  #endif
1883
3719
  #ifdef KEY_C1
3720
+ /* Document-const: KEY_C1
3721
+ * Lower left of keypad
3722
+ */
3723
+ /* Document-const: C1
3724
+ * Lower left of keypad
3725
+ */
1884
3726
  rb_curses_define_const(KEY_C1);
1885
3727
  rb_define_const(mKey, "C1", INT2NUM(KEY_C1));
1886
3728
  #endif
1887
3729
  #ifdef KEY_C3
3730
+ /* Document-const: KEY_C3
3731
+ * Lower right of keypad
3732
+ */
3733
+ /* Document-const: C3
3734
+ * Lower right of keypad
3735
+ */
1888
3736
  rb_curses_define_const(KEY_C3);
1889
3737
  rb_define_const(mKey, "C3", INT2NUM(KEY_C3));
1890
3738
  #endif
1891
3739
  #ifdef KEY_BTAB
3740
+ /* Document-const: BTAB
3741
+ * Back tab key
3742
+ */
3743
+ /* Document-const: KEY_BTAB
3744
+ * Back tab key
3745
+ */
1892
3746
  rb_curses_define_const(KEY_BTAB);
1893
3747
  rb_define_const(mKey, "BTAB", INT2NUM(KEY_BTAB));
1894
3748
  #endif
1895
3749
  #ifdef KEY_BEG
3750
+ /* Document-const: KEY_BEG
3751
+ * Beginning key
3752
+ */
3753
+ /* Document-const: BEG
3754
+ * Beginning key
3755
+ */
1896
3756
  rb_curses_define_const(KEY_BEG);
1897
3757
  rb_define_const(mKey, "BEG", INT2NUM(KEY_BEG));
1898
3758
  #endif
1899
3759
  #ifdef KEY_CANCEL
3760
+ /* Document-const: KEY_CANCEL
3761
+ * Cancel key
3762
+ */
3763
+ /* Document-const: CANCEL
3764
+ * Cancel key
3765
+ */
1900
3766
  rb_curses_define_const(KEY_CANCEL);
1901
3767
  rb_define_const(mKey, "CANCEL", INT2NUM(KEY_CANCEL));
1902
3768
  #endif
1903
3769
  #ifdef KEY_CLOSE
3770
+ /* Document-const: KEY_CLOSE
3771
+ * Close key
3772
+ */
3773
+ /* Document-const: CLOSE
3774
+ * Close key
3775
+ */
1904
3776
  rb_curses_define_const(KEY_CLOSE);
1905
3777
  rb_define_const(mKey, "CLOSE", INT2NUM(KEY_CLOSE));
1906
3778
  #endif
1907
3779
  #ifdef KEY_COMMAND
3780
+ /* Document-const: KEY_COMMAND
3781
+ * Cmd (command) key
3782
+ */
3783
+ /* Document-const: COMMAND
3784
+ * Cmd (command) key
3785
+ */
1908
3786
  rb_curses_define_const(KEY_COMMAND);
1909
3787
  rb_define_const(mKey, "COMMAND", INT2NUM(KEY_COMMAND));
1910
3788
  #endif
1911
3789
  #ifdef KEY_COPY
3790
+ /* Document-const: KEY_COPY
3791
+ * Copy key
3792
+ */
3793
+ /* Document-const: COPY
3794
+ * Copy key
3795
+ */
1912
3796
  rb_curses_define_const(KEY_COPY);
1913
3797
  rb_define_const(mKey, "COPY", INT2NUM(KEY_COPY));
1914
3798
  #endif
1915
3799
  #ifdef KEY_CREATE
3800
+ /* Document-const: KEY_CREATE
3801
+ * Create key
3802
+ */
3803
+ /* Document-const: CREATE
3804
+ * Create key
3805
+ */
1916
3806
  rb_curses_define_const(KEY_CREATE);
1917
3807
  rb_define_const(mKey, "CREATE", INT2NUM(KEY_CREATE));
1918
3808
  #endif
1919
3809
  #ifdef KEY_END
3810
+ /* Document-const: KEY_END
3811
+ * End key
3812
+ */
3813
+ /* Document-const: END
3814
+ * End key
3815
+ */
1920
3816
  rb_curses_define_const(KEY_END);
1921
3817
  rb_define_const(mKey, "END", INT2NUM(KEY_END));
1922
3818
  #endif
1923
3819
  #ifdef KEY_EXIT
3820
+ /* Document-const: KEY_EXIT
3821
+ * Exit key
3822
+ */
3823
+ /* Document-const: EXIT
3824
+ * Exit key
3825
+ */
1924
3826
  rb_curses_define_const(KEY_EXIT);
1925
3827
  rb_define_const(mKey, "EXIT", INT2NUM(KEY_EXIT));
1926
3828
  #endif
1927
3829
  #ifdef KEY_FIND
3830
+ /* Document-const: KEY_FIND
3831
+ * Find key
3832
+ */
3833
+ /* Document-const: FIND
3834
+ * Find key
3835
+ */
1928
3836
  rb_curses_define_const(KEY_FIND);
1929
3837
  rb_define_const(mKey, "FIND", INT2NUM(KEY_FIND));
1930
3838
  #endif
1931
3839
  #ifdef KEY_HELP
3840
+ /* Document-const: KEY_HELP
3841
+ * Help key
3842
+ */
3843
+ /* Document-const: HELP
3844
+ * Help key
3845
+ */
1932
3846
  rb_curses_define_const(KEY_HELP);
1933
3847
  rb_define_const(mKey, "HELP", INT2NUM(KEY_HELP));
1934
3848
  #endif
1935
3849
  #ifdef KEY_MARK
3850
+ /* Document-const: KEY_MARK
3851
+ * Mark key
3852
+ */
3853
+ /* Document-const: MARK
3854
+ * Mark key
3855
+ */
1936
3856
  rb_curses_define_const(KEY_MARK);
1937
3857
  rb_define_const(mKey, "MARK", INT2NUM(KEY_MARK));
1938
3858
  #endif
1939
3859
  #ifdef KEY_MESSAGE
3860
+ /* Document-const: KEY_MESSAGE
3861
+ * Message key
3862
+ */
3863
+ /* Document-const: MESSAGE
3864
+ * Message key
3865
+ */
1940
3866
  rb_curses_define_const(KEY_MESSAGE);
1941
3867
  rb_define_const(mKey, "MESSAGE", INT2NUM(KEY_MESSAGE));
1942
3868
  #endif
1943
3869
  #ifdef KEY_MOVE
3870
+ /* Document-const: KEY_MOVE
3871
+ * Move key
3872
+ */
3873
+ /* Document-const: MOVE
3874
+ * Move key
3875
+ */
1944
3876
  rb_curses_define_const(KEY_MOVE);
1945
3877
  rb_define_const(mKey, "MOVE", INT2NUM(KEY_MOVE));
1946
3878
  #endif
1947
3879
  #ifdef KEY_NEXT
3880
+ /* Document-const: KEY_NEXT
3881
+ * Next object key
3882
+ */
3883
+ /* Document-const: NEXT
3884
+ * Next object key
3885
+ */
1948
3886
  rb_curses_define_const(KEY_NEXT);
1949
3887
  rb_define_const(mKey, "NEXT", INT2NUM(KEY_NEXT));
1950
3888
  #endif
1951
3889
  #ifdef KEY_OPEN
3890
+ /* Document-const: KEY_OPEN
3891
+ * Open key
3892
+ */
3893
+ /* Document-const: OPEN
3894
+ * Open key
3895
+ */
1952
3896
  rb_curses_define_const(KEY_OPEN);
1953
3897
  rb_define_const(mKey, "OPEN", INT2NUM(KEY_OPEN));
1954
3898
  #endif
1955
3899
  #ifdef KEY_OPTIONS
3900
+ /* Document-const: KEY_OPTIONS
3901
+ * Options key
3902
+ */
3903
+ /* Document-const: OPTIONS
3904
+ * Options key
3905
+ */
1956
3906
  rb_curses_define_const(KEY_OPTIONS);
1957
3907
  rb_define_const(mKey, "OPTIONS", INT2NUM(KEY_OPTIONS));
1958
3908
  #endif
1959
3909
  #ifdef KEY_PREVIOUS
3910
+ /* Document-const: KEY_PREVIOUS
3911
+ * Previous object key
3912
+ */
3913
+ /* Document-const: PREVIOUS
3914
+ * Previous object key
3915
+ */
1960
3916
  rb_curses_define_const(KEY_PREVIOUS);
1961
3917
  rb_define_const(mKey, "PREVIOUS", INT2NUM(KEY_PREVIOUS));
1962
3918
  #endif
1963
3919
  #ifdef KEY_REDO
3920
+ /* Document-const: KEY_REDO
3921
+ * Redo key
3922
+ */
3923
+ /* Document-const: REDO
3924
+ * Redo key
3925
+ */
1964
3926
  rb_curses_define_const(KEY_REDO);
1965
3927
  rb_define_const(mKey, "REDO", INT2NUM(KEY_REDO));
1966
3928
  #endif
1967
3929
  #ifdef KEY_REFERENCE
3930
+ /* Document-const: KEY_REFERENCE
3931
+ * Reference key
3932
+ */
3933
+ /* Document-const: REFERENCE
3934
+ * Reference key
3935
+ */
1968
3936
  rb_curses_define_const(KEY_REFERENCE);
1969
3937
  rb_define_const(mKey, "REFERENCE", INT2NUM(KEY_REFERENCE));
1970
3938
  #endif
1971
3939
  #ifdef KEY_REFRESH
3940
+ /* Document-const: KEY_REFRESH
3941
+ * Refresh key
3942
+ */
3943
+ /* Document-const: REFRESH
3944
+ * Refresh key
3945
+ */
1972
3946
  rb_curses_define_const(KEY_REFRESH);
1973
3947
  rb_define_const(mKey, "REFRESH", INT2NUM(KEY_REFRESH));
1974
3948
  #endif
1975
3949
  #ifdef KEY_REPLACE
3950
+ /* Document-const: KEY_REPLACE
3951
+ * Replace key
3952
+ */
3953
+ /* Document-const: REPLACE
3954
+ * Replace key
3955
+ */
1976
3956
  rb_curses_define_const(KEY_REPLACE);
1977
3957
  rb_define_const(mKey, "REPLACE", INT2NUM(KEY_REPLACE));
1978
3958
  #endif
1979
3959
  #ifdef KEY_RESTART
3960
+ /* Document-const: KEY_RESTART
3961
+ * Restart key
3962
+ */
3963
+ /* Document-const: RESTART
3964
+ * Restart key
3965
+ */
1980
3966
  rb_curses_define_const(KEY_RESTART);
1981
3967
  rb_define_const(mKey, "RESTART", INT2NUM(KEY_RESTART));
1982
3968
  #endif
1983
3969
  #ifdef KEY_RESUME
3970
+ /* Document-const: KEY_RESUME
3971
+ * Resume key
3972
+ */
3973
+ /* Document-const: RESUME
3974
+ * Resume key
3975
+ */
1984
3976
  rb_curses_define_const(KEY_RESUME);
1985
3977
  rb_define_const(mKey, "RESUME", INT2NUM(KEY_RESUME));
1986
3978
  #endif
1987
3979
  #ifdef KEY_SAVE
3980
+ /* Document-const: KEY_SAVE
3981
+ * Save key
3982
+ */
3983
+ /* Document-const: SAVE
3984
+ * Save key
3985
+ */
1988
3986
  rb_curses_define_const(KEY_SAVE);
1989
3987
  rb_define_const(mKey, "SAVE", INT2NUM(KEY_SAVE));
1990
3988
  #endif
1991
3989
  #ifdef KEY_SBEG
3990
+ /* Document-const: KEY_SBEG
3991
+ * Shifted beginning key
3992
+ */
3993
+ /* Document-const: SBEG
3994
+ * Shifted beginning key
3995
+ */
1992
3996
  rb_curses_define_const(KEY_SBEG);
1993
3997
  rb_define_const(mKey, "SBEG", INT2NUM(KEY_SBEG));
1994
3998
  #endif
1995
3999
  #ifdef KEY_SCANCEL
4000
+ /* Document-const: KEY_SCANCEL
4001
+ * Shifted cancel key
4002
+ */
4003
+ /* Document-const: SCANCEL
4004
+ * Shifted cancel key
4005
+ */
1996
4006
  rb_curses_define_const(KEY_SCANCEL);
1997
4007
  rb_define_const(mKey, "SCANCEL", INT2NUM(KEY_SCANCEL));
1998
4008
  #endif
1999
4009
  #ifdef KEY_SCOMMAND
4010
+ /* Document-const: KEY_SCOMMAND
4011
+ * Shifted command key
4012
+ */
4013
+ /* Document-const: SCOMMAND
4014
+ * Shifted command key
4015
+ */
2000
4016
  rb_curses_define_const(KEY_SCOMMAND);
2001
4017
  rb_define_const(mKey, "SCOMMAND", INT2NUM(KEY_SCOMMAND));
2002
4018
  #endif
2003
4019
  #ifdef KEY_SCOPY
4020
+ /* Document-const: KEY_SCOPY
4021
+ * Shifted copy key
4022
+ */
4023
+ /* Document-const: SCOPY
4024
+ * Shifted copy key
4025
+ */
2004
4026
  rb_curses_define_const(KEY_SCOPY);
2005
4027
  rb_define_const(mKey, "SCOPY", INT2NUM(KEY_SCOPY));
2006
4028
  #endif
2007
4029
  #ifdef KEY_SCREATE
4030
+ /* Document-const: KEY_SCREATE
4031
+ * Shifted create key
4032
+ */
4033
+ /* Document-const: SCREATE
4034
+ * Shifted create key
4035
+ */
2008
4036
  rb_curses_define_const(KEY_SCREATE);
2009
4037
  rb_define_const(mKey, "SCREATE", INT2NUM(KEY_SCREATE));
2010
4038
  #endif
2011
4039
  #ifdef KEY_SDC
4040
+ /* Document-const: KEY_SDC
4041
+ * Shifted delete char key
4042
+ */
4043
+ /* Document-const: SDC
4044
+ * Shifted delete char key
4045
+ */
2012
4046
  rb_curses_define_const(KEY_SDC);
2013
4047
  rb_define_const(mKey, "SDC", INT2NUM(KEY_SDC));
2014
4048
  #endif
2015
4049
  #ifdef KEY_SDL
4050
+ /* Document-const: KEY_SDL
4051
+ * Shifted delete line key
4052
+ */
4053
+ /* Document-const: SDL
4054
+ * Shifted delete line key
4055
+ */
2016
4056
  rb_curses_define_const(KEY_SDL);
2017
4057
  rb_define_const(mKey, "SDL", INT2NUM(KEY_SDL));
2018
4058
  #endif
2019
4059
  #ifdef KEY_SELECT
4060
+ /* Document-const: KEY_SELECT
4061
+ * Select key
4062
+ */
4063
+ /* Document-const: SELECT
4064
+ * Select key
4065
+ */
2020
4066
  rb_curses_define_const(KEY_SELECT);
2021
4067
  rb_define_const(mKey, "SELECT", INT2NUM(KEY_SELECT));
2022
4068
  #endif
2023
4069
  #ifdef KEY_SEND
4070
+ /* Document-const: KEY_SEND
4071
+ * Shifted end key
4072
+ */
4073
+ /* Document-const: SEND
4074
+ * Shifted end key
4075
+ */
2024
4076
  rb_curses_define_const(KEY_SEND);
2025
4077
  rb_define_const(mKey, "SEND", INT2NUM(KEY_SEND));
2026
4078
  #endif
2027
4079
  #ifdef KEY_SEOL
4080
+ /* Document-const: KEY_SEOL
4081
+ * Shifted clear line key
4082
+ */
4083
+ /* Document-const: SEOL
4084
+ * Shifted clear line key
4085
+ */
2028
4086
  rb_curses_define_const(KEY_SEOL);
2029
4087
  rb_define_const(mKey, "SEOL", INT2NUM(KEY_SEOL));
2030
4088
  #endif
2031
4089
  #ifdef KEY_SEXIT
4090
+ /* Document-const: KEY_SEXIT
4091
+ * Shifted exit key
4092
+ */
4093
+ /* Document-const: SEXIT
4094
+ * Shifted exit key
4095
+ */
2032
4096
  rb_curses_define_const(KEY_SEXIT);
2033
4097
  rb_define_const(mKey, "SEXIT", INT2NUM(KEY_SEXIT));
2034
4098
  #endif
2035
4099
  #ifdef KEY_SFIND
4100
+ /* Document-const: KEY_SFIND
4101
+ * Shifted find key
4102
+ */
4103
+ /* Document-const: SFIND
4104
+ * Shifted find key
4105
+ */
2036
4106
  rb_curses_define_const(KEY_SFIND);
2037
4107
  rb_define_const(mKey, "SFIND", INT2NUM(KEY_SFIND));
2038
4108
  #endif
2039
4109
  #ifdef KEY_SHELP
4110
+ /* Document-const: KEY_SHELP
4111
+ * Shifted help key
4112
+ */
4113
+ /* Document-const: SHELP
4114
+ * Shifted help key
4115
+ */
2040
4116
  rb_curses_define_const(KEY_SHELP);
2041
4117
  rb_define_const(mKey, "SHELP", INT2NUM(KEY_SHELP));
2042
4118
  #endif
2043
4119
  #ifdef KEY_SHOME
4120
+ /* Document-const: KEY_SHOME
4121
+ * Shifted home key
4122
+ */
4123
+ /* Document-const: SHOME
4124
+ * Shifted home key
4125
+ */
2044
4126
  rb_curses_define_const(KEY_SHOME);
2045
4127
  rb_define_const(mKey, "SHOME", INT2NUM(KEY_SHOME));
2046
4128
  #endif
2047
4129
  #ifdef KEY_SIC
4130
+ /* Document-const: KEY_SIC
4131
+ * Shifted input key
4132
+ */
4133
+ /* Document-const: SIC
4134
+ * Shifted input key
4135
+ */
2048
4136
  rb_curses_define_const(KEY_SIC);
2049
4137
  rb_define_const(mKey, "SIC", INT2NUM(KEY_SIC));
2050
4138
  #endif
2051
4139
  #ifdef KEY_SLEFT
4140
+ /* Document-const: KEY_SLEFT
4141
+ * Shifted left arrow key
4142
+ */
4143
+ /* Document-const: SLEFT
4144
+ * Shifted left arrow key
4145
+ */
2052
4146
  rb_curses_define_const(KEY_SLEFT);
2053
4147
  rb_define_const(mKey, "SLEFT", INT2NUM(KEY_SLEFT));
2054
4148
  #endif
2055
4149
  #ifdef KEY_SMESSAGE
4150
+ /* Document-const: KEY_SMESSAGE
4151
+ * Shifted message key
4152
+ */
4153
+ /* Document-const: SMESSAGE
4154
+ * Shifted message key
4155
+ */
2056
4156
  rb_curses_define_const(KEY_SMESSAGE);
2057
4157
  rb_define_const(mKey, "SMESSAGE", INT2NUM(KEY_SMESSAGE));
2058
4158
  #endif
2059
4159
  #ifdef KEY_SMOVE
4160
+ /* Document-const: KEY_SMOVE
4161
+ * Shifted move key
4162
+ */
4163
+ /* Document-const: SMOVE
4164
+ * Shifted move key
4165
+ */
2060
4166
  rb_curses_define_const(KEY_SMOVE);
2061
4167
  rb_define_const(mKey, "SMOVE", INT2NUM(KEY_SMOVE));
2062
4168
  #endif
2063
4169
  #ifdef KEY_SNEXT
4170
+ /* Document-const: KEY_SNEXT
4171
+ * Shifted next key
4172
+ */
4173
+ /* Document-const: SNEXT
4174
+ * Shifted next key
4175
+ */
2064
4176
  rb_curses_define_const(KEY_SNEXT);
2065
4177
  rb_define_const(mKey, "SNEXT", INT2NUM(KEY_SNEXT));
2066
4178
  #endif
2067
4179
  #ifdef KEY_SOPTIONS
4180
+ /* Document-const: KEY_SOPTIONS
4181
+ * Shifted options key
4182
+ */
4183
+ /* Document-const: SOPTIONS
4184
+ * Shifted options key
4185
+ */
2068
4186
  rb_curses_define_const(KEY_SOPTIONS);
2069
4187
  rb_define_const(mKey, "SOPTIONS", INT2NUM(KEY_SOPTIONS));
2070
4188
  #endif
2071
4189
  #ifdef KEY_SPREVIOUS
4190
+ /* Document-const: KEY_SPREVIOUS
4191
+ * Shifted previous key
4192
+ */
4193
+ /* Document-const: SPREVIOUS
4194
+ * Shifted previous key
4195
+ */
2072
4196
  rb_curses_define_const(KEY_SPREVIOUS);
2073
4197
  rb_define_const(mKey, "SPREVIOUS", INT2NUM(KEY_SPREVIOUS));
2074
4198
  #endif
2075
4199
  #ifdef KEY_SPRINT
4200
+ /* Document-const: KEY_SPRINT
4201
+ * Shifted print key
4202
+ */
4203
+ /* Document-const: SPRINT
4204
+ * Shifted print key
4205
+ */
2076
4206
  rb_curses_define_const(KEY_SPRINT);
2077
4207
  rb_define_const(mKey, "SPRINT", INT2NUM(KEY_SPRINT));
2078
4208
  #endif
2079
4209
  #ifdef KEY_SREDO
4210
+ /* Document-const: KEY_SREDO
4211
+ * Shifted redo key
4212
+ */
4213
+ /* Document-const: SREDO
4214
+ * Shifted redo key
4215
+ */
2080
4216
  rb_curses_define_const(KEY_SREDO);
2081
4217
  rb_define_const(mKey, "SREDO", INT2NUM(KEY_SREDO));
2082
4218
  #endif
2083
4219
  #ifdef KEY_SREPLACE
4220
+ /* Document-const: KEY_SREPLACE
4221
+ * Shifted replace key
4222
+ */
4223
+ /* Document-const: SREPLACE
4224
+ * Shifted replace key
4225
+ */
2084
4226
  rb_curses_define_const(KEY_SREPLACE);
2085
4227
  rb_define_const(mKey, "SREPLACE", INT2NUM(KEY_SREPLACE));
2086
4228
  #endif
2087
4229
  #ifdef KEY_SRIGHT
4230
+ /* Document-const: KEY_SRIGHT
4231
+ * Shifted right arrow key
4232
+ */
4233
+ /* Document-const: SRIGHT
4234
+ * Shifted right arrow key
4235
+ */
2088
4236
  rb_curses_define_const(KEY_SRIGHT);
2089
4237
  rb_define_const(mKey, "SRIGHT", INT2NUM(KEY_SRIGHT));
2090
4238
  #endif
2091
4239
  #ifdef KEY_SRSUME
4240
+ /* Document-const: KEY_SRSUME
4241
+ * Shifted resume key
4242
+ */
4243
+ /* Document-const: SRSUME
4244
+ * Shifted resume key
4245
+ */
2092
4246
  rb_curses_define_const(KEY_SRSUME);
2093
4247
  rb_define_const(mKey, "SRSUME", INT2NUM(KEY_SRSUME));
2094
4248
  #endif
2095
4249
  #ifdef KEY_SSAVE
4250
+ /* Document-const: KEY_SSAVE
4251
+ * Shifted save key
4252
+ */
4253
+ /* Document-const: SSAVE
4254
+ * Shifted save key
4255
+ */
2096
4256
  rb_curses_define_const(KEY_SSAVE);
2097
4257
  rb_define_const(mKey, "SSAVE", INT2NUM(KEY_SSAVE));
2098
4258
  #endif
2099
4259
  #ifdef KEY_SSUSPEND
4260
+ /* Document-const: KEY_SSUSPEND
4261
+ * Shifted suspend key
4262
+ */
4263
+ /* Document-const: SSUSPEND
4264
+ * Shifted suspend key
4265
+ */
2100
4266
  rb_curses_define_const(KEY_SSUSPEND);
2101
4267
  rb_define_const(mKey, "SSUSPEND", INT2NUM(KEY_SSUSPEND));
2102
4268
  #endif
2103
4269
  #ifdef KEY_SUNDO
4270
+ /* Document-const: KEY_SUNDO
4271
+ * Shifted undo key
4272
+ */
4273
+ /* Document-const: SUNDO
4274
+ * Shifted undo key
4275
+ */
2104
4276
  rb_curses_define_const(KEY_SUNDO);
2105
4277
  rb_define_const(mKey, "SUNDO", INT2NUM(KEY_SUNDO));
2106
4278
  #endif
2107
4279
  #ifdef KEY_SUSPEND
4280
+ /* Document-const: KEY_SUSPEND
4281
+ * Suspend key
4282
+ */
4283
+ /* Document-const: SUSPEND
4284
+ * Suspend key
4285
+ */
2108
4286
  rb_curses_define_const(KEY_SUSPEND);
2109
4287
  rb_define_const(mKey, "SUSPEND", INT2NUM(KEY_SUSPEND));
2110
4288
  #endif
2111
4289
  #ifdef KEY_UNDO
4290
+ /* Document-const: KEY_UNDO
4291
+ * Undo key
4292
+ */
4293
+ /* Document-const: UNDO
4294
+ * Undo key
4295
+ */
2112
4296
  rb_curses_define_const(KEY_UNDO);
2113
4297
  rb_define_const(mKey, "UNDO", INT2NUM(KEY_UNDO));
2114
4298
  #endif
2115
4299
  #ifdef KEY_RESIZE
4300
+ /* Document-const: KEY_RESIZE
4301
+ * Screen Resized
4302
+ */
4303
+ /* Document-const: RESIZE
4304
+ * Screen Resized
4305
+ */
2116
4306
  rb_curses_define_const(KEY_RESIZE);
2117
4307
  rb_define_const(mKey, "RESIZE", INT2NUM(KEY_RESIZE));
2118
4308
  #endif
2119
4309
  #ifdef KEY_MAX
4310
+ /* Document-const: KEY_MAX
4311
+ * The maximum allowed curses key value.
4312
+ */
4313
+ /* Document-const: MAX
4314
+ * The maximum allowed curses key value.
4315
+ */
2120
4316
  rb_curses_define_const(KEY_MAX);
2121
4317
  rb_define_const(mKey, "MAX", INT2NUM(KEY_MAX));
2122
4318
  #endif
2123
4319
  {
2124
- int c;
2125
- char name[] = "KEY_CTRL_x";
2126
- for( c = 'A'; c <= 'Z'; c++ ){
2127
- sprintf(name, "KEY_CTRL_%c", c);
2128
- rb_define_const(mCurses, name, INT2FIX(c - 'A' + 1));
2129
- }
4320
+ int c;
4321
+ char name[] = "KEY_CTRL_x";
4322
+ for (c = 'A'; c <= 'Z'; c++) {
4323
+ name[sizeof(name) - 2] = c;
4324
+ rb_define_const(mCurses, name, INT2FIX(c - 'A' + 1));
4325
+ }
2130
4326
  }
2131
4327
  #undef rb_curses_define_const
2132
4328