curses 1.2.6 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
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,112 @@
1
+ /* Public Domain Curses */
2
+
3
+ #include "pdcos2.h"
4
+
5
+ /*man-start**************************************************************
6
+
7
+ pdcsetsc
8
+ --------
9
+
10
+ ### Synopsis
11
+
12
+ int PDC_set_blink(bool blinkon);
13
+ void PDC_set_title(const char *title);
14
+
15
+ ### Description
16
+
17
+ PDC_set_blink() toggles whether the A_BLINK attribute sets an
18
+ actual blink mode (TRUE), or sets the background color to high
19
+ intensity (FALSE). The default is platform-dependent (FALSE in
20
+ most cases). It returns OK if it could set the state to match
21
+ the given parameter, ERR otherwise. Current platforms also
22
+ adjust the value of COLORS according to this function -- 16 for
23
+ FALSE, and 8 for TRUE.
24
+
25
+ PDC_set_title() sets the title of the window in which the curses
26
+ program is running. This function may not do anything on some
27
+ platforms. (Currently it only works in Win32 and X11.)
28
+
29
+ ### Portability
30
+ X/Open BSD SYS V
31
+ PDC_set_blink - - -
32
+ PDC_set_title - - -
33
+
34
+ **man-end****************************************************************/
35
+
36
+ int PDC_curs_set(int visibility)
37
+ {
38
+ #ifndef EMXVIDEO
39
+ VIOCURSORINFO pvioCursorInfo;
40
+ #endif
41
+ int ret_vis, hidden = 0, start = 0, end = 0;
42
+
43
+ PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
44
+
45
+ ret_vis = SP->visibility;
46
+ SP->visibility = visibility;
47
+
48
+ switch(visibility)
49
+ {
50
+ case 0: /* invisible */
51
+ #ifdef EMXVIDEO
52
+ start = end = 0;
53
+ #else
54
+ start = pdc_font / 4;
55
+ end = pdc_font;
56
+ hidden = -1;
57
+ #endif
58
+ break;
59
+
60
+ case 2: /* highly visible */
61
+ start = 2; /* almost full-height block */
62
+ end = pdc_font - 1;
63
+ break;
64
+
65
+ default: /* normal visibility */
66
+ start = (SP->orig_cursor >> 8) & 0xff;
67
+ end = SP->orig_cursor & 0xff;
68
+ }
69
+
70
+ #ifdef EMXVIDEO
71
+ if (!visibility)
72
+ v_hidecursor();
73
+ else
74
+ v_ctype(start, end);
75
+ #else
76
+ pvioCursorInfo.yStart = (USHORT)start;
77
+ pvioCursorInfo.cEnd = (USHORT)end;
78
+ pvioCursorInfo.cx = (USHORT)1;
79
+ pvioCursorInfo.attr = hidden;
80
+ VioSetCurType((PVIOCURSORINFO)&pvioCursorInfo, 0);
81
+ #endif
82
+ return ret_vis;
83
+ }
84
+
85
+ void PDC_set_title(const char *title)
86
+ {
87
+ PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
88
+ }
89
+
90
+ int PDC_set_blink(bool blinkon)
91
+ {
92
+ #ifndef EMXVIDEO
93
+ USHORT statebuf[3], result;
94
+
95
+ statebuf[0] = 6; /* length */
96
+ statebuf[1] = 2; /* blink/intensity */
97
+ statebuf[2] = !blinkon;
98
+
99
+ result = VioSetState(&statebuf, 0);
100
+ VioGetState(&statebuf, 0); /* needed? */
101
+
102
+ if (pdc_color_started)
103
+ COLORS = statebuf[2] ? 16 : 8;
104
+
105
+ return (result == 0) ? OK : ERR;
106
+ #else
107
+ if (pdc_color_started)
108
+ COLORS = 16;
109
+
110
+ return blinkon ? ERR : OK;
111
+ #endif
112
+ }
@@ -0,0 +1,52 @@
1
+ /* Public Domain Curses */
2
+
3
+ #include "pdcos2.h"
4
+
5
+ #if defined(OS2) && !defined(__EMX__)
6
+ APIRET APIENTRY DosSleep(ULONG ulTime);
7
+ #endif
8
+
9
+ void PDC_beep(void)
10
+ {
11
+ PDC_LOG(("PDC_beep() - called\n"));
12
+
13
+ #ifdef EMXVIDEO
14
+ putchar('\007');
15
+ #else
16
+ DosBeep(1380, 100);
17
+ #endif
18
+ }
19
+
20
+ void PDC_napms(int ms)
21
+ {
22
+ PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
23
+
24
+ #ifdef __EMX__
25
+ _sleep2(ms);
26
+ #else
27
+ DosSleep(ms);
28
+ #endif
29
+ }
30
+
31
+ const char *PDC_sysname(void)
32
+ {
33
+ return "OS/2";
34
+ }
35
+
36
+ PDCEX PDC_version_info PDC_version = { PDC_PORT_OS2,
37
+ PDC_VER_MAJOR, PDC_VER_MINOR, PDC_VER_CHANGE,
38
+ sizeof( chtype),
39
+ /* note that thus far, 'wide' and 'UTF8' versions exist */
40
+ /* only for SDL2, X11, Win32, and Win32a; elsewhere, */
41
+ /* these will be FALSE */
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,56 @@
1
+ /* Public Domain Curses */
2
+
3
+ /*----------------------------------------------------------------------*
4
+ * Panels for PDCurses *
5
+ *----------------------------------------------------------------------*/
6
+
7
+ #ifndef __PDCURSES_PANEL_H__
8
+ #define __PDCURSES_PANEL_H__ 1
9
+
10
+ #include <curses.h>
11
+
12
+ #if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
13
+ extern "C"
14
+ {
15
+ #endif
16
+
17
+ typedef struct panelobs
18
+ {
19
+ struct panelobs *above;
20
+ struct panel *pan;
21
+ } PANELOBS;
22
+
23
+ typedef struct panel
24
+ {
25
+ WINDOW *win;
26
+ int wstarty;
27
+ int wendy;
28
+ int wstartx;
29
+ int wendx;
30
+ struct panel *below;
31
+ struct panel *above;
32
+ const void *user;
33
+ struct panelobs *obscure;
34
+ } PANEL;
35
+
36
+ PDCEX int bottom_panel(PANEL *pan);
37
+ PDCEX int del_panel(PANEL *pan);
38
+ PDCEX int hide_panel(PANEL *pan);
39
+ PDCEX int move_panel(PANEL *pan, int starty, int startx);
40
+ PDCEX PANEL *new_panel(WINDOW *win);
41
+ PDCEX PANEL *panel_above(const PANEL *pan);
42
+ PDCEX PANEL *panel_below(const PANEL *pan);
43
+ PDCEX int panel_hidden(const PANEL *pan);
44
+ PDCEX const void *panel_userptr(const PANEL *pan);
45
+ PDCEX WINDOW *panel_window(const PANEL *pan);
46
+ PDCEX int replace_panel(PANEL *pan, WINDOW *win);
47
+ PDCEX int set_panel_userptr(PANEL *pan, const void *uptr);
48
+ PDCEX int show_panel(PANEL *pan);
49
+ PDCEX int top_panel(PANEL *pan);
50
+ PDCEX void update_panels(void);
51
+
52
+ #if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
53
+ }
54
+ #endif
55
+
56
+ #endif /* __PDCURSES_PANEL_H__ */
@@ -0,0 +1,25 @@
1
+ PDCurses Portable Core
2
+ ======================
3
+
4
+ This directory contains core PDCurses source code files common to all
5
+ platforms.
6
+
7
+
8
+ Building
9
+ --------
10
+
11
+ These modules are built by the platform-specific makefiles, in the
12
+ platform directories.
13
+
14
+
15
+ Distribution Status
16
+ -------------------
17
+
18
+ The files in this directory are released to the Public Domain.
19
+
20
+
21
+ Acknowledgements
22
+ ----------------
23
+
24
+ The panel library was originally provided by
25
+ Warren Tucker <wht@n4hgf.mt-park.ga.us>
@@ -0,0 +1,693 @@
1
+ /* Public Domain Curses */
2
+
3
+ #include <curspriv.h>
4
+
5
+ /*man-start**************************************************************
6
+
7
+ Name: addch
8
+
9
+ Synopsis:
10
+ int addch(const chtype ch);
11
+ int waddch(WINDOW *win, const chtype ch);
12
+ int mvaddch(int y, int x, const chtype ch);
13
+ int mvwaddch(WINDOW *win, int y, int x, const chtype ch);
14
+ int echochar(const chtype ch);
15
+ int wechochar(WINDOW *win, const chtype ch);
16
+
17
+ int addrawch(chtype ch);
18
+ int waddrawch(WINDOW *win, chtype ch);
19
+ int mvaddrawch(int y, int x, chtype ch);
20
+ int mvwaddrawch(WINDOW *win, int y, int x, chtype ch);
21
+
22
+ int add_wch(const cchar_t *wch);
23
+ int wadd_wch(WINDOW *win, const cchar_t *wch);
24
+ int mvadd_wch(int y, int x, const cchar_t *wch);
25
+ int mvwadd_wch(WINDOW *win, int y, int x, const cchar_t *wch);
26
+ int echo_wchar(const cchar_t *wch);
27
+ int wecho_wchar(WINDOW *win, const cchar_t *wch);
28
+
29
+ Description:
30
+ addch() adds the chtype ch to the default window (stdscr) at the
31
+ current cursor position, and advances the cursor. Note that
32
+ chtypes can convey both text (a single character) and
33
+ attributes, including a color pair. add_wch() is the wide-
34
+ character version of this function, taking a pointer to a
35
+ cchar_t instead of a chtype.
36
+
37
+ waddch() is like addch(), but also lets you specify the window.
38
+ (This is in fact the core output routine.) wadd_wch() is the
39
+ wide version.
40
+
41
+ mvaddch() moves the cursor to the specified (y, x) position, and
42
+ adds ch to stdscr. mvadd_wch() is the wide version.
43
+
44
+ mvwaddch() moves the cursor to the specified position and adds
45
+ ch to the specified window. mvwadd_wch() is the wide version.
46
+
47
+ echochar() adds ch to stdscr at the current cursor position and
48
+ calls refresh(). echo_wchar() is the wide version.
49
+
50
+ wechochar() adds ch to the specified window and calls
51
+ wrefresh(). wecho_wchar() is the wide version.
52
+
53
+ addrawch(), waddrawch(), mvaddrawch() and mvwaddrawch() are
54
+ PDCurses-specific wrappers for addch() etc. that disable the
55
+ translation of control characters.
56
+
57
+ The following applies to all these functions:
58
+
59
+ If the cursor moves on to the right margin, an automatic newline
60
+ is performed. If scrollok is enabled, and a character is added
61
+ to the bottom right corner of the window, the scrolling region
62
+ will be scrolled up one line. If scrolling is not allowed, ERR
63
+ will be returned.
64
+
65
+ If ch is a tab, newline, or backspace, the cursor will be moved
66
+ appropriately within the window. If ch is a newline, the
67
+ clrtoeol routine is called before the cursor is moved to the
68
+ beginning of the next line. If newline mapping is off, the
69
+ cursor will be moved to the next line, but the x coordinate will
70
+ be unchanged. If ch is a tab the cursor is moved to the next
71
+ tab position within the window. If ch is another control
72
+ character, it will be drawn in the ^X notation. Calling the
73
+ inch() routine after adding a control character returns the
74
+ representation of the control character, not the control
75
+ character.
76
+
77
+ Video attributes can be combined with a character by ORing them
78
+ into the parameter. Text, including attributes, can be copied
79
+ from one place to another by using inch() and addch().
80
+
81
+ Note that in PDCurses, for now, a cchar_t and a chtype are the
82
+ same. The text field is 16 bits wide, and is treated as Unicode
83
+ (UCS-2) when PDCurses is built with wide-character support
84
+ (define PDC_WIDE). So, in functions that take a chtype, like
85
+ addch(), both the wide and narrow versions will handle Unicode.
86
+ But for portability, you should use the wide functions.
87
+
88
+ Return Value:
89
+ All functions return OK on success and ERR on error.
90
+
91
+ Portability X/Open BSD SYS V
92
+ addch Y Y Y
93
+ waddch Y Y Y
94
+ mvaddch Y Y Y
95
+ mvwaddch Y Y Y
96
+ echochar Y - 3.0
97
+ wechochar Y - 3.0
98
+ addrawch - - -
99
+ waddrawch - - -
100
+ mvaddrawch - - -
101
+ mvwaddrawch - - -
102
+ add_wch Y
103
+ wadd_wch Y
104
+ mvadd_wch Y
105
+ mvwadd_wch Y
106
+ echo_wchar Y
107
+ wecho_wchar Y
108
+
109
+ **man-end****************************************************************/
110
+
111
+ /* As will be described below, the method used here for combining
112
+ characters requires going beyond the usual 17*2^16 limit for Unicode.
113
+ That can only happen with 64-bit chtype / cchar_t, and it's only
114
+ worth doing if we're going past 8-byte characters in the first place.
115
+ So if PDC_WIDE is defined _and_ we're using 64-bit chtypes, we're
116
+ using the combining character scheme : */
117
+
118
+ #if defined( PDC_WIDE) && defined( CHTYPE_LONG) && CHTYPE_LONG >= 2
119
+ #define USING_COMBINING_CHARACTER_SCHEME
120
+ #endif
121
+
122
+ #ifdef USING_COMBINING_CHARACTER_SCHEME
123
+ #include <stdlib.h>
124
+ #include <assert.h>
125
+ /*
126
+ * A greatly stripped-down version of Markus Kuhn's excellent
127
+ * wcwidth implementation. For his latest version and many
128
+ * comments, see http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
129
+ * For PDCurses, only mk_wcwidth is used, modified to take an
130
+ * int argument instead of wchar_t, because in MS-land, wchar_t
131
+ * is 16 bits; getting the full Unicode range requires 21 bits.
132
+ * Also modified format/indenting to conform to PDCurses norms.
133
+ * NOTE that this version is current only to Unicode 5.0! Some
134
+ * updates are almost certainly needed...
135
+ */
136
+
137
+ struct interval
138
+ {
139
+ int first, last;
140
+ };
141
+
142
+ /* auxiliary function for binary search in interval table */
143
+
144
+ static int bisearch( const int ucs, const struct interval *table, int max)
145
+ {
146
+ int min = 0;
147
+ int mid;
148
+
149
+ if (ucs < table[0].first || ucs > table[max].last)
150
+ return 0;
151
+ while (max >= min)
152
+ {
153
+ mid = (min + max) / 2;
154
+ if (ucs > table[mid].last)
155
+ min = mid + 1;
156
+ else if (ucs < table[mid].first)
157
+ max = mid - 1;
158
+ else
159
+ return 1;
160
+ }
161
+ return 0;
162
+ }
163
+
164
+ /* The following two functions define the column width of an ISO 10646
165
+ * character as follows:
166
+ *
167
+ * - The null character (U+0000) has a column width of 0.
168
+ *
169
+ * - Other C0/C1 control characters and DEL will lead to a return
170
+ * value of -1.
171
+ *
172
+ * - Non-spacing and enclosing combining characters (general
173
+ * category code Mn or Me in the Unicode database) have a
174
+ * column width of 0.
175
+ *
176
+ * - SOFT HYPHEN (U+00AD) has a column width of 1.
177
+ *
178
+ * - Other format characters (general category code Cf in the Unicode
179
+ * database) and ZERO WIDTH SPACE (U+200B) have a column width of 0.
180
+ *
181
+ * - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF)
182
+ * have a column width of 0.
183
+ *
184
+ * - Spacing characters in the East Asian Wide (W) or East Asian
185
+ * Full-width (F) category as defined in Unicode Technical
186
+ * Report #11 have a column width of 2.
187
+ *
188
+ * - All remaining characters (including all printable
189
+ * ISO 8859-1 and WGL4 characters, Unicode control characters,
190
+ * etc.) have a column width of 1.
191
+ *
192
+ * This implementation assumes that wchar_t characters are encoded
193
+ * in ISO 10646.
194
+ */
195
+
196
+ static int mk_wcwidth( const int ucs)
197
+ {
198
+ /* sorted list of non-overlapping intervals of non-spacing characters */
199
+ /* generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c" */
200
+ static const struct interval combining[] =
201
+ {
202
+ { 0x0300, 0x036F }, { 0x0483, 0x0486 }, { 0x0488, 0x0489 },
203
+ { 0x0591, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 },
204
+ { 0x05C4, 0x05C5 }, { 0x05C7, 0x05C7 }, { 0x0600, 0x0603 },
205
+ { 0x0610, 0x0615 }, { 0x064B, 0x065E }, { 0x0670, 0x0670 },
206
+ { 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED },
207
+ { 0x070F, 0x070F }, { 0x0711, 0x0711 }, { 0x0730, 0x074A },
208
+ { 0x07A6, 0x07B0 }, { 0x07EB, 0x07F3 }, { 0x0901, 0x0902 },
209
+ { 0x093C, 0x093C }, { 0x0941, 0x0948 }, { 0x094D, 0x094D },
210
+ { 0x0951, 0x0954 }, { 0x0962, 0x0963 }, { 0x0981, 0x0981 },
211
+ { 0x09BC, 0x09BC }, { 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD },
212
+ { 0x09E2, 0x09E3 }, { 0x0A01, 0x0A02 }, { 0x0A3C, 0x0A3C },
213
+ { 0x0A41, 0x0A42 }, { 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D },
214
+ { 0x0A70, 0x0A71 }, { 0x0A81, 0x0A82 }, { 0x0ABC, 0x0ABC },
215
+ { 0x0AC1, 0x0AC5 }, { 0x0AC7, 0x0AC8 }, { 0x0ACD, 0x0ACD },
216
+ { 0x0AE2, 0x0AE3 }, { 0x0B01, 0x0B01 }, { 0x0B3C, 0x0B3C },
217
+ { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 }, { 0x0B4D, 0x0B4D },
218
+ { 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 }, { 0x0BC0, 0x0BC0 },
219
+ { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 }, { 0x0C46, 0x0C48 },
220
+ { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 }, { 0x0CBC, 0x0CBC },
221
+ { 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD },
222
+ { 0x0CE2, 0x0CE3 }, { 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D },
223
+ { 0x0DCA, 0x0DCA }, { 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 },
224
+ { 0x0E31, 0x0E31 }, { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E },
225
+ { 0x0EB1, 0x0EB1 }, { 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC },
226
+ { 0x0EC8, 0x0ECD }, { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 },
227
+ { 0x0F37, 0x0F37 }, { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E },
228
+ { 0x0F80, 0x0F84 }, { 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 },
229
+ { 0x0F99, 0x0FBC }, { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 },
230
+ { 0x1032, 0x1032 }, { 0x1036, 0x1037 }, { 0x1039, 0x1039 },
231
+ { 0x1058, 0x1059 }, { 0x1160, 0x11FF }, { 0x135F, 0x135F },
232
+ { 0x1712, 0x1714 }, { 0x1732, 0x1734 }, { 0x1752, 0x1753 },
233
+ { 0x1772, 0x1773 }, { 0x17B4, 0x17B5 }, { 0x17B7, 0x17BD },
234
+ { 0x17C6, 0x17C6 }, { 0x17C9, 0x17D3 }, { 0x17DD, 0x17DD },
235
+ { 0x180B, 0x180D }, { 0x18A9, 0x18A9 }, { 0x1920, 0x1922 },
236
+ { 0x1927, 0x1928 }, { 0x1932, 0x1932 }, { 0x1939, 0x193B },
237
+ { 0x1A17, 0x1A18 }, { 0x1B00, 0x1B03 }, { 0x1B34, 0x1B34 },
238
+ { 0x1B36, 0x1B3A }, { 0x1B3C, 0x1B3C }, { 0x1B42, 0x1B42 },
239
+ { 0x1B6B, 0x1B73 }, { 0x1DC0, 0x1DCA }, { 0x1DFE, 0x1DFF },
240
+ { 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x2060, 0x2063 },
241
+ { 0x206A, 0x206F }, { 0x20D0, 0x20EF }, { 0x302A, 0x302F },
242
+ { 0x3099, 0x309A }, { 0xA806, 0xA806 }, { 0xA80B, 0xA80B },
243
+ { 0xA825, 0xA826 }, { 0xFB1E, 0xFB1E }, { 0xFE00, 0xFE0F },
244
+ { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF }, { 0xFFF9, 0xFFFB },
245
+ { 0x10A01, 0x10A03 }, { 0x10A05, 0x10A06 }, { 0x10A0C, 0x10A0F },
246
+ { 0x10A38, 0x10A3A }, { 0x10A3F, 0x10A3F }, { 0x1D167, 0x1D169 },
247
+ { 0x1D173, 0x1D182 }, { 0x1D185, 0x1D18B }, { 0x1D1AA, 0x1D1AD },
248
+ { 0x1D242, 0x1D244 }, { 0xE0001, 0xE0001 }, { 0xE0020, 0xE007F },
249
+ { 0xE0100, 0xE01EF }
250
+ };
251
+
252
+ /* test for 8-bit control characters */
253
+ if (ucs == 0)
254
+ return 0;
255
+ if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0))
256
+ return -1;
257
+
258
+ if( ucs < combining[0].first) /* everything else up to 0x300 is a */
259
+ return( 1); /* plain old single-width character */
260
+ /* binary search in table of non-spacing characters */
261
+ if (bisearch(ucs, combining,
262
+ sizeof(combining) / sizeof(struct interval) - 1))
263
+ return 0;
264
+
265
+ /* if we arrive here, ucs is not a combining or C0/C1 control character */
266
+
267
+ return 1 +
268
+ (ucs >= 0x1100 &&
269
+ (ucs <= 0x115f || /* Hangul Jamo init. consonants */
270
+ ucs == 0x2329 || ucs == 0x232a ||
271
+ (ucs >= 0x2e80 && ucs <= 0xa4cf &&
272
+ ucs != 0x303f) || /* CJK ... Yi */
273
+ (ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */
274
+ (ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility Ideographs */
275
+ (ucs >= 0xfe10 && ucs <= 0xfe19) || /* Vertical forms */
276
+ (ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */
277
+ (ucs >= 0xff00 && ucs <= 0xff60) || /* Fullwidth Forms */
278
+ (ucs >= 0xffe0 && ucs <= 0xffe6) ||
279
+ (ucs >= 0x20000 && ucs <= 0x2fffd) ||
280
+ (ucs >= 0x30000 && ucs <= 0x3fffd)));
281
+ }
282
+
283
+ /* The handling of "fullwidth" characters (those consuming two "normal"
284
+ columns) and combining characters (characters that can add accents to a
285
+ preceding character) in PDCurses is, of necessity, complex.
286
+
287
+ Unicode is defined to have 17 planes of 2^16 characters each, so that
288
+ the maximum Unicode code point is U+10FFFF. When addch() is given a
289
+ fullwidth character, it handles that character "normally", and then
290
+ stores the non-Unicode character DUMMY_CHAR_NEXT_TO_FULLWIDTH
291
+ (U+110000) next to it, just as a placeholder. (That part is actually
292
+ rather simple.)
293
+
294
+ PDCurses handles combining characters by creating entirely new "Unicode"
295
+ (let's call them "post-Unicode") characters, at code point U+110001
296
+ (COMBINED_CHAR_START) and beyond. The 'combos' table keeps track of
297
+ these newly-created characters, essentially saying: "This post-Unicode
298
+ character consists of the following 'root' character, plus an
299
+ added combining character." The 'root' character in question may itself
300
+ be a post-Unicode character; this allows us to add more than one
301
+ combining character.
302
+
303
+ For example, if one calls wchar() with, in succession, 'r' (U+72),
304
+ a circumflex (U+0302), and an acute accent below (U+317), the call
305
+ with the circumflex would cause 'combo' to be allocated, with
306
+ combo[0].root = 'r' and combo[0].added = 0x302. Code point U+110001
307
+ would correspond to this character ('r' plus circumflex). The call
308
+ with the acute accent below would create code point U+110002,
309
+ combo[1].root = 0x110001 and combo[1].added = 0x317. Thus, a character
310
+ with multiple combining characters simply resolves itself as a series
311
+ of "post-Unicode" characters. When the display function in pdcdisp.c
312
+ is asked to show character 0x110001 or 0x110002, it can use
313
+ PDC_expand_combined_characters() to convert that code point to the
314
+ actual series of characters.
315
+
316
+ 'ncurses' handles combined characters in a very different manner: a
317
+ 'cchar' is defined as an array of five characters, so that you can
318
+ add up to four combining characters in any given cell. I had to reject
319
+ that solution because backward compatibility within PDCurses would be
320
+ broken. Quite aside from that, this is a simpler solution, and allows
321
+ for any number of combining characters (though four ought to be enough
322
+ for anybody). */
323
+
324
+ #define MAX_UNICODE 0x10ffff
325
+ #define DUMMY_CHAR_NEXT_TO_FULLWIDTH (MAX_UNICODE + 1)
326
+ #define COMBINED_CHAR_START (MAX_UNICODE + 2)
327
+
328
+ /* "non-standard" 64-bit chtypes */
329
+ static int n_combos = 0, n_combos_allocated = 0;
330
+ static struct combined_char
331
+ {
332
+ int32_t root, added;
333
+ } *combos = NULL;
334
+
335
+ static int find_combined_char_idx( const cchar_t root, const cchar_t added)
336
+ {
337
+ int i;
338
+
339
+ for( i = 0; i < n_combos; i++)
340
+ if( (int32_t)root == combos[i].root && (int32_t)added == combos[i].added)
341
+ return( i);
342
+ /* Didn't find this pair among existing combos; */
343
+ /* create a new one */
344
+ if( i == n_combos_allocated)
345
+ {
346
+ n_combos_allocated += 30 + n_combos_allocated / 2;
347
+ combos = realloc( combos, n_combos_allocated * sizeof( struct combined_char));
348
+ }
349
+ combos[i].root = (int32_t)root;
350
+ combos[i].added = (int32_t)added;
351
+ n_combos++;
352
+ return( i);
353
+ }
354
+
355
+ int PDC_expand_combined_characters( const cchar_t c, cchar_t *added)
356
+ {
357
+ if( !c) /* flag to free up memory */
358
+ {
359
+ n_combos = n_combos_allocated = 0;
360
+ if( combos)
361
+ free( combos);
362
+ combos = NULL;
363
+ return( 0);
364
+ }
365
+ assert( c >= COMBINED_CHAR_START && c < COMBINED_CHAR_START + n_combos);
366
+ *added = combos[c - COMBINED_CHAR_START].added;
367
+ return( combos[c - COMBINED_CHAR_START].root);
368
+ }
369
+
370
+ #endif /* #ifdef USING_COMBINING_CHARACTER_SCHEME */
371
+
372
+ int waddch( WINDOW *win, const chtype ch)
373
+ {
374
+ int x, y;
375
+ #ifdef USING_COMBINING_CHARACTER_SCHEME
376
+ int text_width;
377
+ #endif
378
+ chtype text, attr;
379
+ bool xlat;
380
+
381
+ PDC_LOG(("waddch() - called: win=%p ch=%x (text=%c attr=0x%x)\n",
382
+ win, ch, ch & A_CHARTEXT, ch & A_ATTRIBUTES));
383
+
384
+ if (!win)
385
+ return ERR;
386
+
387
+ x = win->_curx;
388
+ y = win->_cury;
389
+
390
+ if (y > win->_maxy || x > win->_maxx || y < 0 || x < 0)
391
+ return ERR;
392
+
393
+ xlat = !SP->raw_out && !(ch & A_ALTCHARSET);
394
+ text = ch & A_CHARTEXT;
395
+ attr = ch & A_ATTRIBUTES;
396
+ #ifdef USING_COMBINING_CHARACTER_SCHEME
397
+ text_width = mk_wcwidth( (int)text);
398
+
399
+ if( !text_width && text && (x || y))
400
+ { /* it's a combining char; combine w/prev char */
401
+ if( x)
402
+ x--;
403
+ else
404
+ {
405
+ y--;
406
+ x = win->_maxx - 1;
407
+ }
408
+ text = COMBINED_CHAR_START
409
+ + find_combined_char_idx( win->_y[y][x], text);
410
+ }
411
+ #endif
412
+
413
+ if (xlat && (text < ' ' || text == 0x7f))
414
+ {
415
+ int x2;
416
+
417
+ switch ((int)text)
418
+ {
419
+ case '\t':
420
+ for (x2 = ((x / TABSIZE) + 1) * TABSIZE; x < x2; x++)
421
+ {
422
+ if (waddch(win, attr | ' ') == ERR)
423
+ return ERR;
424
+
425
+ /* if tab to next line, exit the loop */
426
+
427
+ if (!win->_curx)
428
+ break;
429
+ }
430
+ return OK;
431
+
432
+ case '\n':
433
+ /* if lf -> crlf */
434
+
435
+ if (!SP->raw_out)
436
+ x = 0;
437
+
438
+ wclrtoeol(win);
439
+
440
+ if (++y > win->_bmarg)
441
+ {
442
+ y--;
443
+
444
+ if (wscrl(win, 1) == ERR)
445
+ return ERR;
446
+ }
447
+
448
+ break;
449
+
450
+ case '\b':
451
+ /* don't back over left margin */
452
+
453
+ if (--x < 0)
454
+ case '\r':
455
+ x = 0;
456
+
457
+ break;
458
+
459
+ case 0x7f:
460
+ if (waddch(win, attr | '^') == ERR)
461
+ return ERR;
462
+
463
+ return waddch(win, attr | '?');
464
+
465
+ default:
466
+ /* handle control chars */
467
+
468
+ if (waddch(win, attr | '^') == ERR)
469
+ return ERR;
470
+
471
+ return waddch(win, ch + '@');
472
+ }
473
+ }
474
+ else
475
+ {
476
+ /* If the incoming character doesn't have its own attribute,
477
+ then use the current attributes for the window. If it has
478
+ attributes but not a color component, OR the attributes to
479
+ the current attributes for the window. If it has a color
480
+ component, use the attributes solely from the incoming
481
+ character. */
482
+
483
+ if (!(attr & A_COLOR))
484
+ attr |= win->_attrs;
485
+
486
+ /* wrs (4/10/93): Apply the same sort of logic for the window
487
+ background, in that it only takes precedence if other color
488
+ attributes are not there and that the background character
489
+ will only print if the printing character is blank. */
490
+
491
+ if (!(attr & A_COLOR))
492
+ attr |= win->_bkgd & A_ATTRIBUTES;
493
+ else
494
+ attr |= win->_bkgd & (A_ATTRIBUTES ^ A_COLOR);
495
+
496
+ if (text == ' ')
497
+ text = win->_bkgd & A_CHARTEXT;
498
+
499
+ /* Add the attribute back into the character. */
500
+
501
+ text |= attr;
502
+
503
+ /* Only change _firstch/_lastch if the character to be added is
504
+ different from the character/attribute that is already in
505
+ that position in the window. */
506
+
507
+ if (win->_y[y][x] != text)
508
+ {
509
+ if (win->_firstch[y] == _NO_CHANGE)
510
+ win->_firstch[y] = win->_lastch[y] = x;
511
+ else
512
+ if (x < win->_firstch[y])
513
+ win->_firstch[y] = x;
514
+ else
515
+ if (x > win->_lastch[y])
516
+ win->_lastch[y] = x;
517
+
518
+ win->_y[y][x] = text;
519
+ }
520
+
521
+ if (++x >= win->_maxx)
522
+ {
523
+ /* wrap around test */
524
+
525
+ x = 0;
526
+
527
+ if (++y > win->_bmarg)
528
+ {
529
+ y--;
530
+
531
+ if (wscrl(win, 1) == ERR)
532
+ {
533
+ PDC_sync(win);
534
+ return ERR;
535
+ }
536
+ }
537
+ }
538
+ }
539
+
540
+ win->_curx = x;
541
+ win->_cury = y;
542
+
543
+ #ifdef USING_COMBINING_CHARACTER_SCHEME
544
+ /* If the character was fullwidth (should occupy two cells), we */
545
+ /* add a "dummy" character next to it : */
546
+ if( text_width == 2 && x)
547
+ waddch( win, DUMMY_CHAR_NEXT_TO_FULLWIDTH);
548
+ #endif
549
+
550
+ if (win->_immed)
551
+ wrefresh(win);
552
+ if (win->_sync)
553
+ wsyncup(win);
554
+
555
+ return OK;
556
+ }
557
+
558
+ int addch(const chtype ch)
559
+ {
560
+ PDC_LOG(("addch() - called: ch=%x\n", ch));
561
+
562
+ return waddch(stdscr, ch);
563
+ }
564
+
565
+ int mvaddch(int y, int x, const chtype ch)
566
+ {
567
+ PDC_LOG(("mvaddch() - called: y=%d x=%d ch=%x\n", y, x, ch));
568
+
569
+ if (move(y,x) == ERR)
570
+ return ERR;
571
+
572
+ return waddch(stdscr, ch);
573
+ }
574
+
575
+ int mvwaddch(WINDOW *win, int y, int x, const chtype ch)
576
+ {
577
+ PDC_LOG(("mvwaddch() - called: win=%p y=%d x=%d ch=%d\n", win, y, x, ch));
578
+
579
+ if (wmove(win, y, x) == ERR)
580
+ return ERR;
581
+
582
+ return waddch(win, ch);
583
+ }
584
+
585
+ int echochar(const chtype ch)
586
+ {
587
+ PDC_LOG(("echochar() - called: ch=%x\n", ch));
588
+
589
+ return wechochar(stdscr, ch);
590
+ }
591
+
592
+ int wechochar(WINDOW *win, const chtype ch)
593
+ {
594
+ PDC_LOG(("wechochar() - called: win=%p ch=%x\n", win, ch));
595
+
596
+ if (waddch(win, ch) == ERR)
597
+ return ERR;
598
+
599
+ return wrefresh(win);
600
+ }
601
+
602
+ int waddrawch(WINDOW *win, chtype ch)
603
+ {
604
+ PDC_LOG(("waddrawch() - called: win=%p ch=%x (text=%c attr=0x%x)\n",
605
+ win, ch, ch & A_CHARTEXT, ch & A_ATTRIBUTES));
606
+
607
+ if ((ch & A_CHARTEXT) < ' ' || (ch & A_CHARTEXT) == 0x7f)
608
+ ch |= A_ALTCHARSET;
609
+
610
+ return waddch(win, ch);
611
+ }
612
+
613
+ int addrawch(chtype ch)
614
+ {
615
+ PDC_LOG(("addrawch() - called: ch=%x\n", ch));
616
+
617
+ return waddrawch(stdscr, ch);
618
+ }
619
+
620
+ int mvaddrawch(int y, int x, chtype ch)
621
+ {
622
+ PDC_LOG(("mvaddrawch() - called: y=%d x=%d ch=%d\n", y, x, ch));
623
+
624
+ if (move(y, x) == ERR)
625
+ return ERR;
626
+
627
+ return waddrawch(stdscr, ch);
628
+ }
629
+
630
+ int mvwaddrawch(WINDOW *win, int y, int x, chtype ch)
631
+ {
632
+ PDC_LOG(("mvwaddrawch() - called: win=%p y=%d x=%d ch=%d\n",
633
+ win, y, x, ch));
634
+
635
+ if (wmove(win, y, x) == ERR)
636
+ return ERR;
637
+
638
+ return waddrawch(win, ch);
639
+ }
640
+
641
+ #ifdef PDC_WIDE
642
+ int wadd_wch(WINDOW *win, const cchar_t *wch)
643
+ {
644
+ PDC_LOG(("wadd_wch() - called: win=%p wch=%x\n", win, *wch));
645
+
646
+ return wch ? waddch(win, *wch) : ERR;
647
+ }
648
+
649
+ int add_wch(const cchar_t *wch)
650
+ {
651
+ PDC_LOG(("add_wch() - called: wch=%x\n", *wch));
652
+
653
+ return wadd_wch(stdscr, wch);
654
+ }
655
+
656
+ int mvadd_wch(int y, int x, const cchar_t *wch)
657
+ {
658
+ PDC_LOG(("mvaddch() - called: y=%d x=%d wch=%x\n", y, x, *wch));
659
+
660
+ if (move(y,x) == ERR)
661
+ return ERR;
662
+
663
+ return wadd_wch(stdscr, wch);
664
+ }
665
+
666
+ int mvwadd_wch(WINDOW *win, int y, int x, const cchar_t *wch)
667
+ {
668
+ PDC_LOG(("mvwaddch() - called: win=%p y=%d x=%d wch=%d\n",
669
+ win, y, x, *wch));
670
+
671
+ if (wmove(win, y, x) == ERR)
672
+ return ERR;
673
+
674
+ return wadd_wch(win, wch);
675
+ }
676
+
677
+ int echo_wchar(const cchar_t *wch)
678
+ {
679
+ PDC_LOG(("echo_wchar() - called: wch=%x\n", *wch));
680
+
681
+ return wecho_wchar(stdscr, wch);
682
+ }
683
+
684
+ int wecho_wchar(WINDOW *win, const cchar_t *wch)
685
+ {
686
+ PDC_LOG(("wecho_wchar() - called: win=%p wch=%x\n", win, *wch));
687
+
688
+ if (!wch || (wadd_wch(win, wch) == ERR))
689
+ return ERR;
690
+
691
+ return wrefresh(win);
692
+ }
693
+ #endif