curses 1.3.0 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (256) 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 +34 -0
  6. data/README.md +14 -46
  7. data/Rakefile +0 -86
  8. data/curses.gemspec +2 -3
  9. data/ext/curses/curses.c +70 -58
  10. data/ext/curses/extconf.rb +134 -21
  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/menu.rb +3 -3
  16. data/sample/mouse_move.rb +75 -0
  17. data/vendor/PDCurses/.gitignore +47 -0
  18. data/vendor/PDCurses/.travis.yml +49 -0
  19. data/vendor/PDCurses/CMakeLists.txt +68 -0
  20. data/vendor/PDCurses/HISTORY.md +2036 -0
  21. data/vendor/PDCurses/IMPLEMNT.md +327 -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.bcc +83 -0
  57. data/vendor/PDCurses/dos/Makefile.dmc +257 -0
  58. data/vendor/PDCurses/dos/Makefile.msc +113 -0
  59. data/vendor/PDCurses/dos/Makefile.wcc +107 -0
  60. data/vendor/PDCurses/dos/README.md +51 -0
  61. data/vendor/PDCurses/dos/bccdos.lrf +9 -0
  62. data/vendor/PDCurses/dos/mscdos.lrf +50 -0
  63. data/vendor/PDCurses/dos/pdcclip.c +132 -0
  64. data/vendor/PDCurses/dos/pdcdisp.c +135 -0
  65. data/vendor/PDCurses/dos/pdcdos.h +194 -0
  66. data/vendor/PDCurses/dos/pdcgetsc.c +98 -0
  67. data/vendor/PDCurses/dos/pdckbd.c +513 -0
  68. data/vendor/PDCurses/dos/pdcscrn.c +785 -0
  69. data/vendor/PDCurses/dos/pdcsetsc.c +101 -0
  70. data/vendor/PDCurses/dos/pdcutil.c +212 -0
  71. data/vendor/PDCurses/libobjs.mif +26 -0
  72. data/vendor/PDCurses/makedist.mif +20 -0
  73. data/vendor/PDCurses/man/README.md +21 -0
  74. data/vendor/PDCurses/man/intro.md +361 -0
  75. data/vendor/PDCurses/man/manext.c +119 -0
  76. data/vendor/PDCurses/man/sdl.md +152 -0
  77. data/vendor/PDCurses/man/sdl2.md +58 -0
  78. data/vendor/PDCurses/man/x11.md +407 -0
  79. data/vendor/PDCurses/ncurses/CMakeLists.txt +66 -0
  80. data/vendor/PDCurses/ncurses/README.md +26 -0
  81. data/vendor/PDCurses/ncurses/makefile +29 -0
  82. data/vendor/PDCurses/os2/CMakeLists.txt +41 -0
  83. data/vendor/PDCurses/os2/Makefile.bcc +90 -0
  84. data/vendor/PDCurses/os2/Makefile.wcc +43 -0
  85. data/vendor/PDCurses/os2/README.md +43 -0
  86. data/vendor/PDCurses/os2/iccos2.lrf +50 -0
  87. data/vendor/PDCurses/os2/iccos2.mak +256 -0
  88. data/vendor/PDCurses/os2/pdcclip.c +188 -0
  89. data/vendor/PDCurses/os2/pdcdisp.c +93 -0
  90. data/vendor/PDCurses/os2/pdcgetsc.c +89 -0
  91. data/vendor/PDCurses/os2/pdckbd.c +521 -0
  92. data/vendor/PDCurses/os2/pdcos2.h +55 -0
  93. data/vendor/PDCurses/os2/pdcscrn.c +449 -0
  94. data/vendor/PDCurses/os2/pdcsetsc.c +112 -0
  95. data/vendor/PDCurses/os2/pdcutil.c +52 -0
  96. data/vendor/PDCurses/panel.h +56 -0
  97. data/vendor/PDCurses/pdcurses/README.md +25 -0
  98. data/vendor/PDCurses/pdcurses/addch.c +693 -0
  99. data/vendor/PDCurses/pdcurses/addchstr.c +245 -0
  100. data/vendor/PDCurses/pdcurses/addstr.c +240 -0
  101. data/vendor/PDCurses/pdcurses/attr.c +359 -0
  102. data/vendor/PDCurses/pdcurses/beep.c +68 -0
  103. data/vendor/PDCurses/pdcurses/bkgd.c +223 -0
  104. data/vendor/PDCurses/pdcurses/border.c +411 -0
  105. data/vendor/PDCurses/pdcurses/clear.c +159 -0
  106. data/vendor/PDCurses/pdcurses/color.c +298 -0
  107. data/vendor/PDCurses/pdcurses/debug.c +109 -0
  108. data/vendor/PDCurses/pdcurses/delch.c +96 -0
  109. data/vendor/PDCurses/pdcurses/deleteln.c +211 -0
  110. data/vendor/PDCurses/pdcurses/deprec.c +27 -0
  111. data/vendor/PDCurses/pdcurses/getch.c +417 -0
  112. data/vendor/PDCurses/pdcurses/getstr.c +474 -0
  113. data/vendor/PDCurses/pdcurses/getyx.c +139 -0
  114. data/vendor/PDCurses/pdcurses/inch.c +127 -0
  115. data/vendor/PDCurses/pdcurses/inchstr.c +214 -0
  116. data/vendor/PDCurses/pdcurses/initscr.c +367 -0
  117. data/vendor/PDCurses/pdcurses/inopts.c +324 -0
  118. data/vendor/PDCurses/pdcurses/insch.c +271 -0
  119. data/vendor/PDCurses/pdcurses/insstr.c +264 -0
  120. data/vendor/PDCurses/pdcurses/instr.c +246 -0
  121. data/vendor/PDCurses/pdcurses/kernel.c +259 -0
  122. data/vendor/PDCurses/pdcurses/keyname.c +157 -0
  123. data/vendor/PDCurses/pdcurses/mouse.c +438 -0
  124. data/vendor/PDCurses/pdcurses/move.c +57 -0
  125. data/vendor/PDCurses/pdcurses/outopts.c +159 -0
  126. data/vendor/PDCurses/pdcurses/overlay.c +214 -0
  127. data/vendor/PDCurses/pdcurses/pad.c +260 -0
  128. data/vendor/PDCurses/pdcurses/panel.c +633 -0
  129. data/vendor/PDCurses/pdcurses/printw.c +126 -0
  130. data/vendor/PDCurses/pdcurses/refresh.c +279 -0
  131. data/vendor/PDCurses/pdcurses/scanw.c +578 -0
  132. data/vendor/PDCurses/pdcurses/scr_dump.c +213 -0
  133. data/vendor/PDCurses/pdcurses/scroll.c +101 -0
  134. data/vendor/PDCurses/pdcurses/slk.c +591 -0
  135. data/vendor/PDCurses/pdcurses/termattr.c +182 -0
  136. data/vendor/PDCurses/pdcurses/terminfo.c +217 -0
  137. data/vendor/PDCurses/pdcurses/touch.c +163 -0
  138. data/vendor/PDCurses/pdcurses/util.c +312 -0
  139. data/vendor/PDCurses/pdcurses/window.c +569 -0
  140. data/vendor/PDCurses/sdl1/Makefile.mng +110 -0
  141. data/vendor/PDCurses/sdl1/README.md +31 -0
  142. data/vendor/PDCurses/sdl1/deffont.h +385 -0
  143. data/vendor/PDCurses/sdl1/deficon.h +23 -0
  144. data/vendor/PDCurses/sdl1/pdcclip.c +131 -0
  145. data/vendor/PDCurses/sdl1/pdcdisp.c +373 -0
  146. data/vendor/PDCurses/sdl1/pdcgetsc.c +30 -0
  147. data/vendor/PDCurses/sdl1/pdckbd.c +405 -0
  148. data/vendor/PDCurses/sdl1/pdcscrn.c +414 -0
  149. data/vendor/PDCurses/sdl1/pdcsdl.h +31 -0
  150. data/vendor/PDCurses/sdl1/pdcsetsc.c +64 -0
  151. data/vendor/PDCurses/sdl1/pdcutil.c +40 -0
  152. data/vendor/PDCurses/sdl1/sdltest.c +79 -0
  153. data/vendor/PDCurses/sdl2/CMakeLists.txt +76 -0
  154. data/vendor/PDCurses/sdl2/Makefile.vc +164 -0
  155. data/vendor/PDCurses/sdl2/README.md +34 -0
  156. data/vendor/PDCurses/sdl2/deffont.h +385 -0
  157. data/vendor/PDCurses/sdl2/deficon.h +23 -0
  158. data/vendor/PDCurses/sdl2/pdcclip.c +93 -0
  159. data/vendor/PDCurses/sdl2/pdcdisp.c +534 -0
  160. data/vendor/PDCurses/sdl2/pdcgetsc.c +30 -0
  161. data/vendor/PDCurses/sdl2/pdckbd.c +480 -0
  162. data/vendor/PDCurses/sdl2/pdcscrn.c +443 -0
  163. data/vendor/PDCurses/sdl2/pdcsdl.h +33 -0
  164. data/vendor/PDCurses/sdl2/pdcsetsc.c +67 -0
  165. data/vendor/PDCurses/sdl2/pdcutil.c +39 -0
  166. data/vendor/PDCurses/sdl2/sdltest.c +81 -0
  167. data/vendor/PDCurses/term.h +48 -0
  168. data/vendor/PDCurses/version.mif +7 -0
  169. data/vendor/PDCurses/vt/CMakeLists.txt +28 -0
  170. data/vendor/PDCurses/vt/Makefile.bcc +111 -0
  171. data/vendor/PDCurses/vt/Makefile.dmc +258 -0
  172. data/vendor/PDCurses/vt/Makefile.vc +144 -0
  173. data/vendor/PDCurses/vt/Makefile.wcc +107 -0
  174. data/vendor/PDCurses/vt/README.md +64 -0
  175. data/vendor/PDCurses/vt/pdcclip.c +20 -0
  176. data/vendor/PDCurses/vt/pdcdisp.c +284 -0
  177. data/vendor/PDCurses/vt/pdcgetsc.c +27 -0
  178. data/vendor/PDCurses/vt/pdckbd.c +394 -0
  179. data/vendor/PDCurses/vt/pdcscrn.c +434 -0
  180. data/vendor/PDCurses/vt/pdcsetsc.c +45 -0
  181. data/vendor/PDCurses/vt/pdcutil.c +43 -0
  182. data/vendor/PDCurses/vt/pdcvt.h +16 -0
  183. data/vendor/PDCurses/watcom.mif +68 -0
  184. data/vendor/PDCurses/wincon/CMakeLists.txt +27 -0
  185. data/vendor/PDCurses/wincon/Makefile.bcc +88 -0
  186. data/vendor/PDCurses/wincon/Makefile.dmc +256 -0
  187. data/vendor/PDCurses/wincon/Makefile.lcc +273 -0
  188. data/vendor/PDCurses/wincon/Makefile.mng +176 -0
  189. data/vendor/PDCurses/wincon/Makefile.vc +144 -0
  190. data/vendor/PDCurses/wincon/Makefile.wcc +51 -0
  191. data/vendor/PDCurses/wincon/README.md +85 -0
  192. data/vendor/PDCurses/wincon/pdcclip.c +174 -0
  193. data/vendor/PDCurses/wincon/pdcdisp.c +143 -0
  194. data/vendor/PDCurses/wincon/pdcgetsc.c +55 -0
  195. data/vendor/PDCurses/wincon/pdckbd.c +786 -0
  196. data/vendor/PDCurses/wincon/pdcscrn.c +717 -0
  197. data/vendor/PDCurses/wincon/pdcsetsc.c +91 -0
  198. data/vendor/PDCurses/wincon/pdcurses.ico +0 -0
  199. data/vendor/PDCurses/wincon/pdcurses.rc +28 -0
  200. data/vendor/PDCurses/wincon/pdcutil.c +41 -0
  201. data/vendor/PDCurses/wincon/pdcwin.h +31 -0
  202. data/vendor/PDCurses/wingui/CMakeLists.txt +27 -0
  203. data/vendor/PDCurses/wingui/Makefile.bcc +85 -0
  204. data/vendor/PDCurses/wingui/Makefile.dmc +259 -0
  205. data/vendor/PDCurses/wingui/Makefile.lcc +273 -0
  206. data/vendor/PDCurses/wingui/Makefile.mng +171 -0
  207. data/vendor/PDCurses/wingui/Makefile.vc +144 -0
  208. data/vendor/PDCurses/wingui/Makefile.wcc +51 -0
  209. data/vendor/PDCurses/wingui/README.md +93 -0
  210. data/vendor/PDCurses/wingui/pdcclip.c +174 -0
  211. data/vendor/PDCurses/wingui/pdcdisp.c +718 -0
  212. data/vendor/PDCurses/wingui/pdcgetsc.c +30 -0
  213. data/vendor/PDCurses/wingui/pdckbd.c +143 -0
  214. data/vendor/PDCurses/wingui/pdcscrn.c +2797 -0
  215. data/vendor/PDCurses/wingui/pdcsetsc.c +89 -0
  216. data/vendor/PDCurses/wingui/pdcurses.ico +0 -0
  217. data/vendor/PDCurses/wingui/pdcurses.rc +28 -0
  218. data/vendor/PDCurses/wingui/pdcutil.c +61 -0
  219. data/vendor/PDCurses/wingui/pdcwin.h +122 -0
  220. data/vendor/PDCurses/x11/Makefile.in +754 -0
  221. data/vendor/PDCurses/x11/PDCurses.spec +82 -0
  222. data/vendor/PDCurses/x11/README.md +62 -0
  223. data/vendor/PDCurses/x11/ScrollBox.c +319 -0
  224. data/vendor/PDCurses/x11/ScrollBox.h +51 -0
  225. data/vendor/PDCurses/x11/ScrollBoxP.h +70 -0
  226. data/vendor/PDCurses/x11/aclocal.m4 +994 -0
  227. data/vendor/PDCurses/x11/big_icon.xbm +46 -0
  228. data/vendor/PDCurses/x11/compose.h +201 -0
  229. data/vendor/PDCurses/x11/config.guess +1500 -0
  230. data/vendor/PDCurses/x11/config.h.in +100 -0
  231. data/vendor/PDCurses/x11/config.sub +1616 -0
  232. data/vendor/PDCurses/x11/configure +6700 -0
  233. data/vendor/PDCurses/x11/configure.ac +295 -0
  234. data/vendor/PDCurses/x11/debian/changelog +6 -0
  235. data/vendor/PDCurses/x11/debian/compat +1 -0
  236. data/vendor/PDCurses/x11/debian/control +11 -0
  237. data/vendor/PDCurses/x11/debian/copyright +27 -0
  238. data/vendor/PDCurses/x11/debian/rules +98 -0
  239. data/vendor/PDCurses/x11/install-sh +253 -0
  240. data/vendor/PDCurses/x11/little_icon.xbm +14 -0
  241. data/vendor/PDCurses/x11/ncurses_cfg.h +45 -0
  242. data/vendor/PDCurses/x11/pdcclip.c +173 -0
  243. data/vendor/PDCurses/x11/pdcdisp.c +85 -0
  244. data/vendor/PDCurses/x11/pdcgetsc.c +28 -0
  245. data/vendor/PDCurses/x11/pdckbd.c +104 -0
  246. data/vendor/PDCurses/x11/pdcscrn.c +258 -0
  247. data/vendor/PDCurses/x11/pdcsetsc.c +95 -0
  248. data/vendor/PDCurses/x11/pdcutil.c +52 -0
  249. data/vendor/PDCurses/x11/pdcx11.c +316 -0
  250. data/vendor/PDCurses/x11/pdcx11.h +191 -0
  251. data/vendor/PDCurses/x11/sb.c +155 -0
  252. data/vendor/PDCurses/x11/x11.c +3686 -0
  253. data/vendor/PDCurses/x11/xcurses-config.in +81 -0
  254. metadata +258 -24
  255. data/.travis.yml +0 -16
  256. data/appveyor.yml +0 -16
