curses 1.2.6 → 1.4.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.
Files changed (253) 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 +28 -0
  5. data/.gitmodules +1 -1
  6. data/.travis.yml +6 -3
  7. data/History.md +40 -0
  8. data/README.md +4 -1
  9. data/Rakefile +0 -83
  10. data/curses.gemspec +2 -3
  11. data/ext/curses/curses.c +1271 -151
  12. data/ext/curses/extconf.rb +140 -17
  13. data/lib/curses.rb +5 -12
  14. data/sample/form.rb +52 -0
  15. data/sample/menu.rb +1 -1
  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/README.md +77 -0
  22. data/vendor/PDCurses/acs_defs.h +265 -0
  23. data/vendor/PDCurses/appveyor.yml +218 -0
  24. data/vendor/PDCurses/cmake/README.md +71 -0
  25. data/vendor/PDCurses/cmake/build_dependencies.cmake +178 -0
  26. data/vendor/PDCurses/cmake/build_options.cmake +25 -0
  27. data/vendor/PDCurses/cmake/dll_version.cmake +26 -0
  28. data/vendor/PDCurses/cmake/gen_config_header.cmake +43 -0
  29. data/vendor/PDCurses/cmake/get_version.cmake +17 -0
  30. data/vendor/PDCurses/cmake/make_uninstall.cmake +19 -0
  31. data/vendor/PDCurses/cmake/project_common.cmake +121 -0
  32. data/vendor/PDCurses/cmake/resource.in.cmake +52 -0
  33. data/vendor/PDCurses/cmake/sdl2_ttf/CMakeLists.txt +83 -0
  34. data/vendor/PDCurses/cmake/target_arch.cmake +36 -0
  35. data/vendor/PDCurses/cmake/version.in.cmake +73 -0
  36. data/vendor/PDCurses/cmake/watcom_open_dos16_toolchain.cmake +96 -0
  37. data/vendor/PDCurses/cmake/watcom_open_dos32_toolchain.cmake +106 -0
  38. data/vendor/PDCurses/cmake/watcom_open_os2v2_toolchain.cmake +105 -0
  39. data/vendor/PDCurses/curses.h +1846 -0
  40. data/vendor/PDCurses/curspriv.h +134 -0
  41. data/vendor/PDCurses/demos/README.md +25 -0
  42. data/vendor/PDCurses/demos/firework.c +144 -0
  43. data/vendor/PDCurses/demos/newtest.c +581 -0
  44. data/vendor/PDCurses/demos/ozdemo.c +447 -0
  45. data/vendor/PDCurses/demos/ptest.c +283 -0
  46. data/vendor/PDCurses/demos/rain.c +157 -0
  47. data/vendor/PDCurses/demos/testcurs.c +1607 -0
  48. data/vendor/PDCurses/demos/tui.c +1048 -0
  49. data/vendor/PDCurses/demos/tui.h +65 -0
  50. data/vendor/PDCurses/demos/tuidemo.c +233 -0
  51. data/vendor/PDCurses/demos/version.c +61 -0
  52. data/vendor/PDCurses/demos/worm.c +432 -0
  53. data/vendor/PDCurses/demos/xmas.c +955 -0
  54. data/vendor/PDCurses/dos/CMakeLists.txt +47 -0
  55. data/vendor/PDCurses/dos/Makefile.bcc +83 -0
  56. data/vendor/PDCurses/dos/Makefile.dmc +257 -0
  57. data/vendor/PDCurses/dos/Makefile.msc +113 -0
  58. data/vendor/PDCurses/dos/Makefile.wcc +107 -0
  59. data/vendor/PDCurses/dos/README.md +51 -0
  60. data/vendor/PDCurses/dos/bccdos.lrf +9 -0
  61. data/vendor/PDCurses/dos/mscdos.lrf +50 -0
  62. data/vendor/PDCurses/dos/pdcclip.c +132 -0
  63. data/vendor/PDCurses/dos/pdcdisp.c +135 -0
  64. data/vendor/PDCurses/dos/pdcdos.h +194 -0
  65. data/vendor/PDCurses/dos/pdcgetsc.c +98 -0
  66. data/vendor/PDCurses/dos/pdckbd.c +513 -0
  67. data/vendor/PDCurses/dos/pdcscrn.c +785 -0
  68. data/vendor/PDCurses/dos/pdcsetsc.c +101 -0
  69. data/vendor/PDCurses/dos/pdcutil.c +212 -0
  70. data/vendor/PDCurses/libobjs.mif +26 -0
  71. data/vendor/PDCurses/makedist.mif +20 -0
  72. data/vendor/PDCurses/man/README.md +21 -0
  73. data/vendor/PDCurses/man/intro.md +361 -0
  74. data/vendor/PDCurses/man/manext.c +119 -0
  75. data/vendor/PDCurses/man/sdl.md +152 -0
  76. data/vendor/PDCurses/man/sdl2.md +58 -0
  77. data/vendor/PDCurses/man/x11.md +407 -0
  78. data/vendor/PDCurses/ncurses/CMakeLists.txt +66 -0
  79. data/vendor/PDCurses/ncurses/README.md +26 -0
  80. data/vendor/PDCurses/ncurses/makefile +29 -0
  81. data/vendor/PDCurses/os2/CMakeLists.txt +41 -0
  82. data/vendor/PDCurses/os2/Makefile.bcc +90 -0
  83. data/vendor/PDCurses/os2/Makefile.wcc +43 -0
  84. data/vendor/PDCurses/os2/README.md +43 -0
  85. data/vendor/PDCurses/os2/iccos2.lrf +50 -0
  86. data/vendor/PDCurses/os2/iccos2.mak +256 -0
  87. data/vendor/PDCurses/os2/pdcclip.c +188 -0
  88. data/vendor/PDCurses/os2/pdcdisp.c +93 -0
  89. data/vendor/PDCurses/os2/pdcgetsc.c +89 -0
  90. data/vendor/PDCurses/os2/pdckbd.c +521 -0
  91. data/vendor/PDCurses/os2/pdcos2.h +55 -0
  92. data/vendor/PDCurses/os2/pdcscrn.c +449 -0
  93. data/vendor/PDCurses/os2/pdcsetsc.c +112 -0
  94. data/vendor/PDCurses/os2/pdcutil.c +52 -0
  95. data/vendor/PDCurses/panel.h +56 -0
  96. data/vendor/PDCurses/pdcurses/README.md +25 -0
  97. data/vendor/PDCurses/pdcurses/addch.c +693 -0
  98. data/vendor/PDCurses/pdcurses/addchstr.c +245 -0
  99. data/vendor/PDCurses/pdcurses/addstr.c +240 -0
  100. data/vendor/PDCurses/pdcurses/attr.c +359 -0
  101. data/vendor/PDCurses/pdcurses/beep.c +68 -0
  102. data/vendor/PDCurses/pdcurses/bkgd.c +223 -0
  103. data/vendor/PDCurses/pdcurses/border.c +411 -0
  104. data/vendor/PDCurses/pdcurses/clear.c +159 -0
  105. data/vendor/PDCurses/pdcurses/color.c +298 -0
  106. data/vendor/PDCurses/pdcurses/debug.c +109 -0
  107. data/vendor/PDCurses/pdcurses/delch.c +96 -0
  108. data/vendor/PDCurses/pdcurses/deleteln.c +211 -0
  109. data/vendor/PDCurses/pdcurses/deprec.c +27 -0
  110. data/vendor/PDCurses/pdcurses/getch.c +417 -0
  111. data/vendor/PDCurses/pdcurses/getstr.c +474 -0
  112. data/vendor/PDCurses/pdcurses/getyx.c +139 -0
  113. data/vendor/PDCurses/pdcurses/inch.c +127 -0
  114. data/vendor/PDCurses/pdcurses/inchstr.c +214 -0
  115. data/vendor/PDCurses/pdcurses/initscr.c +367 -0
  116. data/vendor/PDCurses/pdcurses/inopts.c +324 -0
  117. data/vendor/PDCurses/pdcurses/insch.c +271 -0
  118. data/vendor/PDCurses/pdcurses/insstr.c +264 -0
  119. data/vendor/PDCurses/pdcurses/instr.c +246 -0
  120. data/vendor/PDCurses/pdcurses/kernel.c +259 -0
  121. data/vendor/PDCurses/pdcurses/keyname.c +157 -0
  122. data/vendor/PDCurses/pdcurses/mouse.c +438 -0
  123. data/vendor/PDCurses/pdcurses/move.c +57 -0
  124. data/vendor/PDCurses/pdcurses/outopts.c +159 -0
  125. data/vendor/PDCurses/pdcurses/overlay.c +214 -0
  126. data/vendor/PDCurses/pdcurses/pad.c +260 -0
  127. data/vendor/PDCurses/pdcurses/panel.c +633 -0
  128. data/vendor/PDCurses/pdcurses/printw.c +126 -0
  129. data/vendor/PDCurses/pdcurses/refresh.c +279 -0
  130. data/vendor/PDCurses/pdcurses/scanw.c +578 -0
  131. data/vendor/PDCurses/pdcurses/scr_dump.c +213 -0
  132. data/vendor/PDCurses/pdcurses/scroll.c +101 -0
  133. data/vendor/PDCurses/pdcurses/slk.c +591 -0
  134. data/vendor/PDCurses/pdcurses/termattr.c +182 -0
  135. data/vendor/PDCurses/pdcurses/terminfo.c +217 -0
  136. data/vendor/PDCurses/pdcurses/touch.c +163 -0
  137. data/vendor/PDCurses/pdcurses/util.c +312 -0
  138. data/vendor/PDCurses/pdcurses/window.c +569 -0
  139. data/vendor/PDCurses/sdl1/Makefile.mng +110 -0
  140. data/vendor/PDCurses/sdl1/README.md +31 -0
  141. data/vendor/PDCurses/sdl1/deffont.h +385 -0
  142. data/vendor/PDCurses/sdl1/deficon.h +23 -0
  143. data/vendor/PDCurses/sdl1/pdcclip.c +131 -0
  144. data/vendor/PDCurses/sdl1/pdcdisp.c +373 -0
  145. data/vendor/PDCurses/sdl1/pdcgetsc.c +30 -0
  146. data/vendor/PDCurses/sdl1/pdckbd.c +405 -0
  147. data/vendor/PDCurses/sdl1/pdcscrn.c +414 -0
  148. data/vendor/PDCurses/sdl1/pdcsdl.h +31 -0
  149. data/vendor/PDCurses/sdl1/pdcsetsc.c +64 -0
  150. data/vendor/PDCurses/sdl1/pdcutil.c +40 -0
  151. data/vendor/PDCurses/sdl1/sdltest.c +79 -0
  152. data/vendor/PDCurses/sdl2/CMakeLists.txt +76 -0
  153. data/vendor/PDCurses/sdl2/Makefile.vc +164 -0
  154. data/vendor/PDCurses/sdl2/README.md +34 -0
  155. data/vendor/PDCurses/sdl2/deffont.h +385 -0
  156. data/vendor/PDCurses/sdl2/deficon.h +23 -0
  157. data/vendor/PDCurses/sdl2/pdcclip.c +93 -0
  158. data/vendor/PDCurses/sdl2/pdcdisp.c +534 -0
  159. data/vendor/PDCurses/sdl2/pdcgetsc.c +30 -0
  160. data/vendor/PDCurses/sdl2/pdckbd.c +480 -0
  161. data/vendor/PDCurses/sdl2/pdcscrn.c +443 -0
  162. data/vendor/PDCurses/sdl2/pdcsdl.h +33 -0
  163. data/vendor/PDCurses/sdl2/pdcsetsc.c +67 -0
  164. data/vendor/PDCurses/sdl2/pdcutil.c +39 -0
  165. data/vendor/PDCurses/sdl2/sdltest.c +81 -0
  166. data/vendor/PDCurses/term.h +48 -0
  167. data/vendor/PDCurses/version.mif +7 -0
  168. data/vendor/PDCurses/vt/CMakeLists.txt +28 -0
  169. data/vendor/PDCurses/vt/Makefile.bcc +111 -0
  170. data/vendor/PDCurses/vt/Makefile.dmc +258 -0
  171. data/vendor/PDCurses/vt/Makefile.vc +144 -0
  172. data/vendor/PDCurses/vt/Makefile.wcc +107 -0
  173. data/vendor/PDCurses/vt/README.md +64 -0
  174. data/vendor/PDCurses/vt/pdcclip.c +20 -0
  175. data/vendor/PDCurses/vt/pdcdisp.c +284 -0
  176. data/vendor/PDCurses/vt/pdcgetsc.c +27 -0
  177. data/vendor/PDCurses/vt/pdckbd.c +394 -0
  178. data/vendor/PDCurses/vt/pdcscrn.c +434 -0
  179. data/vendor/PDCurses/vt/pdcsetsc.c +45 -0
  180. data/vendor/PDCurses/vt/pdcutil.c +43 -0
  181. data/vendor/PDCurses/vt/pdcvt.h +16 -0
  182. data/vendor/PDCurses/watcom.mif +68 -0
  183. data/vendor/PDCurses/wincon/CMakeLists.txt +27 -0
  184. data/vendor/PDCurses/wincon/Makefile.bcc +88 -0
  185. data/vendor/PDCurses/wincon/Makefile.dmc +256 -0
  186. data/vendor/PDCurses/wincon/Makefile.lcc +273 -0
  187. data/vendor/PDCurses/wincon/Makefile.mng +176 -0
  188. data/vendor/PDCurses/wincon/Makefile.vc +144 -0
  189. data/vendor/PDCurses/wincon/Makefile.wcc +51 -0
  190. data/vendor/PDCurses/wincon/README.md +85 -0
  191. data/vendor/PDCurses/wincon/pdcclip.c +174 -0
  192. data/vendor/PDCurses/wincon/pdcdisp.c +143 -0
  193. data/vendor/PDCurses/wincon/pdcgetsc.c +55 -0
  194. data/vendor/PDCurses/wincon/pdckbd.c +786 -0
  195. data/vendor/PDCurses/wincon/pdcscrn.c +717 -0
  196. data/vendor/PDCurses/wincon/pdcsetsc.c +91 -0
  197. data/vendor/PDCurses/wincon/pdcurses.ico +0 -0
  198. data/vendor/PDCurses/wincon/pdcurses.rc +28 -0
  199. data/vendor/PDCurses/wincon/pdcutil.c +41 -0
  200. data/vendor/PDCurses/wincon/pdcwin.h +31 -0
  201. data/vendor/PDCurses/wingui/CMakeLists.txt +27 -0
  202. data/vendor/PDCurses/wingui/Makefile.bcc +85 -0
  203. data/vendor/PDCurses/wingui/Makefile.dmc +259 -0
  204. data/vendor/PDCurses/wingui/Makefile.lcc +273 -0
  205. data/vendor/PDCurses/wingui/Makefile.mng +171 -0
  206. data/vendor/PDCurses/wingui/Makefile.vc +144 -0
  207. data/vendor/PDCurses/wingui/Makefile.wcc +51 -0
  208. data/vendor/PDCurses/wingui/README.md +93 -0
  209. data/vendor/PDCurses/wingui/pdcclip.c +174 -0
  210. data/vendor/PDCurses/wingui/pdcdisp.c +718 -0
  211. data/vendor/PDCurses/wingui/pdcgetsc.c +30 -0
  212. data/vendor/PDCurses/wingui/pdckbd.c +143 -0
  213. data/vendor/PDCurses/wingui/pdcscrn.c +2797 -0
  214. data/vendor/PDCurses/wingui/pdcsetsc.c +89 -0
  215. data/vendor/PDCurses/wingui/pdcurses.ico +0 -0
  216. data/vendor/PDCurses/wingui/pdcurses.rc +28 -0
  217. data/vendor/PDCurses/wingui/pdcutil.c +61 -0
  218. data/vendor/PDCurses/wingui/pdcwin.h +122 -0
  219. data/vendor/PDCurses/x11/Makefile.in +754 -0
  220. data/vendor/PDCurses/x11/PDCurses.spec +82 -0
  221. data/vendor/PDCurses/x11/README.md +62 -0
  222. data/vendor/PDCurses/x11/ScrollBox.c +319 -0
  223. data/vendor/PDCurses/x11/ScrollBox.h +51 -0
  224. data/vendor/PDCurses/x11/ScrollBoxP.h +70 -0
  225. data/vendor/PDCurses/x11/aclocal.m4 +994 -0
  226. data/vendor/PDCurses/x11/big_icon.xbm +46 -0
  227. data/vendor/PDCurses/x11/compose.h +201 -0
  228. data/vendor/PDCurses/x11/config.guess +1500 -0
  229. data/vendor/PDCurses/x11/config.h.in +100 -0
  230. data/vendor/PDCurses/x11/config.sub +1616 -0
  231. data/vendor/PDCurses/x11/configure +6700 -0
  232. data/vendor/PDCurses/x11/configure.ac +295 -0
  233. data/vendor/PDCurses/x11/debian/changelog +6 -0
  234. data/vendor/PDCurses/x11/debian/compat +1 -0
  235. data/vendor/PDCurses/x11/debian/control +11 -0
  236. data/vendor/PDCurses/x11/debian/copyright +27 -0
  237. data/vendor/PDCurses/x11/debian/rules +98 -0
  238. data/vendor/PDCurses/x11/install-sh +253 -0
  239. data/vendor/PDCurses/x11/little_icon.xbm +14 -0
  240. data/vendor/PDCurses/x11/ncurses_cfg.h +45 -0
  241. data/vendor/PDCurses/x11/pdcclip.c +173 -0
  242. data/vendor/PDCurses/x11/pdcdisp.c +85 -0
  243. data/vendor/PDCurses/x11/pdcgetsc.c +28 -0
  244. data/vendor/PDCurses/x11/pdckbd.c +104 -0
  245. data/vendor/PDCurses/x11/pdcscrn.c +258 -0
  246. data/vendor/PDCurses/x11/pdcsetsc.c +95 -0
  247. data/vendor/PDCurses/x11/pdcutil.c +52 -0
  248. data/vendor/PDCurses/x11/pdcx11.c +316 -0
  249. data/vendor/PDCurses/x11/pdcx11.h +191 -0
  250. data/vendor/PDCurses/x11/sb.c +155 -0
  251. data/vendor/PDCurses/x11/x11.c +3686 -0
  252. data/vendor/PDCurses/x11/xcurses-config.in +81 -0
  253. metadata +255 -21
