ruby_doc_updates-20110520_0227-curses_vbatts.patch

Vincent Batts, 05/20/2011 03:34 PM

Download (46.7 KB)

View differences:

ext/curses/curses.c
11 11
 *
12 12
 * maintainers:
13 13
 * - Takaaki Tateishi (ttate@kt.jaist.ac.jp)
14
 *
15
 * doumentation:
16
 * - Vincent Batts (vbatts@hashbangbash.com)
14 17
 */
15 18

  
16 19
#include "ruby.h"
......
114 117

  
115 118
/*-------------------------- module Curses --------------------------*/
116 119

  
117
/* def init_screen */
120
/*
121
 * Document-method: Curses.init_screen
122
 *
123
 * Initialize a standard screen
124
 *
125
 * see also Curses.stdscr
126
 */
118 127
static VALUE
119 128
curses_init_screen(void)
120 129
{
......
129 138
    return rb_stdscr;
130 139
}
131 140

  
132
/* def stdscr */
141
/*
142
 * Document-method: Curses.stdscr
143
 *
144
 * The Standard Screen.
145
 * Upon initializing curses, a default window called stdscr,
146
 * which is the size of the terminal screen, is created.
147
 *
148
 * Many curses functions use this window.
149
 */
133 150
#define curses_stdscr curses_init_screen
134 151

  
135
/* def close_screen */
136 152
static VALUE
137 153
curses_close_screen(void)
138 154
{
......
159 175
}
160 176

  
161 177
#ifdef HAVE_ISENDWIN
162
/* def closed? */
163 178
static VALUE
164 179
curses_closed(void)
165 180
{
......
173 188
#define curses_closed rb_f_notimplement
174 189
#endif
175 190

  
176
/* def clear */
177 191
static VALUE
178 192
curses_clear(VALUE obj)
179 193
{
......
182 196
    return Qnil;
183 197
}
184 198

  
185
/* def clrtoeol */
186 199
static VALUE
187 200
curses_clrtoeol(void)
188 201
{
......
191 204
    return Qnil;
192 205
}
193 206

  
194
/* def refresh */
195 207
static VALUE
196 208
curses_refresh(VALUE obj)
197 209
{
......
200 212
    return Qnil;
201 213
}
202 214

  
203
/* def doupdate */
204 215
static VALUE
205 216
curses_doupdate(VALUE obj)
206 217
{
......
213 224
    return Qnil;
214 225
}
215 226

  
216
/* def echo */
217 227
static VALUE
218 228
curses_echo(VALUE obj)
219 229
{
......
222 232
    return Qnil;
223 233
}
224 234

  
225
/* def noecho */
226 235
static VALUE
227 236
curses_noecho(VALUE obj)
228 237
{
......
231 240
    return Qnil;
232 241
}
233 242

  
234
/* def raw */
235 243
static VALUE
236 244
curses_raw(VALUE obj)
237 245
{
......
240 248
    return Qnil;
241 249
}
242 250

  
243
/* def noraw */
244 251
static VALUE
245 252
curses_noraw(VALUE obj)
246 253
{
......
249 256
    return Qnil;
250 257
}
251 258

  
252
/* def cbreak */
253 259
static VALUE
254 260
curses_cbreak(VALUE obj)
255 261
{
......
258 264
    return Qnil;
259 265
}
260 266

  
261
/* def nocbreak */
262 267
static VALUE
263 268
curses_nocbreak(VALUE obj)
264 269
{
......
267 272
    return Qnil;
268 273
}
269 274

  
270
/* def nl */
271 275
static VALUE
272 276
curses_nl(VALUE obj)
273 277
{
......
276 280
    return Qnil;
277 281
}
278 282

  
279
/* def nonl */
280 283
static VALUE
281 284
curses_nonl(VALUE obj)
282 285
{
......
285 288
    return Qnil;
286 289
}
287 290

  
288
/* def beep */
289 291
static VALUE
290 292
curses_beep(VALUE obj)
291 293
{
......
296 298
    return Qnil;
297 299
}
298 300

  
299
/* def flash */
300 301
static VALUE
301 302
curses_flash(VALUE obj)
302 303
{
......
329 330
}
330 331

  
331 332
#ifdef HAVE_UNGETCH
332
/* def ungetch */
333
/* 
334
 * Document-method: Curses.ungetch
335
 * call-seq: ungetch(ch)
336
 *
337
 * Places +ch+ back onto the input queue to be returned by
338
 * the next call to Curses.getch.
339
 *
340
 * There is just one input queue for all windows.
341
 */
333 342
static VALUE
334 343
curses_ungetch(VALUE obj, VALUE ch)
335 344
{
......
342 351
#define curses_ungetch rb_f_notimplement
343 352
#endif
344 353

  
345
/* def setpos(y, x) */
346 354
static VALUE
347 355
curses_setpos(VALUE obj, VALUE y, VALUE x)
348 356
{
......
351 359
    return Qnil;
352 360
}
353 361

  
354
/* def standout */
355 362
static VALUE
356 363
curses_standout(VALUE obj)
357 364
{
......
360 367
    return Qnil;
361 368
}
362 369

  
363
/* def standend */
364 370
static VALUE
365 371
curses_standend(VALUE obj)
366 372
{
......
369 375
    return Qnil;
370 376
}
371 377

  
372
/* def inch */
373 378
static VALUE
374 379
curses_inch(VALUE obj)
375 380
{
......
377 382
    return CH2FIX(inch());
378 383
}
379 384

  
380
/* def addch(ch) */
381 385
static VALUE
382 386
curses_addch(VALUE obj, VALUE ch)
383 387
{
......
386 390
    return Qnil;
387 391
}
388 392

  
389
/* def insch(ch) */
390 393
static VALUE
391 394
curses_insch(VALUE obj, VALUE ch)
392 395
{
......
395 398
    return Qnil;
396 399
}
397 400

  
398
/* def addstr(str) */
401
/*
402
 * Document-method: Curses.addstr
403
 * call-seq: addstr(str)
404
 *
405
 * add a string of characters +str+, to the window and advance cursor
406
 *
407
 */
399 408
static VALUE
400 409
curses_addstr(VALUE obj, VALUE str)
401 410
{
......
416 425
    return Qnil;
417 426
}
418 427

  
419
/* def getch */
428
/*
429
 * Document-method: Curses.getch
430
 *
431
 * Read and returns a character from the window.
432
 *
433
 * See Curses::Key to all the function KEY_* available
434
 *
435
 */
420 436
static VALUE
421 437
curses_getch(VALUE obj)
422 438
{
......
448 464
    return Qnil;
449 465
}
450 466

  
451
/* def getstr */
452 467
static VALUE
453 468
curses_getstr(VALUE obj)
454 469
{
......
459 474
    return rb_locale_str_new_cstr(rtn);
460 475
}
461 476

  
462
/* def delch */
463 477
static VALUE
464 478
curses_delch(VALUE obj)
465 479
{
......
468 482
    return Qnil;
469 483
}
470 484

  
471
/* def delelteln */
472 485
static VALUE
473 486
curses_deleteln(VALUE obj)
474 487
{
......
479 492
    return Qnil;
480 493
}
481 494

  
482
/* def insertln */
483 495
static VALUE
484 496
curses_insertln(VALUE obj)
485 497
{
......
490 502
    return Qnil;
491 503
}
492 504

  
493
/* def keyname */
494 505
static VALUE
495 506
curses_keyname(VALUE obj, VALUE c)
496 507
{
......
581 592
    /* return INT2FIX(attroff(NUM2INT(attrs))); */
582 593
}
583 594

  
595
/*
596
 * call-seq: attrset(attrs)
597
 *
598
 * see also Curses::Window.attrset
599
 *
600
 */
584 601
static VALUE
585 602
curses_attrset(VALUE obj, VALUE attrs)
586 603
{
......
589 606
    /* return INT2FIX(attroff(NUM2INT(attrs))); */
590 607
}
591 608

  
609
/* 
610
 * Document-method: Curses.bkgdset
611
 * call-seq: bkgdset(ch)
612
 *
613
 * Manipulate the background of the named window
614
 * with character Integer +ch+
615
 *
616
 * The background becomes a property of the character
617
 * and moves with the character through any scrolling
618
 * and insert/delete line/character operations.
619
 *
620
 * see also the system manual for curs_bkgd(3)
621
 */
592 622
static VALUE
593 623
curses_bkgdset(VALUE obj, VALUE ch)
594 624
{
......
599 629
    return Qnil;
600 630
}
601 631

  
632
/* 
633
 * call-seq: bkgd(ch)
634
 *
635
 * Window background manipulation routines.
636
 *
637
 * Set the background property of the current
638
 * and then apply the character Integer +ch+ setting
639
 * to every character position in that window.
640
 *
641
 * see also the system manual for curs_bkgd(3)
642
 */
602 643
static VALUE
603 644
curses_bkgd(VALUE obj, VALUE ch)
604 645
{
......
611 652
}
612 653

  
613 654
#if defined(HAVE_USE_DEFAULT_COLORS)
655
/*
656
 * tells the curses library to use terminal's default colors.
657
 *
658
 * see also the system manual for default_colors(3)
659
 */
614 660
static VALUE
615 661
curses_use_default_colors(VALUE obj)
616 662
{
......
623 669
#endif
624 670

  
625 671
#if defined(HAVE_TABSIZE)
672
/* 
673
 * Document-method: TABSIZE=
674
 * call-seq: TABSIZE=(value)
675
 *
676
 * Sets the TABSIZE to Integer +value+
677
 */
626 678
static VALUE
627 679
curses_tabsize_set(VALUE obj, VALUE val)
628 680
{
......
634 686
#endif
635 687

  
636 688
#if defined(HAVE_TABSIZE)
689
/* 
690
 * Returns the number of positions in a tab.
691
 */
637 692
static VALUE
638 693
curses_tabsize_get(VALUE ojb)
639 694
{
......
644 699
#endif
645 700

  
646 701
#if defined(HAVE_ESCDELAY)
702
/* 
703
 * call-seq: ESCDELAY=(value)
704
 *
705
 * Sets the ESCDELAY to Integer +value+
706
 */
647 707
static VALUE
648 708
curses_escdelay_set(VALUE obj, VALUE val)
649 709
{
......
655 715
#endif
656 716

  
657 717
#if defined(HAVE_ESCDELAY)
718
/* 
719
 * Returns the total time, in milliseconds, for which
720
 * curses will await a character sequence, e.g., a function key
721
 */
658 722
static VALUE
659 723
curses_escdelay_get(VALUE obj)
660 724
{
......
664 728
#define curses_escdelay_get rb_f_notimplement
665 729
#endif
666 730

  
731
/* 
732
 * Document-method: Curses.resize
733
 * call-seq: resize(lines, cols)
734
 *
735
 * alias for Curses.resizeterm
736
 *
737
 */
738

  
739
/* 
740
 * Document-method: Curses.resizeterm
741
 * call-seq: resizeterm(lines, cols)
742
 *
743
 * Resize the current term to Fixnum +lines+ and Fixnum +cols+
744
 *
745
 */
667 746
static VALUE
668 747
curses_resizeterm(VALUE obj, VALUE lin, VALUE col)
669 748
{
......
795 874
	xfree(mdata->mevent);
796 875
}
797 876

  
877
/* 
878
 * Document-method: Curses.getmouse
879
 *
880
 * Returns the current mouse or nil
881
 */
798 882
static VALUE
799 883
curses_getmouse(VALUE obj)
800 884
{
......
840 924
    return (UINT2NUM(mdata->mevent -> mem)); \
841 925
}
842 926

  
927
/*
928
 * Document-method: Curses::MouseEvent.eid
929
 *
930
 * Returns the current mouse id
931
 */
843 932
DEFINE_MOUSE_GET_MEMBER(curs_mouse_id, id)
933
/*
934
 * Document-method: Curses::MouseEvent.x
935
 *
936
 * Returns the current mouse's X coordinate
937
 */
844 938
DEFINE_MOUSE_GET_MEMBER(curs_mouse_x, x)
939
/*
940
 * Document-method: Curses::MouseEvent.y
941
 *
942
 * Returns the current mouse's Y coordinate
943
 */
845 944
DEFINE_MOUSE_GET_MEMBER(curs_mouse_y, y)
945
/*
946
 * Document-method: Curses::MouseEvent.z
947
 *
948
 * Returns the current mouse's Z coordinate
949
 */
846 950
DEFINE_MOUSE_GET_MEMBER(curs_mouse_z, z)
951
/*
952
 * Document-method: Curses::MouseEvent.bstate
953
 *
954
 * Returns the current mouse's B state.
955
 *
956
 * ???
957
 */
847 958
DEFINE_MOUSE_GET_MEMBER(curs_mouse_bstate, bstate)
848 959
#undef define_curs_mouse_member
849 960
#endif /* USE_MOUSE */
850 961

  
851 962
#ifdef HAVE_TIMEOUT
963
/*
964
 * Document-method: Curses.timeout=
965
 * call-seq: timeout=(delay)
966
 *
967
 * Sets block and non-blocking reads for the window.
968
 * - If delay is negative, blocking read is used (i.e., waits indefinitely for input).
969
 * - If delay is zero, then non-blocking read is used (i.e., read returns ERR if no input is waiting).
970
 * - If delay is positive, then read blocks for delay milliseconds, and returns ERR if there is still no input.
971
 *
972
 */
852 973
static VALUE
853 974
curses_timeout(VALUE obj, VALUE delay)
854 975
{
......
884 1005

  
885 1006
/*-------------------------- class Window --------------------------*/
886 1007

  
887
/* def self.allocate */
1008
/* returns a Curses::Window object */
888 1009
static VALUE
889 1010
window_s_allocate(VALUE class)
890 1011
{
......
893 1014
    return Data_Make_Struct(class, struct windata, 0, free_window, winp);
894 1015
}
895 1016

  
896
/* def initialize(h, w, top, left) */
1017
/* 
1018
 * Document-method: Curses::Window.new
1019
 * call-seq: new(height, width, top, left)
1020
 *
1021
 * Contruct a new Curses::Window with constraints of 
1022
 * +height+ lines, +width+ columns, begin at +top+ line, and begin +left+ most column.
1023
 *
1024
 * A new window using full screen is called as 
1025
 * 	Curses::Window.new(0,0,0,0)
1026
 *
1027
 */
897 1028
static VALUE
898 1029
window_initialize(VALUE obj, VALUE h, VALUE w, VALUE top, VALUE left)
899 1030
{
......
911 1042
    return obj;
912 1043
}
913 1044

  
914
/* def subwin(height, width, top, left) */
1045
/* 
1046
 * Document-method: Curses::Window.subwin
1047
 * call-seq: subwin(height, width, top, left)
1048
 *
1049
 * Contruct a new subwindow with constraints of 
1050
 * +height+ lines, +width+ columns, begin at +top+ line, and begin +left+ most column.
1051
 *
1052
 */
915 1053
static VALUE
916 1054
window_subwin(VALUE obj, VALUE height, VALUE width, VALUE top, VALUE left)
917 1055
{
......
931 1069
    return win;
932 1070
}
933 1071

  
934
/* def close */
1072
/*  
1073
 * Document-method: Curses::Window.close
1074
 *
1075
 * Deletes the window, and frees the memory
1076
 */
935 1077
static VALUE
936 1078
window_close(VALUE obj)
937 1079
{
......
944 1086
    return Qnil;
945 1087
}
946 1088

  
947
/* def clear */
1089
/*  
1090
 * Document-method: Curses::Window.clear
1091
 *
1092
 * Clear the window.
1093
 */
948 1094
static VALUE
949 1095
window_clear(VALUE obj)
950 1096
{
......
956 1102
    return Qnil;
957 1103
}
958 1104

  
959
/* def clrtoeol */
1105
/*  
1106
 * Document-method: Curses::Window.clrtoeol
1107
 *
1108
 * Clear the window to the end of line, that the cursor is currently on.
1109
 */
960 1110
static VALUE
961 1111
window_clrtoeol(VALUE obj)
962 1112
{
......
968 1118
    return Qnil;
969 1119
}
970 1120

  
971
/* def refresh */
1121
/*  
1122
 * Document-method: Curses::Window.refresh
1123
 *
1124
 * Refreshes the windows and lines.
1125
 *
1126
 */
972 1127
static VALUE
973 1128
window_refresh(VALUE obj)
974 1129
{
......
980 1135
    return Qnil;
981 1136
}
982 1137

  
983
/* def noutrefresh */
1138
/*  
1139
 * Document-method: Curses::Window.noutrefresh
1140
 *
1141
 * Refreshes the windows and lines.
1142
 *
1143
 * Curses::Window.noutrefresh allows multiple updates with
1144
 * more efficiency than Curses::Window.refresh alone.
1145
 */
984 1146
static VALUE
985 1147
window_noutrefresh(VALUE obj)
986 1148
{
......
996 1158
    return Qnil;
997 1159
}
998 1160

  
999
/* def move(y, x) */
1161
/*  
1162
 * Document-method: Curses::Window.move
1163
 * call-seq: move(y,x)
1164
 *
1165
 * Moves the window so that the upper left-hand corner is at position (+y+, +x+)
1166
 */
1000 1167
static VALUE
1001 1168
window_move(VALUE obj, VALUE y, VALUE x)
1002 1169
{
......
1008 1175
    return Qnil;
1009 1176
}
1010 1177

  
1011
/* def setpos(y, x) */
1178
/*  
1179
 * Document-method: Curses::Window.setpos
1180
 * call-seq: setpos(y, x)
1181
 *
1182
 * A setter for the position of the window,
1183
 * using coordinates +x+ and +y+
1184
 *
1185
 */
1012 1186
static VALUE
1013 1187
window_setpos(VALUE obj, VALUE y, VALUE x)
1014 1188
{
......
1019 1193
    return Qnil;
1020 1194
}
1021 1195

  
1022
/* def cury */
1196
/*  
1197
 * Document-method: Curses::Window.cury
1198
 *
1199
 * A getter for the current line (Y coord) of the window
1200
 */
1023 1201
static VALUE
1024 1202
window_cury(VALUE obj)
1025 1203
{
......
1031 1209
    return INT2FIX(y);
1032 1210
}
1033 1211

  
1034
/* def curx */
1212
/*  
1213
 * Document-method: Curses::Window.curx
1214
 *
1215
 * A getter for the current column (X coord) of the window
1216
 */
1035 1217
static VALUE
1036 1218
window_curx(VALUE obj)
1037 1219
{
......
1043 1225
    return INT2FIX(x);
1044 1226
}
1045 1227

  
1046
/* def maxy */
1228
/*  
1229
 * Document-method: Curses::Window.maxy
1230
 *
1231
 * A getter for the maximum lines for the window
1232
 */
1047 1233
static VALUE
1048 1234
window_maxy(VALUE obj)
1049 1235
{
......
1063 1249
#endif
1064 1250
}
1065 1251

  
1066
/* def maxx */
1252
/*  
1253
 * Document-method: Curses::Window.maxx
1254
 *
1255
 * A getter for the maximum columns for the window
1256
 */
1067 1257
static VALUE
1068 1258
window_maxx(VALUE obj)
1069 1259
{
......
1083 1273
#endif
1084 1274
}
1085 1275

  
1086
/* def begy */
1276
/*  
1277
 * Document-method: Curses::Window.begy
1278
 *
1279
 * A getter for the beginning line (Y coord) of the window
1280
 */
1087 1281
static VALUE
1088 1282
window_begy(VALUE obj)
1089 1283
{
......
1099 1293
#endif
1100 1294
}
1101 1295

  
1102
/* def begx */
1296
/*  
1297
 * Document-method: Curses::Window.begx
1298
 *
1299
 * A getter for the beginning column (X coord) of the window
1300
 */
1103 1301
static VALUE
1104 1302
window_begx(VALUE obj)
1105 1303
{
......
1115 1313
#endif
1116 1314
}
1117 1315

  
1118
/* def box(vert, hor) */
1316
/* 
1317
 * Document-method: Curses::Window.box
1318
 * call-seq: box(vert, hor)
1319
 *
1320
 * set the characters to frame the window in.
1321
 * The vertical +vert+ and horizontal +hor+ character.
1322
 *
1323
 * 	win = Curses::Window.new(5,5,5,5)
1324
 * 	win.box(?|, ?-)
1325
 *
1326
 */
1119 1327
static VALUE
1120 1328
window_box(int argc, VALUE *argv, VALUE self)
1121 1329
{
......
1149 1357
    return Qnil;
1150 1358
}
1151 1359

  
1152
/* def standout */
1360
/* 
1361
 * Document-method: Curses::Window.standout
1362
 *
1363
 * Enables the best highlighting mode of the terminal.
1364
 *
1365
 * This is equivalent to Curses::Window.attron(A_STANDOUT)
1366
 *
1367
 * see also Curses::Window.attrset
1368
 */
1153 1369
static VALUE
1154 1370
window_standout(VALUE obj)
1155 1371
{
......
1160 1376
    return Qnil;
1161 1377
}
1162 1378

  
1163
/* def standend */
1379
/* 
1380
 * Document-method: Curses::Window.standend
1381
 *
1382
 * Enables the Normal display (no highlight)
1383
 *
1384
 * This is equivalent to Curses::Window.attron(A_NORMAL)
1385
 *
1386
 * see also Curses::Window.attrset
1387
 */
1164 1388
static VALUE
1165 1389
window_standend(VALUE obj)
1166 1390
{
......
1171 1395
    return Qnil;
1172 1396
}
1173 1397

  
1174
/* def inch */
1398
/* 
1399
 * Document-method: Curses::Window.inch
1400
 *
1401
 * Returns the character at the current position of the window.
1402
 */
1175 1403
static VALUE
1176 1404
window_inch(VALUE obj)
1177 1405
{
......
1181 1409
    return CH2FIX(winch(winp->window));
1182 1410
}
1183 1411

  
1184
/* def addch(ch) */
1412
/* 
1413
 * Document-method: Curses::Window.addch
1414
 * call-seq: addch(ch)
1415
 *
1416
 * Add a character +ch+, with attributes, to the window, then advance the cursor.
1417
 * 
1418
 * see also the system manual for curs_addch(3)
1419
 */
1185 1420
static VALUE
1186 1421
window_addch(VALUE obj, VALUE ch)
1187 1422
{
......
1193 1428
    return Qnil;
1194 1429
}
1195 1430

  
1196
/* def insch(ch) */
1431
/* 
1432
 * Document-method: Curses::Window.insch
1433
 * call-seq: insch(ch)
1434
 *
1435
 * Insert a character +ch+, before the cursor, in the current window
1436
 * 
1437
 */
1197 1438
static VALUE
1198 1439
window_insch(VALUE obj, VALUE ch)
1199 1440
{
......
1205 1446
    return Qnil;
1206 1447
}
1207 1448

  
1208
/* def addstr(str) */
1449
/*
1450
 * Document-method: Curses::Window.addstr
1451
 * call-seq: addstr(str)
1452
 *
1453
 * add a string of characters +str+, to the window and advance cursor
1454
 *
1455
 */
1209 1456
static VALUE
1210 1457
window_addstr(VALUE obj, VALUE str)
1211 1458
{
......
1220 1467
    return Qnil;
1221 1468
}
1222 1469

  
1223
/* def <<(str) */
1470
/*
1471
 * Document-method: Curses::Window.<<
1472
 * call-seq: <<(str)
1473
 *
1474
 * Add String +str+ to the current string.
1475
 *
1476
 * See also Curses::Window.addstr
1477
 */
1224 1478
static VALUE
1225 1479
window_addstr2(VALUE obj, VALUE str)
1226 1480
{
......
1241 1495
    return Qnil;
1242 1496
}
1243 1497

  
1244
/* def getch */
1498
/*
1499
 * Document-method: Curses::Window.getch
1500
 *
1501
 * Read and returns a character from the window.
1502
 *
1503
 * See Curses::Key to all the function KEY_* available
1504
 *
1505
 */
1245 1506
static VALUE
1246 1507
window_getch(VALUE obj)
1247 1508
{
......
1279 1540
    return Qnil;
1280 1541
}
1281 1542

  
1282
/* def getstr */
1543
/*
1544
 * Document-method: Curses::Window.getstr
1545
 *
1546
 * This is equivalent to a series f Curses::Window.getch calls
1547
 *
1548
 */
1283 1549
static VALUE
1284 1550
window_getstr(VALUE obj)
1285 1551
{
......
1292 1558
    return rb_locale_str_new_cstr(arg.rtn);
1293 1559
}
1294 1560

  
1295
/* def delch */
1561
/*
1562
 * Document-method: Curses::Window.delch
1563
 *
1564
 * Delete the character under the cursor
1565
 *
1566
 */
1296 1567
static VALUE
1297 1568
window_delch(VALUE obj)
1298 1569
{
......
1303 1574
    return Qnil;
1304 1575
}
1305 1576

  
1306
/* def delelteln */
1577
/*
1578
 * Document-method: Curses::Window.deleteln
1579
 *
1580
 * Delete the line under the cursor.
1581
 *
1582
 */
1307 1583
static VALUE
1308 1584
window_deleteln(VALUE obj)
1309 1585
{
......
1316 1592
    return Qnil;
1317 1593
}
1318 1594

  
1319
/* def insertln */
1595
/*
1596
 * Document-method: Curses::Window.insertln
1597
 *
1598
 * Inserts a line above the cursor, and the bottom line is lost
1599
 *
1600
 */
1320 1601
static VALUE
1321 1602
window_insertln(VALUE obj)
1322 1603
{
......
1329 1610
    return Qnil;
1330 1611
}
1331 1612

  
1613
/*
1614
 * Document-method: Curses::Window.scrollok
1615
 * call-seq: scrollok(bool)
1616
 *
1617
 * Controls what happens when the cursor of a window
1618
 * is moved off the edge of the window or scrolling region,
1619
 * either as a result of a newline action on the bottom line,
1620
 * or typing the last character of the last line.
1621
 *
1622
 * If disabled, (+bool+ is false), the cursor is left on the bottom line.
1623
 *
1624
 * If enabled, (+bool+ is true), the window is scrolled up one line
1625
 * (Note that to get the physical scrolling effect on the terminal,
1626
 * it is also necessary to call Curses::Window.idlok)
1627
 */
1332 1628
static VALUE
1333 1629
window_scrollok(VALUE obj, VALUE bf)
1334 1630
{
......
1339 1635
    return Qnil;
1340 1636
}
1341 1637

  
1638
/*
1639
 * Document-method: Curses::Window.idlok
1640
 * call-seq: idlok(bool)
1641
 *
1642
 * If +bool+ is +true+ curses considers using the hardware insert/delete
1643
 * line feature of terminals so equipped.
1644
 *
1645
 * If +bool+ is +false+, disables use of line insertion and deletion.
1646
 * This option should be enabled only if the application needs insert/delete
1647
 * line, for example, for a screen editor.
1648
 *
1649
 * It is disabled by default because insert/delete line tends to be visually
1650
 * annoying when used in applications where it is not really needed.
1651
 * If insert/delete line cannot be used, curses redraws the changed portions of all lines.
1652
 *
1653
 */
1342 1654
static VALUE
1343 1655
window_idlok(VALUE obj, VALUE bf)
1344 1656
{
......
1349 1661
    return Qnil;
1350 1662
}
1351 1663

  
1664
/* 
1665
 * Document-method: Curses::Window.setscrreg
1666
 * call-seq: setscrreg(top, bottom)
1667
 *
1668
 * Set a software scrolling region in a window.
1669
 * +top+ and +bottom+ are lines numbers of the margin.
1670
 *
1671
 *  If this option and Curses::Window.scrollok are enabled, an attempt to move off
1672
 *  the bottom margin line causes all lines in the scrolling region
1673
 *  to scroll one line in the direction of the first line.
1674
 *  Only the text of the window is scrolled.
1675
 *
1676
 */
1352 1677
static VALUE
1353 1678
window_setscrreg(VALUE obj, VALUE top, VALUE bottom)
1354 1679
{
......
1366 1691
}
1367 1692

  
1368 1693
#if defined(USE_COLOR) && defined(HAVE_WCOLOR_SET)
1694
/*
1695
 * Document-method: Curses::Window.color_set
1696
 * call-seq: color_set(col)
1697
 * 
1698
 * Sets the current color of the given window to the
1699
 * foreground/background combination described by the Fixnum +col+.
1700
 */
1369 1701
static VALUE
1370 1702
window_color_set(VALUE obj, VALUE col)
1371 1703
{
......
1378 1710
}
1379 1711
#endif /* defined(USE_COLOR) && defined(HAVE_WCOLOR_SET) */
1380 1712

  
1713
/* 
1714
 * Document-method: Curses::Window.scroll
1715
 *
1716
 * Scrolls the current window up one line.
1717
 */
1381 1718
static VALUE
1382 1719
window_scroll(VALUE obj)
1383 1720
{
......
1388 1725
    return (scroll(winp->window) == OK) ? Qtrue : Qfalse;
1389 1726
}
1390 1727

  
1728
/* 
1729
 * Document-method: Curses::Window.scrl
1730
 * call-seq: scrl(num)
1731
 *
1732
 * Scrolls the current window Fixnum +num+ lines.
1733
 * The current cursor position is not changed.
1734
 *
1735
 * For positive +num+, it scrolls up.
1736
 *
1737
 * For negative +num+, it scrolls down.
1738
 *
1739
 */
1391 1740
static VALUE
1392 1741
window_scrl(VALUE obj, VALUE n)
1393 1742
{
......
1402 1751
#endif
1403 1752
}
1404 1753

  
1754
/* 
1755
 * Document-method: Curses::Window.attroff
1756
 * call-seq: attroff(attrs)
1757
 *
1758
 * Turns on the named attributes +attrs+ without affecting any others.
1759
 *
1760
 * See also Curses::Window.attrset
1761
 */
1405 1762
static VALUE
1406 1763
window_attroff(VALUE obj, VALUE attrs)
1407 1764
{
......
1415 1772
#endif
1416 1773
}
1417 1774

  
1775
/* 
1776
 * Document-method: Curses::Window.attron
1777
 * call-seq: attron(attrs)
1778
 *
1779
 * Turns off the named attributes +attrs+
1780
 * without turning any other attributes on or off.
1781
 *
1782
 * See also Curses::Window.attrset
1783
 */
1418 1784
static VALUE
1419 1785
window_attron(VALUE obj, VALUE attrs)
1420 1786
{
......
1437 1803
#endif
1438 1804
}
1439 1805

  
1806
/* 
1807
 * Document-method: Curses::Window.attrset
1808
 * call-seq: attrset(attrs)
1809
 *
1810
 * Sets the current attributes of the given window to +attrs+.
1811
 *
1812
 * The following video attributes, defined in <curses.h>, can
1813
 * be passed to the routines Curses::Window.attron, Curses::Window.attroff,
1814
 * and Curses::Window.attrset, or OR'd with the characters passed to addch.
1815
 *   A_NORMAL        Normal display (no highlight)
1816
 *   A_STANDOUT      Best highlighting mode of the terminal.
1817
 *   A_UNDERLINE     Underlining
1818
 *   A_REVERSE       Reverse video
1819
 *   A_BLINK         Blinking
1820
 *   A_DIM           Half bright
1821
 *   A_BOLD          Extra bright or bold
1822
 *   A_PROTECT       Protected mode
1823
 *   A_INVIS         Invisible or blank mode
1824
 *   A_ALTCHARSET    Alternate character set
1825
 *   A_CHARTEXT      Bit-mask to extract a character
1826
 *   COLOR_PAIR(n)   Color-pair number n
1827
 *
1828
 * TODO: provide some examples here.
1829
 *
1830
 * see also system manual curs_attr(3)
1831
 */
1440 1832
static VALUE
1441 1833
window_attrset(VALUE obj, VALUE attrs)
1442 1834
{
......
1450 1842
#endif
1451 1843
}
1452 1844

  
1845
/*
1846
 * Document-method: Curses::Window.bkgdset
1847
 * call-seq: bkgdset(ch)
1848
 *
1849
 * Manipulate the background of the current window
1850
 * with character Integer +ch+
1851
 *
1852
 * see also Curses.bkgdset
1853
 */
1453 1854
static VALUE
1454 1855
window_bkgdset(VALUE obj, VALUE ch)
1455 1856
{
......
1462 1863
    return Qnil;
1463 1864
}
1464 1865

  
1866
/*
1867
 * Document-method: Curses::Window.bkgd
1868
 * call-seq: bkgd(ch)
1869
 *
1870
 * Set the background of the current window
1871
 * and apply character Integer +ch+ to every character.
1872
 *
1873
 * see also Curses.bkgd
1874
 */
1465 1875
static VALUE
1466 1876
window_bkgd(VALUE obj, VALUE ch)
1467 1877
{
......
1475 1885
#endif
1476 1886
}
1477 1887

  
1888
/*
1889
 * Document-method: Curses::Window.getbkgd
1890
 *
1891
 * Returns an Interer (+ch+) for the character property in the current window.
1892
 */
1478 1893
static VALUE
1479 1894
window_getbkgd(VALUE obj)
1480 1895
{
......
1489 1904
#endif
1490 1905
}
1491 1906

  
1907
/* 
1908
 * Document-method: Curses::Window.resize
1909
 * call-seq: resize(lines, cols)
1910
 *
1911
 * Resize the current window to Fixnum +lines+ and Fixnum +cols+
1912
 *
1913
 */
1492 1914
static VALUE
1493 1915
window_resize(VALUE obj, VALUE lin, VALUE col)
1494 1916
{
......
1504 1926

  
1505 1927

  
1506 1928
#ifdef HAVE_KEYPAD
1929
/*
1930
 * Document-method: Curses::Window.keypad=
1931
 * call-seq: keypad=(bool)
1932
 * 
1933
 * see Curses::Window.keypad
1934
 */
1935

  
1936
/* 
1937
 * Document-method: Curses::Window.keypad
1938
 * call-seq: keypad(bool)
1939
 *
1940
 * Enables the keypad of the user's terminal. 
1941
 * If enabled (+bool+ is +true+), the user can press a function key
1942
 * (such as an arrow key) and wgetch returns a single value representing
1943
 * the function key, as in KEY_LEFT.  If disabled (+bool+ is +false+),
1944
 * curses does not treat function keys specially and the program has to
1945
 * interpret the escape sequences itself.  If the keypad in the terminal
1946
 * can be turned on (made to transmit) and off (made to work locally),
1947
 * turning on this option causes the terminal keypad to be turned on when
1948
 * Curses::Window.getch is called.
1949
 *
1950
 * The default value for keypad is false.
1951
 *
1952
 */
1507 1953
static VALUE
1508 1954
window_keypad(VALUE obj, VALUE val)
1509 1955
{
......
1525 1971
#endif
1526 1972

  
1527 1973
#ifdef HAVE_NODELAY
1974
/*
1975
 * Document-method: Curses::Window.nodelay
1976
 * call-seq: nodelay(bool)
1977
 *
1978
 * Causes Curses::Window.getch to be a non-blocking call.  If no input is ready, getch returns ERR.
1979
 *
1980
 * If disabled (+bool+ is +false+), Curses::Window.getch waits until a key is pressed.
1981
 *
1982
 */
1528 1983
static VALUE
1529 1984
window_nodelay(VALUE obj, VALUE val)
1530 1985
{
......
1544 1999
#endif
1545 2000

  
1546 2001
#ifdef HAVE_WTIMEOUT
2002
/*
2003
 * Document-method: Curses::Window.timeout=
2004
 * call-seq: timeout=(delay)
2005
 *
2006
 * Sets block and non-blocking reads for the window.
2007
 * - If delay is negative, blocking read is used (i.e., waits indefinitely for input).
2008
 * - If delay is zero, then non-blocking read is used (i.e., read returns ERR if no input is waiting).
2009
 * - If delay is positive, then read blocks for delay milliseconds, and returns ERR if there is still no input.
2010
 *
2011
 */
1547 2012
static VALUE
1548 2013
window_timeout(VALUE obj, VALUE delay)
1549 2014
{
......
1558 2023
#endif
1559 2024

  
1560 2025
/*------------------------- Initialization -------------------------*/
2026

  
2027
/* 
2028
 * Document-module: Curses
2029
 *
2030
 * == Description
2031
 * An implementation of the CRT screen handling and optimization library.
2032
 *
2033
 * == Structures
2034
 *
2035
 * === Classes
2036
 *
2037
 * * Curses::Window - class with the means to draw a window or box
2038
 * * Curses::MouseEvent - class for collecting mouse events
2039
 *
2040
 * === Modules
2041
 *
2042
 * * Curses - basis for the curses implementation
2043
 * * Curses::Key - the collection of constants
2044
 *
2045
 * == Examples
2046
 * 
2047
 * * hello.rb
2048
 *     :include: hello.rb
2049
 *
2050
 *
2051
 * * rain.rb
2052
 *     :include: rain.rb
2053
 *
2054
 */
1561 2055
void
1562 2056
Init_curses(void)
1563 2057
{
1564 2058
    mCurses    = rb_define_module("Curses");
2059

  
2060
    /*
2061
     * Document-module: Curses::Key
2062
     *
2063
     *
2064
     * a container for the KEY_* values.
2065
     *
2066
     * See also system manual for getch(3)
2067
     *
2068
     */
1565 2069
    mKey       = rb_define_module_under(mCurses, "Key");
1566 2070

  
1567 2071
    rb_gc_register_address(&rb_stdscr);
1568 2072

  
1569 2073
#ifdef USE_MOUSE
2074
    /* 
2075
     * Document-class: Curses::MouseEvent
2076
     *
2077
     * == Description
2078
     *
2079
     * Curses::MouseEvent
2080
     *
2081
     * == Example
2082
     *
2083
     * * mouse.rb
2084
     *     :include: mouse.rb
2085
     *
2086
     */
1570 2087
    cMouseEvent = rb_define_class_under(mCurses,"MouseEvent",rb_cObject);
1571 2088
    rb_undef_method(CLASS_OF(cMouseEvent),"new");
1572 2089
    rb_define_method(cMouseEvent, "eid", curs_mouse_id, 0);
......
1653 2170
    rb_define_module_function(mCurses, "def_prog_mode", curses_def_prog_mode, 0);
1654 2171
    rb_define_module_function(mCurses, "reset_prog_mode", curses_reset_prog_mode, 0);
1655 2172

  
2173
    /*
2174
     * Document-class: Curses::Window
2175
     * 
2176
     * == Description 
2177
     *
2178
     * The means by which to create and manage frames or windows.
2179
     * While there may be more than one window at a time, only one window 
2180
     * receive the input.
2181
     *
2182
     * == Usage
2183
     *
2184
     * 		require 'curses'
2185
     *
2186
     *		Curses.init_screen()
2187
     *
2188
     * 		my_str = "LOOK! PONIES!"
2189
     * 		win = Curses::Window.new( 8, (my_str.length + 10),
2190
     * 		                          (Curses.lines - 8) / 2,
2191
     * 		                          (Curses.cols - (my_str.length + 10)) / 2 )
2192
     * 		win.box("|", "-")
2193
     * 		win.setpos(2,3)
2194
     * 		win.addstr(my_str)
2195
     * 		# or even
2196
     * 		win << "\nORLY"
2197
     * 		win << "\nYES!! " + my_str
2198
     * 		win.refresh
2199
     * 		win.getch
2200
     * 		win.close
2201
     *
2202
     */
1656 2203
    cWindow = rb_define_class_under(mCurses, "Window", rb_cData);
1657 2204
    rb_define_alloc_func(cWindow, window_s_allocate);
1658 2205
    rb_define_method(cWindow, "initialize", window_initialize, 4);
......
1835 2382
#endif /* USE_MOUSE */
1836 2383

  
1837 2384
#if defined(KEY_MOUSE) && defined(USE_MOUSE)
2385
    /* Document-const: MOUSE
2386
     *
2387
     * Mouse event read
2388
     */
1838 2389
    rb_curses_define_const(KEY_MOUSE);
1839 2390
    rb_define_const(mKey, "MOUSE", INT2NUM(KEY_MOUSE));
1840 2391
#endif
1841 2392
#ifdef KEY_MIN
2393
    /* Document-const: MIN
2394
     *
2395
     * ???
2396
     */
1842 2397
    rb_curses_define_const(KEY_MIN);
1843 2398
    rb_define_const(mKey, "MIN", INT2NUM(KEY_MIN));
1844 2399
#endif
1845 2400
#ifdef KEY_BREAK
2401
    /* Document-const: BREAK
2402
     *
2403
     * Break key
2404
     */
1846 2405
    rb_curses_define_const(KEY_BREAK);
1847 2406
    rb_define_const(mKey, "BREAK", INT2NUM(KEY_BREAK));
1848 2407
#endif
1849 2408
#ifdef KEY_DOWN
2409
    /* Document-const: DOWN
2410
     *
2411
     * the down arrow key
2412
     */
1850 2413
    rb_curses_define_const(KEY_DOWN);
1851 2414
    rb_define_const(mKey, "DOWN", INT2NUM(KEY_DOWN));
1852 2415
#endif
1853 2416
#ifdef KEY_UP
2417
    /* Document-const: UP
2418
     *
2419
     * the up arrow key
2420
     */
1854 2421
    rb_curses_define_const(KEY_UP);
1855 2422
    rb_define_const(mKey, "UP", INT2NUM(KEY_UP));
1856 2423
#endif
1857 2424
#ifdef KEY_LEFT
2425
    /* Document-const: LEFT
2426
     *
2427
     * the left arrow key
2428
     */
1858 2429
    rb_curses_define_const(KEY_LEFT);
1859 2430
    rb_define_const(mKey, "LEFT", INT2NUM(KEY_LEFT));
1860 2431
#endif
1861 2432
#ifdef KEY_RIGHT
2433
    /* Document-const: RIGHT
2434
     *
2435
     * the right arrow key
2436
     */
1862 2437
    rb_curses_define_const(KEY_RIGHT);
1863 2438
    rb_define_const(mKey, "RIGHT", INT2NUM(KEY_RIGHT));
1864 2439
#endif
1865 2440
#ifdef KEY_HOME
2441
    /* Document-const: HOME
2442
     *
2443
     * Home key (upward+left arrow)
2444
     */
1866 2445
    rb_curses_define_const(KEY_HOME);
1867 2446
    rb_define_const(mKey, "HOME", INT2NUM(KEY_HOME));
1868 2447
#endif
1869 2448
#ifdef KEY_BACKSPACE
2449
    /* Document-const: BACKSPACE
2450
     *
2451
     * Backspace
2452
     */
1870 2453
    rb_curses_define_const(KEY_BACKSPACE);
1871 2454
    rb_define_const(mKey, "BACKSPACE", INT2NUM(KEY_BACKSPACE));
1872 2455
#endif
......
1884 2467
    }
1885 2468
#endif
1886 2469
#ifdef KEY_DL
2470
    /* Document-const: DL
2471
     *
2472
     * Delete line
2473
     */
1887 2474
    rb_curses_define_const(KEY_DL);
1888 2475
    rb_define_const(mKey, "DL", INT2NUM(KEY_DL));
1889 2476
#endif
1890 2477
#ifdef KEY_IL
2478
    /* Document-const: IL
2479
     *
2480
     * Insert line
2481
     */
1891 2482
    rb_curses_define_const(KEY_IL);
1892 2483
    rb_define_const(mKey, "IL", INT2NUM(KEY_IL));
1893 2484
#endif
1894 2485
#ifdef KEY_DC
2486
    /* Document-const: DC
2487
     *
2488
     * Delete character
2489
     */
1895 2490
    rb_curses_define_const(KEY_DC);
1896 2491
    rb_define_const(mKey, "DC", INT2NUM(KEY_DC));
1897 2492
#endif
1898 2493
#ifdef KEY_IC
2494
    /* Document-const: IC
2495
     *
2496
     * Insert char or enter insert mode
2497
     */
1899 2498
    rb_curses_define_const(KEY_IC);
1900 2499
    rb_define_const(mKey, "IC", INT2NUM(KEY_IC));
1901 2500
#endif
1902 2501
#ifdef KEY_EIC
2502
    /* Document-const: EIC
2503
     *
2504
     * Enter insert char mode
2505
     */
1903 2506
    rb_curses_define_const(KEY_EIC);
1904 2507
    rb_define_const(mKey, "EIC", INT2NUM(KEY_EIC));
1905 2508
#endif
1906 2509
#ifdef KEY_CLEAR
2510
    /* Document-const: CLEAR
2511
     *
2512
     * Clear Screen
2513
     */
1907 2514
    rb_curses_define_const(KEY_CLEAR);
1908 2515
    rb_define_const(mKey, "CLEAR", INT2NUM(KEY_CLEAR));
1909 2516
#endif
1910 2517
#ifdef KEY_EOS
2518
    /* Document-const: EOS
2519
     *
2520
     * Clear to end of screen
2521
     */
1911 2522
    rb_curses_define_const(KEY_EOS);
1912 2523
    rb_define_const(mKey, "EOS", INT2NUM(KEY_EOS));
1913 2524
#endif
1914 2525
#ifdef KEY_EOL
2526
    /* Document-const: EOL
2527
     *
2528
     * Clear to end of line
2529
     */
1915 2530
    rb_curses_define_const(KEY_EOL);
1916 2531
    rb_define_const(mKey, "EOL", INT2NUM(KEY_EOL));
1917 2532
#endif
1918 2533
#ifdef KEY_SF
2534
    /* Document-const: SF
2535
     *
2536
     * Scroll 1 line forward
2537
     */
1919 2538
    rb_curses_define_const(KEY_SF);
1920 2539
    rb_define_const(mKey, "SF", INT2NUM(KEY_SF));
1921 2540
#endif
1922 2541
#ifdef KEY_SR
2542
    /* Document-const: SR
2543
     *
2544
     * Scroll 1 line backware (reverse)
2545
     */
1923 2546
    rb_curses_define_const(KEY_SR);
1924 2547
    rb_define_const(mKey, "SR", INT2NUM(KEY_SR));
1925 2548
#endif
1926 2549
#ifdef KEY_NPAGE
2550
    /* Document-const: NPAGE
2551
     *
2552
     * Next page
2553
     */
1927 2554
    rb_curses_define_const(KEY_NPAGE);
1928 2555
    rb_define_const(mKey, "NPAGE", INT2NUM(KEY_NPAGE));
1929 2556
#endif
1930 2557
#ifdef KEY_PPAGE
2558
    /* Document-const: PPAGE
2559
     *
2560
     * Previous page
2561
     */
1931 2562
    rb_curses_define_const(KEY_PPAGE);
1932 2563
    rb_define_const(mKey, "PPAGE", INT2NUM(KEY_PPAGE));
1933 2564
#endif
1934 2565
#ifdef KEY_STAB
2566
    /* Document-const: STAB
2567
     *
2568
     * Set tab
... This diff was truncated because it exceeds the maximum size that can be displayed.