@@ -0,0 +1,258 @@
1
+ /* Public Domain Curses */
2
+
3
+ #include "pdcx11.h"
4
+
5
+ /* special purpose function keys */
6
+
7
+ static int PDC_shutdown_key[PDC_MAX_FUNCTION_KEYS] = { 0, 0, 0, 0, 0 };
8
+
9
+ /* COLOR_PAIR to attribute encoding table. */
10
+
11
+ short *xc_atrtab = (short *)NULL;
12
+
13
+ /* close the physical screen */
14
+
15
+ void PDC_scr_close(void)
16
+ {
17
+ PDC_LOG(("PDC_scr_close() - called\n"));
18
+ }
19
+
20
+ void PDC_scr_free(void)
21
+ {
22
+ XCursesExit();
23
+
24
+ xc_atrtab = (short *)NULL;
25
+ }
26
+
27
+ /* open the physical screen -- allocate SP, miscellaneous intialization */
28
+
29
+ int PDC_scr_open(int argc, char **argv)
30
+ {
31
+ extern bool sb_started;
32
+
33
+ PDC_LOG(("PDC_scr_open() - called\n"));
34
+
35
+ if ((XCursesInitscr(argc, argv) == ERR) || !SP)
36
+ return ERR;
37
+
38
+ SP->cursrow = SP->curscol = 0;
39
+ SP->orig_attr = FALSE;
40
+ SP->sb_on = sb_started;
41
+ SP->sb_total_y = 0;
42
+ SP->sb_viewport_y = 0;
43
+ SP->sb_cur_y = 0;
44
+ SP->sb_total_x = 0;
45
+ SP->sb_viewport_x = 0;
46
+ SP->sb_cur_x = 0;
47
+
48
+ return OK;
49
+ }
50
+
51
+ /* the core of resize_term() */
52
+
53
+ int PDC_resize_screen(int nlines, int ncols)
54
+ {
55
+ PDC_LOG(("PDC_resize_screen() - called. Lines: %d Cols: %d\n",
56
+ nlines, ncols));
57
+
58
+ if( !stdscr) /* window hasn't been created yet; we're */
59
+ { /* specifying its size before doing so */
60
+ XCursesLINES = nlines;
61
+ XCursesCOLS = ncols;
62
+ return OK;
63
+ }
64
+
65
+ if (nlines || ncols || !SP->resized)
66
+ return ERR;
67
+
68
+ shmdt((char *)Xcurscr);
69
+ XCursesInstructAndWait(CURSES_RESIZE);
70
+
71
+ if ((shmid_Xcurscr = shmget(shmkey_Xcurscr,
72
+ SP->XcurscrSize + XCURSESSHMMIN, 0700)) < 0)
73
+ {
74
+ perror("Cannot allocate shared memory for curscr");
75
+ kill(xc_otherpid, SIGKILL);
76
+ return ERR;
77
+ }
78
+
79
+ XCursesLINES = SP->lines;
80
+ XCursesCOLS = SP->cols;
81
+
82
+ PDC_LOG(("%s:shmid_Xcurscr %d shmkey_Xcurscr %d SP->lines %d "
83
+ "SP->cols %d\n", XCLOGMSG, shmid_Xcurscr,
84
+ shmkey_Xcurscr, SP->lines, SP->cols));
85
+
86
+ Xcurscr = (unsigned char*)shmat(shmid_Xcurscr, 0, 0);
87
+ xc_atrtab = (short *)(Xcurscr + XCURSCR_ATRTAB_OFF);
88
+
89
+ SP->resized = FALSE;
90
+
91
+ return OK;
92
+ }
93
+
94
+ void PDC_reset_prog_mode(void)
95
+ {
96
+ PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
97
+ }
98
+
99
+ void PDC_reset_shell_mode(void)
100
+ {
101
+ PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
102
+ }
103
+
104
+ void PDC_restore_screen_mode(int i)
105
+ {
106
+ }
107
+
108
+ void PDC_save_screen_mode(int i)
109
+ {
110
+ }
111
+
112
+ void PDC_init_pair(short pair, short fg, short bg)
113
+ {
114
+ xc_atrtab[pair * 2] = fg;
115
+ xc_atrtab[pair * 2 + 1] = bg;
116
+ }
117
+
118
+ int PDC_pair_content(short pair, short *fg, short *bg)
119
+ {
120
+ *fg = xc_atrtab[pair * 2];
121
+ *bg = xc_atrtab[pair * 2 + 1];
122
+
123
+ return OK;
124
+ }
125
+
126
+ bool PDC_can_change_color(void)
127
+ {
128
+ return TRUE;
129
+ }
130
+
131
+ int PDC_color_content(short color, short *red, short *green, short *blue)
132
+ {
133
+ XColor *tmp = (XColor *)(Xcurscr + XCURSCR_XCOLOR_OFF);
134
+
135
+ tmp->pixel = color;
136
+
137
+ XCursesInstructAndWait(CURSES_GET_COLOR);
138
+
139
+ *red = ((double)(tmp->red) * 1000 / 65535) + 0.5;
140
+ *green = ((double)(tmp->green) * 1000 / 65535) + 0.5;
141
+ *blue = ((double)(tmp->blue) * 1000 / 65535) + 0.5;
142
+
143
+ return OK;
144
+ }
145
+
146
+ int PDC_init_color(short color, short red, short green, short blue)
147
+ {
148
+ XColor *tmp = (XColor *)(Xcurscr + XCURSCR_XCOLOR_OFF);
149
+
150
+ tmp->pixel = color;
151
+
152
+ tmp->red = ((double)red * 65535 / 1000) + 0.5;
153
+ tmp->green = ((double)green * 65535 / 1000) + 0.5;
154
+ tmp->blue = ((double)blue * 65535 / 1000) + 0.5;
155
+
156
+ XCursesInstructAndWait(CURSES_SET_COLOR);
157
+
158
+ return OK;
159
+ }
160
+
161
+ /*man-start**************************************************************
162
+
163
+ Function keys
164
+ -------------
165
+
166
+ ### Synopsis
167
+
168
+ int PDC_set_function_key( const unsigned function, const int new_key);
169
+
170
+ ### Description
171
+
172
+ Allows one to set a 'shut down' key, and reassign hotkeys used for
173
+ pasting from the clipboard and enlarging and decreasing the font size,
174
+ and for using the font selection dialog (on platforms where these
175
+ things are possible and implemented). For example, calling
176
+
177
+ PDC_set_function_key( FUNCTION_KEY_SHUT_DOWN, ALT_Q);
178
+
179
+ would reset PDCurses such that, if the user clicks on the 'close' box,
180
+ Alt-Q would be added to the key queue. This would give the app the
181
+ opportunity to shut things down gracefully, perhaps asking "are you
182
+ sure", and/or "save changes or discard or cancel", rather than just
183
+ having the window close (the default behavior).
184
+
185
+ Similarly, one can set FUNCTION_KEY_ABORT to a key which, when pressed,
186
+ will cause the program to abort gracelessly (no key returned to the
187
+ application). One would normally use this to enable/disable Ctrl-C or
188
+ Ctrl-Break.
189
+
190
+ ### Return Value
191
+
192
+ Returns key code previously set for that function, or -1 if the
193
+ function does not actually exist.
194
+
195
+ ### Portability
196
+
197
+ PDCurses-only function.
198
+
199
+ **man-end****************************************************************/
200
+
201
+ int PDC_set_function_key( const unsigned function, const int new_key)
202
+ {
203
+ int old_key = -1;
204
+
205
+ if (function < PDC_MAX_FUNCTION_KEYS)
206
+ {
207
+ old_key = PDC_shutdown_key[function];
208
+ PDC_shutdown_key[function] = new_key;
209
+ }
210
+ if (function == FUNCTION_KEY_SHUT_DOWN)
211
+ {
212
+ SP->exit_key = new_key;
213
+ }
214
+ return(old_key);
215
+ }
216
+
217
+
218
+ /*man-start**************************************************************
219
+
220
+ Resize limits
221
+ -------------
222
+
223
+ ### Synopsis
224
+
225
+ void PDC_set_resize_limits( const int new_min_lines,
226
+ const int new_max_lines,
227
+ const int new_min_cols,
228
+ const int new_max_cols);
229
+
230
+ ### Description
231
+
232
+ For platforms supporting resizable windows (SDLx, WinGUI, X11). Some
233
+ programs may be unprepared for a resize event; for these, calling
234
+ this function with the max and min limits equal ensures that no
235
+ user resizing can be done. Other programs may require at least a
236
+ certain number, and/or no more than a certain number, of columns
237
+ and/or lines.
238
+
239
+ ### Portability
240
+
241
+ PDCurses-only function.
242
+
243
+ **man-end****************************************************************/
244
+
245
+ /* Note that at least at present, only WinGUI pays any attention to
246
+ resize limits. */
247
+
248
+ int PDC_min_lines = 25, PDC_min_cols = 80;
249
+ int PDC_max_lines = 25, PDC_max_cols = 80;
250
+
251
+ void PDC_set_resize_limits( const int new_min_lines, const int new_max_lines,
252
+ const int new_min_cols, const int new_max_cols)
253
+ {
254
+ PDC_min_lines = max( new_min_lines, 2);
255
+ PDC_max_lines = max( new_max_lines, PDC_min_lines);
256
+ PDC_min_cols = max( new_min_cols, 2);
257
+ PDC_max_cols = max( new_max_cols, PDC_min_cols);
258
+ }
@@ -0,0 +1,95 @@
1
+ /* Public Domain Curses */
2
+
3
+ #include "pdcx11.h"
4
+
5
+ #include <string.h>
6
+
7
+ /*man-start**************************************************************
8
+
9
+ pdcsetsc
10
+ --------
11
+
12
+ ### Synopsis
13
+
14
+ int PDC_set_blink(bool blinkon);
15
+ void PDC_set_title(const char *title);
16
+
17
+ ### Description
18
+
19
+ PDC_set_blink() toggles whether the A_BLINK attribute sets an
20
+ actual blink mode (TRUE), or sets the background color to high
21
+ intensity (FALSE). The default is platform-dependent (FALSE in
22
+ most cases). It returns OK if it could set the state to match
23
+ the given parameter, ERR otherwise. Current platforms also
24
+ adjust the value of COLORS according to this function -- 16 for
25
+ FALSE, and 8 for TRUE.
26
+
27
+ PDC_set_title() sets the title of the window in which the curses
28
+ program is running. This function may not do anything on some
29
+ platforms. (Currently it only works in Win32 and X11.)
30
+
31
+ ### Portability
32
+ X/Open BSD SYS V
33
+ PDC_set_blink - - -
34
+ PDC_set_title - - -
35
+
36
+ **man-end****************************************************************/
37
+
38
+ int PDC_curs_set(int visibility)
39
+ {
40
+ int ret_vis = SP->visibility;
41
+
42
+ PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
43
+
44
+ if (visibility != -1)
45
+ SP->visibility = visibility;
46
+
47
+ PDC_display_cursor(SP->cursrow, SP->curscol, SP->cursrow,
48
+ SP->curscol, visibility);
49
+
50
+ return ret_vis;
51
+ }
52
+
53
+ void PDC_set_title(const char *title)
54
+ {
55
+ int len;
56
+
57
+ PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
58
+
59
+ len = strlen(title) + 1; /* write nul character */
60
+
61
+ XCursesInstruct(CURSES_TITLE);
62
+
63
+ if (XC_write_display_socket_int(len) >= 0)
64
+ if (XC_write_socket(xc_display_sock, title, len) >= 0)
65
+ return;
66
+
67
+ XCursesExitCursesProcess(1, "exiting from PDC_set_title");
68
+ }
69
+
70
+ /* If PDC_really_blinking is TRUE, then text with the A_BLINK */
71
+ /* attribute will actually blink. Otherwise, such text will */
72
+ /* be shown with higher color intensity (the R, G, and B values */
73
+ /* are averaged with pure white). See pdcdisp.c for details of */
74
+ /* how this is done. */
75
+ /* Unlike on other PDCurses platforms, this doesn't require */
76
+ /* decreasing the number of colors by half. Also, the choice */
77
+ /* indicated by 'blinkon' will actually be respected, so OK is */
78
+ /* always returned (most platforms don't actually support */
79
+ /* blinking). */
80
+ /* The default behavior is to not show A_BLINK text as */
81
+ /* blinking, i.e., PDC_really_blinking = FALSE. Blinking text */
82
+ /* can be pretty annoying to some people. You should probably */
83
+ /* call PDC_set_blink( TRUE) only if there is something to which */
84
+ /* the user _must_ pay attention; say, "the nuclear reactor */
85
+ /* is about to melt down". Otherwise, the bolder, brighter */
86
+ /* text should be attention-getting enough. */
87
+
88
+ int PDC_set_blink(bool blinkon)
89
+ {
90
+ if (pdc_color_started) /* We've got 256 colors in this version */
91
+ COLORS = 256;
92
+
93
+ XCursesInstruct( blinkon ? CURSES_BLINK_ON : CURSES_BLINK_OFF);
94
+ return OK;
95
+ }
@@ -0,0 +1,52 @@
1
+ /* Public Domain Curses */
2
+
3
+ #include "pdcx11.h"
4
+
5
+ #if defined(HAVE_POLL) && !defined(HAVE_USLEEP)
6
+ # include <poll.h>
7
+ #endif
8
+
9
+ void PDC_beep(void)
10
+ {
11
+ PDC_LOG(("PDC_beep() - called\n"));
12
+
13
+ XCursesInstruct(CURSES_BELL);
14
+ }
15
+
16
+ void PDC_napms(int ms)
17
+ {
18
+ PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
19
+
20
+ #if defined(HAVE_USLEEP)
21
+
22
+ usleep(1000 * ms);
23
+
24
+ #elif defined(HAVE_POLL)
25
+ {
26
+ struct pollfd fd;
27
+ fd.fd = -1;
28
+ fd.events = 0;
29
+ poll(&fd, 1, ms);
30
+ }
31
+ #endif
32
+ }
33
+
34
+ const char *PDC_sysname(void)
35
+ {
36
+ return "X11";
37
+ }
38
+
39
+ PDC_version_info PDC_version = { PDC_PORT_WINGUI,
40
+ PDC_VER_MAJOR, PDC_VER_MINOR, PDC_VER_CHANGE,
41
+ sizeof( chtype),
42
+ #ifdef PDC_WIDE
43
+ TRUE,
44
+ #else
45
+ FALSE,
46
+ #endif
47
+ #ifdef PDC_FORCE_UTF8
48
+ TRUE,
49
+ #else
50
+ FALSE,
51
+ #endif
52
+ };
@@ -0,0 +1,316 @@
1
+ /* Public Domain Curses */
2
+
3
+ #include "pdcx11.h"
4
+
5
+ #include <errno.h>
6
+ #include <stdlib.h>
7
+
8
+ /*** Functions that are called by both processes ***/
9
+
10
+ unsigned char *Xcurscr;
11
+
12
+ int XCursesProcess = 1;
13
+ int shmidSP;
14
+ int shmid_Xcurscr;
15
+ int shmkeySP;
16
+ int shmkey_Xcurscr;
17
+ int xc_otherpid;
18
+ int XCursesLINES = 24;
19
+ int XCursesCOLS = 80;
20
+ int xc_display_sock;
21
+ int xc_key_sock;
22
+ int xc_display_sockets[2];
23
+ int xc_key_sockets[2];
24
+ int xc_exit_sock;
25
+
26
+ fd_set xc_readfds;
27
+
28
+ static void _dummy_function(void)
29
+ {
30
+ PDC_napms( 1);
31
+ }
32
+
33
+ void XC_get_line_lock(int row)
34
+ {
35
+ /* loop until we can write to the line -- Patch by:
36
+ Georg Fuchs, georg.fuchs@rz.uni-regensburg.de */
37
+
38
+ while (*(Xcurscr + XCURSCR_FLAG_OFF + row))
39
+ _dummy_function();
40
+
41
+ *(Xcurscr + XCURSCR_FLAG_OFF + row) = 1;
42
+ }
43
+
44
+ void XC_release_line_lock(int row)
45
+ {
46
+ *(Xcurscr + XCURSCR_FLAG_OFF + row) = 0;
47
+ }
48
+
49
+ int XC_write_socket(int sock_num, const void *buf, int len)
50
+ {
51
+ int start = 0, rc;
52
+
53
+ PDC_LOG(("%s:XC_write_socket called: sock_num %d len %d\n",
54
+ XCLOGMSG, sock_num, len));
55
+
56
+ #ifdef MOUSE_DEBUG
57
+ if (sock_num == xc_key_sock)
58
+ printf("%s:XC_write_socket(key) len: %d\n", XCLOGMSG, len);
59
+ #endif
60
+ while (1)
61
+ {
62
+ rc = write(sock_num, (const char *)buf + start, len);
63
+
64
+ if (rc < 0 || rc == len)
65
+ return rc;
66
+
67
+ len -= rc;
68
+ start = rc;
69
+ }
70
+ }
71
+
72
+ int XC_read_socket(int sock_num, void *buf, int len)
73
+ {
74
+ int start = 0, length = len, rc;
75
+
76
+ PDC_LOG(("%s:XC_read_socket called: sock_num %d len %d\n",
77
+ XCLOGMSG, sock_num, len));
78
+
79
+ while (1)
80
+ {
81
+ rc = read(sock_num, (char *)buf + start, length);
82
+
83
+ #ifdef MOUSE_DEBUG
84
+ if (sock_num == xc_key_sock)
85
+ printf("%s:XC_read_socket(key) rc %d errno %d "
86
+ "resized: %d\n", XCLOGMSG, rc, errno, SP->resized);
87
+ #endif
88
+ if (rc < 0 && sock_num == xc_key_sock && errno == EINTR
89
+ && SP->resized != FALSE)
90
+ {
91
+ MOUSE_LOG(("%s:continuing\n", XCLOGMSG));
92
+
93
+ rc = 0;
94
+
95
+ if (SP->resized > 1)
96
+ SP->resized = TRUE;
97
+ else
98
+ SP->resized = FALSE;
99
+
100
+ memcpy(buf, &rc, sizeof(int));
101
+
102
+ return 0;
103
+ }
104
+
105
+ if (rc <= 0 || rc == length)
106
+ return rc;
107
+
108
+ length -= rc;
109
+ start = rc;
110
+ }
111
+ }
112
+
113
+ int XC_write_display_socket_int(int x)
114
+ {
115
+ return XC_write_socket(xc_display_sock, &x, sizeof(int));
116
+ }
117
+
118
+ #ifdef PDCDEBUG
119
+ void XC_say(const char *msg)
120
+ {
121
+ PDC_LOG(("%s:%s", XCLOGMSG, msg));
122
+ }
123
+ #endif
124
+
125
+ /*** Functions that are called by the "curses" process ***/
126
+
127
+ int XCursesInstruct(int flag)
128
+ {
129
+ PDC_LOG(("%s:XCursesInstruct() - called flag %d\n", XCLOGMSG, flag));
130
+
131
+ /* Send a request to X */
132
+
133
+ if (XC_write_display_socket_int(flag) < 0)
134
+ XCursesExitCursesProcess(4, "exiting from XCursesInstruct");
135
+
136
+ return OK;
137
+ }
138
+
139
+ int XCursesInstructAndWait(int flag)
140
+ {
141
+ int result;
142
+
143
+ XC_LOG(("XCursesInstructAndWait() - called\n"));
144
+
145
+ /* tell X we want to do something */
146
+
147
+ XCursesInstruct(flag);
148
+
149
+ /* wait for X to say the refresh has occurred*/
150
+
151
+ if (XC_read_socket(xc_display_sock, &result, sizeof(int)) < 0)
152
+ XCursesExitCursesProcess(5, "exiting from XCursesInstructAndWait");
153
+
154
+ if (result != CURSES_CONTINUE)
155
+ XCursesExitCursesProcess(6, "exiting from XCursesInstructAndWait"
156
+ " - synchronization error");
157
+
158
+ return OK;
159
+ }
160
+
161
+ static int _setup_curses(void)
162
+ {
163
+ int wait_value;
164
+
165
+ XC_LOG(("_setup_curses called\n"));
166
+
167
+ close(xc_display_sockets[1]);
168
+ close(xc_key_sockets[1]);
169
+
170
+ xc_display_sock = xc_display_sockets[0];
171
+ xc_key_sock = xc_key_sockets[0];
172
+
173
+ FD_ZERO(&xc_readfds);
174
+
175
+ XC_read_socket(xc_display_sock, &wait_value, sizeof(int));
176
+
177
+ if (wait_value != CURSES_CHILD)
178
+ return ERR;
179
+
180
+ /* Set LINES and COLS now so that the size of the shared memory
181
+ segment can be allocated */
182
+
183
+ if ((shmidSP = shmget(shmkeySP, sizeof(SCREEN) + XCURSESSHMMIN, 0700)) < 0)
184
+ {
185
+ perror("Cannot allocate shared memory for SCREEN");
186
+ kill(xc_otherpid, SIGKILL);
187
+ return ERR;
188
+ }
189
+
190
+ SP = (SCREEN*)shmat(shmidSP, 0, 0);
191
+
192
+ XCursesLINES = SP->lines;
193
+ LINES = XCursesLINES - SP->linesrippedoff - SP->slklines;
194
+ XCursesCOLS = COLS = SP->cols;
195
+
196
+ if ((shmid_Xcurscr = shmget(shmkey_Xcurscr,
197
+ SP->XcurscrSize + XCURSESSHMMIN, 0700)) < 0)
198
+ {
199
+ perror("Cannot allocate shared memory for curscr");
200
+ kill(xc_otherpid, SIGKILL);
201
+ return ERR;
202
+ }
203
+
204
+ PDC_LOG(("%s:shmid_Xcurscr %d shmkey_Xcurscr %d LINES %d COLS %d\n",
205
+ XCLOGMSG, shmid_Xcurscr, shmkey_Xcurscr, LINES, COLS));
206
+
207
+ Xcurscr = (unsigned char *)shmat(shmid_Xcurscr, 0, 0);
208
+ xc_atrtab = (short *)(Xcurscr + XCURSCR_ATRTAB_OFF);
209
+
210
+ XC_LOG(("cursesprocess exiting from Xinitscr\n"));
211
+
212
+ /* Always trap SIGWINCH if the C library supports SIGWINCH */
213
+
214
+ XCursesSetSignal(SIGWINCH, XCursesSigwinchHandler);
215
+
216
+ atexit(XCursesExit);
217
+
218
+ return OK;
219
+ }
220
+
221
+ int XCursesInitscr(int argc, char *argv[])
222
+ {
223
+ int pid, rc;
224
+
225
+ XC_LOG(("XCursesInitscr() - called\n"));
226
+
227
+ shmkeySP = getpid();
228
+
229
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, xc_display_sockets) < 0)
230
+ {
231
+ fprintf(stderr, "ERROR: cannot create display socketpair\n");
232
+ return ERR;
233
+ }
234
+
235
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, xc_key_sockets) < 0)
236
+ {
237
+ fprintf(stderr, "ERROR: cannot create key socketpair\n");
238
+ return ERR;
239
+ }
240
+
241
+ pid = fork();
242
+
243
+ switch(pid)
244
+ {
245
+ case -1:
246
+ fprintf(stderr, "ERROR: cannot fork()\n");
247
+ return ERR;
248
+ break;
249
+
250
+ case 0: /* child */
251
+ shmkey_Xcurscr = getpid();
252
+ #ifdef XISPARENT
253
+ XCursesProcess = 0;
254
+ rc = _setup_curses();
255
+ #else
256
+ XCursesProcess = 1;
257
+ xc_otherpid = getppid();
258
+ rc = XCursesSetupX(argc, argv);
259
+ #endif
260
+ break;
261
+
262
+ default: /* parent */
263
+ shmkey_Xcurscr = pid;
264
+ #ifdef XISPARENT
265
+ XCursesProcess = 1;
266
+ xc_otherpid = pid;
267
+ rc = XCursesSetupX(argc, argv);
268
+ #else
269
+ XCursesProcess = 0;
270
+ rc = _setup_curses();
271
+ #endif
272
+ }
273
+
274
+ return rc;
275
+ }
276
+
277
+ static void _cleanup_curses_process(int rc)
278
+ {
279
+ PDC_LOG(("%s:_cleanup_curses_process() - called: %d\n", XCLOGMSG, rc));
280
+
281
+ shutdown(xc_display_sock, 2);
282
+ close(xc_display_sock);
283
+
284
+ shutdown(xc_key_sock, 2);
285
+ close(xc_key_sock);
286
+
287
+ shmdt((char *)SP);
288
+ shmdt((char *)Xcurscr);
289
+
290
+ if (rc)
291
+ _exit(rc);
292
+ }
293
+
294
+ void XCursesExitCursesProcess(int rc, char *msg)
295
+ {
296
+ PDC_LOG(("%s:XCursesExitCursesProcess() - called: %d %s\n",
297
+ XCLOGMSG, rc, msg));
298
+
299
+ endwin();
300
+ _cleanup_curses_process(rc);
301
+ }
302
+
303
+ void XCursesExit(void)
304
+ {
305
+ static bool called = FALSE;
306
+
307
+ XC_LOG(("XCursesExit() - called\n"));
308
+
309
+ if (FALSE == called)
310
+ {
311
+ XCursesInstruct(CURSES_EXIT);
312
+ _cleanup_curses_process(0);
313
+
314
+ called = TRUE;
315
+ }
316
+ }