curses 1.3.2 → 1.4.3

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.
Files changed (262) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +19 -0
  3. data/.github/workflows/ubuntu.yml +26 -0
  4. data/.github/workflows/windows.yml +25 -0
  5. data/History.md +27 -0
  6. data/README.md +14 -46
  7. data/Rakefile +0 -86
  8. data/curses.gemspec +3 -4
  9. data/ext/curses/curses.c +194 -38
  10. data/ext/curses/extconf.rb +81 -22
  11. data/lib/curses.rb +5 -12
  12. data/sample/addch.rb +16 -0
  13. data/sample/attr_demo.rb +32 -0
  14. data/sample/colors.rb +26 -0
  15. data/sample/mouse_move.rb +75 -0
  16. data/vendor/PDCurses/.gitignore +47 -0
  17. data/vendor/PDCurses/.travis.yml +49 -0
  18. data/vendor/PDCurses/CMakeLists.txt +68 -0
  19. data/vendor/PDCurses/HISTORY.md +2036 -0
  20. data/vendor/PDCurses/IMPLEMNT.md +327 -0
  21. data/vendor/PDCurses/Makefile +27 -0
  22. data/vendor/PDCurses/README.md +77 -0
  23. data/vendor/PDCurses/acs_defs.h +265 -0
  24. data/vendor/PDCurses/appveyor.yml +218 -0
  25. data/vendor/PDCurses/cmake/README.md +71 -0
  26. data/vendor/PDCurses/cmake/build_dependencies.cmake +178 -0
  27. data/vendor/PDCurses/cmake/build_options.cmake +25 -0
  28. data/vendor/PDCurses/cmake/dll_version.cmake +26 -0
  29. data/vendor/PDCurses/cmake/gen_config_header.cmake +43 -0
  30. data/vendor/PDCurses/cmake/get_version.cmake +17 -0
  31. data/vendor/PDCurses/cmake/make_uninstall.cmake +19 -0
  32. data/vendor/PDCurses/cmake/project_common.cmake +121 -0
  33. data/vendor/PDCurses/cmake/resource.in.cmake +52 -0
  34. data/vendor/PDCurses/cmake/sdl2_ttf/CMakeLists.txt +83 -0
  35. data/vendor/PDCurses/cmake/target_arch.cmake +36 -0
  36. data/vendor/PDCurses/cmake/version.in.cmake +73 -0
  37. data/vendor/PDCurses/cmake/watcom_open_dos16_toolchain.cmake +96 -0
  38. data/vendor/PDCurses/cmake/watcom_open_dos32_toolchain.cmake +106 -0
  39. data/vendor/PDCurses/cmake/watcom_open_os2v2_toolchain.cmake +105 -0
  40. data/vendor/PDCurses/curses.h +1846 -0
  41. data/vendor/PDCurses/curspriv.h +134 -0
  42. data/vendor/PDCurses/demos/README.md +25 -0
  43. data/vendor/PDCurses/demos/firework.c +144 -0
  44. data/vendor/PDCurses/demos/newtest.c +581 -0
  45. data/vendor/PDCurses/demos/ozdemo.c +447 -0
  46. data/vendor/PDCurses/demos/ptest.c +283 -0
  47. data/vendor/PDCurses/demos/rain.c +157 -0
  48. data/vendor/PDCurses/demos/testcurs.c +1607 -0
  49. data/vendor/PDCurses/demos/tui.c +1048 -0
  50. data/vendor/PDCurses/demos/tui.h +65 -0
  51. data/vendor/PDCurses/demos/tuidemo.c +233 -0
  52. data/vendor/PDCurses/demos/version.c +61 -0
  53. data/vendor/PDCurses/demos/worm.c +432 -0
  54. data/vendor/PDCurses/demos/xmas.c +955 -0
  55. data/vendor/PDCurses/dos/CMakeLists.txt +47 -0
  56. data/vendor/PDCurses/dos/Makefile +105 -0
  57. data/vendor/PDCurses/dos/Makefile.bcc +83 -0
  58. data/vendor/PDCurses/dos/Makefile.dmc +257 -0
  59. data/vendor/PDCurses/dos/Makefile.msc +113 -0
  60. data/vendor/PDCurses/dos/Makefile.wcc +107 -0
  61. data/vendor/PDCurses/dos/README.md +51 -0
  62. data/vendor/PDCurses/dos/bccdos.lrf +9 -0
  63. data/vendor/PDCurses/dos/mscdos.lrf +50 -0
  64. data/vendor/PDCurses/dos/pdcclip.c +132 -0
  65. data/vendor/PDCurses/dos/pdcdisp.c +135 -0
  66. data/vendor/PDCurses/dos/pdcdos.h +194 -0
  67. data/vendor/PDCurses/dos/pdcgetsc.c +98 -0
  68. data/vendor/PDCurses/dos/pdckbd.c +513 -0
  69. data/vendor/PDCurses/dos/pdcscrn.c +785 -0
  70. data/vendor/PDCurses/dos/pdcsetsc.c +101 -0
  71. data/vendor/PDCurses/dos/pdcutil.c +212 -0
  72. data/vendor/PDCurses/libobjs.mif +26 -0
  73. data/vendor/PDCurses/makedist.mif +20 -0
  74. data/vendor/PDCurses/man/Makefile +37 -0
  75. data/vendor/PDCurses/man/README.md +21 -0
  76. data/vendor/PDCurses/man/intro.md +361 -0
  77. data/vendor/PDCurses/man/manext.c +119 -0
  78. data/vendor/PDCurses/man/sdl.md +152 -0
  79. data/vendor/PDCurses/man/sdl2.md +58 -0
  80. data/vendor/PDCurses/man/x11.md +407 -0
  81. data/vendor/PDCurses/ncurses/CMakeLists.txt +66 -0
  82. data/vendor/PDCurses/ncurses/README.md +26 -0
  83. data/vendor/PDCurses/ncurses/makefile +29 -0
  84. data/vendor/PDCurses/os2/CMakeLists.txt +41 -0
  85. data/vendor/PDCurses/os2/Makefile +132 -0
  86. data/vendor/PDCurses/os2/Makefile.bcc +90 -0
  87. data/vendor/PDCurses/os2/Makefile.wcc +43 -0
  88. data/vendor/PDCurses/os2/README.md +43 -0
  89. data/vendor/PDCurses/os2/iccos2.lrf +50 -0
  90. data/vendor/PDCurses/os2/iccos2.mak +256 -0
  91. data/vendor/PDCurses/os2/pdcclip.c +188 -0
  92. data/vendor/PDCurses/os2/pdcdisp.c +93 -0
  93. data/vendor/PDCurses/os2/pdcgetsc.c +89 -0
  94. data/vendor/PDCurses/os2/pdckbd.c +521 -0
  95. data/vendor/PDCurses/os2/pdcos2.h +55 -0
  96. data/vendor/PDCurses/os2/pdcscrn.c +449 -0
  97. data/vendor/PDCurses/os2/pdcsetsc.c +112 -0
  98. data/vendor/PDCurses/os2/pdcutil.c +52 -0
  99. data/vendor/PDCurses/panel.h +56 -0
  100. data/vendor/PDCurses/pdcurses/README.md +25 -0
  101. data/vendor/PDCurses/pdcurses/addch.c +693 -0
  102. data/vendor/PDCurses/pdcurses/addchstr.c +245 -0
  103. data/vendor/PDCurses/pdcurses/addstr.c +240 -0
  104. data/vendor/PDCurses/pdcurses/attr.c +359 -0
  105. data/vendor/PDCurses/pdcurses/beep.c +68 -0
  106. data/vendor/PDCurses/pdcurses/bkgd.c +223 -0
  107. data/vendor/PDCurses/pdcurses/border.c +411 -0
  108. data/vendor/PDCurses/pdcurses/clear.c +159 -0
  109. data/vendor/PDCurses/pdcurses/color.c +298 -0
  110. data/vendor/PDCurses/pdcurses/debug.c +109 -0
  111. data/vendor/PDCurses/pdcurses/delch.c +96 -0
  112. data/vendor/PDCurses/pdcurses/deleteln.c +211 -0
  113. data/vendor/PDCurses/pdcurses/deprec.c +27 -0
  114. data/vendor/PDCurses/pdcurses/getch.c +417 -0
  115. data/vendor/PDCurses/pdcurses/getstr.c +474 -0
  116. data/vendor/PDCurses/pdcurses/getyx.c +139 -0
  117. data/vendor/PDCurses/pdcurses/inch.c +127 -0
  118. data/vendor/PDCurses/pdcurses/inchstr.c +214 -0
  119. data/vendor/PDCurses/pdcurses/initscr.c +367 -0
  120. data/vendor/PDCurses/pdcurses/inopts.c +324 -0
  121. data/vendor/PDCurses/pdcurses/insch.c +271 -0
  122. data/vendor/PDCurses/pdcurses/insstr.c +264 -0
  123. data/vendor/PDCurses/pdcurses/instr.c +246 -0
  124. data/vendor/PDCurses/pdcurses/kernel.c +259 -0
  125. data/vendor/PDCurses/pdcurses/keyname.c +157 -0
  126. data/vendor/PDCurses/pdcurses/mouse.c +438 -0
  127. data/vendor/PDCurses/pdcurses/move.c +57 -0
  128. data/vendor/PDCurses/pdcurses/outopts.c +159 -0
  129. data/vendor/PDCurses/pdcurses/overlay.c +214 -0
  130. data/vendor/PDCurses/pdcurses/pad.c +260 -0
  131. data/vendor/PDCurses/pdcurses/panel.c +633 -0
  132. data/vendor/PDCurses/pdcurses/printw.c +126 -0
  133. data/vendor/PDCurses/pdcurses/refresh.c +279 -0
  134. data/vendor/PDCurses/pdcurses/scanw.c +578 -0
  135. data/vendor/PDCurses/pdcurses/scr_dump.c +213 -0
  136. data/vendor/PDCurses/pdcurses/scroll.c +101 -0
  137. data/vendor/PDCurses/pdcurses/slk.c +591 -0
  138. data/vendor/PDCurses/pdcurses/termattr.c +182 -0
  139. data/vendor/PDCurses/pdcurses/terminfo.c +217 -0
  140. data/vendor/PDCurses/pdcurses/touch.c +163 -0
  141. data/vendor/PDCurses/pdcurses/util.c +312 -0
  142. data/vendor/PDCurses/pdcurses/window.c +569 -0
  143. data/vendor/PDCurses/sdl1/Makefile +129 -0
  144. data/vendor/PDCurses/sdl1/Makefile.mng +110 -0
  145. data/vendor/PDCurses/sdl1/README.md +31 -0
  146. data/vendor/PDCurses/sdl1/deffont.h +385 -0
  147. data/vendor/PDCurses/sdl1/deficon.h +23 -0
  148. data/vendor/PDCurses/sdl1/pdcclip.c +131 -0
  149. data/vendor/PDCurses/sdl1/pdcdisp.c +373 -0
  150. data/vendor/PDCurses/sdl1/pdcgetsc.c +30 -0
  151. data/vendor/PDCurses/sdl1/pdckbd.c +405 -0
  152. data/vendor/PDCurses/sdl1/pdcscrn.c +414 -0
  153. data/vendor/PDCurses/sdl1/pdcsdl.h +31 -0
  154. data/vendor/PDCurses/sdl1/pdcsetsc.c +64 -0
  155. data/vendor/PDCurses/sdl1/pdcutil.c +40 -0
  156. data/vendor/PDCurses/sdl1/sdltest.c +79 -0
  157. data/vendor/PDCurses/sdl2/CMakeLists.txt +76 -0
  158. data/vendor/PDCurses/sdl2/Makefile +135 -0
  159. data/vendor/PDCurses/sdl2/Makefile.vc +164 -0
  160. data/vendor/PDCurses/sdl2/README.md +34 -0
  161. data/vendor/PDCurses/sdl2/deffont.h +385 -0
  162. data/vendor/PDCurses/sdl2/deficon.h +23 -0
  163. data/vendor/PDCurses/sdl2/pdcclip.c +93 -0
  164. data/vendor/PDCurses/sdl2/pdcdisp.c +534 -0
  165. data/vendor/PDCurses/sdl2/pdcgetsc.c +30 -0
  166. data/vendor/PDCurses/sdl2/pdckbd.c +480 -0
  167. data/vendor/PDCurses/sdl2/pdcscrn.c +443 -0
  168. data/vendor/PDCurses/sdl2/pdcsdl.h +33 -0
  169. data/vendor/PDCurses/sdl2/pdcsetsc.c +67 -0
  170. data/vendor/PDCurses/sdl2/pdcutil.c +39 -0
  171. data/vendor/PDCurses/sdl2/sdltest.c +81 -0
  172. data/vendor/PDCurses/term.h +48 -0
  173. data/vendor/PDCurses/version.mif +7 -0
  174. data/vendor/PDCurses/vt/CMakeLists.txt +28 -0
  175. data/vendor/PDCurses/vt/Makefile +135 -0
  176. data/vendor/PDCurses/vt/Makefile.bcc +111 -0
  177. data/vendor/PDCurses/vt/Makefile.dmc +258 -0
  178. data/vendor/PDCurses/vt/Makefile.vc +144 -0
  179. data/vendor/PDCurses/vt/Makefile.wcc +107 -0
  180. data/vendor/PDCurses/vt/README.md +64 -0
  181. data/vendor/PDCurses/vt/pdcclip.c +20 -0
  182. data/vendor/PDCurses/vt/pdcdisp.c +284 -0
  183. data/vendor/PDCurses/vt/pdcgetsc.c +27 -0
  184. data/vendor/PDCurses/vt/pdckbd.c +394 -0
  185. data/vendor/PDCurses/vt/pdcscrn.c +434 -0
  186. data/vendor/PDCurses/vt/pdcsetsc.c +45 -0
  187. data/vendor/PDCurses/vt/pdcutil.c +43 -0
  188. data/vendor/PDCurses/vt/pdcvt.h +16 -0
  189. data/vendor/PDCurses/watcom.mif +68 -0
  190. data/vendor/PDCurses/wincon/CMakeLists.txt +27 -0
  191. data/vendor/PDCurses/wincon/Makefile.bcc +88 -0
  192. data/vendor/PDCurses/wincon/Makefile.dmc +256 -0
  193. data/vendor/PDCurses/wincon/Makefile.lcc +273 -0
  194. data/vendor/PDCurses/wincon/Makefile.mng +176 -0
  195. data/vendor/PDCurses/wincon/Makefile.vc +144 -0
  196. data/vendor/PDCurses/wincon/Makefile.wcc +51 -0
  197. data/vendor/PDCurses/wincon/README.md +85 -0
  198. data/vendor/PDCurses/wincon/pdcclip.c +174 -0
  199. data/vendor/PDCurses/wincon/pdcdisp.c +143 -0
  200. data/vendor/PDCurses/wincon/pdcgetsc.c +55 -0
  201. data/vendor/PDCurses/wincon/pdckbd.c +786 -0
  202. data/vendor/PDCurses/wincon/pdcscrn.c +717 -0
  203. data/vendor/PDCurses/wincon/pdcsetsc.c +91 -0
  204. data/vendor/PDCurses/wincon/pdcurses.ico +0 -0
  205. data/vendor/PDCurses/wincon/pdcurses.rc +28 -0
  206. data/vendor/PDCurses/wincon/pdcutil.c +41 -0
  207. data/vendor/PDCurses/wincon/pdcwin.h +31 -0
  208. data/vendor/PDCurses/wingui/CMakeLists.txt +27 -0
  209. data/vendor/PDCurses/wingui/Makefile.bcc +85 -0
  210. data/vendor/PDCurses/wingui/Makefile.dmc +259 -0
  211. data/vendor/PDCurses/wingui/Makefile.lcc +273 -0
  212. data/vendor/PDCurses/wingui/Makefile.mng +171 -0
  213. data/vendor/PDCurses/wingui/Makefile.vc +144 -0
  214. data/vendor/PDCurses/wingui/Makefile.wcc +51 -0
  215. data/vendor/PDCurses/wingui/README.md +93 -0
  216. data/vendor/PDCurses/wingui/pdcclip.c +174 -0
  217. data/vendor/PDCurses/wingui/pdcdisp.c +718 -0
  218. data/vendor/PDCurses/wingui/pdcgetsc.c +30 -0
  219. data/vendor/PDCurses/wingui/pdckbd.c +143 -0
  220. data/vendor/PDCurses/wingui/pdcscrn.c +2797 -0
  221. data/vendor/PDCurses/wingui/pdcsetsc.c +89 -0
  222. data/vendor/PDCurses/wingui/pdcurses.ico +0 -0
  223. data/vendor/PDCurses/wingui/pdcurses.rc +28 -0
  224. data/vendor/PDCurses/wingui/pdcutil.c +61 -0
  225. data/vendor/PDCurses/wingui/pdcwin.h +122 -0
  226. data/vendor/PDCurses/x11/Makefile.in +754 -0
  227. data/vendor/PDCurses/x11/PDCurses.spec +82 -0
  228. data/vendor/PDCurses/x11/README.md +62 -0
  229. data/vendor/PDCurses/x11/ScrollBox.c +319 -0
  230. data/vendor/PDCurses/x11/ScrollBox.h +51 -0
  231. data/vendor/PDCurses/x11/ScrollBoxP.h +70 -0
  232. data/vendor/PDCurses/x11/aclocal.m4 +994 -0
  233. data/vendor/PDCurses/x11/big_icon.xbm +46 -0
  234. data/vendor/PDCurses/x11/compose.h +201 -0
  235. data/vendor/PDCurses/x11/config.guess +1500 -0
  236. data/vendor/PDCurses/x11/config.h.in +100 -0
  237. data/vendor/PDCurses/x11/config.sub +1616 -0
  238. data/vendor/PDCurses/x11/configure +6700 -0
  239. data/vendor/PDCurses/x11/configure.ac +295 -0
  240. data/vendor/PDCurses/x11/debian/changelog +6 -0
  241. data/vendor/PDCurses/x11/debian/compat +1 -0
  242. data/vendor/PDCurses/x11/debian/control +11 -0
  243. data/vendor/PDCurses/x11/debian/copyright +27 -0
  244. data/vendor/PDCurses/x11/debian/rules +98 -0
  245. data/vendor/PDCurses/x11/install-sh +253 -0
  246. data/vendor/PDCurses/x11/little_icon.xbm +14 -0
  247. data/vendor/PDCurses/x11/ncurses_cfg.h +45 -0
  248. data/vendor/PDCurses/x11/pdcclip.c +173 -0
  249. data/vendor/PDCurses/x11/pdcdisp.c +85 -0
  250. data/vendor/PDCurses/x11/pdcgetsc.c +28 -0
  251. data/vendor/PDCurses/x11/pdckbd.c +104 -0
  252. data/vendor/PDCurses/x11/pdcscrn.c +258 -0
  253. data/vendor/PDCurses/x11/pdcsetsc.c +95 -0
  254. data/vendor/PDCurses/x11/pdcutil.c +52 -0
  255. data/vendor/PDCurses/x11/pdcx11.c +316 -0
  256. data/vendor/PDCurses/x11/pdcx11.h +191 -0
  257. data/vendor/PDCurses/x11/sb.c +155 -0
  258. data/vendor/PDCurses/x11/x11.c +3686 -0
  259. data/vendor/PDCurses/x11/xcurses-config.in +81 -0
  260. metadata +259 -25
  261. data/.travis.yml +0 -16
  262. data/appveyor.yml +0 -16
