curses 1.3.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (262) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +19 -0
  3. data/.github/workflows/ubuntu.yml +26 -0
  4. data/.github/workflows/windows.yml +25 -0
  5. data/History.md +27 -0
  6. data/README.md +14 -46
  7. data/Rakefile +0 -86
  8. data/curses.gemspec +3 -4
  9. data/ext/curses/curses.c +194 -38
  10. data/ext/curses/extconf.rb +81 -22
  11. data/lib/curses.rb +5 -12
  12. data/sample/addch.rb +16 -0
  13. data/sample/attr_demo.rb +32 -0
  14. data/sample/colors.rb +26 -0
  15. data/sample/mouse_move.rb +75 -0
  16. data/vendor/PDCurses/.gitignore +47 -0
  17. data/vendor/PDCurses/.travis.yml +49 -0
  18. data/vendor/PDCurses/CMakeLists.txt +68 -0
  19. data/vendor/PDCurses/HISTORY.md +2036 -0
  20. data/vendor/PDCurses/IMPLEMNT.md +327 -0
  21. data/vendor/PDCurses/Makefile +27 -0
  22. data/vendor/PDCurses/README.md +77 -0
  23. data/vendor/PDCurses/acs_defs.h +265 -0
  24. data/vendor/PDCurses/appveyor.yml +218 -0
  25. data/vendor/PDCurses/cmake/README.md +71 -0
  26. data/vendor/PDCurses/cmake/build_dependencies.cmake +178 -0
  27. data/vendor/PDCurses/cmake/build_options.cmake +25 -0
  28. data/vendor/PDCurses/cmake/dll_version.cmake +26 -0
  29. data/vendor/PDCurses/cmake/gen_config_header.cmake +43 -0
  30. data/vendor/PDCurses/cmake/get_version.cmake +17 -0
  31. data/vendor/PDCurses/cmake/make_uninstall.cmake +19 -0
  32. data/vendor/PDCurses/cmake/project_common.cmake +121 -0
  33. data/vendor/PDCurses/cmake/resource.in.cmake +52 -0
  34. data/vendor/PDCurses/cmake/sdl2_ttf/CMakeLists.txt +83 -0
  35. data/vendor/PDCurses/cmake/target_arch.cmake +36 -0
  36. data/vendor/PDCurses/cmake/version.in.cmake +73 -0
  37. data/vendor/PDCurses/cmake/watcom_open_dos16_toolchain.cmake +96 -0
  38. data/vendor/PDCurses/cmake/watcom_open_dos32_toolchain.cmake +106 -0
  39. data/vendor/PDCurses/cmake/watcom_open_os2v2_toolchain.cmake +105 -0
  40. data/vendor/PDCurses/curses.h +1846 -0
  41. data/vendor/PDCurses/curspriv.h +134 -0
  42. data/vendor/PDCurses/demos/README.md +25 -0
  43. data/vendor/PDCurses/demos/firework.c +144 -0
  44. data/vendor/PDCurses/demos/newtest.c +581 -0
  45. data/vendor/PDCurses/demos/ozdemo.c +447 -0
  46. data/vendor/PDCurses/demos/ptest.c +283 -0
  47. data/vendor/PDCurses/demos/rain.c +157 -0
  48. data/vendor/PDCurses/demos/testcurs.c +1607 -0
  49. data/vendor/PDCurses/demos/tui.c +1048 -0
  50. data/vendor/PDCurses/demos/tui.h +65 -0
  51. data/vendor/PDCurses/demos/tuidemo.c +233 -0
  52. data/vendor/PDCurses/demos/version.c +61 -0
  53. data/vendor/PDCurses/demos/worm.c +432 -0
  54. data/vendor/PDCurses/demos/xmas.c +955 -0
  55. data/vendor/PDCurses/dos/CMakeLists.txt +47 -0
  56. data/vendor/PDCurses/dos/Makefile +105 -0
  57. data/vendor/PDCurses/dos/Makefile.bcc +83 -0
  58. data/vendor/PDCurses/dos/Makefile.dmc +257 -0
  59. data/vendor/PDCurses/dos/Makefile.msc +113 -0
  60. data/vendor/PDCurses/dos/Makefile.wcc +107 -0
  61. data/vendor/PDCurses/dos/README.md +51 -0
  62. data/vendor/PDCurses/dos/bccdos.lrf +9 -0
  63. data/vendor/PDCurses/dos/mscdos.lrf +50 -0
  64. data/vendor/PDCurses/dos/pdcclip.c +132 -0
  65. data/vendor/PDCurses/dos/pdcdisp.c +135 -0
  66. data/vendor/PDCurses/dos/pdcdos.h +194 -0
  67. data/vendor/PDCurses/dos/pdcgetsc.c +98 -0
  68. data/vendor/PDCurses/dos/pdckbd.c +513 -0
  69. data/vendor/PDCurses/dos/pdcscrn.c +785 -0
  70. data/vendor/PDCurses/dos/pdcsetsc.c +101 -0
  71. data/vendor/PDCurses/dos/pdcutil.c +212 -0
  72. data/vendor/PDCurses/libobjs.mif +26 -0
  73. data/vendor/PDCurses/makedist.mif +20 -0
  74. data/vendor/PDCurses/man/Makefile +37 -0
  75. data/vendor/PDCurses/man/README.md +21 -0
  76. data/vendor/PDCurses/man/intro.md +361 -0
  77. data/vendor/PDCurses/man/manext.c +119 -0
  78. data/vendor/PDCurses/man/sdl.md +152 -0
  79. data/vendor/PDCurses/man/sdl2.md +58 -0
  80. data/vendor/PDCurses/man/x11.md +407 -0
  81. data/vendor/PDCurses/ncurses/CMakeLists.txt +66 -0
  82. data/vendor/PDCurses/ncurses/README.md +26 -0
  83. data/vendor/PDCurses/ncurses/makefile +29 -0
  84. data/vendor/PDCurses/os2/CMakeLists.txt +41 -0
  85. data/vendor/PDCurses/os2/Makefile +132 -0
  86. data/vendor/PDCurses/os2/Makefile.bcc +90 -0
  87. data/vendor/PDCurses/os2/Makefile.wcc +43 -0
  88. data/vendor/PDCurses/os2/README.md +43 -0
  89. data/vendor/PDCurses/os2/iccos2.lrf +50 -0
  90. data/vendor/PDCurses/os2/iccos2.mak +256 -0
  91. data/vendor/PDCurses/os2/pdcclip.c +188 -0
  92. data/vendor/PDCurses/os2/pdcdisp.c +93 -0
  93. data/vendor/PDCurses/os2/pdcgetsc.c +89 -0
  94. data/vendor/PDCurses/os2/pdckbd.c +521 -0
  95. data/vendor/PDCurses/os2/pdcos2.h +55 -0
  96. data/vendor/PDCurses/os2/pdcscrn.c +449 -0
  97. data/vendor/PDCurses/os2/pdcsetsc.c +112 -0
  98. data/vendor/PDCurses/os2/pdcutil.c +52 -0
  99. data/vendor/PDCurses/panel.h +56 -0
  100. data/vendor/PDCurses/pdcurses/README.md +25 -0
  101. data/vendor/PDCurses/pdcurses/addch.c +693 -0
  102. data/vendor/PDCurses/pdcurses/addchstr.c +245 -0
  103. data/vendor/PDCurses/pdcurses/addstr.c +240 -0
  104. data/vendor/PDCurses/pdcurses/attr.c +359 -0
  105. data/vendor/PDCurses/pdcurses/beep.c +68 -0
  106. data/vendor/PDCurses/pdcurses/bkgd.c +223 -0
  107. data/vendor/PDCurses/pdcurses/border.c +411 -0
  108. data/vendor/PDCurses/pdcurses/clear.c +159 -0
  109. data/vendor/PDCurses/pdcurses/color.c +298 -0
  110. data/vendor/PDCurses/pdcurses/debug.c +109 -0
  111. data/vendor/PDCurses/pdcurses/delch.c +96 -0
  112. data/vendor/PDCurses/pdcurses/deleteln.c +211 -0
  113. data/vendor/PDCurses/pdcurses/deprec.c +27 -0
  114. data/vendor/PDCurses/pdcurses/getch.c +417 -0
  115. data/vendor/PDCurses/pdcurses/getstr.c +474 -0
  116. data/vendor/PDCurses/pdcurses/getyx.c +139 -0
  117. data/vendor/PDCurses/pdcurses/inch.c +127 -0
  118. data/vendor/PDCurses/pdcurses/inchstr.c +214 -0
  119. data/vendor/PDCurses/pdcurses/initscr.c +367 -0
  120. data/vendor/PDCurses/pdcurses/inopts.c +324 -0
  121. data/vendor/PDCurses/pdcurses/insch.c +271 -0
  122. data/vendor/PDCurses/pdcurses/insstr.c +264 -0
  123. data/vendor/PDCurses/pdcurses/instr.c +246 -0
  124. data/vendor/PDCurses/pdcurses/kernel.c +259 -0
  125. data/vendor/PDCurses/pdcurses/keyname.c +157 -0
  126. data/vendor/PDCurses/pdcurses/mouse.c +438 -0
  127. data/vendor/PDCurses/pdcurses/move.c +57 -0
  128. data/vendor/PDCurses/pdcurses/outopts.c +159 -0
  129. data/vendor/PDCurses/pdcurses/overlay.c +214 -0
  130. data/vendor/PDCurses/pdcurses/pad.c +260 -0
  131. data/vendor/PDCurses/pdcurses/panel.c +633 -0
  132. data/vendor/PDCurses/pdcurses/printw.c +126 -0
  133. data/vendor/PDCurses/pdcurses/refresh.c +279 -0
  134. data/vendor/PDCurses/pdcurses/scanw.c +578 -0
  135. data/vendor/PDCurses/pdcurses/scr_dump.c +213 -0
  136. data/vendor/PDCurses/pdcurses/scroll.c +101 -0
  137. data/vendor/PDCurses/pdcurses/slk.c +591 -0
  138. data/vendor/PDCurses/pdcurses/termattr.c +182 -0
  139. data/vendor/PDCurses/pdcurses/terminfo.c +217 -0
  140. data/vendor/PDCurses/pdcurses/touch.c +163 -0
  141. data/vendor/PDCurses/pdcurses/util.c +312 -0
  142. data/vendor/PDCurses/pdcurses/window.c +569 -0
  143. data/vendor/PDCurses/sdl1/Makefile +129 -0
  144. data/vendor/PDCurses/sdl1/Makefile.mng +110 -0
  145. data/vendor/PDCurses/sdl1/README.md +31 -0
  146. data/vendor/PDCurses/sdl1/deffont.h +385 -0
  147. data/vendor/PDCurses/sdl1/deficon.h +23 -0
  148. data/vendor/PDCurses/sdl1/pdcclip.c +131 -0
  149. data/vendor/PDCurses/sdl1/pdcdisp.c +373 -0
  150. data/vendor/PDCurses/sdl1/pdcgetsc.c +30 -0
  151. data/vendor/PDCurses/sdl1/pdckbd.c +405 -0
  152. data/vendor/PDCurses/sdl1/pdcscrn.c +414 -0
  153. data/vendor/PDCurses/sdl1/pdcsdl.h +31 -0
  154. data/vendor/PDCurses/sdl1/pdcsetsc.c +64 -0
  155. data/vendor/PDCurses/sdl1/pdcutil.c +40 -0
  156. data/vendor/PDCurses/sdl1/sdltest.c +79 -0
  157. data/vendor/PDCurses/sdl2/CMakeLists.txt +76 -0
  158. data/vendor/PDCurses/sdl2/Makefile +135 -0
  159. data/vendor/PDCurses/sdl2/Makefile.vc +164 -0
  160. data/vendor/PDCurses/sdl2/README.md +34 -0
  161. data/vendor/PDCurses/sdl2/deffont.h +385 -0
  162. data/vendor/PDCurses/sdl2/deficon.h +23 -0
  163. data/vendor/PDCurses/sdl2/pdcclip.c +93 -0
  164. data/vendor/PDCurses/sdl2/pdcdisp.c +534 -0
  165. data/vendor/PDCurses/sdl2/pdcgetsc.c +30 -0
  166. data/vendor/PDCurses/sdl2/pdckbd.c +480 -0
  167. data/vendor/PDCurses/sdl2/pdcscrn.c +443 -0
  168. data/vendor/PDCurses/sdl2/pdcsdl.h +33 -0
  169. data/vendor/PDCurses/sdl2/pdcsetsc.c +67 -0
  170. data/vendor/PDCurses/sdl2/pdcutil.c +39 -0
  171. data/vendor/PDCurses/sdl2/sdltest.c +81 -0
  172. data/vendor/PDCurses/term.h +48 -0
  173. data/vendor/PDCurses/version.mif +7 -0
  174. data/vendor/PDCurses/vt/CMakeLists.txt +28 -0
  175. data/vendor/PDCurses/vt/Makefile +135 -0
  176. data/vendor/PDCurses/vt/Makefile.bcc +111 -0
  177. data/vendor/PDCurses/vt/Makefile.dmc +258 -0
  178. data/vendor/PDCurses/vt/Makefile.vc +144 -0
  179. data/vendor/PDCurses/vt/Makefile.wcc +107 -0
  180. data/vendor/PDCurses/vt/README.md +64 -0
  181. data/vendor/PDCurses/vt/pdcclip.c +20 -0
  182. data/vendor/PDCurses/vt/pdcdisp.c +284 -0
  183. data/vendor/PDCurses/vt/pdcgetsc.c +27 -0
  184. data/vendor/PDCurses/vt/pdckbd.c +394 -0
  185. data/vendor/PDCurses/vt/pdcscrn.c +434 -0
  186. data/vendor/PDCurses/vt/pdcsetsc.c +45 -0
  187. data/vendor/PDCurses/vt/pdcutil.c +43 -0
  188. data/vendor/PDCurses/vt/pdcvt.h +16 -0
  189. data/vendor/PDCurses/watcom.mif +68 -0
  190. data/vendor/PDCurses/wincon/CMakeLists.txt +27 -0
  191. data/vendor/PDCurses/wincon/Makefile.bcc +88 -0
  192. data/vendor/PDCurses/wincon/Makefile.dmc +256 -0
  193. data/vendor/PDCurses/wincon/Makefile.lcc +273 -0
  194. data/vendor/PDCurses/wincon/Makefile.mng +176 -0
  195. data/vendor/PDCurses/wincon/Makefile.vc +144 -0
  196. data/vendor/PDCurses/wincon/Makefile.wcc +51 -0
  197. data/vendor/PDCurses/wincon/README.md +85 -0
  198. data/vendor/PDCurses/wincon/pdcclip.c +174 -0
  199. data/vendor/PDCurses/wincon/pdcdisp.c +143 -0
  200. data/vendor/PDCurses/wincon/pdcgetsc.c +55 -0
  201. data/vendor/PDCurses/wincon/pdckbd.c +786 -0
  202. data/vendor/PDCurses/wincon/pdcscrn.c +717 -0
  203. data/vendor/PDCurses/wincon/pdcsetsc.c +91 -0
  204. data/vendor/PDCurses/wincon/pdcurses.ico +0 -0
  205. data/vendor/PDCurses/wincon/pdcurses.rc +28 -0
  206. data/vendor/PDCurses/wincon/pdcutil.c +41 -0
  207. data/vendor/PDCurses/wincon/pdcwin.h +31 -0
  208. data/vendor/PDCurses/wingui/CMakeLists.txt +27 -0
  209. data/vendor/PDCurses/wingui/Makefile.bcc +85 -0
  210. data/vendor/PDCurses/wingui/Makefile.dmc +259 -0
  211. data/vendor/PDCurses/wingui/Makefile.lcc +273 -0
  212. data/vendor/PDCurses/wingui/Makefile.mng +171 -0
  213. data/vendor/PDCurses/wingui/Makefile.vc +144 -0
  214. data/vendor/PDCurses/wingui/Makefile.wcc +51 -0
  215. data/vendor/PDCurses/wingui/README.md +93 -0
  216. data/vendor/PDCurses/wingui/pdcclip.c +174 -0
  217. data/vendor/PDCurses/wingui/pdcdisp.c +718 -0
  218. data/vendor/PDCurses/wingui/pdcgetsc.c +30 -0
  219. data/vendor/PDCurses/wingui/pdckbd.c +143 -0
  220. data/vendor/PDCurses/wingui/pdcscrn.c +2797 -0
  221. data/vendor/PDCurses/wingui/pdcsetsc.c +89 -0
  222. data/vendor/PDCurses/wingui/pdcurses.ico +0 -0
  223. data/vendor/PDCurses/wingui/pdcurses.rc +28 -0
  224. data/vendor/PDCurses/wingui/pdcutil.c +61 -0
  225. data/vendor/PDCurses/wingui/pdcwin.h +122 -0
  226. data/vendor/PDCurses/x11/Makefile.in +754 -0
  227. data/vendor/PDCurses/x11/PDCurses.spec +82 -0
  228. data/vendor/PDCurses/x11/README.md +62 -0
  229. data/vendor/PDCurses/x11/ScrollBox.c +319 -0
  230. data/vendor/PDCurses/x11/ScrollBox.h +51 -0
  231. data/vendor/PDCurses/x11/ScrollBoxP.h +70 -0
  232. data/vendor/PDCurses/x11/aclocal.m4 +994 -0
  233. data/vendor/PDCurses/x11/big_icon.xbm +46 -0
  234. data/vendor/PDCurses/x11/compose.h +201 -0
  235. data/vendor/PDCurses/x11/config.guess +1500 -0
  236. data/vendor/PDCurses/x11/config.h.in +100 -0
  237. data/vendor/PDCurses/x11/config.sub +1616 -0
  238. data/vendor/PDCurses/x11/configure +6700 -0
  239. data/vendor/PDCurses/x11/configure.ac +295 -0
  240. data/vendor/PDCurses/x11/debian/changelog +6 -0
  241. data/vendor/PDCurses/x11/debian/compat +1 -0
  242. data/vendor/PDCurses/x11/debian/control +11 -0
  243. data/vendor/PDCurses/x11/debian/copyright +27 -0
  244. data/vendor/PDCurses/x11/debian/rules +98 -0
  245. data/vendor/PDCurses/x11/install-sh +253 -0
  246. data/vendor/PDCurses/x11/little_icon.xbm +14 -0
  247. data/vendor/PDCurses/x11/ncurses_cfg.h +45 -0
  248. data/vendor/PDCurses/x11/pdcclip.c +173 -0
  249. data/vendor/PDCurses/x11/pdcdisp.c +85 -0
  250. data/vendor/PDCurses/x11/pdcgetsc.c +28 -0
  251. data/vendor/PDCurses/x11/pdckbd.c +104 -0
  252. data/vendor/PDCurses/x11/pdcscrn.c +258 -0
  253. data/vendor/PDCurses/x11/pdcsetsc.c +95 -0
  254. data/vendor/PDCurses/x11/pdcutil.c +52 -0
  255. data/vendor/PDCurses/x11/pdcx11.c +316 -0
  256. data/vendor/PDCurses/x11/pdcx11.h +191 -0
  257. data/vendor/PDCurses/x11/sb.c +155 -0
  258. data/vendor/PDCurses/x11/x11.c +3686 -0
  259. data/vendor/PDCurses/x11/xcurses-config.in +81 -0
  260. metadata +259 -25
  261. data/.travis.yml +0 -16
  262. data/appveyor.yml +0 -16
