curses 1.3.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,785 @@
1
+ /* Public Domain Curses */
2
+
3
+ #include "pdcdos.h"
4
+
5
+ #include <stdlib.h>
6
+
7
+ #ifdef CHTYPE_LONG
8
+ # define PDC_OFFSET 32
9
+ #else
10
+ # define PDC_OFFSET 8
11
+ #endif
12
+
13
+ /* COLOR_PAIR to attribute encoding table. */
14
+
15
+ unsigned char *pdc_atrtab = (unsigned char *)NULL;
16
+
17
+ int pdc_adapter; /* screen type */
18
+ int pdc_scrnmode; /* default screen mode */
19
+ int pdc_font; /* default font size */
20
+ bool pdc_direct_video; /* allow direct screen memory writes */
21
+ bool pdc_bogus_adapter; /* TRUE if adapter has insane values */
22
+ unsigned pdc_video_seg; /* video base segment */
23
+ unsigned pdc_video_ofs; /* video base offset */
24
+
25
+ static short curstoreal[16], realtocurs[16] =
26
+ {
27
+ COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN, COLOR_RED,
28
+ COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE, COLOR_BLACK + 8,
29
+ COLOR_BLUE + 8, COLOR_GREEN + 8, COLOR_CYAN + 8, COLOR_RED + 8,
30
+ COLOR_MAGENTA + 8, COLOR_YELLOW + 8, COLOR_WHITE + 8
31
+ };
32
+
33
+ static bool sizeable = FALSE; /* TRUE if adapter is resizeable */
34
+
35
+ static unsigned short *saved_screen = NULL;
36
+ static int saved_lines = 0;
37
+ static int saved_cols = 0;
38
+
39
+ static int saved_scrnmode[3];
40
+ static int saved_font[3];
41
+
42
+ /* special purpose function keys */
43
+ static int PDC_shutdown_key[PDC_MAX_FUNCTION_KEYS] = { 0, 0, 0, 0, 0 };
44
+
45
+ /* Thanks to Jeff Duntemann, K16RA for providing the impetus
46
+ (through the Dr. Dobbs Journal, March 1989 issue) for getting
47
+ the routines below merged into Bjorn Larsson's PDCurses 1.3...
48
+ -- frotz@dri.com 900730 */
49
+
50
+ /* _get_font() - Get the current font size */
51
+
52
+ static int _get_font(void)
53
+ {
54
+ int retval;
55
+
56
+ retval = getdosmemword(0x485);
57
+
58
+ /* Assume the MDS Genius is in 66 line mode. */
59
+
60
+ if ((retval == 0) && (pdc_adapter == _MDS_GENIUS))
61
+ retval = _FONT15;
62
+
63
+ switch (pdc_adapter)
64
+ {
65
+ case _MDA:
66
+ retval = 10; /* POINTS is not certain on MDA/Hercules */
67
+ break;
68
+
69
+ case _EGACOLOR:
70
+ case _EGAMONO:
71
+ switch (retval)
72
+ {
73
+ case _FONT8:
74
+ case _FONT14:
75
+ break;
76
+ default:
77
+ retval = _FONT14;
78
+ }
79
+ break;
80
+
81
+ case _CGA:
82
+ retval = _FONT8;
83
+ }
84
+
85
+ return retval;
86
+ }
87
+
88
+ /* _set_font() - Sets the current font size, if the adapter allows such a
89
+ change. It is an error to attempt to change the font size on a
90
+ "bogus" adapter. The reason for this is that we have a known video
91
+ adapter identity problem. e.g. Two adapters report the same identifying
92
+ characteristics. */
93
+
94
+ static void _set_font(int size)
95
+ {
96
+ PDCREGS regs;
97
+
98
+ if (pdc_bogus_adapter)
99
+ return;
100
+
101
+ switch (pdc_adapter)
102
+ {
103
+ case _CGA:
104
+ case _MDA:
105
+ case _MCGACOLOR:
106
+ case _MCGAMONO:
107
+ case _MDS_GENIUS:
108
+ break;
109
+
110
+ case _EGACOLOR:
111
+ case _EGAMONO:
112
+ if (sizeable && (pdc_font != size))
113
+ {
114
+ switch (size)
115
+ {
116
+ case _FONT8:
117
+ regs.W.ax = 0x1112;
118
+ regs.h.bl = 0x00;
119
+ PDCINT(0x10, regs);
120
+ break;
121
+ case _FONT14:
122
+ regs.W.ax = 0x1111;
123
+ regs.h.bl = 0x00;
124
+ PDCINT(0x10, regs);
125
+ }
126
+ }
127
+ break;
128
+
129
+ case _VGACOLOR:
130
+ case _VGAMONO:
131
+ if (sizeable && (pdc_font != size))
132
+ {
133
+ switch (size)
134
+ {
135
+ case _FONT8:
136
+ regs.W.ax = 0x1112;
137
+ regs.h.bl = 0x00;
138
+ PDCINT(0x10, regs);
139
+ break;
140
+ case _FONT14:
141
+ regs.W.ax = 0x1111;
142
+ regs.h.bl = 0x00;
143
+ PDCINT(0x10, regs);
144
+ break;
145
+ case _FONT16:
146
+ regs.W.ax = 0x1114;
147
+ regs.h.bl = 0x00;
148
+ PDCINT(0x10, regs);
149
+ }
150
+ }
151
+ }
152
+
153
+ curs_set(SP->visibility);
154
+
155
+ pdc_font = _get_font();
156
+ }
157
+
158
+ /* _set_80x25() - force a known screen state: 80x25 text mode. Forces the
159
+ appropriate 80x25 alpha mode given the display adapter. */
160
+
161
+ static void _set_80x25(void)
162
+ {
163
+ PDCREGS regs;
164
+
165
+ switch (pdc_adapter)
166
+ {
167
+ case _CGA:
168
+ case _EGACOLOR:
169
+ case _EGAMONO:
170
+ case _VGACOLOR:
171
+ case _VGAMONO:
172
+ case _MCGACOLOR:
173
+ case _MCGAMONO:
174
+ regs.h.ah = 0x00;
175
+ regs.h.al = 0x03;
176
+ PDCINT(0x10, regs);
177
+ break;
178
+ case _MDA:
179
+ regs.h.ah = 0x00;
180
+ regs.h.al = 0x07;
181
+ PDCINT(0x10, regs);
182
+ }
183
+ }
184
+
185
+ /* _get_scrn_mode() - Return the current BIOS video mode */
186
+
187
+ static int _get_scrn_mode(void)
188
+ {
189
+ PDCREGS regs;
190
+
191
+ regs.h.ah = 0x0f;
192
+ PDCINT(0x10, regs);
193
+
194
+ return (int)regs.h.al;
195
+ }
196
+
197
+ /* _set_scrn_mode() - Sets the BIOS Video Mode Number only if it is
198
+ different from the current video mode. */
199
+
200
+ static void _set_scrn_mode(int new_mode)
201
+ {
202
+ PDCREGS regs;
203
+
204
+ if (_get_scrn_mode() != new_mode)
205
+ {
206
+ regs.h.ah = 0;
207
+ regs.h.al = (unsigned char) new_mode;
208
+ PDCINT(0x10, regs);
209
+ }
210
+
211
+ pdc_font = _get_font();
212
+ pdc_scrnmode = new_mode;
213
+ LINES = PDC_get_rows();
214
+ COLS = PDC_get_columns();
215
+ }
216
+
217
+ /* _sanity_check() - A video adapter identification sanity check. This
218
+ routine will force sane values for various control flags. */
219
+
220
+ static int _sanity_check(int adapter)
221
+ {
222
+ int fontsize = _get_font();
223
+ int rows = PDC_get_rows();
224
+
225
+ PDC_LOG(("_sanity_check() - called: Adapter %d\n", adapter));
226
+
227
+ switch (adapter)
228
+ {
229
+ case _EGACOLOR:
230
+ case _EGAMONO:
231
+ switch (rows)
232
+ {
233
+ case 25:
234
+ case 43:
235
+ break;
236
+ default:
237
+ pdc_bogus_adapter = TRUE;
238
+ }
239
+
240
+ switch (fontsize)
241
+ {
242
+ case _FONT8:
243
+ case _FONT14:
244
+ break;
245
+ default:
246
+ pdc_bogus_adapter = TRUE;
247
+ }
248
+ break;
249
+
250
+ case _VGACOLOR:
251
+ case _VGAMONO:
252
+ break;
253
+
254
+ case _CGA:
255
+ case _MDA:
256
+ case _MCGACOLOR:
257
+ case _MCGAMONO:
258
+ switch (rows)
259
+ {
260
+ case 25:
261
+ break;
262
+ default:
263
+ pdc_bogus_adapter = TRUE;
264
+ }
265
+ break;
266
+
267
+ default:
268
+ pdc_bogus_adapter = TRUE;
269
+ }
270
+
271
+ if (pdc_bogus_adapter)
272
+ {
273
+ sizeable = FALSE;
274
+ pdc_direct_video = FALSE;
275
+ }
276
+
277
+ return adapter;
278
+ }
279
+
280
+ /* _query_adapter_type() - Determine PC video adapter type. */
281
+
282
+ static int _query_adapter_type(void)
283
+ {
284
+ PDCREGS regs;
285
+ int retval = _NONE;
286
+
287
+ /* thanks to paganini@ax.apc.org for the GO32 fix */
288
+
289
+ #if !defined(__DJGPP__) && !defined(__WATCOMC__)
290
+ struct SREGS segs;
291
+ #endif
292
+ short video_base = getdosmemword(0x463);
293
+
294
+ PDC_LOG(("_query_adapter_type() - called\n"));
295
+
296
+ /* attempt to call VGA Identify Adapter Function */
297
+
298
+ regs.W.ax = 0x1a00;
299
+ PDCINT(0x10, regs);
300
+
301
+ if ((regs.h.al == 0x1a) && (retval == _NONE))
302
+ {
303
+ /* We know that the PS/2 video BIOS is alive and well. */
304
+
305
+ switch (regs.h.al)
306
+ {
307
+ case 0:
308
+ retval = _NONE;
309
+ break;
310
+ case 1:
311
+ retval = _MDA;
312
+ break;
313
+ case 2:
314
+ retval = _CGA;
315
+ break;
316
+ case 4:
317
+ retval = _EGACOLOR;
318
+ sizeable = TRUE;
319
+ break;
320
+ case 5:
321
+ retval = _EGAMONO;
322
+ break;
323
+ case 26: /* ...alt. VGA BIOS... */
324
+ case 7:
325
+ retval = _VGACOLOR;
326
+ sizeable = TRUE;
327
+ break;
328
+ case 8:
329
+ retval = _VGAMONO;
330
+ break;
331
+ case 10:
332
+ case 13:
333
+ retval = _MCGACOLOR;
334
+ break;
335
+ case 12:
336
+ retval = _MCGAMONO;
337
+ break;
338
+ default:
339
+ retval = _CGA;
340
+ }
341
+ }
342
+ else
343
+ {
344
+ /* No VGA BIOS, check for an EGA BIOS by selecting an
345
+ Alternate Function Service...
346
+
347
+ bx == 0x0010 --> return EGA information */
348
+
349
+ regs.h.ah = 0x12;
350
+ regs.W.bx = 0x10;
351
+ PDCINT(0x10, regs);
352
+
353
+ if ((regs.h.bl != 0x10) && (retval == _NONE))
354
+ {
355
+ /* An EGA BIOS exists */
356
+
357
+ regs.h.ah = 0x12;
358
+ regs.h.bl = 0x10;
359
+ PDCINT(0x10, regs);
360
+
361
+ if (regs.h.bh == 0)
362
+ retval = _EGACOLOR;
363
+ else
364
+ retval = _EGAMONO;
365
+ }
366
+ else if (retval == _NONE)
367
+ {
368
+ /* Now we know we only have CGA or MDA */
369
+
370
+ PDCINT(0x11, regs);
371
+
372
+ switch (regs.h.al & 0x30)
373
+ {
374
+ case 0x10:
375
+ case 0x20:
376
+ retval = _CGA;
377
+ break;
378
+ case 0x30:
379
+ retval = _MDA;
380
+ break;
381
+ default:
382
+ retval = _NONE;
383
+ }
384
+ }
385
+ }
386
+
387
+ if (video_base == 0x3d4)
388
+ {
389
+ pdc_video_seg = 0xb800;
390
+ switch (retval)
391
+ {
392
+ case _EGAMONO:
393
+ retval = _EGACOLOR;
394
+ break;
395
+ case _VGAMONO:
396
+ retval = _VGACOLOR;
397
+ }
398
+ }
399
+
400
+ if (video_base == 0x3b4)
401
+ {
402
+ pdc_video_seg = 0xb000;
403
+ switch (retval)
404
+ {
405
+ case _EGACOLOR:
406
+ retval = _EGAMONO;
407
+ break;
408
+ case _VGACOLOR:
409
+ retval = _VGAMONO;
410
+ }
411
+ }
412
+
413
+ if ((retval == _NONE)
414
+ #ifndef CGA_DIRECT
415
+ || (retval == _CGA)
416
+ #endif
417
+ )
418
+ pdc_direct_video = FALSE;
419
+
420
+ if ((unsigned)pdc_video_seg == 0xb000)
421
+ SP->mono = TRUE;
422
+ else
423
+ SP->mono = FALSE;
424
+
425
+ /* Check for DESQview shadow buffer
426
+ thanks to paganini@ax.apc.org for the GO32 fix */
427
+
428
+ #ifndef __WATCOMC__
429
+ regs.h.ah = 0xfe;
430
+ regs.h.al = 0;
431
+ regs.x.di = pdc_video_ofs;
432
+ # ifdef __DJGPP__
433
+ regs.x.es = pdc_video_seg;
434
+ __dpmi_int(0x10, &regs);
435
+ pdc_video_seg = regs.x.es;
436
+ # else
437
+ segs.es = pdc_video_seg;
438
+ int86x(0x10, &regs, &regs, &segs);
439
+ pdc_video_seg = segs.es;
440
+ # endif
441
+ pdc_video_ofs = regs.x.di;
442
+ #endif
443
+ if (!pdc_adapter)
444
+ pdc_adapter = retval;
445
+
446
+ return _sanity_check(retval);
447
+ }
448
+
449
+ /* close the physical screen -- may restore the screen to its state
450
+ before PDC_scr_open(); miscellaneous cleanup */
451
+
452
+ void PDC_scr_close(void)
453
+ {
454
+ #if SMALL || MEDIUM
455
+ # ifndef __PACIFIC__
456
+ struct SREGS segregs;
457
+ # endif
458
+ int ds;
459
+ #endif
460
+ PDC_LOG(("PDC_scr_close() - called\n"));
461
+
462
+ if (getenv("PDC_RESTORE_SCREEN") && saved_screen)
463
+ {
464
+ #ifdef __DJGPP__
465
+ dosmemput(saved_screen, saved_lines * saved_cols * 2,
466
+ (unsigned long)_FAR_POINTER(pdc_video_seg,
467
+ pdc_video_ofs));
468
+ #else
469
+ # if (SMALL || MEDIUM)
470
+ # ifdef __PACIFIC__
471
+ ds = FP_SEG((void far *)saved_screen);
472
+ # else
473
+ segread(&segregs);
474
+ ds = segregs.ds;
475
+ # endif
476
+ movedata(ds, (int)saved_screen, pdc_video_seg, pdc_video_ofs,
477
+ (saved_lines * saved_cols * 2));
478
+ # else
479
+ memcpy((void *)_FAR_POINTER(pdc_video_seg, pdc_video_ofs),
480
+ (void *)saved_screen, (saved_lines * saved_cols * 2));
481
+ # endif
482
+ #endif
483
+ free(saved_screen);
484
+ saved_screen = NULL;
485
+ }
486
+
487
+ reset_shell_mode();
488
+
489
+ if (SP->visibility != 1)
490
+ curs_set(1);
491
+
492
+ /* Position cursor to the bottom left of the screen. */
493
+
494
+ PDC_gotoyx(PDC_get_rows() - 2, 0);
495
+ }
496
+
497
+ void PDC_scr_free(void)
498
+ {
499
+ if (SP)
500
+ free(SP);
501
+ if (pdc_atrtab)
502
+ free(pdc_atrtab);
503
+
504
+ pdc_atrtab = (unsigned char *)NULL;
505
+ }
506
+
507
+ /* open the physical screen -- allocate SP, miscellaneous intialization,
508
+ and may save the existing screen for later restoration */
509
+
510
+ int PDC_scr_open(int argc, char **argv)
511
+ {
512
+ #if SMALL || MEDIUM
513
+ # ifndef __PACIFIC__
514
+ struct SREGS segregs;
515
+ # endif
516
+ int ds;
517
+ #endif
518
+ int i;
519
+
520
+ PDC_LOG(("PDC_scr_open() - called\n"));
521
+
522
+ SP = calloc(1, sizeof(SCREEN));
523
+ pdc_atrtab = calloc(PDC_COLOR_PAIRS * PDC_OFFSET, 1);
524
+
525
+ if (!SP || !pdc_atrtab)
526
+ return ERR;
527
+
528
+ for (i = 0; i < 16; i++)
529
+ curstoreal[realtocurs[i]] = i;
530
+
531
+ SP->orig_attr = FALSE;
532
+
533
+ pdc_direct_video = TRUE; /* Assume that we can */
534
+ pdc_video_seg = 0xb000; /* Base screen segment addr */
535
+ pdc_video_ofs = 0x0; /* Base screen segment ofs */
536
+
537
+ pdc_adapter = _query_adapter_type();
538
+ pdc_scrnmode = _get_scrn_mode();
539
+ pdc_font = _get_font();
540
+
541
+ SP->lines = PDC_get_rows();
542
+ SP->cols = PDC_get_columns();
543
+
544
+ SP->mouse_wait = PDC_CLICK_PERIOD;
545
+ SP->audible = TRUE;
546
+
547
+ /* If the environment variable PDCURSES_BIOS is set, the DOS int10()
548
+ BIOS calls are used in place of direct video memory access. */
549
+
550
+ if (getenv("PDCURSES_BIOS"))
551
+ pdc_direct_video = FALSE;
552
+
553
+ /* This code for preserving the current screen. */
554
+
555
+ if (getenv("PDC_RESTORE_SCREEN"))
556
+ {
557
+ saved_lines = SP->lines;
558
+ saved_cols = SP->cols;
559
+
560
+ saved_screen = malloc(saved_lines * saved_cols * 2);
561
+
562
+ if (!saved_screen)
563
+ {
564
+ SP->_preserve = FALSE;
565
+ return OK;
566
+ }
567
+ #ifdef __DJGPP__
568
+ dosmemget((unsigned long)_FAR_POINTER(pdc_video_seg, pdc_video_ofs),
569
+ saved_lines * saved_cols * 2, saved_screen);
570
+ #else
571
+ # if SMALL || MEDIUM
572
+ # ifdef __PACIFIC__
573
+ ds = FP_SEG((void far *) saved_screen);
574
+ # else
575
+ segread(&segregs);
576
+ ds = segregs.ds;
577
+ # endif
578
+ movedata(pdc_video_seg, pdc_video_ofs, ds, (int)saved_screen,
579
+ (saved_lines * saved_cols * 2));
580
+ # else
581
+ memcpy((void *)saved_screen,
582
+ (void *)_FAR_POINTER(pdc_video_seg, pdc_video_ofs),
583
+ (saved_lines * saved_cols * 2));
584
+ # endif
585
+ #endif
586
+ }
587
+
588
+ SP->_preserve = (getenv("PDC_PRESERVE_SCREEN") != NULL);
589
+
590
+ return OK;
591
+ }
592
+
593
+ /* the core of resize_term() */
594
+
595
+ int PDC_resize_screen(int nlines, int ncols)
596
+ {
597
+ PDC_LOG(("PDC_resize_screen() - called. Lines: %d Cols: %d\n",
598
+ nlines, ncols));
599
+
600
+ if( !stdscr) /* window hasn't been created yet; we're */
601
+ { /* specifying its size before doing so */
602
+ return OK; /* ...which doesn't work in DOS */
603
+ }
604
+
605
+ /* Trash the stored value of orig_cursor -- it's only good if the
606
+ video mode doesn't change */
607
+
608
+ SP->orig_cursor = 0x0607;
609
+
610
+ switch (pdc_adapter)
611
+ {
612
+ case _EGACOLOR:
613
+ if (nlines >= 43)
614
+ _set_font(_FONT8);
615
+ else
616
+ _set_80x25();
617
+ break;
618
+
619
+ case _VGACOLOR:
620
+ if (nlines > 28)
621
+ _set_font(_FONT8);
622
+ else
623
+ if (nlines > 25)
624
+ _set_font(_FONT14);
625
+ else
626
+ _set_80x25();
627
+ }
628
+
629
+ PDC_set_blink(COLORS == 8);
630
+
631
+ return OK;
632
+ }
633
+
634
+ void PDC_reset_prog_mode(void)
635
+ {
636
+ PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
637
+ }
638
+
639
+ void PDC_reset_shell_mode(void)
640
+ {
641
+ PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
642
+ }
643
+
644
+ void PDC_restore_screen_mode(int i)
645
+ {
646
+ if (i >= 0 && i <= 2)
647
+ {
648
+ pdc_font = _get_font();
649
+ _set_font(saved_font[i]);
650
+
651
+ if (_get_scrn_mode() != saved_scrnmode[i])
652
+ _set_scrn_mode(saved_scrnmode[i]);
653
+ }
654
+ }
655
+
656
+ void PDC_save_screen_mode(int i)
657
+ {
658
+ if (i >= 0 && i <= 2)
659
+ {
660
+ saved_font[i] = pdc_font;
661
+ saved_scrnmode[i] = pdc_scrnmode;
662
+ }
663
+ }
664
+
665
+ void PDC_init_pair(short pair, short fg, short bg)
666
+ {
667
+ unsigned char att, temp_bg;
668
+ chtype i;
669
+
670
+ fg = curstoreal[fg];
671
+ bg = curstoreal[bg];
672
+
673
+ for (i = 0; i < PDC_OFFSET; i++)
674
+ {
675
+ att = fg | (bg << 4);
676
+
677
+ if (i & (A_REVERSE >> PDC_ATTR_SHIFT))
678
+ att = bg | (fg << 4);
679
+ if (i & (A_UNDERLINE >> PDC_ATTR_SHIFT))
680
+ att = 1;
681
+ if (i & (A_INVIS >> PDC_ATTR_SHIFT))
682
+ {
683
+ temp_bg = att >> 4;
684
+ att = temp_bg << 4 | temp_bg;
685
+ }
686
+ if (i & (A_BOLD >> PDC_ATTR_SHIFT))
687
+ att |= 8;
688
+ if (i & (A_BLINK >> PDC_ATTR_SHIFT))
689
+ att |= 128;
690
+
691
+ pdc_atrtab[pair * PDC_OFFSET + i] = att;
692
+ }
693
+ }
694
+
695
+ int PDC_pair_content(short pair, short *fg, short *bg)
696
+ {
697
+ *fg = realtocurs[pdc_atrtab[pair * PDC_OFFSET] & 0x0F];
698
+ *bg = realtocurs[(pdc_atrtab[pair * PDC_OFFSET] & 0xF0) >> 4];
699
+
700
+ return OK;
701
+ }
702
+
703
+ /* _egapal() - Find the EGA palette value (0-63) for the color (0-15).
704
+ On VGA, this is an index into the DAC. */
705
+
706
+ static short _egapal(short color)
707
+ {
708
+ PDCREGS regs;
709
+
710
+ regs.W.ax = 0x1007;
711
+ regs.h.bl = curstoreal[color];
712
+
713
+ PDCINT(0x10, regs);
714
+
715
+ return regs.h.bh;
716
+ }
717
+
718
+ bool PDC_can_change_color(void)
719
+ {
720
+ return (pdc_adapter == _VGACOLOR);
721
+ }
722
+
723
+ /* These are only valid when pdc_adapter == _VGACOLOR */
724
+
725
+ int PDC_color_content(short color, short *red, short *green, short *blue)
726
+ {
727
+ PDCREGS regs;
728
+
729
+ /* Read single DAC register */
730
+
731
+ regs.W.ax = 0x1015;
732
+ regs.h.bl = _egapal(color);
733
+
734
+ PDCINT(0x10, regs);
735
+
736
+ /* Scale and store */
737
+
738
+ *red = DIVROUND((unsigned)(regs.h.dh) * 1000, 63);
739
+ *green = DIVROUND((unsigned)(regs.h.ch) * 1000, 63);
740
+ *blue = DIVROUND((unsigned)(regs.h.cl) * 1000, 63);
741
+
742
+ return OK;
743
+ }
744
+
745
+ int PDC_init_color(short color, short red, short green, short blue)
746
+ {
747
+ PDCREGS regs;
748
+
749
+ /* Scale */
750
+
751
+ regs.h.dh = DIVROUND((unsigned)red * 63, 1000);
752
+ regs.h.ch = DIVROUND((unsigned)green * 63, 1000);
753
+ regs.h.cl = DIVROUND((unsigned)blue * 63, 1000);
754
+
755
+ /* Set single DAC register */
756
+
757
+ regs.W.ax = 0x1010;
758
+ regs.W.bx = _egapal(color);
759
+
760
+ PDCINT(0x10, regs);
761
+
762
+ return OK;
763
+ }
764
+
765
+ /* Does nothing in the DOS (or OS/2 or Win32 console) flavors of PDCurses,
766
+ which lack user resizing. See X11 or Win32a versions of this function for
767
+ details of what it does on platforms that do support user resizing. */
768
+
769
+ void PDC_set_resize_limits( const int new_min_lines, const int new_max_lines,
770
+ const int new_min_cols, const int new_max_cols)
771
+ {
772
+ }
773
+
774
+ /* PDC_set_function_key() does nothing on this platform */
775
+ int PDC_set_function_key( const unsigned function, const int new_key)
776
+ {
777
+ int old_key = -1;
778
+
779
+ if( function < PDC_MAX_FUNCTION_KEYS)
780
+ {
781
+ old_key = PDC_shutdown_key[function];
782
+ PDC_shutdown_key[function] = new_key;
783
+ }
784
+ return( old_key);
785
+ }