curses 1.2.6 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +19 -0
  3. data/.github/workflows/ubuntu.yml +26 -0
  4. data/.github/workflows/windows.yml +28 -0
  5. data/.gitmodules +1 -1
  6. data/.travis.yml +6 -3
  7. data/History.md +40 -0
  8. data/README.md +4 -1
  9. data/Rakefile +0 -83
  10. data/curses.gemspec +2 -3
  11. data/ext/curses/curses.c +1271 -151
  12. data/ext/curses/extconf.rb +140 -17
  13. data/lib/curses.rb +5 -12
  14. data/sample/form.rb +52 -0
  15. data/sample/menu.rb +1 -1
  16. data/vendor/PDCurses/.gitignore +47 -0
  17. data/vendor/PDCurses/.travis.yml +49 -0
  18. data/vendor/PDCurses/CMakeLists.txt +68 -0
  19. data/vendor/PDCurses/HISTORY.md +2036 -0
  20. data/vendor/PDCurses/IMPLEMNT.md +327 -0
  21. data/vendor/PDCurses/README.md +77 -0
  22. data/vendor/PDCurses/acs_defs.h +265 -0
  23. data/vendor/PDCurses/appveyor.yml +218 -0
  24. data/vendor/PDCurses/cmake/README.md +71 -0
  25. data/vendor/PDCurses/cmake/build_dependencies.cmake +178 -0
  26. data/vendor/PDCurses/cmake/build_options.cmake +25 -0
  27. data/vendor/PDCurses/cmake/dll_version.cmake +26 -0
  28. data/vendor/PDCurses/cmake/gen_config_header.cmake +43 -0
  29. data/vendor/PDCurses/cmake/get_version.cmake +17 -0
  30. data/vendor/PDCurses/cmake/make_uninstall.cmake +19 -0
  31. data/vendor/PDCurses/cmake/project_common.cmake +121 -0
  32. data/vendor/PDCurses/cmake/resource.in.cmake +52 -0
  33. data/vendor/PDCurses/cmake/sdl2_ttf/CMakeLists.txt +83 -0
  34. data/vendor/PDCurses/cmake/target_arch.cmake +36 -0
  35. data/vendor/PDCurses/cmake/version.in.cmake +73 -0
  36. data/vendor/PDCurses/cmake/watcom_open_dos16_toolchain.cmake +96 -0
  37. data/vendor/PDCurses/cmake/watcom_open_dos32_toolchain.cmake +106 -0
  38. data/vendor/PDCurses/cmake/watcom_open_os2v2_toolchain.cmake +105 -0
  39. data/vendor/PDCurses/curses.h +1846 -0
  40. data/vendor/PDCurses/curspriv.h +134 -0
  41. data/vendor/PDCurses/demos/README.md +25 -0
  42. data/vendor/PDCurses/demos/firework.c +144 -0
  43. data/vendor/PDCurses/demos/newtest.c +581 -0
  44. data/vendor/PDCurses/demos/ozdemo.c +447 -0
  45. data/vendor/PDCurses/demos/ptest.c +283 -0
  46. data/vendor/PDCurses/demos/rain.c +157 -0
  47. data/vendor/PDCurses/demos/testcurs.c +1607 -0
  48. data/vendor/PDCurses/demos/tui.c +1048 -0
  49. data/vendor/PDCurses/demos/tui.h +65 -0
  50. data/vendor/PDCurses/demos/tuidemo.c +233 -0
  51. data/vendor/PDCurses/demos/version.c +61 -0
  52. data/vendor/PDCurses/demos/worm.c +432 -0
  53. data/vendor/PDCurses/demos/xmas.c +955 -0
  54. data/vendor/PDCurses/dos/CMakeLists.txt +47 -0
  55. data/vendor/PDCurses/dos/Makefile.bcc +83 -0
  56. data/vendor/PDCurses/dos/Makefile.dmc +257 -0
  57. data/vendor/PDCurses/dos/Makefile.msc +113 -0
  58. data/vendor/PDCurses/dos/Makefile.wcc +107 -0
  59. data/vendor/PDCurses/dos/README.md +51 -0
  60. data/vendor/PDCurses/dos/bccdos.lrf +9 -0
  61. data/vendor/PDCurses/dos/mscdos.lrf +50 -0
  62. data/vendor/PDCurses/dos/pdcclip.c +132 -0
  63. data/vendor/PDCurses/dos/pdcdisp.c +135 -0
  64. data/vendor/PDCurses/dos/pdcdos.h +194 -0
  65. data/vendor/PDCurses/dos/pdcgetsc.c +98 -0
  66. data/vendor/PDCurses/dos/pdckbd.c +513 -0
  67. data/vendor/PDCurses/dos/pdcscrn.c +785 -0
  68. data/vendor/PDCurses/dos/pdcsetsc.c +101 -0
  69. data/vendor/PDCurses/dos/pdcutil.c +212 -0
  70. data/vendor/PDCurses/libobjs.mif +26 -0
  71. data/vendor/PDCurses/makedist.mif +20 -0
  72. data/vendor/PDCurses/man/README.md +21 -0
  73. data/vendor/PDCurses/man/intro.md +361 -0
  74. data/vendor/PDCurses/man/manext.c +119 -0
  75. data/vendor/PDCurses/man/sdl.md +152 -0
  76. data/vendor/PDCurses/man/sdl2.md +58 -0
  77. data/vendor/PDCurses/man/x11.md +407 -0
  78. data/vendor/PDCurses/ncurses/CMakeLists.txt +66 -0
  79. data/vendor/PDCurses/ncurses/README.md +26 -0
  80. data/vendor/PDCurses/ncurses/makefile +29 -0
  81. data/vendor/PDCurses/os2/CMakeLists.txt +41 -0
  82. data/vendor/PDCurses/os2/Makefile.bcc +90 -0
  83. data/vendor/PDCurses/os2/Makefile.wcc +43 -0
  84. data/vendor/PDCurses/os2/README.md +43 -0
  85. data/vendor/PDCurses/os2/iccos2.lrf +50 -0
  86. data/vendor/PDCurses/os2/iccos2.mak +256 -0
  87. data/vendor/PDCurses/os2/pdcclip.c +188 -0
  88. data/vendor/PDCurses/os2/pdcdisp.c +93 -0
  89. data/vendor/PDCurses/os2/pdcgetsc.c +89 -0
  90. data/vendor/PDCurses/os2/pdckbd.c +521 -0
  91. data/vendor/PDCurses/os2/pdcos2.h +55 -0
  92. data/vendor/PDCurses/os2/pdcscrn.c +449 -0
  93. data/vendor/PDCurses/os2/pdcsetsc.c +112 -0
  94. data/vendor/PDCurses/os2/pdcutil.c +52 -0
  95. data/vendor/PDCurses/panel.h +56 -0
  96. data/vendor/PDCurses/pdcurses/README.md +25 -0
  97. data/vendor/PDCurses/pdcurses/addch.c +693 -0
  98. data/vendor/PDCurses/pdcurses/addchstr.c +245 -0
  99. data/vendor/PDCurses/pdcurses/addstr.c +240 -0
  100. data/vendor/PDCurses/pdcurses/attr.c +359 -0
  101. data/vendor/PDCurses/pdcurses/beep.c +68 -0
  102. data/vendor/PDCurses/pdcurses/bkgd.c +223 -0
  103. data/vendor/PDCurses/pdcurses/border.c +411 -0
  104. data/vendor/PDCurses/pdcurses/clear.c +159 -0
  105. data/vendor/PDCurses/pdcurses/color.c +298 -0
  106. data/vendor/PDCurses/pdcurses/debug.c +109 -0
  107. data/vendor/PDCurses/pdcurses/delch.c +96 -0
  108. data/vendor/PDCurses/pdcurses/deleteln.c +211 -0
  109. data/vendor/PDCurses/pdcurses/deprec.c +27 -0
  110. data/vendor/PDCurses/pdcurses/getch.c +417 -0
  111. data/vendor/PDCurses/pdcurses/getstr.c +474 -0
  112. data/vendor/PDCurses/pdcurses/getyx.c +139 -0
  113. data/vendor/PDCurses/pdcurses/inch.c +127 -0
  114. data/vendor/PDCurses/pdcurses/inchstr.c +214 -0
  115. data/vendor/PDCurses/pdcurses/initscr.c +367 -0
  116. data/vendor/PDCurses/pdcurses/inopts.c +324 -0
  117. data/vendor/PDCurses/pdcurses/insch.c +271 -0
  118. data/vendor/PDCurses/pdcurses/insstr.c +264 -0
  119. data/vendor/PDCurses/pdcurses/instr.c +246 -0
  120. data/vendor/PDCurses/pdcurses/kernel.c +259 -0
  121. data/vendor/PDCurses/pdcurses/keyname.c +157 -0
  122. data/vendor/PDCurses/pdcurses/mouse.c +438 -0
  123. data/vendor/PDCurses/pdcurses/move.c +57 -0
  124. data/vendor/PDCurses/pdcurses/outopts.c +159 -0
  125. data/vendor/PDCurses/pdcurses/overlay.c +214 -0
  126. data/vendor/PDCurses/pdcurses/pad.c +260 -0
  127. data/vendor/PDCurses/pdcurses/panel.c +633 -0
  128. data/vendor/PDCurses/pdcurses/printw.c +126 -0
  129. data/vendor/PDCurses/pdcurses/refresh.c +279 -0
  130. data/vendor/PDCurses/pdcurses/scanw.c +578 -0
  131. data/vendor/PDCurses/pdcurses/scr_dump.c +213 -0
  132. data/vendor/PDCurses/pdcurses/scroll.c +101 -0
  133. data/vendor/PDCurses/pdcurses/slk.c +591 -0
  134. data/vendor/PDCurses/pdcurses/termattr.c +182 -0
  135. data/vendor/PDCurses/pdcurses/terminfo.c +217 -0
  136. data/vendor/PDCurses/pdcurses/touch.c +163 -0
  137. data/vendor/PDCurses/pdcurses/util.c +312 -0
  138. data/vendor/PDCurses/pdcurses/window.c +569 -0
  139. data/vendor/PDCurses/sdl1/Makefile.mng +110 -0
  140. data/vendor/PDCurses/sdl1/README.md +31 -0
  141. data/vendor/PDCurses/sdl1/deffont.h +385 -0
  142. data/vendor/PDCurses/sdl1/deficon.h +23 -0
  143. data/vendor/PDCurses/sdl1/pdcclip.c +131 -0
  144. data/vendor/PDCurses/sdl1/pdcdisp.c +373 -0
  145. data/vendor/PDCurses/sdl1/pdcgetsc.c +30 -0
  146. data/vendor/PDCurses/sdl1/pdckbd.c +405 -0
  147. data/vendor/PDCurses/sdl1/pdcscrn.c +414 -0
  148. data/vendor/PDCurses/sdl1/pdcsdl.h +31 -0
  149. data/vendor/PDCurses/sdl1/pdcsetsc.c +64 -0
  150. data/vendor/PDCurses/sdl1/pdcutil.c +40 -0
  151. data/vendor/PDCurses/sdl1/sdltest.c +79 -0
  152. data/vendor/PDCurses/sdl2/CMakeLists.txt +76 -0
  153. data/vendor/PDCurses/sdl2/Makefile.vc +164 -0
  154. data/vendor/PDCurses/sdl2/README.md +34 -0
  155. data/vendor/PDCurses/sdl2/deffont.h +385 -0
  156. data/vendor/PDCurses/sdl2/deficon.h +23 -0
  157. data/vendor/PDCurses/sdl2/pdcclip.c +93 -0
  158. data/vendor/PDCurses/sdl2/pdcdisp.c +534 -0
  159. data/vendor/PDCurses/sdl2/pdcgetsc.c +30 -0
  160. data/vendor/PDCurses/sdl2/pdckbd.c +480 -0
  161. data/vendor/PDCurses/sdl2/pdcscrn.c +443 -0
  162. data/vendor/PDCurses/sdl2/pdcsdl.h +33 -0
  163. data/vendor/PDCurses/sdl2/pdcsetsc.c +67 -0
  164. data/vendor/PDCurses/sdl2/pdcutil.c +39 -0
  165. data/vendor/PDCurses/sdl2/sdltest.c +81 -0
  166. data/vendor/PDCurses/term.h +48 -0
  167. data/vendor/PDCurses/version.mif +7 -0
  168. data/vendor/PDCurses/vt/CMakeLists.txt +28 -0
  169. data/vendor/PDCurses/vt/Makefile.bcc +111 -0
  170. data/vendor/PDCurses/vt/Makefile.dmc +258 -0
  171. data/vendor/PDCurses/vt/Makefile.vc +144 -0
  172. data/vendor/PDCurses/vt/Makefile.wcc +107 -0
  173. data/vendor/PDCurses/vt/README.md +64 -0
  174. data/vendor/PDCurses/vt/pdcclip.c +20 -0
  175. data/vendor/PDCurses/vt/pdcdisp.c +284 -0
  176. data/vendor/PDCurses/vt/pdcgetsc.c +27 -0
  177. data/vendor/PDCurses/vt/pdckbd.c +394 -0
  178. data/vendor/PDCurses/vt/pdcscrn.c +434 -0
  179. data/vendor/PDCurses/vt/pdcsetsc.c +45 -0
  180. data/vendor/PDCurses/vt/pdcutil.c +43 -0
  181. data/vendor/PDCurses/vt/pdcvt.h +16 -0
  182. data/vendor/PDCurses/watcom.mif +68 -0
  183. data/vendor/PDCurses/wincon/CMakeLists.txt +27 -0
  184. data/vendor/PDCurses/wincon/Makefile.bcc +88 -0
  185. data/vendor/PDCurses/wincon/Makefile.dmc +256 -0
  186. data/vendor/PDCurses/wincon/Makefile.lcc +273 -0
  187. data/vendor/PDCurses/wincon/Makefile.mng +176 -0
  188. data/vendor/PDCurses/wincon/Makefile.vc +144 -0
  189. data/vendor/PDCurses/wincon/Makefile.wcc +51 -0
  190. data/vendor/PDCurses/wincon/README.md +85 -0
  191. data/vendor/PDCurses/wincon/pdcclip.c +174 -0
  192. data/vendor/PDCurses/wincon/pdcdisp.c +143 -0
  193. data/vendor/PDCurses/wincon/pdcgetsc.c +55 -0
  194. data/vendor/PDCurses/wincon/pdckbd.c +786 -0
  195. data/vendor/PDCurses/wincon/pdcscrn.c +717 -0
  196. data/vendor/PDCurses/wincon/pdcsetsc.c +91 -0
  197. data/vendor/PDCurses/wincon/pdcurses.ico +0 -0
  198. data/vendor/PDCurses/wincon/pdcurses.rc +28 -0
  199. data/vendor/PDCurses/wincon/pdcutil.c +41 -0
  200. data/vendor/PDCurses/wincon/pdcwin.h +31 -0
  201. data/vendor/PDCurses/wingui/CMakeLists.txt +27 -0
  202. data/vendor/PDCurses/wingui/Makefile.bcc +85 -0
  203. data/vendor/PDCurses/wingui/Makefile.dmc +259 -0
  204. data/vendor/PDCurses/wingui/Makefile.lcc +273 -0
  205. data/vendor/PDCurses/wingui/Makefile.mng +171 -0
  206. data/vendor/PDCurses/wingui/Makefile.vc +144 -0
  207. data/vendor/PDCurses/wingui/Makefile.wcc +51 -0
  208. data/vendor/PDCurses/wingui/README.md +93 -0
  209. data/vendor/PDCurses/wingui/pdcclip.c +174 -0
  210. data/vendor/PDCurses/wingui/pdcdisp.c +718 -0
  211. data/vendor/PDCurses/wingui/pdcgetsc.c +30 -0
  212. data/vendor/PDCurses/wingui/pdckbd.c +143 -0
  213. data/vendor/PDCurses/wingui/pdcscrn.c +2797 -0
  214. data/vendor/PDCurses/wingui/pdcsetsc.c +89 -0
  215. data/vendor/PDCurses/wingui/pdcurses.ico +0 -0
  216. data/vendor/PDCurses/wingui/pdcurses.rc +28 -0
  217. data/vendor/PDCurses/wingui/pdcutil.c +61 -0
  218. data/vendor/PDCurses/wingui/pdcwin.h +122 -0
  219. data/vendor/PDCurses/x11/Makefile.in +754 -0
  220. data/vendor/PDCurses/x11/PDCurses.spec +82 -0
  221. data/vendor/PDCurses/x11/README.md +62 -0
  222. data/vendor/PDCurses/x11/ScrollBox.c +319 -0
  223. data/vendor/PDCurses/x11/ScrollBox.h +51 -0
  224. data/vendor/PDCurses/x11/ScrollBoxP.h +70 -0
  225. data/vendor/PDCurses/x11/aclocal.m4 +994 -0
  226. data/vendor/PDCurses/x11/big_icon.xbm +46 -0
  227. data/vendor/PDCurses/x11/compose.h +201 -0
  228. data/vendor/PDCurses/x11/config.guess +1500 -0
  229. data/vendor/PDCurses/x11/config.h.in +100 -0
  230. data/vendor/PDCurses/x11/config.sub +1616 -0
  231. data/vendor/PDCurses/x11/configure +6700 -0
  232. data/vendor/PDCurses/x11/configure.ac +295 -0
  233. data/vendor/PDCurses/x11/debian/changelog +6 -0
  234. data/vendor/PDCurses/x11/debian/compat +1 -0
  235. data/vendor/PDCurses/x11/debian/control +11 -0
  236. data/vendor/PDCurses/x11/debian/copyright +27 -0
  237. data/vendor/PDCurses/x11/debian/rules +98 -0
  238. data/vendor/PDCurses/x11/install-sh +253 -0
  239. data/vendor/PDCurses/x11/little_icon.xbm +14 -0
  240. data/vendor/PDCurses/x11/ncurses_cfg.h +45 -0
  241. data/vendor/PDCurses/x11/pdcclip.c +173 -0
  242. data/vendor/PDCurses/x11/pdcdisp.c +85 -0
  243. data/vendor/PDCurses/x11/pdcgetsc.c +28 -0
  244. data/vendor/PDCurses/x11/pdckbd.c +104 -0
  245. data/vendor/PDCurses/x11/pdcscrn.c +258 -0
  246. data/vendor/PDCurses/x11/pdcsetsc.c +95 -0
  247. data/vendor/PDCurses/x11/pdcutil.c +52 -0
  248. data/vendor/PDCurses/x11/pdcx11.c +316 -0
  249. data/vendor/PDCurses/x11/pdcx11.h +191 -0
  250. data/vendor/PDCurses/x11/sb.c +155 -0
  251. data/vendor/PDCurses/x11/x11.c +3686 -0
  252. data/vendor/PDCurses/x11/xcurses-config.in +81 -0
  253. metadata +255 -21