@@ -0,0 +1,534 @@
1
+ /* Public Domain Curses */
2
+
3
+ #include "pdcsdl.h"
4
+
5
+ #include <stdlib.h>
6
+ #include <stdint.h>
7
+ #include <string.h>
8
+
9
+ #ifdef CHTYPE_LONG
10
+ # ifdef PDC_WIDE
11
+ # define USE_UNICODE_ACS_CHARS 1
12
+ # else
13
+ # define USE_UNICODE_ACS_CHARS 0
14
+ # endif
15
+ # include "acs_defs.h"
16
+ #endif
17
+
18
+ /* see 'addch.c' for an explanation of how combining chars are handled. */
19
+
20
+ #if defined( CHTYPE_LONG) && CHTYPE_LONG >= 2 && defined( PDC_WIDE)
21
+ #define USING_COMBINING_CHARACTER_SCHEME
22
+ #define MAX_UNICODE 0x10ffff
23
+ #define DUMMY_CHAR_NEXT_TO_FULLWIDTH (MAX_UNICODE + 1)
24
+ int PDC_expand_combined_characters( const cchar_t c, cchar_t *added); /* addch.c */
25
+ #endif
26
+
27
+ Uint32 pdc_lastupdate = 0;
28
+ int PDC_really_blinking = FALSE;
29
+ static bool PDC_blink_state = FALSE;
30
+
31
+ #define MAXRECT 200 /* maximum number of rects to queue up before
32
+ an update is forced; the number was chosen
33
+ arbitrarily */
34
+
35
+ static SDL_Rect uprect[MAXRECT]; /* table of rects to update */
36
+ static int rectcount = 0; /* index into uprect */
37
+ static SDL_Color foreground_rgb, background_rgb; /* current foreground, background */
38
+
39
+ /* do the real updates on a delay */
40
+
41
+ void PDC_update_rects(void)
42
+ {
43
+ if (rectcount)
44
+ {
45
+ /* if the maximum number of rects has been reached, we're
46
+ probably better off doing a full screen update */
47
+
48
+ if (rectcount == MAXRECT)
49
+ SDL_UpdateWindowSurface(pdc_window);
50
+ else
51
+ SDL_UpdateWindowSurfaceRects(pdc_window, uprect, rectcount);
52
+
53
+ pdc_lastupdate = SDL_GetTicks();
54
+ rectcount = 0;
55
+ }
56
+ }
57
+
58
+ /* PDC_get_rgb_values(), extract_packed_rgb(), intensified_component(), */
59
+ /* intensified_color(), and dimmed_color() each exist in x11/x11.c, */
60
+ /* win32a/pdcdisp.c, and sdl2/pdcdisp.c in forms slightly modified for */
61
+ /* each platform. But they all look pretty much alike. */
62
+
63
+ #if defined( CHTYPE_LONG) && CHTYPE_LONG >= 2
64
+ /* PDCurses stores RGBs in fifteen bits, five bits each */
65
+ /* for red, green, blue. A Pixel uses eight bits per */
66
+ /* channel. Hence the following. */
67
+ static SDL_Color extract_packed_rgb( const chtype color)
68
+ {
69
+ SDL_Color rval;
70
+
71
+ rval.r = (Uint8)( (color << 3) & 0xf8);
72
+ rval.g = (Uint8)( (color >> 2) & 0xf8);
73
+ rval.b = (Uint8)( (color >> 7) & 0xf8);
74
+ rval.a = (Uint8)255;
75
+ return rval;
76
+ }
77
+ #endif
78
+
79
+ /* This function 'intensifies' a color by shifting it toward white. */
80
+ /* It used to average the input color with white. Then it did a */
81
+ /* weighted average: 2/3 of the input color, 1/3 white, for a */
82
+ /* lower "intensification" level. */
83
+ /* Then Mark Hessling suggested that the output level should */
84
+ /* remap zero to 85 (= 255 / 3, so one-third intensity), and input */
85
+ /* of 192 or greater should be remapped to 255 (full intensity). */
86
+ /* Assuming we want a linear response between zero and 192, that */
87
+ /* leads to output = 85 + input * (255-85)/192. */
88
+ /* This should lead to proper handling of bold text in legacy */
89
+ /* apps, where "bold" means "high intensity". */
90
+
91
+ static Uint8 intensified_component( Uint8 component)
92
+ {
93
+ if( component >= 192)
94
+ component = 255;
95
+ else
96
+ component = 85 + component * (255 - 85) / 192;
97
+ return( component);
98
+ }
99
+
100
+ static SDL_Color intensified_color( SDL_Color ival)
101
+ {
102
+ SDL_Color oval;
103
+
104
+ oval.r = intensified_component( ival.r);
105
+ oval.g = intensified_component( ival.g);
106
+ oval.b = intensified_component( ival.b);
107
+ return( oval);
108
+ }
109
+
110
+ /* For use in adjusting colors for A_DIMmed characters. Just */
111
+ /* knocks down the intensity of R, G, and B by 1/3. */
112
+
113
+ static SDL_Color dimmed_color( SDL_Color ival)
114
+ {
115
+ ival.r -= ival.r / 3;
116
+ ival.g -= ival.g / 3;
117
+ ival.b -= ival.b / 3;
118
+ return( ival);
119
+ }
120
+
121
+ void PDC_get_rgb_values( const chtype srcp,
122
+ SDL_Color *fore_rgb, SDL_Color *back_rgb)
123
+ {
124
+ bool reverse_colors = ((srcp & A_REVERSE) ? TRUE : FALSE);
125
+ bool intensify_backgnd = FALSE;
126
+
127
+ #if defined( CHTYPE_LONG) && CHTYPE_LONG >= 2
128
+ if( srcp & A_RGB_COLOR)
129
+ {
130
+ /* Extract RGB from 30 bits of the color field */
131
+ *back_rgb = extract_packed_rgb( srcp >> PDC_COLOR_SHIFT);
132
+ *fore_rgb = extract_packed_rgb( srcp >> (PDC_COLOR_SHIFT + 15));
133
+ }
134
+ else
135
+ #endif
136
+ {
137
+ short foreground_index, background_index;
138
+
139
+ PDC_pair_content( PAIR_NUMBER( srcp), &foreground_index, &background_index);
140
+ *fore_rgb = pdc_color[foreground_index];
141
+ if( background_index >= 0)
142
+ *back_rgb = pdc_color[background_index];
143
+ }
144
+
145
+ if( srcp & A_BLINK)
146
+ {
147
+ if( !PDC_really_blinking) /* convert 'blinking' to 'bold' */
148
+ intensify_backgnd = TRUE;
149
+ else if( PDC_blink_state)
150
+ reverse_colors = !reverse_colors;
151
+ }
152
+ if( reverse_colors)
153
+ {
154
+ const SDL_Color temp = *fore_rgb;
155
+
156
+ *fore_rgb = *back_rgb;
157
+ *back_rgb = temp;
158
+ }
159
+
160
+ if( srcp & A_BOLD)
161
+ *fore_rgb = intensified_color( *fore_rgb);
162
+ if( intensify_backgnd)
163
+ *back_rgb = intensified_color( *back_rgb);
164
+ if( srcp & A_DIM)
165
+ {
166
+ *fore_rgb = dimmed_color( *fore_rgb);
167
+ *back_rgb = dimmed_color( *back_rgb);
168
+ }
169
+ }
170
+
171
+ #define same_colors( A, B) ((A).r==(B).r && (A).g==(B).g && (A).b==(B).b)
172
+
173
+ /* set the font colors to match the chtype's attribute */
174
+
175
+ static void _set_attr(chtype ch)
176
+ {
177
+ static chtype oldch = (chtype)(-1); /* current attribute */
178
+ ch &= (A_COLOR|A_BOLD|A_BLINK|A_REVERSE | A_DIM | A_RGB_COLOR);
179
+
180
+ if (oldch != ch)
181
+ {
182
+ SDL_Color fore_rgb, back_rgb;
183
+
184
+ if (SP->mono)
185
+ return;
186
+ PDC_get_rgb_values( ch, &fore_rgb, &back_rgb);
187
+
188
+ if( !same_colors( fore_rgb, foreground_rgb))
189
+ {
190
+ #ifndef PDC_WIDE
191
+ SDL_SetPaletteColors(pdc_font->format->palette,
192
+ &fore_rgb, pdc_flastc, 1);
193
+ #endif
194
+ foreground_rgb = fore_rgb;
195
+ }
196
+
197
+ if( !same_colors( back_rgb, background_rgb))
198
+ {
199
+ #ifndef PDC_WIDE
200
+ SDL_SetPaletteColors(pdc_font->format->palette,
201
+ &back_rgb, 0, 1);
202
+ #endif
203
+ background_rgb = back_rgb;
204
+ }
205
+
206
+ oldch = ch;
207
+ }
208
+ }
209
+
210
+ #ifdef PDC_WIDE
211
+ static void set_font_style( const chtype ch)
212
+ {
213
+ static int old_font_style = -1;
214
+ int font_style = ((ch & A_BOLD) ? TTF_STYLE_BOLD : 0);
215
+
216
+ if( ch & A_ITALIC)
217
+ font_style |= TTF_STYLE_ITALIC;
218
+ if( font_style != old_font_style)
219
+ {
220
+ TTF_SetFontStyle( pdc_ttffont, font_style);
221
+ old_font_style = font_style;
222
+ }
223
+ }
224
+ #endif
225
+
226
+ /* draw a cursor at (y, x) */
227
+
228
+ void PDC_gotoyx(int row, int col)
229
+ {
230
+ SDL_Rect src, dest;
231
+ chtype ch;
232
+ int oldrow, oldcol;
233
+ const int cursor_style =
234
+ (SP->visibility >> (PDC_blink_state ? 8 : 0)) & 0xff;
235
+ #ifdef PDC_WIDE
236
+ Uint16 chstr[2] = {0, 0};
237
+ #endif
238
+
239
+
240
+ PDC_LOG(("PDC_gotoyx() - called: row %d col %d from row %d col %d\n",
241
+ row, col, SP->cursrow, SP->curscol));
242
+
243
+ if (SP->mono)
244
+ return;
245
+
246
+ oldrow = SP->cursrow;
247
+ oldcol = SP->curscol;
248
+
249
+ /* clear the old cursor */
250
+
251
+ PDC_transform_line(oldrow, oldcol, 1, curscr->_y[oldrow] + oldcol);
252
+
253
+ if (!cursor_style)
254
+ return;
255
+
256
+ /* draw a new cursor by overprinting the existing character in
257
+ reverse, either the full cell (when cursor_style == 2) or the
258
+ lowest quarter of it (when cursor_style == 1) */
259
+
260
+ ch = curscr->_y[row][col] ^ A_REVERSE;
261
+
262
+ _set_attr(ch);
263
+
264
+ #ifdef CHTYPE_LONG
265
+ if (ch & A_ALTCHARSET && !(ch & 0xff80))
266
+ ch = acs_map[ch & 0x7f];
267
+ #endif
268
+ src.h = (cursor_style == 1) ? pdc_fheight >> 2 : pdc_fheight;
269
+ src.w = pdc_fwidth;
270
+
271
+ dest.y = (row + 1) * pdc_fheight - src.h + pdc_yoffset;
272
+ dest.x = col * pdc_fwidth + pdc_xoffset;
273
+
274
+ #ifdef PDC_WIDE
275
+ chstr[0] = ch & A_CHARTEXT;
276
+ set_font_style( ch);
277
+
278
+ pdc_font = TTF_RenderUNICODE_Solid( pdc_ttffont, chstr, foreground_rgb);
279
+ if (pdc_font)
280
+ {
281
+ dest.h = src.h;
282
+ dest.w = src.w;
283
+ src.x = 0;
284
+ src.y = 0;
285
+ SDL_SetColorKey( pdc_font, SDL_FALSE, 0);
286
+ SDL_SetPaletteColors(pdc_font->format->palette, &background_rgb, 0, 1);
287
+ SDL_BlitSurface(pdc_font, &src, pdc_screen, &dest);
288
+ SDL_FreeSurface(pdc_font);
289
+ pdc_font = NULL;
290
+ }
291
+ #else
292
+
293
+ src.x = (ch & 0xff) % 32 * pdc_fwidth;
294
+ src.y = (ch & 0xff) / 32 * pdc_fheight + (pdc_fheight - src.h);
295
+
296
+ SDL_BlitSurface(pdc_font, &src, pdc_screen, &dest);
297
+ #endif
298
+
299
+ if (oldrow != row || oldcol != col)
300
+ {
301
+ if (rectcount == MAXRECT)
302
+ PDC_update_rects();
303
+
304
+ uprect[rectcount++] = dest;
305
+ }
306
+ }
307
+
308
+ /* handle the A_*LINE attributes */
309
+
310
+ static void _highlight( SDL_Rect *dest, chtype ch)
311
+ {
312
+ SDL_Color col;
313
+ Uint32 pixel_value;
314
+
315
+ if (SP->mono)
316
+ return;
317
+
318
+ if (SP->line_color == -1)
319
+ col = foreground_rgb;
320
+ else
321
+ col = pdc_color[SP->line_color];
322
+ pixel_value = SDL_MapRGB( pdc_screen->format, col.r, col.g, col.b);
323
+ if (ch & (A_UNDERLINE | A_OVERLINE | A_STRIKEOUT))
324
+ {
325
+ dest->h = 1;
326
+
327
+ if (ch & A_OVERLINE)
328
+ SDL_FillRect(pdc_screen, dest, pixel_value);
329
+
330
+ if (ch & A_UNDERLINE)
331
+ {
332
+ dest->y += pdc_fheight - 1;
333
+ SDL_FillRect(pdc_screen, dest, pixel_value);
334
+ dest->y -= pdc_fheight - 1;
335
+ }
336
+
337
+ if (ch & A_STRIKEOUT)
338
+ {
339
+ dest->y += pdc_fheight / 2;
340
+ SDL_FillRect(pdc_screen, dest, pixel_value);
341
+ dest->y -= pdc_fheight / 2;
342
+ }
343
+
344
+ dest->h = pdc_fheight;
345
+ }
346
+
347
+ if (ch & (A_LEFTLINE|A_RIGHTLINE))
348
+ {
349
+
350
+ dest->w = 1;
351
+
352
+ if (ch & A_LEFTLINE)
353
+ SDL_FillRect(pdc_screen, dest, pixel_value);
354
+
355
+ if (ch & A_RIGHTLINE)
356
+ {
357
+ dest->x += pdc_fwidth - 1;
358
+ SDL_FillRect(pdc_screen, dest, pixel_value);
359
+ dest->x -= pdc_fwidth - 1;
360
+ }
361
+
362
+ dest->w = pdc_fwidth;
363
+ }
364
+ }
365
+
366
+ /* update the given physical line to look like the corresponding line in
367
+ curscr */
368
+
369
+ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
370
+ {
371
+ SDL_Rect src, dest, lastrect;
372
+ int j;
373
+ #ifdef PDC_WIDE
374
+ Uint16 chstr[2] = {0, 0};
375
+ #endif
376
+
377
+ PDC_LOG(("PDC_transform_line() - called: lineno=%d\n", lineno));
378
+
379
+ if (rectcount == MAXRECT)
380
+ PDC_update_rects();
381
+
382
+ src.h = pdc_fheight;
383
+ src.w = pdc_fwidth;
384
+
385
+ dest.y = pdc_fheight * lineno + pdc_yoffset;
386
+ dest.x = pdc_fwidth * x + pdc_xoffset;
387
+ dest.h = pdc_fheight;
388
+ dest.w = pdc_fwidth * len;
389
+
390
+ /* if the previous rect was just above this one, with the same width
391
+ and horizontal position, then merge the new one with it instead
392
+ of adding a new entry */
393
+
394
+ if (rectcount)
395
+ lastrect = uprect[rectcount - 1];
396
+
397
+ if (rectcount && lastrect.x == dest.x && lastrect.w == dest.w)
398
+ {
399
+ if (lastrect.y + lastrect.h == dest.y)
400
+ uprect[rectcount - 1].h = lastrect.h + pdc_fheight;
401
+ else
402
+ if (lastrect.y != dest.y)
403
+ uprect[rectcount++] = dest;
404
+ }
405
+ else
406
+ uprect[rectcount++] = dest;
407
+
408
+ dest.w = pdc_fwidth;
409
+
410
+ #ifdef PDC_WIDE
411
+ src.x = 0;
412
+ src.y = 0;
413
+ #endif
414
+
415
+ for (j = 0; j < len; j++)
416
+ {
417
+ chtype ch = srcp[j];
418
+ #ifdef PDC_WIDE
419
+ chtype ch1;
420
+ #endif
421
+
422
+ _set_attr(ch);
423
+
424
+ #ifdef CHTYPE_LONG
425
+ if (ch & A_ALTCHARSET && !(ch & 0xff80))
426
+ ch = (ch & (A_ATTRIBUTES ^ A_ALTCHARSET)) | acs_map[ch & 0x7f];
427
+ #endif
428
+
429
+ #ifdef PDC_WIDE
430
+ ch1 = ch & A_CHARTEXT;
431
+ #ifdef USING_COMBINING_CHARACTER_SCHEME
432
+ /* We can't actually display combining characters in cmd.exe. So
433
+ show the 'base' character and throw away the modifying marks. */
434
+ if( ch1 == DUMMY_CHAR_NEXT_TO_FULLWIDTH)
435
+ ch1 = ' ';
436
+ else if( ch1 > MAX_UNICODE)
437
+ {
438
+ cchar_t added;
439
+ int n_combined = 0;
440
+
441
+ while( (ch1 = PDC_expand_combined_characters( ch1,
442
+ &added)) > MAX_UNICODE)
443
+ {
444
+ n_combined++;
445
+ }
446
+ }
447
+ #ifdef USE_FOR_SUPPLEMENTAL_MULTILINGUAL_PLANE
448
+ /* At present, SDL does not (I think) support SMP Unicode */
449
+ /* (Unicode past 64K). If it ever does, we'll need the */
450
+ /* following breakup of SMP into Unicode surrogates (q.v.) */
451
+ if( ch1 > 0xffff)
452
+ {
453
+ ch1 -= 0x10000;
454
+ chstr[0] = (Uint16)( 0xdc00 | (ch1 & 0x3ff)); /* lower 10 bits */
455
+ ch1 = (0xd800 | (ch1 >> 10)); /* upper 10 bits */
456
+ }
457
+ #endif
458
+ #endif
459
+ chstr[0] = (Uint16)ch1;
460
+ set_font_style( ch);
461
+ pdc_font = TTF_RenderUNICODE_Solid(pdc_ttffont, chstr,
462
+ foreground_rgb);
463
+
464
+ if (pdc_font)
465
+ {
466
+ SDL_SetColorKey( pdc_font, SDL_FALSE, 0);
467
+ SDL_SetPaletteColors(pdc_font->format->palette,
468
+ &background_rgb, 0, 1);
469
+ SDL_BlitSurface(pdc_font, &src, pdc_screen, &dest);
470
+ SDL_FreeSurface(pdc_font);
471
+ pdc_font = NULL;
472
+ }
473
+ #else
474
+ src.x = (ch & 0xff) % 32 * pdc_fwidth;
475
+ src.y = (ch & 0xff) / 32 * pdc_fheight;
476
+
477
+ SDL_LowerBlit(pdc_font, &src, pdc_screen, &dest);
478
+ #endif
479
+
480
+ if (ch & (A_UNDERLINE|A_LEFTLINE|A_RIGHTLINE|A_OVERLINE|A_STRIKEOUT))
481
+ _highlight( &dest, ch);
482
+
483
+ dest.x += pdc_fwidth;
484
+ }
485
+ }
486
+
487
+
488
+ /* If PDC_really_blinking is 'true', we need to redraw all text with
489
+ the A_BLINK attribute set every 500 milliseconds. (We also need to redraw
490
+ it when blinking is turned off.) If the line-drawing color changes, we
491
+ need to redraw all under/over/left/right-lined text, and strikeout text.
492
+ This function, therefore, redraws all text of a specified attribute. */
493
+
494
+ static void redraw_text_with_attribute( const chtype attribute)
495
+ {
496
+ int i, j, k;
497
+
498
+ for( i = 0; i < SP->lines; i++)
499
+ {
500
+ const chtype *srcp = curscr->_y[i];
501
+
502
+ for( j = 0; j < SP->cols; j++)
503
+ if( srcp[j] & attribute)
504
+ {
505
+ k = j + 1;
506
+ while( k < SP->cols && (srcp[k] & attribute))
507
+ k++;
508
+ PDC_transform_line( i, j, k - j, srcp + j);
509
+ j = k;
510
+ }
511
+ }
512
+ }
513
+
514
+ /* Twice a second, we blink the cursor, blink text if it's "really"
515
+ blinking (or draw it as 'standout' if it was previously blinking), and
516
+ if the line color has changed, we redraw all the lined text. */
517
+
518
+ void PDC_twice_a_second( void)
519
+ {
520
+ static int previously_really_blinking;
521
+ static int prev_line_color = -1;
522
+
523
+ PDC_blink_state = !PDC_blink_state;
524
+ PDC_gotoyx(SP->cursrow, SP->curscol);
525
+ if( PDC_really_blinking || previously_really_blinking)
526
+ redraw_text_with_attribute( A_BLINK);
527
+ previously_really_blinking = PDC_really_blinking;
528
+ if( prev_line_color != SP->line_color)
529
+ {
530
+ redraw_text_with_attribute( A_UNDERLINE | A_OVERLINE | A_STRIKEOUT
531
+ | A_LEFTLINE | A_RIGHTLINE);
532
+ prev_line_color = SP->line_color;
533
+ }
534
+ }
@@ -0,0 +1,30 @@
1
+ /* Public Domain Curses */
2
+
3
+ #include "pdcsdl.h"
4
+
5
+ /* get the cursor size/shape */
6
+
7
+ int PDC_get_cursor_mode(void)
8
+ {
9
+ PDC_LOG(("PDC_get_cursor_mode() - called\n"));
10
+
11
+ return 0;
12
+ }
13
+
14
+ /* return number of screen rows */
15
+
16
+ int PDC_get_rows(void)
17
+ {
18
+ PDC_LOG(("PDC_get_rows() - called\n"));
19
+
20
+ return pdc_sheight / pdc_fheight;
21
+ }
22
+
23
+ /* return width of screen/viewport */
24
+
25
+ int PDC_get_columns(void)
26
+ {
27
+ PDC_LOG(("PDC_get_columns() - called\n"));
28
+
29
+ return pdc_swidth / pdc_fwidth;
30
+ }