data/ext/curses/curses.c CHANGED
@@ -20,7 +20,9 @@
20
20
  #include "ruby/io.h"
21
21
  #include "ruby/thread.h"
22
22
 
23
- #if defined(HAVE_NCURSESW_CURSES_H)
23
+ #if defined(HAVE_PDCURSES_H)
24
+ # include <pdcurses.h>
25
+ #elif defined(HAVE_NCURSESW_CURSES_H)
24
26
  # include <ncursesw/curses.h>
25
27
  #elif defined(HAVE_NCURSES_CURSES_H)
26
28
  # include <ncurses/curses.h>
@@ -80,8 +82,19 @@
80
82
  # define USE_MOUSE 1
81
83
  #endif
82
84
 
83
- #define NUM2CH NUM2CHR
84
- #define CH2FIX CHR2FIX
85
+ #define OBJ2CHTYPE rb_obj2chtype_inline
86
+
87
+ static inline chtype
88
+ rb_obj2chtype_inline(VALUE x)
89
+ {
90
+ if (RB_TYPE_P(x, RUBY_T_STRING)) {
91
+ ID id_ord;
92
+
93
+ CONST_ID(id_ord, "ord");
94
+ x = rb_funcall(x, id_ord, 0);
95
+ }
96
+ return NUM2CHTYPE(x);
97
+ }
85
98
 