@@ -0,0 +1,51 @@
1
+ # Watcom WMAKE Makefile for PDCurses library - Win32 Watcom C/C++ 10.6+
2
+ #
3
+ # Usage: wmake -f [wingui/]Makefile.wcc [DEBUG=Y] [WIDE=Y] [UTF8=Y] [target]
4
+ #
5
+ # where target can be any of:
6
+ # [all|demos|pdcurses.lib|testcurs.exe...]
7
+
8
+ !ifdef %PDCURSES_SRCDIR
9
+ PDCURSES_SRCDIR = $(%PDCURSES_SRCDIR)
10
+ !else
11
+ PDCURSES_SRCDIR = ..
12
+ !endif
13
+
14
+ !include $(PDCURSES_SRCDIR)/version.mif
15
+
16
+ osdir = $(PDCURSES_SRCDIR)/wingui
17
+
18
+ CC = wcc386
19
+ TARGET = nt_win
20
+
21
+ CFLAGS = -ei -zq -wx -i=$(PDCURSES_SRCDIR)
22
+
23
+ !ifeq DEBUG Y
24
+ CFLAGS += -hd -od -d2 -dDEBUG -DPDCDEBUG
25
+ LDFLAGS = DEBUG ALL op q sys $(TARGET)
26
+ !else
27
+ CFLAGS += -oneatx
28
+ LDFLAGS = op q sys $(TARGET)
29
+ !endif
30
+
31
+ !ifeq WIDE Y
32
+ CFLAGS += -DPDC_WIDE
33
+ !endif
34
+
35
+ !ifeq UTF8 Y
36
+ CFLAGS += -DPDC_FORCE_UTF8
37
+ !endif
38
+
39
+ LIBEXE = wlib -q -n -t
40
+
41
+ !include $(PDCURSES_SRCDIR)/watcom.mif
42
+
43
+ $(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
44
+ $(LIBEXE) $@ $(LIBOBJS) $(PDCOBJS)
45
+ copy $(LIBCURSES) panel.lib
46
+
47
+ PLATFORM1 = Watcom C++ WinGUI
48
+ PLATFORM2 = Open Watcom 1.6 for WinGUI
49
+ ARCNAME = pdc$(VER)_wcc_w32
50
+
51
+ !include $(PDCURSES_SRCDIR)/makedist.mif
@@ -0,0 +1,93 @@
1
+ PDCurses for WinGUI
2
+ ==================
3
+
4
+ This directory contains PDCurses source code files specific to Win32
5
+ graphics mode (Win95 and all subsequent forks of Windows).
6
+
7
+ Building
8
+ --------
9
+
10
+ (Note that the following is almost identical to the instructions
11
+ for the Win32 console flavor of PDCurses.)
12
+
13
+ - Choose the appropriate makefile for your compiler:
14
+
15
+ Makefile.bcc - Borland C++ 4.0.2+
16
+ Makefile.dmc - Digital Mars
17
+ Makefile.lcc - LCC-Win32
18
+ Makefile.mng - MinGW, Cygnus GNU Compiler
19
+ Makefile.vc - Microsoft Visual C++ 2.0+ or later & Intel(R) compiler
20
+ Makefile.wcc - Watcom 10.6+ or OpenWATCOM
21
+
22
+ - Optionally, you can build in a different directory than the platform
23
+ directory by setting PDCURSES_SRCDIR to point to the directory where
24
+ you unpacked PDCurses, and changing to your target directory:
25
+
26
+ set PDCURSES_SRCDIR=c:\pdcurses
27
+
28
+ This won't work with the LCC or Digital Mars makefiles, nor will the
29
+ options described below.
30
+
31
+ - Build it:
32
+
33
+ make -f makefilename
34
+
35
+ (For Watcom, use "wmake" instead of "make"; for MSVC, "nmake".) You'll
36
+ get the libraries (pdcurses.lib or .a, depending on your compiler; and
37
+ panel.lib or .a), the demos (*.exe), and a lot of object files. Note
38
+ that the panel library is just a copy of the main library, provided
39
+ for convenience; both panel and curses functions are in the main
40
+ library.
41
+
42
+ You can also give the optional parameter "WIDE=Y", to build the
43
+ library with wide-character (Unicode) support:
44
+
45
+ make -f Makefile.mng WIDE=Y
46
+
47
+ When built this way, the library is not compatible with Windows 9x,
48
+ unless you also link with the Microsoft Layer for Unicode (not
49
+ tested).
50
+
51
+ For the Intel(R) compiler, use Makefile.vc and add ICC=Y.
52
+
53
+ By default, Makefile.vc results in 64-bit code for both VC and Intel(R).
54
+ Add IX86=Y to generate 32-bit code. (Other builds are 32-bit only.)
55
+
56
+ Another option, "UTF8=Y", makes PDCurses ignore the system locale, and
57
+ treat all narrow-character strings as UTF-8. This option has no effect
58
+ unless WIDE=Y is also set. This was originally provided to get around
59
+ poor support for UTF-8 in the Win32 console:
60
+
61
+ make -f Makefile.mng WIDE=Y UTF8=Y
62
+
63
+ WinGUI doesn't have the same limitations as the Win32 console flavor,
64
+ but UTF-8 and non-UTF-8 versions are still available. If nothing else,
65
+ this means that if you've built a Win32 console PDCurses DLL with any
66
+ configuration, you can build a matching WinGUI DLL and swap between
67
+ console or GUI PDCurses just by swapping DLLs.
68
+
69
+ You can also use the optional parameter "DLL=Y" with Visual C++,
70
+ MinGW or Cygwin, to build the library as a DLL:
71
+
72
+ nmake -f Makefile.vc WIDE=Y DLL=Y
73
+
74
+ When you build the library as a Windows DLL, you must always define
75
+ PDC_DLL_BUILD when linking against it. (Or, if you only want to use
76
+ the DLL, you could add this definition to your curses.h.)
77
+
78
+ If cross-compiling from Linux, add the parameter `_w64=1` to get
79
+ 64-bit code (default will be 32-bit).
80
+
81
+ make -f Makefile.mng _w64=1 [WIDE=Y UTF8=Y DLL=Y]
82
+
83
+ Distribution Status
84
+ -------------------
85
+
86
+ The files in this directory are released to the Public Domain.
87
+
88
+ Acknowledgements
89
+ ----------------
90
+
91
+ Based heavily on the Win32 console flavor of PDCurses by Chris Szurgot
92
+ <szurgot[at]itribe.net>, ported to Win32 GUI by Bill Gray
93
+ <pluto[at]projectpluto.com>.
@@ -0,0 +1,174 @@
1
+ /* Public Domain Curses */
2
+
3
+ #include "pdcwin.h"
4
+
5
+ /*man-start**************************************************************
6
+
7
+ clipboard
8
+ ---------
9
+
10
+ ### Synopsis
11
+
12
+ int PDC_getclipboard(char **contents, long *length);
13
+ int PDC_setclipboard(const char *contents, long length);
14
+ int PDC_freeclipboard(char *contents);
15
+ int PDC_clearclipboard(void);
16
+
17
+ ### Description
18
+
19
+ PDC_getclipboard() gets the textual contents of the system's
20
+ clipboard. This function returns the contents of the clipboard
21
+ in the contents argument. It is the responsibility of the
22
+ caller to free the memory returned, via PDC_freeclipboard().
23
+ The length of the clipboard contents is returned in the length
24
+ argument.
25
+
26
+ PDC_setclipboard copies the supplied text into the system's
27
+ clipboard, emptying the clipboard prior to the copy.
28
+
29
+ PDC_clearclipboard() clears the internal clipboard.
30
+
31
+ ### Return Values
32
+
33
+ indicator of success/failure of call.
34
+ PDC_CLIP_SUCCESS the call was successful
35
+ PDC_CLIP_MEMORY_ERROR unable to allocate sufficient memory for
36
+ the clipboard contents
37
+ PDC_CLIP_EMPTY the clipboard contains no text
38
+ PDC_CLIP_ACCESS_ERROR no clipboard support
39
+
40
+ ### Portability
41
+ X/Open BSD SYS V
42
+ PDC_getclipboard - - -
43
+ PDC_setclipboard - - -
44
+ PDC_freeclipboard - - -
45
+ PDC_clearclipboard - - -
46
+
47
+ **man-end****************************************************************/
48
+
49
+ #ifdef PDC_WIDE
50
+ # define PDC_TEXT CF_UNICODETEXT
51
+ #else
52
+ # define PDC_TEXT CF_OEMTEXT
53
+ #endif
54
+
55
+ int PDC_getclipboard_handle( HANDLE *handle)
56
+ {
57
+ PDC_LOG(("PDC_getclipboard() - called\n"));
58
+
59
+ if (!OpenClipboard(NULL))
60
+ {
61
+ return PDC_CLIP_ACCESS_ERROR;
62
+ }
63
+
64
+ if ((*handle = GetClipboardData(PDC_TEXT)) == NULL)
65
+ {
66
+ CloseClipboard();
67
+ return PDC_CLIP_EMPTY;
68
+ }
69
+
70
+ return PDC_CLIP_SUCCESS;
71
+ }
72
+
73
+ int PDC_getclipboard(char **contents, long *length)
74
+ {
75
+ HANDLE handle;
76
+ int rval = PDC_getclipboard_handle( &handle);
77
+
78
+ if( rval == PDC_CLIP_SUCCESS)
79
+ {
80
+ void *tptr = GlobalLock( handle);
81
+
82
+ if( tptr)
83
+ {
84
+ #ifdef PDC_WIDE
85
+ size_t len = wcslen((wchar_t *)tptr) * 3;
86
+ #else
87
+ size_t len = strlen( tptr);
88
+ #endif
89
+
90
+ *contents = (char *)GlobalAlloc( GMEM_FIXED, len + 1);
91
+
92
+ if( !*contents)
93
+ rval = PDC_CLIP_MEMORY_ERROR;
94
+ else
95
+ {
96
+ #ifdef PDC_WIDE
97
+ len = PDC_wcstombs( (char *)*contents, tptr, len);
98
+ #else
99
+ strcpy((char *)*contents, tptr);
100
+ #endif
101
+ }
102
+ *length = (long)len;
103
+ GlobalUnlock( handle);
104
+ }
105
+ else
106
+ rval = PDC_CLIP_MEMORY_ERROR;
107
+ CloseClipboard();
108
+ }
109
+ return rval;
110
+ }
111
+
112
+ int PDC_setclipboard_raw( const char *contents, long length,
113
+ const bool translate_multibyte_to_wide_char)
114
+ {
115
+ HGLOBAL handle;
116
+ LPTSTR buff;
117
+
118
+ PDC_LOG(("PDC_setclipboard() - called\n"));
119
+
120
+ if (!OpenClipboard(NULL))
121
+ return PDC_CLIP_ACCESS_ERROR;
122
+
123
+ handle = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE,
124
+ (length + 1) * sizeof(TCHAR));
125
+
126
+ if (!handle)
127
+ return PDC_CLIP_MEMORY_ERROR;
128
+
129
+ buff = GlobalLock(handle);
130
+
131
+ #ifdef PDC_WIDE
132
+ if( translate_multibyte_to_wide_char)
133
+ PDC_mbstowcs((wchar_t *)buff, contents, length);
134
+ else
135
+ memcpy((char *)buff, contents, (length + 1) * sizeof( wchar_t));
136
+ #else
137
+ memcpy((char *)buff, contents, length);
138
+ buff[length] = 0; /* ensure null termination */
139
+ #endif
140
+ GlobalUnlock(handle);
141
+ EmptyClipboard();
142
+
143
+ if( !SetClipboardData(PDC_TEXT, handle))
144
+ {
145
+ GlobalFree(handle);
146
+ return PDC_CLIP_ACCESS_ERROR;
147
+ }
148
+
149
+ CloseClipboard();
150
+
151
+ return PDC_CLIP_SUCCESS;
152
+ }
153
+
154
+ int PDC_setclipboard(const char *contents, long length)
155
+ {
156
+ return( PDC_setclipboard_raw( contents, length, TRUE));
157
+ }
158
+
159
+ int PDC_freeclipboard(char *contents)
160
+ {
161
+ PDC_LOG(("PDC_freeclipboard() - called\n"));
162
+
163
+ GlobalFree(contents);
164
+ return PDC_CLIP_SUCCESS;
165
+ }
166
+
167
+ int PDC_clearclipboard(void)
168
+ {
169
+ PDC_LOG(("PDC_clearclipboard() - called\n"));
170
+
171
+ EmptyClipboard();
172
+
173
+ return PDC_CLIP_SUCCESS;
174
+ }
@@ -0,0 +1,718 @@
1
+ /* Public Domain Curses */
2
+
3
+ #include "pdcwin.h"
4
+
5
+ #include <assert.h>
6
+ #include <stdlib.h>
7
+ #include <string.h>
8
+ #include <tchar.h>
9
+
10
+ /* For this 'real Windows' version, we use all Unicode all the time,
11
+ including for ACS characters, and even when PDC_WIDE isn't #defined
12
+ (i.e., when running in 'legacy' 8-bit character mode) See 'acs_defs.h'
13
+ for details. */
14
+
15
+ #define USE_UNICODE_ACS_CHARS 1
16
+
17
+ #include "acs_defs.h"
18
+
19
+ static const unsigned short starting_ascii_to_unicode[32] = {
20
+ 0,
21
+ 0x263a, /* 1 smiling face */
22
+ 0x263b, /* 2 smiling face inverted */
23
+ 0x2665, /* 3 heart */
24
+ 0x2666, /* 4 diamond */
25
+ 0x2663, /* 5 club */
26
+ 0x2660, /* 6 spade */
27
+ 0x2024, /* 7 small bullet */
28
+ 0x25d8, /* 8 inverted bullet */
29
+ 0x25bc, /* 9 hollow bullet */
30
+ 0x25d9, /* 10 inverted hollow bullet */
31
+ 0x2642, /* 11 male/Mars symbol */
32
+ 0x2640, /* 12 female/Venus symbol */
33
+ 0x266a, /* 13 eighth note */
34
+ 0x266c, /* 14 two sixteenth notes */
35
+ 0x263c, /* 15 splat */
36
+ 0x25b6, /* 16 right-pointing triangle */
37
+ 0x25c0, /* 17 left-pointing triangle */
38
+ 0x2195, /* 18 double up/down arrow */
39
+ 0x203c, /* 19 double exclamation !! */
40
+ 0x00b6, /* 20 pilcrow */
41
+ 0xa7, /* 21 */
42
+ 0x2582, /* 22 lower 1/3 block */
43
+ 0x280d, /* 23 double up/down arrow */
44
+ 0x2191, /* 24 up arrow */
45
+ 0x2193, /* 25 down arrow */
46
+ 0x2192, /* 26 right arrow */
47
+ 0x2190, /* 27 left arrow */
48
+ 0x2319, /* 28 */
49
+ 0x280c, /* 29 left & right arrow */
50
+ 0x25b2, /* 30 up triangle */
51
+ 0x25bc}; /* 31 down triangle */
52
+
53
+ /* Cursors may be added to the 'shapes' array. A 'shapes' string
54
+ defines the cursor as one or more rectangles, separated by semicolons.
55
+ The coordinates of the upper left and lower right corners are given,
56
+ usually just as integers from zero to eight. Thus, "0488" means a
57
+ rectangle running from (0,4), middle of the left side, to (8,8),
58
+ bottom right corner: a rectangle filling the bottom half of the
59
+ character cell. "0048" would fill the left half of the cell, and
60
+ "0082;6088" would fill the top and bottom quarters of the cell.
61
+
62
+ However, a coordinate may be followed by a + or -, and then by a
63
+ single-digit offset in pixels. So "08-4" refers to a point on the
64
+ left-hand side of the character cell, four pixels from the bottom. I
65
+ admit that the cursor descriptions themselves look a little strange!
66
+ But this way of describing cursors is compact and lends itself to some
67
+ pretty simple code.
68
+
69
+ The first three lines are standard PDCurses cursors: 0=no cursor,
70
+ 1=four-pixel thick line at bottom of the cell, 2="high-intensity",
71
+ i.e., a filled block. The rest are extended cursors, not currently
72
+ available in other PDCurses flavors. */
73
+
74
+ #define N_CURSORS 9
75
+
76
+ static void redraw_cursor_from_index( const HDC hdc, const int idx)
77
+ {
78
+ const char *shapes[N_CURSORS] = {
79
+ "", /* 0: invisible */
80
+ "08-488", /* 1: normal: four lines at bottom */
81
+ "0088", /* 2: full block */
82
+ "0088;0+10+18-18-1", /* 3: outlined block */
83
+ "28-368;4-10+34+18-3;2060+3", /* 4: caret */
84
+ "0488", /* 5: bottom half block */
85
+ "2266", /* 6: central block */
86
+ "0385;3053;3558", /* 7: cross */
87
+ "0088;0+10+48-18-4" }; /* 8: outlined block: heavy top/bottom*/
88
+ const char *sptr = shapes[idx];
89
+ LONG left, top;
90
+ extern int PDC_cxChar, PDC_cyChar;
91
+
92
+ left = SP->curscol * PDC_cxChar;
93
+ top = SP->cursrow * PDC_cyChar;
94
+ while( *sptr)
95
+ {
96
+ int i;
97
+ LONG coords[4];
98
+ RECT rect;
99
+
100
+ for( i = 0; i < 4; i++)
101
+ {
102
+ coords[i] = (( i & 1) ?
103
+ top + (PDC_cyChar * (*sptr - '0') + 4) / 8 :
104
+ left + (PDC_cxChar * (*sptr - '0') + 4) / 8);
105
+ sptr++;
106
+ if( *sptr == '+' || *sptr == '-')
107
+ {
108
+ if( *sptr == '+')
109
+ coords[i] += sptr[1] - '0';
110
+ else
111
+ coords[i] -= sptr[1] - '0';
112
+ sptr += 2;
113
+ }
114
+ }
115
+ rect.left = coords[0];
116
+ rect.top = coords[1];
117
+ rect.right = coords[2];
118
+ rect.bottom = coords[3];
119
+ InvertRect( hdc, &rect);
120
+ if( *sptr == ';')
121
+ sptr++;
122
+ }
123
+ }
124
+
125
+ /* PDC_current_cursor_state( ) determines which cursor, if any,
126
+ is currently shown. This may depend on the blink state. Also,
127
+ if the window currently lacks the focus, we show cursor 3 (a hollow
128
+ box) in place of any visible cursor. */
129
+
130
+ static int PDC_current_cursor_state( void)
131
+ {
132
+ extern int PDC_blink_state;
133
+ extern HWND PDC_hWnd;
134
+ const int shift_amount = (PDC_blink_state ? 0 : 8);
135
+ const int cursor_style_for_unfocussed_window =
136
+ PDC_CURSOR( PDC_CURSOR_OUTLINE, PDC_CURSOR_OUTLINE);
137
+ int cursor_style;
138
+
139
+ /* for unfocussed windows, show an hollow box: */
140
+ if( SP->visibility && (PDC_hWnd != GetForegroundWindow( )))
141
+ cursor_style = cursor_style_for_unfocussed_window;
142
+ else /* otherwise, just show the cursor "normally" */
143
+ cursor_style = SP->visibility;
144
+ return( (cursor_style >> shift_amount) & 0xff);
145
+ }
146
+
147
+ static void redraw_cursor( const HDC hdc)
148
+ {
149
+ const int cursor_style = PDC_current_cursor_state( );
150
+
151
+ if( cursor_style > 0 && cursor_style < N_CURSORS)
152
+ redraw_cursor_from_index( hdc, cursor_style);
153
+ }
154
+
155
+ /* position "hardware" cursor at (y, x). We don't have a for-real hardware */
156
+ /* cursor in this version, of course, but we can fake it. Note that much */
157
+ /* of the logic was borrowed from the SDL version. In particular, the */
158
+ /* cursor is moved by first overwriting the "original" location. */
159
+
160
+ void PDC_gotoyx(int row, int col)
161
+ {
162
+ PDC_LOG(("PDC_gotoyx() - called: row %d col %d from row %d col %d\n",
163
+ row, col, SP->cursrow, SP->curscol));
164
+
165
+ /* clear the old cursor, if it's on-screen: */
166
+ if( SP->cursrow >= 0 && SP->curscol >= 0 &&
167
+ SP->cursrow < SP->lines && SP->curscol < SP->cols)
168
+ {
169
+ const int temp_visibility = SP->visibility;
170
+
171
+ SP->visibility = 0;
172
+ PDC_transform_line( SP->cursrow, SP->curscol, 1,
173
+ curscr->_y[SP->cursrow] + SP->curscol);
174
+ SP->visibility = temp_visibility;
175
+ }
176
+
177
+ /* ...then draw the new (assuming it's actually visible). */
178
+ /* This used to require some logic. Now the redraw_cursor() */
179
+ /* function figures out what cursor should be drawn, if any. */
180
+ if( SP->visibility)
181
+ {
182
+ extern HWND PDC_hWnd;
183
+ HDC hdc = GetDC( PDC_hWnd) ;
184
+
185
+ SP->curscol = col;
186
+ SP->cursrow = row;
187
+ redraw_cursor( hdc);
188
+ ReleaseDC( PDC_hWnd, hdc) ;
189
+ }
190
+ }
191
+
192
+ int PDC_font_size = 12;
193
+ TCHAR PDC_font_name[80];
194
+
195
+ static LOGFONT PDC_get_logical_font( const int font_idx)
196
+ {
197
+ LOGFONT lf;
198
+
199
+ memset(&lf, 0, sizeof(LOGFONT)); /* Clear out structure. */
200
+ lf.lfHeight = -PDC_font_size;
201
+ #ifdef PDC_WIDE
202
+ if( !*PDC_font_name)
203
+ wcscpy( PDC_font_name, _T("Courier New"));
204
+ if( font_idx & 4)
205
+ wcscpy( lf.lfFaceName, _T("Unifont"));
206
+ else
207
+ wcscpy( lf.lfFaceName, PDC_font_name );
208
+ /* wprintf( L"New font: %s\n", PDC_font_name); */
209
+ #else
210
+ if( !*PDC_font_name)
211
+ strcpy( PDC_font_name, "Courier New");
212
+ if( font_idx & 4)
213
+ strcpy( lf.lfFaceName, "Unifont");
214
+ else
215
+ strcpy( lf.lfFaceName, PDC_font_name);
216
+ #endif
217
+ /* lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN; */
218
+ lf.lfPitchAndFamily = FF_MODERN;
219
+ lf.lfWeight = ((font_idx & 1) ? FW_EXTRABOLD : FW_NORMAL);
220
+ lf.lfItalic = ((font_idx & 2) ? TRUE : FALSE);
221
+ lf.lfCharSet = ANSI_CHARSET;
222
+ lf.lfQuality = PROOF_QUALITY;
223
+ lf.lfOutPrecision = OUT_RASTER_PRECIS;
224
+ return( lf);
225
+ }
226
+
227
+ HFONT PDC_get_font_handle( const int font_idx)
228
+ {
229
+ LOGFONT lf = PDC_get_logical_font( font_idx);
230
+
231
+ return( CreateFontIndirect( &lf));
232
+ }
233
+
234
+ int debug_printf( const char *format, ...); /* pdcscrn.c */
235
+
236
+ int PDC_choose_a_new_font( void)
237
+ {
238
+ LOGFONT lf = PDC_get_logical_font( 0);
239
+ CHOOSEFONT cf;
240
+ int rval;
241
+ extern HWND PDC_hWnd;
242
+
243
+ lf.lfHeight = -PDC_font_size;
244
+ debug_printf( "In PDC_choose_a_new_font: %d\n", lf.lfHeight);
245
+ memset( &cf, 0, sizeof( CHOOSEFONT));
246
+ cf.lStructSize = sizeof( CHOOSEFONT);
247
+ cf.Flags = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
248
+ cf.hwndOwner = PDC_hWnd;
249
+ cf.lpLogFont = &lf;
250
+ cf.rgbColors = RGB( 0, 0, 0);
251
+ rval = ChooseFont( &cf);
252
+ if( rval)
253
+ #ifdef PDC_WIDE
254
+ wcscpy( PDC_font_name, lf.lfFaceName);
255
+ #else
256
+ strcpy( PDC_font_name, lf.lfFaceName);
257
+ #endif
258
+ debug_printf( "rval %d; %ld\n", rval, CommDlgExtendedError( ));
259
+ debug_printf( "output size: %d\n", lf.lfHeight);
260
+ PDC_font_size = -lf.lfHeight;
261
+ return( rval);
262
+ }
263
+
264
+ /* This function 'intensifies' a color by shifting it toward white. */
265
+ /* It used to average the input color with white. Then it did a */
266
+ /* weighted average: 2/3 of the input color, 1/3 white, for a */
267
+ /* lower "intensification" level. */
268
+ /* Then Mark Hessling suggested that the output level should */
269
+ /* remap zero to 85 (= 255 / 3, so one-third intensity), and input */
270
+ /* of 192 or greater should be remapped to 255 (full intensity). */
271
+ /* Assuming we want a linear response between zero and 192, that */
272
+ /* leads to output = 85 + input * (255-85)/192. */
273
+ /* This should lead to proper handling of bold text in legacy */
274
+ /* apps, where "bold" means "high intensity". */
275
+
276
+ static COLORREF intensified_color( COLORREF ival)
277
+ {
278
+ int rgb, i;
279
+ COLORREF oval = 0;
280
+
281
+ for( i = 0; i < 3; i++, ival >>= 8)
282
+ {
283
+ rgb = (int)( ival & 0xff);
284
+ if( rgb >= 192)
285
+ rgb = 255;
286
+ else
287
+ rgb = 85 + rgb * (255 - 85) / 192;
288
+ oval |= ((COLORREF)rgb << (i * 8));
289
+ }
290
+ return( oval);
291
+ }
292
+
293
+ /* For use in adjusting colors for A_DIMmed characters. Just */
294
+ /* knocks down the intensity of R, G, and B by 1/3. */
295
+
296
+ static COLORREF dimmed_color( COLORREF ival)
297
+ {
298
+ unsigned i;
299
+ COLORREF oval = 0;
300
+
301
+ for( i = 0; i < 3; i++, ival >>= 8)
302
+ {
303
+ unsigned rgb = (unsigned)( ival & 0xff);
304
+
305
+ rgb -= (rgb / 3);
306
+ oval |= ((COLORREF)rgb << (i * 8));
307
+ }
308
+ return( oval);
309
+ }
310
+
311
+ /* see 'addch.c' for an explanation of how combining chars are handled. */
312
+
313
+ #if defined( CHTYPE_LONG) && CHTYPE_LONG >= 2
314
+ #ifdef PDC_WIDE
315
+ #define USING_COMBINING_CHARACTER_SCHEME
316
+ int PDC_expand_combined_characters( const cchar_t c, cchar_t *added); /* addch.c */
317
+ #endif
318
+
319
+ /* PDC_get_rgb_values(), extract_packed_rgb(), intensified_component(), */
320
+ /* intensified_color(), and dimmed_color() each exist in x11/x11.c, */
321
+ /* wingui/pdcdisp.c, and sdl2/pdcdisp.c in forms slightly modified for */
322
+ /* each platform. But they all look pretty much alike. */
323
+
324
+ /* PDCurses stores RGBs in fifteen bits, five bits each */
325
+ /* for red, green, blue. A COLORREF uses eight bits per */
326
+ /* channel. Hence the following. */
327
+ static COLORREF extract_packed_rgb( const chtype color)
328
+ {
329
+ const int red = (int)( (color << 3) & 0xf8);
330
+ const int green = (int)( (color >> 2) & 0xf8);
331
+ const int blue = (int)( (color >> 7) & 0xf8);
332
+
333
+ return( RGB( red, green, blue));
334
+ }
335
+ #endif
336
+
337
+
338
+ void PDC_get_rgb_values( const chtype srcp,
339
+ COLORREF *foreground_rgb, COLORREF *background_rgb)
340
+ {
341
+ const int color = (int)(( srcp & A_COLOR) >> PDC_COLOR_SHIFT);
342
+ bool reverse_colors = ((srcp & A_REVERSE) ? TRUE : FALSE);
343
+ bool intensify_backgnd = FALSE;
344
+
345
+ #if defined( CHTYPE_LONG) && CHTYPE_LONG >= 2
346
+ if( srcp & A_RGB_COLOR)
347
+ {
348
+ /* Extract RGB from 30 bits of the color field */
349
+ *background_rgb = extract_packed_rgb( srcp >> PDC_COLOR_SHIFT);
350
+ *foreground_rgb = extract_packed_rgb( srcp >> (PDC_COLOR_SHIFT + 15));
351
+ }
352
+ else
353
+ #endif
354
+ {
355
+ extern COLORREF *pdc_rgbs;
356
+ short foreground_index, background_index;
357
+
358
+ PDC_pair_content( (short)color, &foreground_index, &background_index);
359
+ *foreground_rgb = pdc_rgbs[foreground_index];
360
+ *background_rgb = pdc_rgbs[background_index];
361
+ }
362
+
363
+ if( srcp & A_BLINK)
364
+ {
365
+ extern int PDC_really_blinking; /* see 'pdcsetsc.c' */
366
+ extern int PDC_blink_state;
367
+
368
+ if( !PDC_really_blinking) /* convert 'blinking' to 'bold' */
369
+ intensify_backgnd = TRUE;
370
+ else if( PDC_blink_state)
371
+ reverse_colors = !reverse_colors;
372
+ }
373
+ if( reverse_colors)
374
+ {
375
+ const COLORREF temp = *foreground_rgb;
376
+
377
+ *foreground_rgb = *background_rgb;
378
+ *background_rgb = temp;
379
+ }
380
+
381
+ if( srcp & A_BOLD)
382
+ *foreground_rgb = intensified_color( *foreground_rgb);
383
+ if( intensify_backgnd)
384
+ *background_rgb = intensified_color( *background_rgb);
385
+ if( srcp & A_DIM)
386
+ *foreground_rgb = dimmed_color( *foreground_rgb);
387
+ if( srcp & A_DIM)
388
+ *background_rgb = dimmed_color( *background_rgb);
389
+ }
390
+
391
+ #ifdef PDC_WIDE
392
+ const chtype MAX_UNICODE = 0x110000;
393
+ #endif
394
+
395
+ #ifdef USE_FALLBACK_FONT
396
+ GLYPHSET *PDC_unicode_range_data = NULL;
397
+
398
+ /* Note that in the following, if a character has a Unicode point
399
+ greater than 64K (i.e., it's not in the Basic Multilingual Plane),
400
+ we assume it has a glyph in the font. The problem is that, due to
401
+ the brain-dead implementation of Unicode in Windoze, we can't
402
+ actually tell if there is a glyph or not; the "range" data is 16-bit. */
403
+
404
+ static bool character_is_in_font( chtype ichar)
405
+ {
406
+ int i;
407
+ WCRANGE *wptr = PDC_unicode_range_data->ranges;
408
+
409
+ if( (ichar & A_ALTCHARSET) && (ichar & A_CHARTEXT) < 0x80)
410
+ ichar = acs_map[ichar & 0x7f];
411
+ ichar &= A_CHARTEXT;
412
+ if( ichar > MAX_UNICODE) /* assume combining chars won't be */
413
+ return( FALSE); /* supported; they rarely are */
414
+ if( ichar > 0xffff) /* see above comments */
415
+ return( TRUE);
416
+ for( i = PDC_unicode_range_data->cRanges; i; i--, wptr++)
417
+ if( wptr->wcLow > ichar)
418
+ return( FALSE);
419
+ else if( wptr->wcLow + wptr->cGlyphs > ichar)
420
+ return( TRUE);
421
+ /* Didn't find it in any range; it must not be in the font */
422
+ return( FALSE);
423
+ }
424
+ #endif /* #ifdef USE_FALLBACK_FONT */
425
+
426
+ /* update the given physical line to look like the corresponding line in
427
+ curscr.
428
+
429
+ NOTE that if x > 0, we decrement it and srcp, and increment the
430
+ length. In other words, we draw the preceding character, too. This
431
+ is done because, at certain font sizes, characters break out and
432
+ overwrite the preceding character. That results in debris left on
433
+ the screen.
434
+
435
+ The code also now increments the length only, drawing one more
436
+ character (i.e., draws the character following the "text we really
437
+ want"). Again, this helps to avoid debris left on the screen.
438
+
439
+ The 'ExtTextOut' function takes an lpDx array that specifies the exact
440
+ placement of each character relative to the previous character. This seems
441
+ to help avoid most (but not all) stray pixels from being displayed. The
442
+ problem is that, at certain font sizes, letters may be drawn that don't
443
+ fit properly in the clip rectangle; and they aren't actually clipped
444
+ correctly, despite the use of the ETO_CLIPPED flag. But things do seem
445
+ to be much better than was the case back when plain 'TextOut' was used. */
446
+
447
+ #define N_CACHED_FONTS 8
448
+
449
+ static HFONT hFonts[N_CACHED_FONTS];
450
+
451
+ #define BUFFSIZE 50
452
+
453
+ int PDC_find_ends_of_selected_text( const int line,
454
+ const RECT *rect, int *x); /* pdcscrn.c */
455
+
456
+ void PDC_transform_line_given_hdc( const HDC hdc, const int lineno,
457
+ int x, int len, const chtype *srcp)
458
+ {
459
+ HFONT hOldFont = (HFONT)0;
460
+ extern int PDC_cxChar, PDC_cyChar;
461
+ int i, curr_color = -1;
462
+ attr_t font_attrib = (attr_t)-1;
463
+ int cursor_overwritten = FALSE;
464
+ COLORREF foreground_rgb = 0;
465
+ chtype prev_ch = 0;
466
+ extern RECT PDC_mouse_rect; /* see 'pdcscrn.c' */
467
+ int selection[2];
468
+
469
+ if( !srcp) /* just freeing up fonts */
470
+ {
471
+ for( i = 0; i < N_CACHED_FONTS; i++)
472
+ if( hFonts[i])
473
+ {
474
+ DeleteObject( hFonts[i]);
475
+ hFonts[i] = NULL;
476
+ }
477
+ #ifdef USE_FALLBACK_FONT
478
+ if( PDC_unicode_range_data)
479
+ {
480
+ free( PDC_unicode_range_data);
481
+ PDC_unicode_range_data = NULL;
482
+ }
483
+ #endif
484
+ return;
485
+ }
486
+ /* Seems to me as if the input text to this function */
487
+ if( x < 0) /* should _never_ be off-screen. But it sometimes is. */
488
+ { /* Clipping is therefore necessary. */
489
+ len += x;
490
+ srcp -= x;
491
+ x = 0;
492
+ }
493
+ len++; /* draw an extra char to avoid leaving garbage on screen */
494
+ if( len > SP->cols - x)
495
+ len = SP->cols - x;
496
+ if( lineno >= SP->lines || len <= 0 || lineno < 0)
497
+ return;
498
+ if( x) /* back up by one character to avoid */
499
+ { /* leaving garbage on the screen */
500
+ x--;
501
+ len++;
502
+ srcp--;
503
+ }
504
+ if( lineno == SP->cursrow && SP->curscol >= x && SP->curscol < x + len)
505
+ if( PDC_current_cursor_state( ))
506
+ cursor_overwritten = TRUE;
507
+
508
+
509
+ while( len)
510
+ {
511
+ extern int PDC_really_blinking; /* see 'pdcsetsc.c' */
512
+ const attr_t attrib = (attr_t)( *srcp >> PDC_REAL_ATTR_SHIFT);
513
+ const int color = (int)(( *srcp & A_COLOR) >> PDC_COLOR_SHIFT);
514
+ attr_t new_font_attrib = (*srcp & (A_BOLD | A_ITALIC));
515
+ RECT clip_rect;
516
+ wchar_t buff[BUFFSIZE];
517
+ int lpDx[BUFFSIZE + 1];
518
+ int olen = 0;
519
+ #ifdef USE_FALLBACK_FONT
520
+ const bool in_font = character_is_in_font( *srcp);
521
+ #endif
522
+
523
+ for( i = 0; i < len && olen < BUFFSIZE - 1
524
+ #ifdef USE_FALLBACK_FONT
525
+ && (in_font == character_is_in_font( srcp[i])
526
+ || (srcp[i] & A_CHARTEXT) == MAX_UNICODE)
527
+ #endif
528
+ && attrib == (attr_t)( srcp[i] >> PDC_REAL_ATTR_SHIFT); i++)
529
+ {
530
+ chtype ch = srcp[i] & A_CHARTEXT;
531
+
532
+ #if( defined( PDC_WIDE) && defined( CHTYPE_LONG))
533
+ if( ch > 0xffff && ch < MAX_UNICODE) /* use Unicode surrogates to fit */
534
+ { /* >64K values into 16-bit wchar_t: */
535
+ ch -= 0x10000;
536
+ buff[olen] = (wchar_t)( 0xd800 | (ch >> 10));
537
+ lpDx[olen] = 0; /* ^ upper 10 bits */
538
+ olen++;
539
+ ch = (wchar_t)( 0xdc00 | (ch & 0x3ff)); /* lower 10 bits */
540
+ }
541
+ #if( CHTYPE_LONG >= 2) /* "non-standard" 64-bit chtypes; combining */
542
+ if( ch > MAX_UNICODE) /* chars & fullwidth supported */
543
+ {
544
+ cchar_t added[10], root = ch;
545
+ int n_combined = 0;
546
+
547
+ while( (root = PDC_expand_combined_characters( root,
548
+ &added[n_combined])) > MAX_UNICODE)
549
+ {
550
+ n_combined++;
551
+ }
552
+ buff[olen] = (wchar_t)root;
553
+ lpDx[olen] = 0;
554
+ olen++;
555
+ ch = (wchar_t)added[n_combined];
556
+ while( n_combined)
557
+ {
558
+ n_combined--;
559
+ buff[olen] = (wchar_t)added[n_combined];
560
+ lpDx[olen] = 0;
561
+ olen++;
562
+ }
563
+ }
564
+ #endif
565
+ #endif
566
+ if( (srcp[i] & A_ALTCHARSET) && ch < 0x80)
567
+ ch = acs_map[ch & 0x7f];
568
+ else if( ch < 32)
569
+ ch = starting_ascii_to_unicode[ch];
570
+ #ifndef PDC_WIDE /* If we're in Unicode, assume */
571
+ else if( ch <= 0xff) /* the incoming text doesn't need */
572
+ { /* code-page translation */
573
+ char c = (char)ch;
574
+ wchar_t z;
575
+
576
+ mbtowc( &z, &c, 1);
577
+ ch = (chtype)z;
578
+ }
579
+ assert( "We should never get here");
580
+ #endif
581
+ buff[olen] = (wchar_t)ch;
582
+ lpDx[olen] = PDC_cxChar;
583
+ #ifdef PDC_WIDE
584
+ if( ch != MAX_UNICODE)
585
+ olen++;
586
+ else if( olen) /* prev char is double-width */
587
+ lpDx[olen - 1] = 2 * PDC_cxChar;
588
+ #else
589
+ olen++;
590
+ #endif
591
+ }
592
+ lpDx[olen] = PDC_cxChar;
593
+ if( color != curr_color || ((prev_ch ^ *srcp) & (A_REVERSE | A_BLINK | A_BOLD | A_DIM)))
594
+ {
595
+ COLORREF background_rgb;
596
+
597
+ PDC_get_rgb_values( *srcp, &foreground_rgb, &background_rgb);
598
+ curr_color = color;
599
+ SetTextColor( hdc, foreground_rgb);
600
+ SetBkColor( hdc, background_rgb);
601
+ }
602
+ if( !PDC_really_blinking && (*srcp & A_BLINK))
603
+ new_font_attrib &= ~A_BLINK;
604
+ #ifdef USE_FALLBACK_FONT
605
+ if( !in_font) /* flag to indicate use of */
606
+ new_font_attrib |= 1; /* fallback font */
607
+ #endif
608
+ if( new_font_attrib != font_attrib)
609
+ {
610
+ HFONT hFont;
611
+ int idx = 0;
612
+
613
+ font_attrib = new_font_attrib;
614
+ if( font_attrib & A_BOLD)
615
+ idx |= 1;
616
+ if( font_attrib & A_ITALIC)
617
+ idx |= 2;
618
+ if( font_attrib & 1) /* use Unifont or other fallback font */
619
+ idx |= 4;
620
+ if( !hFonts[idx])
621
+ hFonts[idx] = PDC_get_font_handle( idx);
622
+ hFont = SelectObject( hdc, hFonts[idx]);
623
+ if( !hOldFont)
624
+ hOldFont = hFont;
625
+ }
626
+ prev_ch = *srcp;
627
+ clip_rect.left = x * PDC_cxChar;
628
+ clip_rect.top = lineno * PDC_cyChar;
629
+ clip_rect.right = clip_rect.left + i * PDC_cxChar;
630
+ clip_rect.bottom = clip_rect.top + PDC_cyChar;
631
+ ExtTextOutW( hdc, clip_rect.left, clip_rect.top,
632
+ ETO_CLIPPED | ETO_OPAQUE, &clip_rect,
633
+ buff, olen, (olen > 1 ? lpDx : NULL));
634
+ #ifdef A_OVERLINE
635
+ if( *srcp & (A_UNDERLINE | A_RIGHTLINE | A_LEFTLINE | A_OVERLINE | A_STRIKEOUT))
636
+ #else
637
+ if( *srcp & (A_UNDERLINE | A_RIGHTLINE | A_LEFTLINE))
638
+ #endif
639
+ {
640
+ const int y1 = clip_rect.top;
641
+ const int y2 = clip_rect.bottom - 1;
642
+ const int x1 = clip_rect.left;
643
+ const int x2 = clip_rect.right;
644
+ int j;
645
+ extern COLORREF *pdc_rgbs;
646
+ const HPEN pen = CreatePen( PS_SOLID, 1, (SP->line_color == -1 ?
647
+ foreground_rgb : pdc_rgbs[SP->line_color]));
648
+ const HPEN old_pen = SelectObject( hdc, pen);
649
+
650
+ if( *srcp & A_UNDERLINE)
651
+ {
652
+ MoveToEx( hdc, x1, y2, NULL);
653
+ LineTo( hdc, x2, y2);
654
+ }
655
+ #ifdef A_OVERLINE
656
+ if( *srcp & A_OVERLINE)
657
+ {
658
+ MoveToEx( hdc, x1, y1, NULL);
659
+ LineTo( hdc, x2, y1);
660
+ }
661
+ if( *srcp & A_STRIKEOUT)
662
+ {
663
+ MoveToEx( hdc, x1, (y1 + y2) / 2, NULL);
664
+ LineTo( hdc, x2, (y1 + y2) / 2);
665
+ }
666
+ #endif
667
+ if( *srcp & A_RIGHTLINE)
668
+ for( j = 0; j < i; j++)
669
+ {
670
+ MoveToEx( hdc, x2 - j * PDC_cxChar - 1, y1, NULL);
671
+ LineTo( hdc, x2 - j * PDC_cxChar - 1, y2);
672
+ }
673
+ if( *srcp & A_LEFTLINE)
674
+ for( j = 0; j < i; j++)
675
+ {
676
+ MoveToEx( hdc, x1 + j * PDC_cxChar, y1, NULL);
677
+ LineTo( hdc, x1 + j * PDC_cxChar, y2);
678
+ }
679
+ SelectObject( hdc, old_pen);
680
+ DeleteObject( pen);
681
+ }
682
+ if( PDC_find_ends_of_selected_text( lineno, &PDC_mouse_rect, selection))
683
+ if( x <= selection[1] + 1 && x + i >= selection[0])
684
+ {
685
+ RECT rect;
686
+
687
+ rect.top = lineno * PDC_cyChar;
688
+ rect.bottom = rect.top + PDC_cyChar;
689
+ rect.right = max( x, selection[0]);
690
+ rect.left = min( x + i, selection[1] + 1);
691
+ rect.right *= PDC_cxChar;
692
+ rect.left *= PDC_cxChar;
693
+ InvertRect( hdc, &rect);
694
+ }
695
+ len -= i;
696
+ x += i;
697
+ srcp += i;
698
+ }
699
+ SelectObject( hdc, hOldFont);
700
+ /* ...did we step on the cursor? If so, redraw it: */
701
+ if( cursor_overwritten)
702
+ redraw_cursor( hdc);
703
+ }
704
+
705
+ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
706
+ {
707
+ if( !srcp) /* just freeing up fonts */
708
+ PDC_transform_line_given_hdc( 0, 0, 0, 0, NULL);
709
+ else
710
+ {
711
+ extern HWND PDC_hWnd;
712
+ const HDC hdc = GetDC( PDC_hWnd) ;
713
+
714
+ PDC_transform_line_given_hdc( hdc, lineno, x, len, srcp);
715
+ ReleaseDC( PDC_hWnd, hdc);
716
+ }
717
+ }
718
+