@@ -0,0 +1,30 @@
1
+ /* Public Domain Curses */
2
+
3
+ #include "pdcsdl.h"
4
+
5
+ /* get the cursor size/shape */
6
+
7
+ int PDC_get_cursor_mode(void)
8
+ {
9
+ PDC_LOG(("PDC_get_cursor_mode() - called\n"));
10
+
11
+ return 0;
12
+ }
13
+
14
+ /* return number of screen rows */
15
+
16
+ int PDC_get_rows(void)
17
+ {
18
+ PDC_LOG(("PDC_get_rows() - called\n"));
19
+
20
+ return pdc_sheight / pdc_fheight;
21
+ }
22
+
23
+ /* return width of screen/viewport */
24
+
25
+ int PDC_get_columns(void)
26
+ {
27
+ PDC_LOG(("PDC_get_columns() - called\n"));
28
+
29
+ return pdc_swidth / pdc_fwidth;
30
+ }
@@ -0,0 +1,405 @@
1
+ /* Public Domain Curses */
2
+
3
+ #include "pdcsdl.h"
4
+
5
+ /*man-start**************************************************************
6
+
7
+ pdckbd
8
+ ------
9
+
10
+ ### Synopsis
11
+
12
+ unsigned long PDC_get_input_fd(void);
13
+
14
+ ### Description
15
+
16
+ PDC_get_input_fd() returns the file descriptor that PDCurses
17
+ reads its input from. It can be used for select().
18
+
19
+ ### Portability
20
+ X/Open BSD SYS V
21
+ PDC_get_input_fd - - -
22
+
23
+ **man-end****************************************************************/
24
+
25
+ #include <string.h>
26
+
27
+ unsigned long pdc_key_modifiers = 0L;
28
+
29
+ static SDL_Event event;
30
+ static SDLKey oldkey;
31
+ static MOUSE_STATUS old_mouse_status;
32
+
33
+ static struct
34
+ {
35
+ SDLKey keycode;
36
+ bool numkeypad;
37
+ unsigned short normal;
38
+ unsigned short shifted;
39
+ unsigned short control;
40
+ unsigned short alt;
41
+ } key_table[] =
42
+ {
43
+ /* keycode keypad normal shifted control alt*/
44
+ {SDLK_LEFT, FALSE, KEY_LEFT, KEY_SLEFT, CTL_LEFT, ALT_LEFT},
45
+ {SDLK_RIGHT, FALSE, KEY_RIGHT, KEY_SRIGHT, CTL_RIGHT, ALT_RIGHT},
46
+ {SDLK_UP, FALSE, KEY_UP, KEY_SUP, CTL_UP, ALT_UP},
47
+ {SDLK_DOWN, FALSE, KEY_DOWN, KEY_SDOWN, CTL_DOWN, ALT_DOWN},
48
+ {SDLK_HOME, FALSE, KEY_HOME, KEY_SHOME, CTL_HOME, ALT_HOME},
49
+ {SDLK_END, FALSE, KEY_END, KEY_SEND, CTL_END, ALT_END},
50
+ {SDLK_PAGEUP, FALSE, KEY_PPAGE, KEY_SPREVIOUS,CTL_PGUP, ALT_PGUP},
51
+ {SDLK_PAGEDOWN,FALSE, KEY_NPAGE, KEY_SNEXT, CTL_PGDN, ALT_PGDN},
52
+ {SDLK_INSERT, FALSE, KEY_IC, KEY_SIC, CTL_INS, ALT_INS},
53
+ {SDLK_DELETE, FALSE, KEY_DC, KEY_SDC, CTL_DEL, ALT_DEL},
54
+ {SDLK_F1, FALSE, KEY_F(1), KEY_F(13), KEY_F(25), KEY_F(37)},
55
+ {SDLK_F2, FALSE, KEY_F(2), KEY_F(14), KEY_F(26), KEY_F(38)},
56
+ {SDLK_F3, FALSE, KEY_F(3), KEY_F(15), KEY_F(27), KEY_F(39)},
57
+ {SDLK_F4, FALSE, KEY_F(4), KEY_F(16), KEY_F(28), KEY_F(40)},
58
+ {SDLK_F5, FALSE, KEY_F(5), KEY_F(17), KEY_F(29), KEY_F(41)},
59
+ {SDLK_F6, FALSE, KEY_F(6), KEY_F(18), KEY_F(30), KEY_F(42)},
60
+ {SDLK_F7, FALSE, KEY_F(7), KEY_F(19), KEY_F(31), KEY_F(43)},
61
+ {SDLK_F8, FALSE, KEY_F(8), KEY_F(20), KEY_F(32), KEY_F(44)},
62
+ {SDLK_F9, FALSE, KEY_F(9), KEY_F(21), KEY_F(33), KEY_F(45)},
63
+ {SDLK_F10, FALSE, KEY_F(10), KEY_F(22), KEY_F(34), KEY_F(46)},
64
+ {SDLK_F11, FALSE, KEY_F(11), KEY_F(23), KEY_F(35), KEY_F(47)},
65
+ {SDLK_F12, FALSE, KEY_F(12), KEY_F(24), KEY_F(36), KEY_F(48)},
66
+ {SDLK_F13, FALSE, KEY_F(13), KEY_F(25), KEY_F(37), KEY_F(49)},
67
+ {SDLK_F14, FALSE, KEY_F(14), KEY_F(26), KEY_F(38), KEY_F(50)},
68
+ {SDLK_F15, FALSE, KEY_F(15), KEY_F(27), KEY_F(39), KEY_F(51)},
69
+ {SDLK_BACKSPACE,FALSE, 0x08, 0x08, CTL_BKSP, ALT_BKSP},
70
+ {SDLK_TAB, FALSE, 0x09, KEY_BTAB, CTL_TAB, ALT_TAB},
71
+ {SDLK_PRINT, FALSE, KEY_PRINT, KEY_SPRINT, KEY_PRINT, KEY_PRINT},
72
+ {SDLK_PAUSE, FALSE, KEY_SUSPEND, KEY_SSUSPEND, KEY_SUSPEND, KEY_SUSPEND},
73
+ {SDLK_CLEAR, FALSE, KEY_CLEAR, KEY_CLEAR, KEY_CLEAR, KEY_CLEAR},
74
+ {SDLK_BREAK, FALSE, KEY_BREAK, KEY_BREAK, KEY_BREAK, KEY_BREAK},
75
+ {SDLK_HELP, FALSE, KEY_HELP, KEY_SHELP, KEY_LHELP, KEY_HELP},
76
+ {SDLK_MENU, FALSE, KEY_OPTIONS, KEY_SOPTIONS, KEY_OPTIONS, KEY_OPTIONS},
77
+ {SDLK_ESCAPE, FALSE, 0x1B, 0x1B, 0x1B, ALT_ESC},
78
+ {SDLK_KP_ENTER,TRUE, PADENTER, PADENTER, CTL_PADENTER,ALT_PADENTER},
79
+ {SDLK_KP_PLUS, TRUE, PADPLUS, '+', CTL_PADPLUS, ALT_PADPLUS},
80
+ {SDLK_KP_MINUS,TRUE, PADMINUS, '-', CTL_PADMINUS,ALT_PADMINUS},
81
+ {SDLK_KP_MULTIPLY,TRUE,PADSTAR, '*', CTL_PADSTAR, ALT_PADSTAR},
82
+ {SDLK_KP_DIVIDE,TRUE, PADSLASH, '/', CTL_PADSLASH,ALT_PADSLASH},
83
+ {SDLK_KP_PERIOD,TRUE, PADSTOP, '.', CTL_PADSTOP, ALT_PADSTOP},
84
+ {SDLK_KP0, TRUE, PAD0, '0', CTL_PAD0, ALT_PAD0},
85
+ {SDLK_KP1, TRUE, KEY_C1, '1', CTL_PAD1, ALT_PAD1},
86
+ {SDLK_KP2, TRUE, KEY_C2, '2', CTL_PAD2, ALT_PAD2},
87
+ {SDLK_KP3, TRUE, KEY_C3, '3', CTL_PAD3, ALT_PAD3},
88
+ {SDLK_KP4, TRUE, KEY_B1, '4', CTL_PAD4, ALT_PAD4},
89
+ {SDLK_KP5, TRUE, KEY_B2, '5', CTL_PAD5, ALT_PAD5},
90
+ {SDLK_KP6, TRUE, KEY_B3, '6', CTL_PAD6, ALT_PAD6},
91
+ {SDLK_KP7, TRUE, KEY_A1, '7', CTL_PAD7, ALT_PAD7},
92
+ {SDLK_KP8, TRUE, KEY_A2, '8', CTL_PAD8, ALT_PAD8},
93
+ {SDLK_KP9, TRUE, KEY_A3, '9', CTL_PAD9, ALT_PAD9},
94
+ {0, 0, 0, 0, 0, 0}
95
+ };
96
+
97
+ unsigned long PDC_get_input_fd(void)
98
+ {
99
+ PDC_LOG(("PDC_get_input_fd() - called\n"));
100
+
101
+ return 0L; /* test this */
102
+ }
103
+
104
+ void PDC_set_keyboard_binary(bool on)
105
+ {
106
+ PDC_LOG(("PDC_set_keyboard_binary() - called\n"));
107
+ }
108
+
109
+ /* check if a key or mouse event is waiting */
110
+
111
+ bool PDC_check_key(void)
112
+ {
113
+ Uint32 current = SDL_GetTicks();
114
+ int haveevent = SDL_PollEvent(&event);
115
+
116
+ /* if we have an event, or 30 ms have passed without a screen
117
+ update, or the timer has wrapped, update now */
118
+
119
+ if (haveevent ||
120
+ current < pdc_lastupdate || ((current - pdc_lastupdate) > 30))
121
+ PDC_update_rects();
122
+
123
+ return haveevent;
124
+ }
125
+
126
+ static int _process_key_event(void)
127
+ {
128
+ int i, key = 0;
129
+
130
+ pdc_key_modifiers = 0L;
131
+ SP->key_code = FALSE;
132
+
133
+ if (event.type == SDL_KEYUP)
134
+ {
135
+ if (SP->return_key_modifiers && event.key.keysym.sym == oldkey)
136
+ {
137
+ switch (oldkey)
138
+ {
139
+ case SDLK_RSHIFT:
140
+ return KEY_SHIFT_R;
141
+ case SDLK_LSHIFT:
142
+ return KEY_SHIFT_L;
143
+ case SDLK_RCTRL:
144
+ return KEY_CONTROL_R;
145
+ case SDLK_LCTRL:
146
+ return KEY_CONTROL_L;
147
+ case SDLK_RALT:
148
+ return KEY_ALT_R;
149
+ case SDLK_LALT:
150
+ return KEY_ALT_L;
151
+ default:
152
+ break;
153
+ }
154
+ }
155
+
156
+ return -1;
157
+ }
158
+
159
+ oldkey = event.key.keysym.sym;
160
+
161
+ if (SP->save_key_modifiers)
162
+ {
163
+ if (event.key.keysym.mod & KMOD_NUM)
164
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
165
+
166
+ if (event.key.keysym.mod & KMOD_SHIFT)
167
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
168
+
169
+ if (event.key.keysym.mod & KMOD_CTRL)
170
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
171
+
172
+ if (event.key.keysym.mod & KMOD_ALT)
173
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_ALT;
174
+ }
175
+
176
+ for (i = 0; key_table[i].keycode; i++)
177
+ {
178
+ if (key_table[i].keycode == event.key.keysym.sym)
179
+ {
180
+ if ((event.key.keysym.mod & KMOD_SHIFT) ||
181
+ (key_table[i].numkeypad && (event.key.keysym.mod & KMOD_NUM)))
182
+ {
183
+ key = key_table[i].shifted;
184
+ }
185
+ else if (event.key.keysym.mod & KMOD_CTRL)
186
+ {
187
+ key = key_table[i].control;
188
+ }
189
+ else if (event.key.keysym.mod & KMOD_ALT)
190
+ {
191
+ key = key_table[i].alt;
192
+ }
193
+
194
+ /* To get here, we ignore all other modifiers */
195
+
196
+ else
197
+ key = key_table[i].normal;
198
+
199
+ SP->key_code = (key > 0x100);
200
+ break;
201
+ }
202
+ }
203
+
204
+ if (!key)
205
+ {
206
+ key = event.key.keysym.unicode;
207
+
208
+ if (key > 0x7f)
209
+ key = 0;
210
+ }
211
+
212
+ /* Handle ALT letters and numbers */
213
+
214
+ if (event.key.keysym.mod & KMOD_ALT)
215
+ {
216
+ if (key >= 'A' && key <= 'Z')
217
+ {
218
+ key += ALT_A - 'A';
219
+ SP->key_code = TRUE;
220
+ }
221
+
222
+ if (key >= 'a' && key <= 'z')
223
+ {
224
+ key += ALT_A - 'a';
225
+ SP->key_code = TRUE;
226
+ }
227
+
228
+ if (key >= '0' && key <= '9')
229
+ {
230
+ key += ALT_0 - '0';
231
+ SP->key_code = TRUE;
232
+ }
233
+ }
234
+
235
+ return key ? key : -1;
236
+ }
237
+
238
+ static int _process_mouse_event(void)
239
+ {
240
+ SDLMod keymods;
241
+ short shift_flags = 0;
242
+
243
+ memset(&pdc_mouse_status, 0, sizeof(MOUSE_STATUS));
244
+
245
+ keymods = SDL_GetModState();
246
+
247
+ if (keymods & KMOD_SHIFT)
248
+ shift_flags |= BUTTON_SHIFT;
249
+
250
+ if (keymods & KMOD_CTRL)
251
+ shift_flags |= BUTTON_CONTROL;
252
+
253
+ if (keymods & KMOD_ALT)
254
+ shift_flags |= BUTTON_ALT;
255
+
256
+ if (event.type == SDL_MOUSEMOTION)
257
+ {
258
+ int i;
259
+
260
+ pdc_mouse_status.x = event.motion.x / pdc_fwidth;
261
+ pdc_mouse_status.y = event.motion.y / pdc_fheight;
262
+
263
+ if (!event.motion.state ||
264
+ (pdc_mouse_status.x == old_mouse_status.x &&
265
+ pdc_mouse_status.y == old_mouse_status.y))
266
+ return -1;
267
+
268
+ pdc_mouse_status.changes = PDC_MOUSE_MOVED;
269
+
270
+ for (i = 0; i < 3; i++)
271
+ {
272
+ if (event.motion.state & SDL_BUTTON(i + 1))
273
+ {
274
+ pdc_mouse_status.button[i] = BUTTON_MOVED | shift_flags;
275
+ pdc_mouse_status.changes |= (1 << i);
276
+ }
277
+ }
278
+ }
279
+ else
280
+ {
281
+ short action = (event.button.state == SDL_PRESSED) ?
282
+ BUTTON_PRESSED : BUTTON_RELEASED;
283
+ Uint8 btn = event.button.button;
284
+
285
+ /* handle scroll wheel */
286
+
287
+ if ((btn >= 4 && btn <= 7) && action == BUTTON_RELEASED)
288
+ {
289
+ pdc_mouse_status.x = pdc_mouse_status.y = -1;
290
+
291
+ switch (btn)
292
+ {
293
+ case 4:
294
+ pdc_mouse_status.changes = PDC_MOUSE_WHEEL_UP;
295
+ break;
296
+ case 5:
297
+ pdc_mouse_status.changes = PDC_MOUSE_WHEEL_DOWN;
298
+ break;
299
+ case 6:
300
+ pdc_mouse_status.changes = PDC_MOUSE_WHEEL_LEFT;
301
+ break;
302
+ case 7:
303
+ pdc_mouse_status.changes = PDC_MOUSE_WHEEL_RIGHT;
304
+ }
305
+
306
+ SP->key_code = TRUE;
307
+ return KEY_MOUSE;
308
+ }
309
+
310
+ if (btn < 1 || btn > 3)
311
+ return -1;
312
+
313
+ /* check for a click -- a press followed immediately by a release */
314
+
315
+ if (action == BUTTON_PRESSED && SP->mouse_wait)
316
+ {
317
+ SDL_Event rel;
318
+
319
+ napms(SP->mouse_wait);
320
+
321
+ if (SDL_PollEvent(&rel))
322
+ {
323
+ if (rel.type == SDL_MOUSEBUTTONUP && rel.button.button == btn)
324
+ action = BUTTON_CLICKED;
325
+ else
326
+ SDL_PushEvent(&rel);
327
+ }
328
+ }
329
+
330
+ pdc_mouse_status.x = event.button.x / pdc_fwidth;
331
+ pdc_mouse_status.y = event.button.y / pdc_fheight;
332
+
333
+ btn--;
334
+
335
+ pdc_mouse_status.button[btn] = action | shift_flags;
336
+ pdc_mouse_status.changes = (1 << btn);
337
+ }
338
+
339
+ old_mouse_status = pdc_mouse_status;
340
+
341
+ SP->key_code = TRUE;
342
+ return KEY_MOUSE;
343
+ }
344
+
345
+ /* return the next available key or mouse event */
346
+
347
+ int PDC_get_key(void)
348
+ {
349
+ switch (event.type)
350
+ {
351
+ case SDL_QUIT:
352
+ exit(1);
353
+ case SDL_VIDEORESIZE:
354
+ if (pdc_own_screen &&
355
+ (event.resize.h / pdc_fheight != LINES ||
356
+ event.resize.w / pdc_fwidth != COLS))
357
+ {
358
+ pdc_sheight = event.resize.h;
359
+ pdc_swidth = event.resize.w;
360
+
361
+ if (!SP->resized)
362
+ {
363
+ SP->resized = TRUE;
364
+ return KEY_RESIZE;
365
+ }
366
+ }
367
+ break;
368
+ case SDL_MOUSEMOTION:
369
+ SDL_ShowCursor(SDL_ENABLE);
370
+ case SDL_MOUSEBUTTONUP:
371
+ case SDL_MOUSEBUTTONDOWN:
372
+ oldkey = SDLK_SPACE;
373
+ if (SP->_trap_mbe)
374
+ return _process_mouse_event();
375
+ break;
376
+ case SDL_KEYUP:
377
+ case SDL_KEYDOWN:
378
+ PDC_mouse_set();
379
+ return _process_key_event();
380
+ }
381
+
382
+ return -1;
383
+ }
384
+
385
+ /* discard any pending keyboard or mouse input -- this is the core
386
+ routine for flushinp() */
387
+
388
+ void PDC_flushinp(void)
389
+ {
390
+ PDC_LOG(("PDC_flushinp() - called\n"));
391
+
392
+ while (PDC_check_key());
393
+ }
394
+
395
+ int PDC_mouse_set(void)
396
+ {
397
+ SDL_ShowCursor(SP->_trap_mbe ? SDL_ENABLE : SDL_DISABLE);
398
+
399
+ return OK;
400
+ }
401
+
402
+ int PDC_modifiers_set(void)
403
+ {
404
+ return OK;
405
+ }
@@ -0,0 +1,414 @@
1
+ /* Public Domain Curses */
2
+
3
+ #include "pdcsdl.h"
4
+
5
+ #include <stdlib.h>
6
+ #ifndef PDC_WIDE
7
+ #include "deffont.h"
8
+ #endif
9
+ #include "deficon.h"
10
+
11
+ #ifdef PDC_WIDE
12
+ # ifndef PDC_FONT_PATH
13
+ # ifdef _WIN32
14
+ #define PDC_FONT_PATH "C:/Windows/Fonts/lucon.ttf"
15
+ # elif defined(__APPLE__)
16
+ #define PDC_FONT_PATH "/Library/Fonts/Courier New.ttf"
17
+ # else
18
+ #define PDC_FONT_PATH "/usr/share/fonts/truetype/freefont/FreeMono.ttf"
19
+ # endif
20
+ # endif
21
+ TTF_Font *pdc_ttffont = NULL;
22
+ int pdc_font_size = 18;
23
+ #endif
24
+
25
+ SDL_Surface *pdc_screen = NULL, *pdc_font = NULL, *pdc_icon = NULL,
26
+ *pdc_back = NULL, *pdc_tileback = NULL;
27
+ int pdc_sheight = 0, pdc_swidth = 0, pdc_yoffset = 0, pdc_xoffset = 0;
28
+
29
+ SDL_Color pdc_color[256];
30
+ Uint32 pdc_mapped[256];
31
+ int pdc_fheight, pdc_fwidth, pdc_flastc;
32
+ bool pdc_own_screen;
33
+
34
+ /* special purpose function keys */
35
+ static int PDC_shutdown_key[PDC_MAX_FUNCTION_KEYS] = { 0, 0, 0, 0, 0 };
36
+
37
+ /* COLOR_PAIR to attribute encoding table. */
38
+
39
+ static struct {short f, b;} atrtab[PDC_COLOR_PAIRS];
40
+
41
+ static void _clean(void)
42
+ {
43
+ #ifdef PDC_WIDE
44
+ if (pdc_ttffont)
45
+ {
46
+ TTF_CloseFont(pdc_ttffont);
47
+ TTF_Quit();
48
+ }
49
+ #endif
50
+ SDL_FreeSurface(pdc_tileback);
51
+ SDL_FreeSurface(pdc_back);
52
+ SDL_FreeSurface(pdc_icon);
53
+ SDL_FreeSurface(pdc_font);
54
+
55
+ SDL_Quit();
56
+ }
57
+
58
+ void PDC_retile(void)
59
+ {
60
+ if (pdc_tileback)
61
+ SDL_FreeSurface(pdc_tileback);
62
+
63
+ pdc_tileback = SDL_DisplayFormat(pdc_screen);
64
+ if (pdc_tileback == NULL)
65
+ return;
66
+
67
+ if (pdc_back)
68
+ {
69
+ SDL_Rect dest;
70
+
71
+ dest.y = 0;
72
+
73
+ while (dest.y < pdc_tileback->h)
74
+ {
75
+ dest.x = 0;
76
+
77
+ while (dest.x < pdc_tileback->w)
78
+ {
79
+ SDL_BlitSurface(pdc_back, 0, pdc_tileback, &dest);
80
+ dest.x += pdc_back->w;
81
+ }
82
+
83
+ dest.y += pdc_back->h;
84
+ }
85
+
86
+ SDL_BlitSurface(pdc_tileback, 0, pdc_screen, 0);
87
+ }
88
+ }
89
+
90
+ void PDC_scr_close(void)
91
+ {
92
+ PDC_LOG(("PDC_scr_close() - called\n"));
93
+ }
94
+
95
+ void PDC_scr_free(void)
96
+ {
97
+ if (SP)
98
+ free(SP);
99
+ }
100
+
101
+ static int default_pdc_swidth = 80, default_pdc_sheight = 25;
102
+
103
+ /* open the physical screen -- allocate SP, miscellaneous intialization */
104
+
105
+ int PDC_scr_open(int argc, char **argv)
106
+ {
107
+ int i, r, g, b;
108
+
109
+ PDC_LOG(("PDC_scr_open() - called\n"));
110
+
111
+ SP = calloc(1, sizeof(SCREEN));
112
+
113
+ if (!SP)
114
+ return ERR;
115
+
116
+ pdc_own_screen = !pdc_screen;
117
+
118
+ if (pdc_own_screen)
119
+ {
120
+ if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) < 0)
121
+ {
122
+ fprintf(stderr, "Could not start SDL: %s\n", SDL_GetError());
123
+ return ERR;
124
+ }
125
+
126
+ atexit(_clean);
127
+ }
128
+
129
+ #ifdef PDC_WIDE
130
+ if (!pdc_ttffont)
131
+ {
132
+ const char *ptsz, *fname;
133
+
134
+ if (TTF_Init() == -1)
135
+ {
136
+ fprintf(stderr, "Could not start SDL_TTF: %s\n", SDL_GetError());
137
+ return ERR;
138
+ }
139
+
140
+ ptsz = getenv("PDC_FONT_SIZE");
141
+ if (ptsz != NULL)
142
+ pdc_font_size = atoi(ptsz);
143
+ if (pdc_font_size <= 0)
144
+ pdc_font_size = 18;
145
+
146
+ fname = getenv("PDC_FONT");
147
+ pdc_ttffont = TTF_OpenFont(fname ? fname : PDC_FONT_PATH,
148
+ pdc_font_size);
149
+ }
150
+
151
+ if (!pdc_ttffont)
152
+ {
153
+ fprintf(stderr, "Could not load font\n");
154
+ return ERR;
155
+ }
156
+
157
+ TTF_SetFontKerning(pdc_ttffont, 0);
158
+ TTF_SetFontHinting(pdc_ttffont, TTF_HINTING_MONO);
159
+
160
+ SP->mono = FALSE;
161
+ #else
162
+ if (!pdc_font)
163
+ {
164
+ const char *fname = getenv("PDC_FONT");
165
+ pdc_font = SDL_LoadBMP(fname ? fname : "pdcfont.bmp");
166
+ }
167
+
168
+ if (!pdc_font)
169
+ pdc_font = SDL_LoadBMP_RW(SDL_RWFromMem(deffont, sizeof(deffont)), 0);
170
+
171
+ if (!pdc_font)
172
+ {
173
+ fprintf(stderr, "Could not load font\n");
174
+ return ERR;
175
+ }
176
+
177
+ SP->mono = !pdc_font->format->palette;
178
+ #endif
179
+
180
+ if (!SP->mono && !pdc_back)
181
+ {
182
+ const char *bname = getenv("PDC_BACKGROUND");
183
+ pdc_back = SDL_LoadBMP(bname ? bname : "pdcback.bmp");
184
+ }
185
+
186
+ if (!SP->mono && (pdc_back || !pdc_own_screen))
187
+ {
188
+ SP->orig_attr = TRUE;
189
+ SP->orig_fore = COLOR_WHITE;
190
+ SP->orig_back = -1;
191
+ }
192
+ else
193
+ SP->orig_attr = FALSE;
194
+
195
+ #ifdef PDC_WIDE
196
+ TTF_SizeText(pdc_ttffont, "W", &pdc_fwidth, &pdc_fheight);
197
+ #else
198
+ pdc_fheight = pdc_font->h / 8;
199
+ pdc_fwidth = pdc_font->w / 32;
200
+
201
+ if (!SP->mono)
202
+ pdc_flastc = pdc_font->format->palette->ncolors - 1;
203
+ #endif
204
+
205
+ if (pdc_own_screen && !pdc_icon)
206
+ {
207
+ const char *iname = getenv("PDC_ICON");
208
+ pdc_icon = SDL_LoadBMP(iname ? iname : "pdcicon.bmp");
209
+
210
+ if (!pdc_icon)
211
+ pdc_icon = SDL_LoadBMP_RW(SDL_RWFromMem(deficon,
212
+ sizeof(deficon)), 0);
213
+
214
+ if (pdc_icon)
215
+ SDL_WM_SetIcon(pdc_icon, NULL);
216
+ }
217
+
218
+ if (pdc_own_screen)
219
+ {
220
+ const char *env = getenv("PDC_LINES");
221
+ pdc_sheight = (env ? atoi(env) : default_pdc_sheight) * pdc_fheight;
222
+
223
+ env = getenv("PDC_COLS");
224
+ pdc_swidth = (env ? atoi(env) : default_pdc_swidth) * pdc_fwidth;
225
+
226
+ pdc_screen = SDL_SetVideoMode(pdc_swidth, pdc_sheight, 0,
227
+ SDL_SWSURFACE|SDL_ANYFORMAT|SDL_RESIZABLE);
228
+ }
229
+ else
230
+ {
231
+ if (!pdc_sheight)
232
+ pdc_sheight = pdc_screen->h - pdc_yoffset;
233
+
234
+ if (!pdc_swidth)
235
+ pdc_swidth = pdc_screen->w - pdc_xoffset;
236
+ }
237
+
238
+ if (!pdc_screen)
239
+ {
240
+ fprintf(stderr, "Couldn't create a surface: %s\n", SDL_GetError());
241
+ return ERR;
242
+ }
243
+
244
+ if (SP->orig_attr)
245
+ PDC_retile();
246
+
247
+ COLORS = 256; /* we have 256 colors in this flavor of PDCurses */
248
+ for (i = 0; i < 8; i++)
249
+ {
250
+ pdc_color[i].r = (i & COLOR_RED) ? 0xc0 : 0;
251
+ pdc_color[i].g = (i & COLOR_GREEN) ? 0xc0 : 0;
252
+ pdc_color[i].b = (i & COLOR_BLUE) ? 0xc0 : 0;
253
+
254
+ pdc_color[i + 8].r = (i & COLOR_RED) ? 0xff : 0x40;
255
+ pdc_color[i + 8].g = (i & COLOR_GREEN) ? 0xff : 0x40;
256
+ pdc_color[i + 8].b = (i & COLOR_BLUE) ? 0xff : 0x40;
257
+ }
258
+
259
+ /* 256-color xterm extended palette: 216 colors in a
260
+ 6x6x6 color cube, plus 24 (not 50) shades of gray */
261
+ i = 16;
262
+ for( r = 0; r < 6; r++)
263
+ for( g = 0; g < 6; g++)
264
+ for( b = 0; b < 6; b++, i++)
265
+ {
266
+ pdc_color[i].r = ( r ? r * 40 + 55 : 0);
267
+ pdc_color[i].g = ( g ? g * 40 + 55 : 0);
268
+ pdc_color[i].b = ( b ? b * 40 + 55 : 0);
269
+ }
270
+ for( i = 232; i < 256; i++)
271
+ pdc_color[i].r = pdc_color[i].g = pdc_color[i].b = (i - 232) * 10 + 8;
272
+ for (i = 0; i < 256; i++)
273
+ pdc_mapped[i] = SDL_MapRGB(pdc_screen->format, pdc_color[i].r,
274
+ pdc_color[i].g, pdc_color[i].b);
275
+
276
+ SDL_EnableUNICODE(1);
277
+
278
+ PDC_mouse_set();
279
+
280
+ if (pdc_own_screen)
281
+ PDC_set_title(argc ? argv[0] : "PDCurses");
282
+
283
+ SP->lines = PDC_get_rows();
284
+ SP->cols = PDC_get_columns();
285
+
286
+ SP->mouse_wait = PDC_CLICK_PERIOD;
287
+ SP->audible = FALSE;
288
+
289
+ PDC_reset_prog_mode();
290
+
291
+ return OK;
292
+ }
293
+
294
+ /* the core of resize_term() */
295
+
296
+ int PDC_resize_screen(int nlines, int ncols)
297
+ {
298
+ if( !stdscr) /* window hasn't been created yet; we're */
299
+ { /* specifying its size before doing so */
300
+ default_pdc_swidth = ncols;
301
+ default_pdc_sheight = nlines;
302
+ return OK;
303
+ }
304
+
305
+ if (!pdc_own_screen)
306
+ return ERR;
307
+
308
+ if (nlines && ncols)
309
+ {
310
+ pdc_sheight = nlines * pdc_fheight;
311
+ pdc_swidth = ncols * pdc_fwidth;
312
+ }
313
+
314
+ SDL_FreeSurface(pdc_screen);
315
+
316
+ pdc_screen = SDL_SetVideoMode(pdc_swidth, pdc_sheight, 0,
317
+ SDL_SWSURFACE|SDL_ANYFORMAT|SDL_RESIZABLE);
318
+
319
+ if (pdc_tileback)
320
+ PDC_retile();
321
+
322
+ SP->resized = FALSE;
323
+ SP->cursrow = SP->curscol = 0;
324
+
325
+ return OK;
326
+ }
327
+
328
+ void PDC_reset_prog_mode(void)
329
+ {
330
+ PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
331
+
332
+ PDC_flushinp();
333
+ SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
334
+ }
335
+
336
+ void PDC_reset_shell_mode(void)
337
+ {
338
+ PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
339
+
340
+ SDL_EnableKeyRepeat(0, 0);
341
+ PDC_flushinp();
342
+ }
343
+
344
+ void PDC_restore_screen_mode(int i)
345
+ {
346
+ }
347
+
348
+ void PDC_save_screen_mode(int i)
349
+ {
350
+ }
351
+
352
+ void PDC_init_pair(short pair, short fg, short bg)
353
+ {
354
+ atrtab[pair].f = fg;
355
+ atrtab[pair].b = bg;
356
+ }
357
+
358
+ int PDC_pair_content(short pair, short *fg, short *bg)
359
+ {
360
+ *fg = atrtab[pair].f;
361
+ *bg = atrtab[pair].b;
362
+
363
+ return OK;
364
+ }
365
+
366
+ bool PDC_can_change_color(void)
367
+ {
368
+ return TRUE;
369
+ }
370
+
371
+ int PDC_color_content(short color, short *red, short *green, short *blue)
372
+ {
373
+ *red = DIVROUND(pdc_color[color].r * 1000, 255);
374
+ *green = DIVROUND(pdc_color[color].g * 1000, 255);
375
+ *blue = DIVROUND(pdc_color[color].b * 1000, 255);
376
+
377
+ return OK;
378
+ }
379
+
380
+ int PDC_init_color(short color, short red, short green, short blue)
381
+ {
382
+ pdc_color[color].r = DIVROUND(red * 255, 1000);
383
+ pdc_color[color].g = DIVROUND(green * 255, 1000);
384
+ pdc_color[color].b = DIVROUND(blue * 255, 1000);
385
+
386
+ pdc_mapped[color] = SDL_MapRGB(pdc_screen->format, pdc_color[color].r,
387
+ pdc_color[color].g, pdc_color[color].b);
388
+
389
+ wrefresh(curscr);
390
+
391
+ return OK;
392
+ }
393
+
394
+ /* Does nothing in the SDL flavors of PDCurses. That may change, eventually,
395
+ allowing one to limit the range of user-resizable windows. See X11 or Win32a
396
+ versions of this function for details. */
397
+
398
+ void PDC_set_resize_limits( const int new_min_lines, const int new_max_lines,
399
+ const int new_min_cols, const int new_max_cols)
400
+ {
401
+ }
402
+
403
+ /* PDC_set_function_key() does nothing on this platform */
404
+ int PDC_set_function_key( const unsigned function, const int new_key)
405
+ {
406
+ int old_key = -1;
407
+
408
+ if( function < PDC_MAX_FUNCTION_KEYS)
409
+ {
410
+ old_key = PDC_shutdown_key[function];
411
+ PDC_shutdown_key[function] = new_key;
412
+ }
413
+ return( old_key);
414
+ }