86
99
  static VALUE mCurses;
87
100
  static VALUE mKey;
@@ -289,7 +302,7 @@ static void curses_finalize(VALUE);
289
302
  * see also Curses.stdscr
290
303
  */
291
304
  static VALUE
292
- curses_init_screen(void)
305
+ curses_init_screen(VALUE self)
293
306
  {
294
307
  if (rb_stdscr) return rb_stdscr;
295
308
  initscr();
@@ -312,7 +325,7 @@ curses_init_screen(void)
312
325
  *
313
326
  * Many curses functions use this window.
314
327
  */
315
- #define curses_stdscr curses_init_screen
328
+ #define curses_stdscr() curses_init_screen(Qnil)
316
329
 
317
330
  /*
318
331
  * Document-method: Curses.close_screen
@@ -328,7 +341,7 @@ curses_init_screen(void)
328
341
  *
329
342
  */
330
343
  static VALUE
331
- curses_close_screen(void)
344
+ curses_close_screen(VALUE self)
332
345
  {
333
346
  curses_stdscr();
334
347
  #ifdef HAVE_ISENDWIN
@@ -368,7 +381,7 @@ curses_finalize(VALUE dummy)
368
381
  * returns +false+ otherwise.
369
382
  */
370
383
  static VALUE
371
- curses_closed(void)
384
+ curses_closed(VALUE self)
372
385
  {
373
386
  curses_stdscr();
374
387
  if (isendwin()) {
@@ -418,7 +431,7 @@ curses_erase(VALUE obj)
418
431
  * Clears to the end of line, that the cursor is currently on.
419
432
  */
420
433
  static VALUE
421
- curses_clrtoeol(void)
434
+ curses_clrtoeol(VALUE self)
422
435
  {
423
436
  curses_stdscr();
424
437
  clrtoeol();
@@ -607,6 +620,20 @@ curses_nonl(VALUE obj)
607
620
  return Qnil;
608
621
  }
609
622
 
623
+ /*
624
+ * Document-method: Curses.flushinp
625
+ *
626
+ * The flushinp routine throws away any typeahead that has been
627
+ * typed by the user and has not yet been read by the program.
628
+ */
629
+ static VALUE
630
+ curses_flushinp(VALUE obj)
631
+ {
632
+ curses_stdscr();
633
+ flushinp();
634
+ return Qnil;
635
+ }
636
+
610
637
  /*
611
638
  * Document-method: Curses.beep
612
639
  *
@@ -745,7 +772,7 @@ static VALUE
745
772
  curses_inch(VALUE obj)
746
773
  {
747
774
  curses_stdscr();
748
- return CH2FIX(inch());
775
+ return CHTYPE2NUM(inch());
749
776
  }
750
777
 
751
778
  /*
@@ -760,7 +787,7 @@ static VALUE
760
787
  curses_addch(VALUE obj, VALUE ch)
761
788
  {
762
789
  curses_stdscr();
763
- addch(NUM2CH(ch));
790
+ addch(OBJ2CHTYPE(ch));
764
791
  return Qnil;
765
792
  }
766
793
 
@@ -775,7 +802,7 @@ static VALUE
775
802
  curses_insch(VALUE obj, VALUE ch)
776
803
  {
777
804
  curses_stdscr();
778
- insch(NUM2CH(ch));
805
+ insch(OBJ2CHTYPE(ch));
779
806
  return Qnil;
780
807
  }
781
808
 
@@ -947,7 +974,7 @@ curses_keyname(VALUE obj, VALUE c)
947
974
  * Returns the number of lines on the screen
948
975
  */
949
976
  static VALUE
950
- curses_lines(void)
977
+ curses_lines(VALUE self)
951
978
  {
952
979
  return INT2FIX(LINES);
953
980
  }
@@ -958,7 +985,7 @@ curses_lines(void)
958
985
  * Returns the number of columns on the screen
959
986
  */
960
987
  static VALUE
961
- curses_cols(void)
988
+ curses_cols(VALUE self)
962
989
  {
963
990
  return INT2FIX(COLS);
964
991
  }
@@ -1104,7 +1131,7 @@ curses_bkgdset(VALUE obj, VALUE ch)
1104
1131
  {
1105
1132
  #ifdef HAVE_BKGDSET
1106
1133
  curses_stdscr();
1107
- bkgdset(NUM2CHTYPE(ch));
1134
+ bkgdset(OBJ2CHTYPE(ch));
1108
1135
  #endif
1109
1136
  return Qnil;
1110
1137
  }
@@ -1125,7 +1152,7 @@ curses_bkgd(VALUE obj, VALUE ch)
1125
1152
  {
1126
1153
  #ifdef HAVE_BKGD
1127
1154
  curses_stdscr();
1128
- return (bkgd(NUM2CHTYPE(ch)) == OK) ? Qtrue : Qfalse;
1155
+ return (bkgd(OBJ2CHTYPE(ch)) == OK) ? Qtrue : Qfalse;
1129
1156
  #else
1130
1157
  return Qfalse;
1131
1158
  #endif
@@ -1546,7 +1573,7 @@ static VALUE
1546
1573
  curses_mousemask(VALUE obj, VALUE mask)
1547
1574
  {
1548
1575
  curses_stdscr();
1549
- return INT2NUM(mousemask(NUM2UINT(mask),NULL));
1576
+ return ULONG2NUM(mousemask(NUM2UINT(mask),NULL));
1550
1577
  }
1551
1578
 
1552
1579
  #define DEFINE_MOUSE_GET_MEMBER(func_name,mem) \
@@ -1587,7 +1614,12 @@ DEFINE_MOUSE_GET_MEMBER(curs_mouse_z, z)
1587
1614
  * Returns the current mouse's button state. Use this with the button state
1588
1615
  * constants to determine which buttons were pressed.
1589
1616
  */
1590
- DEFINE_MOUSE_GET_MEMBER(curs_mouse_bstate, bstate)
1617
+ static VALUE curs_mouse_bstate(VALUE mouse)
1618
+ {
1619
+ struct mousedata *mdata;
1620
+ GetMOUSE(mouse, mdata);
1621
+ return ULONG2NUM(mdata->mevent->bstate);
1622
+ }
1591
1623
  #undef define_curs_mouse_member
1592
1624
  #endif /* USE_MOUSE */
1593
1625
 
@@ -1679,7 +1711,7 @@ window_initialize(VALUE obj, VALUE h, VALUE w, VALUE top, VALUE left)
1679
1711
  struct windata *winp;
1680
1712
  WINDOW *window;
1681
1713
 
1682
- curses_init_screen();
1714
+ curses_init_screen(Qnil);
1683
1715
  TypedData_Get_Struct(obj, struct windata, &windata_type, winp);
1684
1716
  if (winp->window) delwin(winp->window);
1685
1717
  window = newwin(NUM2INT(h), NUM2INT(w), NUM2INT(top), NUM2INT(left));
@@ -2176,7 +2208,7 @@ window_begx(VALUE obj)
2176
2208
 
2177
2209
  /*
2178
2210
  * Document-method: Curses::Window.box
2179
- * call-seq: box(vert, hor)
2211
+ * call-seq: box(vert = nil, hor = nil, corn = nil)
2180
2212
  *
2181
2213
  * set the characters to frame the window in.
2182
2214
  * The vertical +vert+ and horizontal +hor+ character.
@@ -2191,16 +2223,18 @@ window_box(int argc, VALUE *argv, VALUE self)
2191
2223
  struct windata *winp;
2192
2224
  VALUE vert, hor, corn;
2193
2225
 
2194
- rb_scan_args(argc, argv, "21", &vert, &hor, &corn);
2226
+ rb_scan_args(argc, argv, "03", &vert, &hor, &corn);
2195
2227
 
2196
2228
  GetWINDOW(self, winp);
2197
- box(winp->window, NUM2CH(vert), NUM2CH(hor));
2229
+ box(winp->window,
2230
+ NIL_P(vert) ? 0 : OBJ2CHTYPE(vert),
2231
+ NIL_P(hor) ? 0 : OBJ2CHTYPE(hor));
2198
2232
 
2199
2233
  if (!NIL_P(corn)) {
2200
2234
  int cur_x, cur_y, x, y;
2201
2235
  chtype c;
2202
2236
 
2203
- c = NUM2CH(corn);
2237
+ c = OBJ2CHTYPE(corn);
2204
2238
  getyx(winp->window, cur_y, cur_x);
2205
2239
  x = NUM2INT(window_maxx(self)) - 1;
2206
2240
  y = NUM2INT(window_maxy(self)) - 1;
@@ -2267,7 +2301,7 @@ window_inch(VALUE obj)
2267
2301
  struct windata *winp;
2268
2302
 
2269
2303
  GetWINDOW(obj, winp);
2270
- return CH2FIX(winch(winp->window));
2304
+ return CHTYPE2NUM(winch(winp->window));
2271
2305
  }
2272
2306
 
2273
2307
  /*
@@ -2284,7 +2318,7 @@ window_addch(VALUE obj, VALUE ch)
2284
2318
  struct windata *winp;
2285
2319
 
2286
2320
  GetWINDOW(obj, winp);
2287
- waddch(winp->window, NUM2CH(ch));
2321
+ waddch(winp->window, OBJ2CHTYPE(ch));
2288
2322
 
2289
2323
  return Qnil;
2290
2324
  }
@@ -2302,7 +2336,7 @@ window_insch(VALUE obj, VALUE ch)
2302
2336
  struct windata *winp;
2303
2337
 
2304
2338
  GetWINDOW(obj, winp);
2305
- winsch(winp->window, NUM2CH(ch));
2339
+ winsch(winp->window, OBJ2CHTYPE(ch));
2306
2340
 
2307
2341
  return Qnil;
2308
2342
  }
@@ -2730,7 +2764,7 @@ window_bkgdset(VALUE obj, VALUE ch)
2730
2764
  struct windata *winp;
2731
2765
 
2732
2766
  GetWINDOW(obj,winp);
2733
- wbkgdset(winp->window, NUM2CHTYPE(ch));
2767
+ wbkgdset(winp->window, OBJ2CHTYPE(ch));
2734
2768
  #endif
2735
2769
  return Qnil;
2736
2770
  }
@@ -2751,7 +2785,7 @@ window_bkgd(VALUE obj, VALUE ch)
2751
2785
  struct windata *winp;
2752
2786
 
2753
2787
  GetWINDOW(obj,winp);
2754
- return (wbkgd(winp->window, NUM2CHTYPE(ch)) == OK) ? Qtrue : Qfalse;
2788
+ return (wbkgd(winp->window, OBJ2CHTYPE(ch)) == OK) ? Qtrue : Qfalse;
2755
2789
  #else
2756
2790
  return Qfalse;
2757
2791
  #endif
@@ -2919,7 +2953,7 @@ pad_initialize(VALUE obj, VALUE h, VALUE w)
2919
2953
  struct windata *padp;
2920
2954
  WINDOW *window;
2921
2955
 
2922
- curses_init_screen();
2956
+ curses_init_screen(Qnil);
2923
2957
  TypedData_Get_Struct(obj, struct windata, &windata_type, padp);
2924
2958
  if (padp->window) delwin(padp->window);
2925
2959
  window = newpad(NUM2INT(h), NUM2INT(w));
@@ -3090,7 +3124,7 @@ item_initialize(VALUE obj, VALUE name, VALUE description)
3090
3124
  {
3091
3125
  struct itemdata *itemp;
3092
3126
 
3093
- curses_init_screen();
3127
+ curses_init_screen(Qnil);
3094
3128
  TypedData_Get_Struct(obj, struct itemdata, &itemdata_type, itemp);
3095
3129
  if (itemp->item) {
3096
3130
  rb_raise(rb_eRuntimeError, "already initialized item");
@@ -3303,7 +3337,7 @@ menu_initialize(VALUE obj, VALUE items)
3303
3337
  ID id_new;
3304
3338
 
3305
3339
  Check_Type(items, T_ARRAY);
3306
- curses_init_screen();
3340
+ curses_init_screen(Qnil);
3307
3341
  TypedData_Get_Struct(obj, struct menudata, &menudata_type, menup);
3308
3342
  if (menup->menu) {
3309
3343
  rb_raise(rb_eRuntimeError, "already initialized menu");
@@ -3598,6 +3632,121 @@ menu_set_format(VALUE obj, VALUE rows, VALUE cols)
3598
3632
  return obj;
3599
3633
  }
3600
3634
 
3635
+ /*
3636
+ * Document-method: Curses::Menu#mark=
3637
+ *
3638
+ * call-seq:
3639
+ * mark=(str)
3640
+ *
3641
+ * Set the mark string to distinguish the selected items
3642
+ */
3643
+ static VALUE
3644
+ menu_set_mark(VALUE obj, VALUE mark)
3645
+ {
3646
+ struct menudata *menup;
3647
+
3648
+ GetMENU(obj, menup);
3649
+ set_menu_mark(menup->menu, StringValueCStr(mark));
3650
+
3651
+ return obj;
3652
+ }
3653
+
3654
+ /*
3655
+ * Document-method: Curses::Menu#mark
3656
+ *
3657
+ * call-seq:
3658
+ * mark
3659
+ *
3660
+ * Get the Menu's mark string
3661
+ */
3662
+ static VALUE
3663
+ menu_get_mark(VALUE obj)
3664
+ {
3665
+ struct menudata *menup;
3666
+ const char *mark;
3667
+
3668
+ GetMENU(obj, menup);
3669
+ mark = menu_mark(menup->menu);
3670
+
3671
+ return rb_external_str_new_with_enc(mark, strlen(mark), terminal_encoding);
3672
+ }
3673
+
3674
+ /*
3675
+ * Document-method: Curses::Menu#fore=
3676
+ *
3677
+ * call-seq:
3678
+ * fore=(attr)
3679
+ *
3680
+ * Sets the foreground attribute of menu.
3681
+ * This is the highlight used for selected menu items.
3682
+ */
3683
+ static VALUE
3684
+ menu_set_fore(VALUE obj, VALUE attr)
3685
+ {
3686
+ struct menudata *menup;
3687
+
3688
+ GetMENU(obj, menup);
3689
+ set_menu_fore(menup->menu, NUM2CHTYPE(attr));
3690
+
3691
+ return attr;
3692
+ }
3693
+
3694
+ /*
3695
+ * Document-method: Curses::Menu#fore
3696
+ *
3697
+ * call-seq:
3698
+ * fore
3699
+ *
3700
+ * Sets the foreground attribute of menu.
3701
+ * This is the highlight used for selected menu items.
3702
+ */
3703
+ static VALUE
3704
+ menu_get_fore(VALUE obj, VALUE attr)
3705
+ {
3706
+ struct menudata *menup;
3707
+
3708
+ GetMENU(obj, menup);
3709
+
3710
+ return CHTYPE2NUM(menu_fore(menup->menu));
3711
+ }
3712
+
3713
+ /*
3714
+ * Document-method: Curses::Menu#set_back
3715
+ *
3716
+ * call-seq:
3717
+ * set_back(attr)
3718
+ *
3719
+ * Get the background attribute of menu.
3720
+ */
3721
+ static VALUE
3722
+ menu_set_back(VALUE obj, VALUE attr)
3723
+ {
3724
+ struct menudata *menup;
3725
+
3726
+ GetMENU(obj, menup);
3727
+ CHTYPE2NUM(set_menu_back(menup->menu, NUM2CHTYPE(attr)));
3728
+
3729
+ return attr;
3730
+ }
3731
+
3732
+ /*
3733
+ * Document-method: Curses::Menu#back
3734
+ *
3735
+ * call-seq:
3736
+ * back
3737
+ *
3738
+ * Get the background attribute of menu.
3739
+ */
3740
+ static VALUE
3741
+ menu_get_back(VALUE obj, VALUE attr)
3742
+ {
3743
+ struct menudata *menup;
3744
+
3745
+ GetMENU(obj, menup);
3746
+
3747
+ return CHTYPE2NUM(menu_back(menup->menu));
3748
+ }
3749
+
3601
3750
  /*
3602
3751
  * Document-method: Curses::Menu#format
3603
3752
  *
@@ -3759,7 +3908,7 @@ field_initialize(VALUE obj, VALUE height, VALUE width,
3759
3908
  {
3760
3909
  struct fielddata *fieldp;
3761
3910
 
3762
- curses_init_screen();
3911
+ curses_init_screen(Qnil);
3763
3912
  TypedData_Get_Struct(obj, struct fielddata, &fielddata_type, fieldp);
3764
3913
  if (fieldp->field) {
3765
3914
  rb_raise(rb_eRuntimeError, "already initialized field");
@@ -4217,7 +4366,7 @@ form_initialize(VALUE obj, VALUE fields)
4217
4366
  int i;
4218
4367
 
4219
4368
  Check_Type(fields, T_ARRAY);
4220
- curses_init_screen();
4369
+ curses_init_screen(Qnil);
4221
4370
  TypedData_Get_Struct(obj, struct formdata, &formdata_type, formp);
4222
4371
  if (formp->form) {
4223
4372
  rb_raise(rb_eRuntimeError, "already initialized form");
@@ -4717,7 +4866,7 @@ Init_curses(void)
4717
4866
  rb_define_module_function(mCurses, "init_screen", curses_init_screen, 0);
4718
4867
  rb_define_module_function(mCurses, "close_screen", curses_close_screen, 0);
4719
4868
  rb_define_module_function(mCurses, "closed?", curses_closed, 0);
4720
- rb_define_module_function(mCurses, "stdscr", curses_stdscr, 0);
4869
+ rb_define_module_function(mCurses, "stdscr", curses_init_screen, 0);
4721
4870
  rb_define_module_function(mCurses, "refresh", curses_refresh, 0);
4722
4871
  rb_define_module_function(mCurses, "doupdate", curses_doupdate, 0);
4723
4872
  rb_define_module_function(mCurses, "clear", curses_clear, 0);
@@ -4733,6 +4882,7 @@ Init_curses(void)
4733
4882
  rb_define_module_function(mCurses, "nocrmode", curses_nocbreak, 0);
4734
4883
  rb_define_module_function(mCurses, "nl", curses_nl, 0);
4735
4884
  rb_define_module_function(mCurses, "nonl", curses_nonl, 0);
4885
+ rb_define_module_function(mCurses, "flushinp", curses_flushinp, 0);
4736
4886
  rb_define_module_function(mCurses, "beep", curses_beep, 0);
4737
4887
  rb_define_module_function(mCurses, "flash", curses_flash, 0);
4738
4888
  rb_define_module_function(mCurses, "ungetch", curses_ungetch, 1);
@@ -4857,7 +5007,7 @@ Init_curses(void)
4857
5007
  * win.close
4858
5008
  *
4859
5009
  */
4860
- cWindow = rb_define_class_under(mCurses, "Window", rb_cData);
5010
+ cWindow = rb_define_class_under(mCurses, "Window", rb_cObject);
4861
5011
  rb_define_alloc_func(cWindow, window_s_allocate);
4862
5012
  rb_define_method(cWindow, "initialize", window_initialize, 4);
4863
5013
  rb_define_method(cWindow, "subwin", window_subwin, 4);
@@ -4941,7 +5091,7 @@ Init_curses(void)
4941
5091
  #endif
4942
5092
 
4943
5093
  #ifdef HAVE_MENU
4944
- cItem = rb_define_class_under(mCurses, "Item", rb_cData);
5094
+ cItem = rb_define_class_under(mCurses, "Item", rb_cObject);
4945
5095
  rb_define_alloc_func(cItem, item_s_allocate);
4946
5096
  rb_define_method(cItem, "initialize", item_initialize, 2);
4947
5097
  rb_define_method(cItem, "==", item_eq, 1);
@@ -4952,7 +5102,7 @@ Init_curses(void)
4952
5102
  rb_define_method(cItem, "opts_off", item_opts_off_m, 1);
4953
5103
  rb_define_method(cItem, "opts", item_opts_m, 0);
4954
5104
 
4955
- cMenu = rb_define_class_under(mCurses, "Menu", rb_cData);
5105
+ cMenu = rb_define_class_under(mCurses, "Menu", rb_cObject);
4956
5106
  rb_define_alloc_func(cMenu, menu_s_allocate);
4957
5107
  rb_define_method(cMenu, "initialize", menu_initialize, 1);
4958
5108
  rb_define_method(cMenu, "post", menu_post, 0);
@@ -4968,6 +5118,12 @@ Init_curses(void)
4968
5118
  rb_define_method(cMenu, "scale", menu_scale, 0);
4969
5119
  rb_define_method(cMenu, "set_format", menu_set_format, 2);
4970
5120
  rb_define_method(cMenu, "format", menu_format_m, 0);
5121
+ rb_define_method(cMenu, "mark=", menu_set_mark, 1);
5122
+ rb_define_method(cMenu, "mark", menu_get_mark, 0);
5123
+ rb_define_method(cMenu, "fore=", menu_set_fore, 1);
5124
+ rb_define_method(cMenu, "fore", menu_get_fore, 0);
5125
+ rb_define_method(cMenu, "back=", menu_set_back, 1);
5126
+ rb_define_method(cMenu, "back", menu_get_back, 0);
4971
5127
  rb_define_method(cMenu, "set_opts", menu_set_opts, 1);
4972
5128
  rb_define_method(cMenu, "opts_on", menu_opts_on_m, 1);
4973
5129
  rb_define_method(cMenu, "opts_off", menu_opts_off_m, 1);
@@ -4975,7 +5131,7 @@ Init_curses(void)
4975
5131
  #endif
4976
5132
 
4977
5133
  #ifdef HAVE_FORM
4978
- cField = rb_define_class_under(mCurses, "Field", rb_cData);
5134
+ cField = rb_define_class_under(mCurses, "Field", rb_cObject);
4979
5135
  rb_define_alloc_func(cField, field_s_allocate);
4980
5136
  rb_define_method(cField, "initialize", field_initialize, 6);
4981
5137
  rb_define_method(cField, "set_buffer", field_set_buffer, 2);
@@ -5002,7 +5158,7 @@ Init_curses(void)
5002
5158
  rb_define_method(cField, "max=", field_set_max, 1);
5003
5159
  rb_define_method(cField, "set_type", field_set_type, -1);
5004
5160
 
5005
- cForm = rb_define_class_under(mCurses, "Form", rb_cData);
5161
+ cForm = rb_define_class_under(mCurses, "Form", rb_cObject);
5006
5162
  rb_define_alloc_func(cForm, form_s_allocate);
5007
5163
  rb_define_method(cForm, "initialize", form_initialize, 1);
5008
5164
  rb_define_method(cForm, "post", form_post, 0);
@@ -1,5 +1,6 @@
1
1
  require 'mkmf'
2
2
  require 'shellwords'
3
+ require 'fileutils'
3
4
 
4
5
  def have_all(*args)
5
6
  old_libs = $libs.dup
@@ -22,7 +23,68 @@ def have_all(*args)
22
23
  end
23
24
  end
24
25
 
25
- dir_config('curses')
26
+ def exec_command(cmd)
27
+ puts "> #{cmd}"
28
+ if !system(cmd)
29
+ STDERR.puts("External command failed")
30
+ exit 1
31
+ end
32
+ end
33
+
34
+ $library_candidates = [
35
+ ["ncursesw/curses.h", ["ncursesw"]],
36
+ ["ncurses.h", ["ncursesw", "ncurses"]],
37
+ ["ncurses/curses.h", ["ncurses"]],
38
+ ["curses_colr/curses.h", ["cur_colr"]],
39
+ ["curses.h", ["curses", "pdcurses"]],
40
+ # ["xcurses.h", ["XCurses"]], # XCurses (PDCurses for X11)
41
+ ]
42
+
43
+ $mingw = /mingw/ =~ RUBY_PLATFORM
44
+ $mswin = /mswin/ =~ RUBY_PLATFORM
45
+ $windows = $mingw || $mswin
46
+ $x64 = /x64/ =~ RUBY_PLATFORM
47
+ $use_system_libs = arg_config('--use-system-libraries',
48
+ ENV.key?("CURSES_USE_SYSTEM_LIBRARIES"))
49
+ $idefault = nil
50
+ $ldefault = nil
51
+ $pdcurses_wide_default = nil
52
+ $pdcurses_dll_default = nil
53
+ $curses_version_default = nil
54
+ $use_bundled_pdcurses = !$use_system_libs && /mingw|mswin/ =~ RUBY_PLATFORM
55
+ if $use_bundled_pdcurses
56
+ $pdcurses_wide_default = true
57
+ $curses_version_default = "function"
58
+ pdcurses_dir = File.expand_path("../../vendor/PDCurses", __dir__)
59
+ $idefault = $ldefault = pdcurses_dir
60
+ wincon_dir = File.expand_path("wincon", pdcurses_dir)
61
+ old_dir = Dir.pwd
62
+ Dir.chdir(wincon_dir)
63
+ begin
64
+ if $mswin
65
+ exec_command "nmake -f Makefile.vc clean all WIDE=Y DLL=Y"
66
+ FileUtils.cp("pdcurses.dll", pdcurses_dir)
67
+ FileUtils.cp("pdcurses.lib", pdcurses_dir)
68
+ $pdcurses_dll_default = true
69
+ else
70
+ if $x64
71
+ exec_command "make -f Makefile.mng clean all _w64=1 WIDE=Y DLL=N"
72
+ else
73
+ exec_command "make -f Makefile.mng clean all WIDE=Y DLL=N"
74
+ end
75
+ FileUtils.cp("pdcurses.a", File.expand_path("libpdcurses.a", pdcurses_dir))
76
+ end
77
+ ensure
78
+ Dir.chdir(old_dir)
79
+ end
80
+ FileUtils.cp(File.expand_path("curses.h", pdcurses_dir),
81
+ File.expand_path("pdcurses.h", pdcurses_dir))
82
+ $library_candidates = [
83
+ ["pdcurses.h", ["pdcurses"]]
84
+ ]
85
+ end
86
+
87
+ dir_config('curses', $idefault, $ldefault)
26
88
  dir_config('ncurses')
27
89
  dir_config('termcap')
28
90
 
@@ -32,14 +94,7 @@ have_library("tinfow", "tgetent") ||
32
94
  have_library("termcap", "tgetent")
33
95
 
34
96
  header_library = nil
35
- [
36
- ["ncursesw/curses.h", ["ncursesw"]],
37
- ["ncurses.h", ["ncursesw", "ncurses"]],
38
- ["ncurses/curses.h", ["ncurses"]],
39
- ["curses_colr/curses.h", ["cur_colr"]],
40
- ["curses.h", ["curses", "pdcurses"]],
41
- # ["xcurses.h", ["XCurses"]], # XCurses (PDCurses for X11)
42
- ].each {|hdr, libs|
97
+ $library_candidates.each {|hdr, libs|
43
98
  header_library = have_all(
44
99
  lambda { have_header(hdr) && hdr },
45
100
  lambda {|h| libs.find {|lib| have_library(lib, "initscr", h) } })
@@ -89,8 +144,8 @@ if header_library
89
144
  # --with-curses-version=function for SVR4
90
145
  # --with-curses-version=variable for ncurses and PDcurses
91
146
  # (not given) automatically determined
92
-
93
- case with_curses_version = with_config("curses-version")
147
+ with_curses_version = with_config("curses-version", $curses_version_default)
148
+ case with_curses_version
94
149
  when "function"
95
150
  $defs << '-DHAVE_FUNC_CURSES_VERSION'
96
151
  when "variable"
@@ -136,27 +191,29 @@ if header_library
136
191
  warn "unexpected value for --with-curses-version: #{with_curses_version}"
137
192
  end
138
193
 
139
- if enable_config("pdcurses-wide")
194
+ if enable_config("pdcurses-wide", $pdcurses_wide_default)
140
195
  $defs << '-DPDC_WIDE'
141
196
  end
142
197
 
143
- if enable_config("pdcurses-dll")
198
+ if enable_config("pdcurses-dll", $pdcurses_dll_default)
144
199
  $defs << '-DPDC_DLL_BUILD'
145
200
  end
146
201
 
147
- if (have_header("ncursesw/menu.h") ||
148
- have_header("ncurses/menu.h") ||
149
- have_header("curses/menu.h") ||
150
- have_header("menu.h")) &&
202
+ if !$use_bundled_pdcurses &&
203
+ (have_header("ncursesw/menu.h") ||
204
+ have_header("ncurses/menu.h") ||
205
+ have_header("curses/menu.h") ||
206
+ have_header("menu.h")) &&
151
207
  (have_library("menuw", "new_menu") ||
152
208
  have_library("menu", "new_menu"))
153
209
  $defs << '-DHAVE_MENU'
154
210
  end
155
211
 
156
- if (have_header("ncursesw/form.h") ||
157
- have_header("ncurses/form.h") ||
158
- have_header("curses/form.h") ||
159
- have_header("form.h")) &&
212
+ if !$use_bundled_pdcurses &&
213
+ (have_header("ncursesw/form.h") ||
214
+ have_header("ncurses/form.h") ||
215
+ have_header("curses/form.h") ||
216
+ have_header("form.h")) &&
160
217
  (have_library("formw", "new_form") ||
161
218
  have_library("form", "new_form"))
162
219
  $defs << '-DHAVE_FORM'
@@ -166,7 +223,9 @@ if header_library
166
223
  ["WINDOW", "MEVENT", "ITEM", "MENU", "FIELD", "FORM"].each do |type|
167
224
  checking_for("sizeof(#{type}) is available") {
168
225
  if try_compile(<<EOF, Shellwords.join($defs))
169
- #if defined(HAVE_NCURSESW_CURSES_H)
226
+ #if defined(HAVE_PDCURSES_H)
227
+ # include <pdcurses.h>
228
+ #elif defined(HAVE_NCURSESW_CURSES_H)
170
229
  # include <ncursesw/curses.h>
171
230
  #elif defined(HAVE_NCURSES_CURSES_H)
172
231
  # include <ncurses/curses.h>
data/lib/curses.rb CHANGED
@@ -1,24 +1,17 @@
1
- platform = RUBY_PLATFORM.sub(/i[3-7]86/, "x86")
2
- pdcurses_path = File.expand_path("../vendor/#{platform}/PDCurses", __dir__)
3
- pdcurses_bundled = File.directory?(pdcurses_path)
4
- if pdcurses_bundled
1
+ pdcurses_dll = File.expand_path("../vendor/PDCurses/pdcurses.dll", __dir__)
2
+ if File.exist?(pdcurses_dll)
5
3
  path = ENV["PATH"]
6
4
  dir = File::ALT_SEPARATOR ?
7
- pdcurses_path.tr("/", File::ALT_SEPARATOR) : dir
5
+ File.dirname(pdcurses_dll).tr("/", File::ALT_SEPARATOR) : dir
8
6
  dirs = path.split(File::PATH_SEPARATOR)
9
7
  if !dirs.include?(dir)
10
8
  ENV["PATH"] = [dir, *dirs].join(File::PATH_SEPARATOR)
11
9
  end
12
10
  end
13
11
 
14
- begin
15
- major, minor, _ = RUBY_VERSION.split(/\./)
16
- require "#{major}.#{minor}/curses.so"
17
- rescue LoadError
18
- require "curses.so"
19
- end
12
+ require "curses.so"
20
13
 
21
- if pdcurses_bundled
14
+ if /mingw|mswin/ =~ RUBY_PLATFORM
22
15
  Curses.keyboard_encoding = Encoding::UTF_8
23
16
  end
24
17
 
data/sample/addch.rb ADDED
@@ -0,0 +1,16 @@
1
+ require_relative "../lib/curses"
2
+ include Curses
3
+
4
+ init_screen
5
+ begin
6
+ addstr("The following letter A should be BOLD and UNDERLINED by using addch:\n")
7
+ addch('A'.ord | A_BOLD | A_UNDERLINE)
8
+
9
+ addstr("\nIt should look the same as when using attron and addstr:\n")
10
+ attron(A_BOLD | A_UNDERLINE)
11
+ addstr("A")
12
+ getch
13
+
14
+ ensure
15
+ close_screen
16
+ end