curses 1.3.0 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (256) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +19 -0
  3. data/.github/workflows/ubuntu.yml +26 -0
  4. data/.github/workflows/windows.yml +25 -0
  5. data/History.md +34 -0
  6. data/README.md +14 -46
  7. data/Rakefile +0 -86
  8. data/curses.gemspec +2 -3
  9. data/ext/curses/curses.c +70 -58
  10. data/ext/curses/extconf.rb +134 -21
  11. data/lib/curses.rb +5 -12
  12. data/sample/addch.rb +16 -0
  13. data/sample/attr_demo.rb +32 -0
  14. data/sample/colors.rb +26 -0
  15. data/sample/menu.rb +3 -3
  16. data/sample/mouse_move.rb +75 -0
  17. data/vendor/PDCurses/.gitignore +47 -0
  18. data/vendor/PDCurses/.travis.yml +49 -0
  19. data/vendor/PDCurses/CMakeLists.txt +68 -0
  20. data/vendor/PDCurses/HISTORY.md +2036 -0
  21. data/vendor/PDCurses/IMPLEMNT.md +327 -0
  22. data/vendor/PDCurses/README.md +77 -0
  23. data/vendor/PDCurses/acs_defs.h +265 -0
  24. data/vendor/PDCurses/appveyor.yml +218 -0
  25. data/vendor/PDCurses/cmake/README.md +71 -0
  26. data/vendor/PDCurses/cmake/build_dependencies.cmake +178 -0
  27. data/vendor/PDCurses/cmake/build_options.cmake +25 -0
  28. data/vendor/PDCurses/cmake/dll_version.cmake +26 -0
  29. data/vendor/PDCurses/cmake/gen_config_header.cmake +43 -0
  30. data/vendor/PDCurses/cmake/get_version.cmake +17 -0
  31. data/vendor/PDCurses/cmake/make_uninstall.cmake +19 -0
  32. data/vendor/PDCurses/cmake/project_common.cmake +121 -0
  33. data/vendor/PDCurses/cmake/resource.in.cmake +52 -0
  34. data/vendor/PDCurses/cmake/sdl2_ttf/CMakeLists.txt +83 -0
  35. data/vendor/PDCurses/cmake/target_arch.cmake +36 -0
  36. data/vendor/PDCurses/cmake/version.in.cmake +73 -0
  37. data/vendor/PDCurses/cmake/watcom_open_dos16_toolchain.cmake +96 -0
  38. data/vendor/PDCurses/cmake/watcom_open_dos32_toolchain.cmake +106 -0
  39. data/vendor/PDCurses/cmake/watcom_open_os2v2_toolchain.cmake +105 -0
  40. data/vendor/PDCurses/curses.h +1846 -0
  41. data/vendor/PDCurses/curspriv.h +134 -0
  42. data/vendor/PDCurses/demos/README.md +25 -0
  43. data/vendor/PDCurses/demos/firework.c +144 -0
  44. data/vendor/PDCurses/demos/newtest.c +581 -0
  45. data/vendor/PDCurses/demos/ozdemo.c +447 -0
  46. data/vendor/PDCurses/demos/ptest.c +283 -0
  47. data/vendor/PDCurses/demos/rain.c +157 -0
  48. data/vendor/PDCurses/demos/testcurs.c +1607 -0
  49. data/vendor/PDCurses/demos/tui.c +1048 -0
  50. data/vendor/PDCurses/demos/tui.h +65 -0
  51. data/vendor/PDCurses/demos/tuidemo.c +233 -0
  52. data/vendor/PDCurses/demos/version.c +61 -0
  53. data/vendor/PDCurses/demos/worm.c +432 -0
  54. data/vendor/PDCurses/demos/xmas.c +955 -0
  55. data/vendor/PDCurses/dos/CMakeLists.txt +47 -0
  56. data/vendor/PDCurses/dos/Makefile.bcc +83 -0
  57. data/vendor/PDCurses/dos/Makefile.dmc +257 -0
  58. data/vendor/PDCurses/dos/Makefile.msc +113 -0
  59. data/vendor/PDCurses/dos/Makefile.wcc +107 -0
  60. data/vendor/PDCurses/dos/README.md +51 -0
  61. data/vendor/PDCurses/dos/bccdos.lrf +9 -0
  62. data/vendor/PDCurses/dos/mscdos.lrf +50 -0
  63. data/vendor/PDCurses/dos/pdcclip.c +132 -0
  64. data/vendor/PDCurses/dos/pdcdisp.c +135 -0
  65. data/vendor/PDCurses/dos/pdcdos.h +194 -0
  66. data/vendor/PDCurses/dos/pdcgetsc.c +98 -0
  67. data/vendor/PDCurses/dos/pdckbd.c +513 -0
  68. data/vendor/PDCurses/dos/pdcscrn.c +785 -0
  69. data/vendor/PDCurses/dos/pdcsetsc.c +101 -0
  70. data/vendor/PDCurses/dos/pdcutil.c +212 -0
  71. data/vendor/PDCurses/libobjs.mif +26 -0
  72. data/vendor/PDCurses/makedist.mif +20 -0
  73. data/vendor/PDCurses/man/README.md +21 -0
  74. data/vendor/PDCurses/man/intro.md +361 -0
  75. data/vendor/PDCurses/man/manext.c +119 -0
  76. data/vendor/PDCurses/man/sdl.md +152 -0
  77. data/vendor/PDCurses/man/sdl2.md +58 -0
  78. data/vendor/PDCurses/man/x11.md +407 -0
  79. data/vendor/PDCurses/ncurses/CMakeLists.txt +66 -0
  80. data/vendor/PDCurses/ncurses/README.md +26 -0
  81. data/vendor/PDCurses/ncurses/makefile +29 -0
  82. data/vendor/PDCurses/os2/CMakeLists.txt +41 -0
  83. data/vendor/PDCurses/os2/Makefile.bcc +90 -0
  84. data/vendor/PDCurses/os2/Makefile.wcc +43 -0
  85. data/vendor/PDCurses/os2/README.md +43 -0
  86. data/vendor/PDCurses/os2/iccos2.lrf +50 -0
  87. data/vendor/PDCurses/os2/iccos2.mak +256 -0
  88. data/vendor/PDCurses/os2/pdcclip.c +188 -0
  89. data/vendor/PDCurses/os2/pdcdisp.c +93 -0
  90. data/vendor/PDCurses/os2/pdcgetsc.c +89 -0
  91. data/vendor/PDCurses/os2/pdckbd.c +521 -0
  92. data/vendor/PDCurses/os2/pdcos2.h +55 -0
  93. data/vendor/PDCurses/os2/pdcscrn.c +449 -0
  94. data/vendor/PDCurses/os2/pdcsetsc.c +112 -0
  95. data/vendor/PDCurses/os2/pdcutil.c +52 -0
  96. data/vendor/PDCurses/panel.h +56 -0
  97. data/vendor/PDCurses/pdcurses/README.md +25 -0
  98. data/vendor/PDCurses/pdcurses/addch.c +693 -0
  99. data/vendor/PDCurses/pdcurses/addchstr.c +245 -0
  100. data/vendor/PDCurses/pdcurses/addstr.c +240 -0
  101. data/vendor/PDCurses/pdcurses/attr.c +359 -0
  102. data/vendor/PDCurses/pdcurses/beep.c +68 -0
  103. data/vendor/PDCurses/pdcurses/bkgd.c +223 -0
  104. data/vendor/PDCurses/pdcurses/border.c +411 -0
  105. data/vendor/PDCurses/pdcurses/clear.c +159 -0
  106. data/vendor/PDCurses/pdcurses/color.c +298 -0
  107. data/vendor/PDCurses/pdcurses/debug.c +109 -0
  108. data/vendor/PDCurses/pdcurses/delch.c +96 -0
  109. data/vendor/PDCurses/pdcurses/deleteln.c +211 -0
  110. data/vendor/PDCurses/pdcurses/deprec.c +27 -0
  111. data/vendor/PDCurses/pdcurses/getch.c +417 -0
  112. data/vendor/PDCurses/pdcurses/getstr.c +474 -0
  113. data/vendor/PDCurses/pdcurses/getyx.c +139 -0
  114. data/vendor/PDCurses/pdcurses/inch.c +127 -0
  115. data/vendor/PDCurses/pdcurses/inchstr.c +214 -0
  116. data/vendor/PDCurses/pdcurses/initscr.c +367 -0
  117. data/vendor/PDCurses/pdcurses/inopts.c +324 -0
  118. data/vendor/PDCurses/pdcurses/insch.c +271 -0
  119. data/vendor/PDCurses/pdcurses/insstr.c +264 -0
  120. data/vendor/PDCurses/pdcurses/instr.c +246 -0
  121. data/vendor/PDCurses/pdcurses/kernel.c +259 -0
  122. data/vendor/PDCurses/pdcurses/keyname.c +157 -0
  123. data/vendor/PDCurses/pdcurses/mouse.c +438 -0
  124. data/vendor/PDCurses/pdcurses/move.c +57 -0
  125. data/vendor/PDCurses/pdcurses/outopts.c +159 -0
  126. data/vendor/PDCurses/pdcurses/overlay.c +214 -0
  127. data/vendor/PDCurses/pdcurses/pad.c +260 -0
  128. data/vendor/PDCurses/pdcurses/panel.c +633 -0
  129. data/vendor/PDCurses/pdcurses/printw.c +126 -0
  130. data/vendor/PDCurses/pdcurses/refresh.c +279 -0
  131. data/vendor/PDCurses/pdcurses/scanw.c +578 -0
  132. data/vendor/PDCurses/pdcurses/scr_dump.c +213 -0
  133. data/vendor/PDCurses/pdcurses/scroll.c +101 -0
  134. data/vendor/PDCurses/pdcurses/slk.c +591 -0
  135. data/vendor/PDCurses/pdcurses/termattr.c +182 -0
  136. data/vendor/PDCurses/pdcurses/terminfo.c +217 -0
  137. data/vendor/PDCurses/pdcurses/touch.c +163 -0
  138. data/vendor/PDCurses/pdcurses/util.c +312 -0
  139. data/vendor/PDCurses/pdcurses/window.c +569 -0
  140. data/vendor/PDCurses/sdl1/Makefile.mng +110 -0
  141. data/vendor/PDCurses/sdl1/README.md +31 -0
  142. data/vendor/PDCurses/sdl1/deffont.h +385 -0
  143. data/vendor/PDCurses/sdl1/deficon.h +23 -0
  144. data/vendor/PDCurses/sdl1/pdcclip.c +131 -0
  145. data/vendor/PDCurses/sdl1/pdcdisp.c +373 -0
  146. data/vendor/PDCurses/sdl1/pdcgetsc.c +30 -0
  147. data/vendor/PDCurses/sdl1/pdckbd.c +405 -0
  148. data/vendor/PDCurses/sdl1/pdcscrn.c +414 -0
  149. data/vendor/PDCurses/sdl1/pdcsdl.h +31 -0
  150. data/vendor/PDCurses/sdl1/pdcsetsc.c +64 -0
  151. data/vendor/PDCurses/sdl1/pdcutil.c +40 -0
  152. data/vendor/PDCurses/sdl1/sdltest.c +79 -0
  153. data/vendor/PDCurses/sdl2/CMakeLists.txt +76 -0
  154. data/vendor/PDCurses/sdl2/Makefile.vc +164 -0
  155. data/vendor/PDCurses/sdl2/README.md +34 -0
  156. data/vendor/PDCurses/sdl2/deffont.h +385 -0
  157. data/vendor/PDCurses/sdl2/deficon.h +23 -0
  158. data/vendor/PDCurses/sdl2/pdcclip.c +93 -0
  159. data/vendor/PDCurses/sdl2/pdcdisp.c +534 -0
  160. data/vendor/PDCurses/sdl2/pdcgetsc.c +30 -0
  161. data/vendor/PDCurses/sdl2/pdckbd.c +480 -0
  162. data/vendor/PDCurses/sdl2/pdcscrn.c +443 -0
  163. data/vendor/PDCurses/sdl2/pdcsdl.h +33 -0
  164. data/vendor/PDCurses/sdl2/pdcsetsc.c +67 -0
  165. data/vendor/PDCurses/sdl2/pdcutil.c +39 -0
  166. data/vendor/PDCurses/sdl2/sdltest.c +81 -0
  167. data/vendor/PDCurses/term.h +48 -0
  168. data/vendor/PDCurses/version.mif +7 -0
  169. data/vendor/PDCurses/vt/CMakeLists.txt +28 -0
  170. data/vendor/PDCurses/vt/Makefile.bcc +111 -0
  171. data/vendor/PDCurses/vt/Makefile.dmc +258 -0
  172. data/vendor/PDCurses/vt/Makefile.vc +144 -0
  173. data/vendor/PDCurses/vt/Makefile.wcc +107 -0
  174. data/vendor/PDCurses/vt/README.md +64 -0
  175. data/vendor/PDCurses/vt/pdcclip.c +20 -0
  176. data/vendor/PDCurses/vt/pdcdisp.c +284 -0
  177. data/vendor/PDCurses/vt/pdcgetsc.c +27 -0
  178. data/vendor/PDCurses/vt/pdckbd.c +394 -0
  179. data/vendor/PDCurses/vt/pdcscrn.c +434 -0
  180. data/vendor/PDCurses/vt/pdcsetsc.c +45 -0
  181. data/vendor/PDCurses/vt/pdcutil.c +43 -0
  182. data/vendor/PDCurses/vt/pdcvt.h +16 -0
  183. data/vendor/PDCurses/watcom.mif +68 -0
  184. data/vendor/PDCurses/wincon/CMakeLists.txt +27 -0
  185. data/vendor/PDCurses/wincon/Makefile.bcc +88 -0
  186. data/vendor/PDCurses/wincon/Makefile.dmc +256 -0
  187. data/vendor/PDCurses/wincon/Makefile.lcc +273 -0
  188. data/vendor/PDCurses/wincon/Makefile.mng +176 -0
  189. data/vendor/PDCurses/wincon/Makefile.vc +144 -0
  190. data/vendor/PDCurses/wincon/Makefile.wcc +51 -0
  191. data/vendor/PDCurses/wincon/README.md +85 -0
  192. data/vendor/PDCurses/wincon/pdcclip.c +174 -0
  193. data/vendor/PDCurses/wincon/pdcdisp.c +143 -0
  194. data/vendor/PDCurses/wincon/pdcgetsc.c +55 -0
  195. data/vendor/PDCurses/wincon/pdckbd.c +786 -0
  196. data/vendor/PDCurses/wincon/pdcscrn.c +717 -0
  197. data/vendor/PDCurses/wincon/pdcsetsc.c +91 -0
  198. data/vendor/PDCurses/wincon/pdcurses.ico +0 -0
  199. data/vendor/PDCurses/wincon/pdcurses.rc +28 -0
  200. data/vendor/PDCurses/wincon/pdcutil.c +41 -0
  201. data/vendor/PDCurses/wincon/pdcwin.h +31 -0
  202. data/vendor/PDCurses/wingui/CMakeLists.txt +27 -0
  203. data/vendor/PDCurses/wingui/Makefile.bcc +85 -0
  204. data/vendor/PDCurses/wingui/Makefile.dmc +259 -0
  205. data/vendor/PDCurses/wingui/Makefile.lcc +273 -0
  206. data/vendor/PDCurses/wingui/Makefile.mng +171 -0
  207. data/vendor/PDCurses/wingui/Makefile.vc +144 -0
  208. data/vendor/PDCurses/wingui/Makefile.wcc +51 -0
  209. data/vendor/PDCurses/wingui/README.md +93 -0
  210. data/vendor/PDCurses/wingui/pdcclip.c +174 -0
  211. data/vendor/PDCurses/wingui/pdcdisp.c +718 -0
  212. data/vendor/PDCurses/wingui/pdcgetsc.c +30 -0
  213. data/vendor/PDCurses/wingui/pdckbd.c +143 -0
  214. data/vendor/PDCurses/wingui/pdcscrn.c +2797 -0
  215. data/vendor/PDCurses/wingui/pdcsetsc.c +89 -0
  216. data/vendor/PDCurses/wingui/pdcurses.ico +0 -0
  217. data/vendor/PDCurses/wingui/pdcurses.rc +28 -0
  218. data/vendor/PDCurses/wingui/pdcutil.c +61 -0
  219. data/vendor/PDCurses/wingui/pdcwin.h +122 -0
  220. data/vendor/PDCurses/x11/Makefile.in +754 -0
  221. data/vendor/PDCurses/x11/PDCurses.spec +82 -0
  222. data/vendor/PDCurses/x11/README.md +62 -0
  223. data/vendor/PDCurses/x11/ScrollBox.c +319 -0
  224. data/vendor/PDCurses/x11/ScrollBox.h +51 -0
  225. data/vendor/PDCurses/x11/ScrollBoxP.h +70 -0
  226. data/vendor/PDCurses/x11/aclocal.m4 +994 -0
  227. data/vendor/PDCurses/x11/big_icon.xbm +46 -0
  228. data/vendor/PDCurses/x11/compose.h +201 -0
  229. data/vendor/PDCurses/x11/config.guess +1500 -0
  230. data/vendor/PDCurses/x11/config.h.in +100 -0
  231. data/vendor/PDCurses/x11/config.sub +1616 -0
  232. data/vendor/PDCurses/x11/configure +6700 -0
  233. data/vendor/PDCurses/x11/configure.ac +295 -0
  234. data/vendor/PDCurses/x11/debian/changelog +6 -0
  235. data/vendor/PDCurses/x11/debian/compat +1 -0
  236. data/vendor/PDCurses/x11/debian/control +11 -0
  237. data/vendor/PDCurses/x11/debian/copyright +27 -0
  238. data/vendor/PDCurses/x11/debian/rules +98 -0
  239. data/vendor/PDCurses/x11/install-sh +253 -0
  240. data/vendor/PDCurses/x11/little_icon.xbm +14 -0
  241. data/vendor/PDCurses/x11/ncurses_cfg.h +45 -0
  242. data/vendor/PDCurses/x11/pdcclip.c +173 -0
  243. data/vendor/PDCurses/x11/pdcdisp.c +85 -0
  244. data/vendor/PDCurses/x11/pdcgetsc.c +28 -0
  245. data/vendor/PDCurses/x11/pdckbd.c +104 -0
  246. data/vendor/PDCurses/x11/pdcscrn.c +258 -0
  247. data/vendor/PDCurses/x11/pdcsetsc.c +95 -0
  248. data/vendor/PDCurses/x11/pdcutil.c +52 -0
  249. data/vendor/PDCurses/x11/pdcx11.c +316 -0
  250. data/vendor/PDCurses/x11/pdcx11.h +191 -0
  251. data/vendor/PDCurses/x11/sb.c +155 -0
  252. data/vendor/PDCurses/x11/x11.c +3686 -0
  253. data/vendor/PDCurses/x11/xcurses-config.in +81 -0
  254. metadata +258 -24
  255. data/.travis.yml +0 -16
  256. data/appveyor.yml +0 -16
@@ -0,0 +1,298 @@
1
+ /* Public Domain Curses */
2
+
3
+ #include <curspriv.h>
4
+
5
+ /*man-start**************************************************************
6
+
7
+ color
8
+ -----
9
+
10
+ ### Synopsis
11
+
12
+ int start_color(void);
13
+ int init_pair(short pair, short fg, short bg);
14
+ int init_color(short color, short red, short green, short blue);
15
+ bool has_colors(void);
16
+ bool can_change_color(void);
17
+ int color_content(short color, short *red, short *green, short *blue);
18
+ int pair_content(short pair, short *fg, short *bg);
19
+
20
+ int assume_default_colors(int f, int b);
21
+ int use_default_colors(void);
22
+
23
+ int PDC_set_line_color(short color);
24
+
25
+ ### Description
26
+
27
+ To use these routines, start_color() must be called, usually
28
+ immediately after initscr(). Colors are always used in pairs,
29
+ referred to as color-pairs. A color-pair consists of a
30
+ foreground color and a background color. A color-pair is
31
+ initialized via init_pair(). After initialization, COLOR_PAIR(n)
32
+ can be used like any other video attribute.
33
+
34
+ start_color() initializes eight basic colors (black, red, green,
35
+ yellow, blue, magenta, cyan, and white), and two global
36
+ variables; COLORS and COLOR_PAIRS (respectively defining the
37
+ maximum number of colors and color-pairs the terminal is capable
38
+ of displaying).
39
+
40
+ init_pair() changes the definition of a color-pair. It takes
41
+ three arguments: the number of the color-pair to be redefined,
42
+ and the new values of the foreground and background colors. The
43
+ pair number must be between 0 and COLOR_PAIRS - 1, inclusive.
44
+ The foreground and background must be between 0 and COLORS - 1,
45
+ inclusive. If the color pair was previously initialized, the
46
+ screen is refreshed, and all occurrences of that color-pair are
47
+ changed to the new definition.
48
+
49
+ has_colors() indicates if the terminal supports, and can
50
+ maniplulate color. It returns TRUE or FALSE.
51
+
52
+ can_change_color() indicates if the terminal has the capability
53
+ to change the definition of its colors.
54
+
55
+ pair_content() is used to determine what the colors of a given
56
+ color-pair consist of.
57
+
58
+ assume_default_colors() and use_default_colors() emulate the
59
+ ncurses extensions of the same names. assume_default_colors(f,
60
+ b) is essentially the same as init_pair(0, f, b) (which isn't
61
+ allowed); it redefines the default colors. use_default_colors()
62
+ allows the use of -1 as a foreground or background color with
63
+ init_pair(), and calls assume_default_colors(-1, -1); -1
64
+ represents the foreground or background color that the terminal
65
+ had at startup. If the environment variable PDC_ORIGINAL_COLORS
66
+ is set at the time start_color() is called, that's equivalent to
67
+ calling use_default_colors().
68
+
69
+ PDC_set_line_color() is used to set the color, globally, for
70
+ the color of the lines drawn for the attributes: A_UNDERLINE,
71
+ A_OVERLINE, A_LEFTLINE and A_RIGHTLINE. A value of -1 (the
72
+ default) indicates that the current foreground color should be
73
+ used.
74
+
75
+ NOTE: COLOR_PAIR() and PAIR_NUMBER() are implemented as macros.
76
+
77
+ ### Return Value
78
+
79
+ All functions return OK on success and ERR on error, except for
80
+ has_colors() and can_change_colors(), which return TRUE or FALSE.
81
+
82
+ ### Portability
83
+ X/Open BSD SYS V
84
+ start_color Y - 3.2
85
+ init_pair Y - 3.2
86
+ init_color Y - 3.2
87
+ has_colors Y - 3.2
88
+ can_change_color Y - 3.2
89
+ color_content Y - 3.2
90
+ pair_content Y - 3.2
91
+ assume_default_colors - - -
92
+ use_default_colors - - -
93
+ PDC_set_line_color - - -
94
+
95
+ **man-end****************************************************************/
96
+
97
+ #include <stdlib.h>
98
+ #include <string.h>
99
+
100
+ int COLORS = 0;
101
+ int COLOR_PAIRS = PDC_COLOR_PAIRS;
102
+
103
+ bool pdc_color_started = FALSE;
104
+
105
+ /* pair_set[] tracks whether a pair has been set via init_pair() */
106
+
107
+ static bool pair_set[PDC_COLOR_PAIRS];
108
+ static bool default_colors = FALSE;
109
+ static short first_col = 0;
110
+
111
+ int start_color(void)
112
+ {
113
+ PDC_LOG(("start_color() - called\n"));
114
+
115
+ if (SP->mono)
116
+ return ERR;
117
+
118
+ pdc_color_started = TRUE;
119
+
120
+ PDC_set_blink(FALSE); /* Also sets COLORS, to 8 or 16 */
121
+
122
+ if (!default_colors && SP->orig_attr && getenv("PDC_ORIGINAL_COLORS"))
123
+ default_colors = TRUE;
124
+
125
+ PDC_init_atrtab();
126
+
127
+ memset(pair_set, 0, PDC_COLOR_PAIRS);
128
+
129
+ return OK;
130
+ }
131
+
132
+ static void _normalize(short *fg, short *bg)
133
+ {
134
+ if (*fg == -1)
135
+ *fg = SP->orig_attr ? SP->orig_fore : COLOR_WHITE;
136
+
137
+ if (*bg == -1)
138
+ *bg = SP->orig_attr ? SP->orig_back : COLOR_BLACK;
139
+ }
140
+
141
+ int init_pair(short pair, short fg, short bg)
142
+ {
143
+ PDC_LOG(("init_pair() - called: pair %d fg %d bg %d\n", pair, fg, bg));
144
+
145
+ if (!pdc_color_started || pair < 1 || pair >= COLOR_PAIRS ||
146
+ fg < first_col || fg >= COLORS || bg < first_col || bg >= COLORS)
147
+ return ERR;
148
+
149
+ _normalize(&fg, &bg);
150
+
151
+ /* To allow the PDC_PRESERVE_SCREEN option to work, we only reset
152
+ curscr if this call to init_pair() alters a color pair created by
153
+ the user. */
154
+
155
+ if (pair_set[pair])
156
+ {
157
+ short oldfg, oldbg;
158
+
159
+ PDC_pair_content(pair, &oldfg, &oldbg);
160
+
161
+ if (oldfg != fg || oldbg != bg)
162
+ curscr->_clear = TRUE;
163
+ }
164
+
165
+ PDC_init_pair(pair, fg, bg);
166
+
167
+ pair_set[pair] = TRUE;
168
+
169
+ return OK;
170
+ }
171
+
172
+ bool has_colors(void)
173
+ {
174
+ PDC_LOG(("has_colors() - called\n"));
175
+
176
+ return !(SP->mono);
177
+ }
178
+
179
+ int init_color(short color, short red, short green, short blue)
180
+ {
181
+ PDC_LOG(("init_color() - called\n"));
182
+
183
+ if (color < 0 || color >= COLORS || !PDC_can_change_color() ||
184
+ red < 0 || red > 1000 || green < 0 || green > 1000 ||
185
+ blue < 0 || blue > 1000)
186
+ return ERR;
187
+
188
+ return PDC_init_color(color, red, green, blue);
189
+ }
190
+
191
+ int color_content(short color, short *red, short *green, short *blue)
192
+ {
193
+ PDC_LOG(("color_content() - called\n"));
194
+
195
+ if (color < 0 || color >= COLORS || !red || !green || !blue)
196
+ return ERR;
197
+
198
+ if (PDC_can_change_color())
199
+ return PDC_color_content(color, red, green, blue);
200
+ else
201
+ {
202
+ /* Simulated values for platforms that don't support palette
203
+ changing */
204
+
205
+ short maxval = (color & 8) ? 1000 : 680;
206
+
207
+ *red = (color & COLOR_RED) ? maxval : 0;
208
+ *green = (color & COLOR_GREEN) ? maxval : 0;
209
+ *blue = (color & COLOR_BLUE) ? maxval : 0;
210
+
211
+ return OK;
212
+ }
213
+ }
214
+
215
+ bool can_change_color(void)
216
+ {
217
+ PDC_LOG(("can_change_color() - called\n"));
218
+
219
+ return PDC_can_change_color();
220
+ }
221
+
222
+ int pair_content(short pair, short *fg, short *bg)
223
+ {
224
+ PDC_LOG(("pair_content() - called\n"));
225
+
226
+ if (pair < 0 || pair >= COLOR_PAIRS || !fg || !bg)
227
+ return ERR;
228
+
229
+ return PDC_pair_content(pair, fg, bg);
230
+ }
231
+
232
+ int assume_default_colors(int f, int b)
233
+ {
234
+ PDC_LOG(("assume_default_colors() - called: f %d b %d\n", f, b));
235
+
236
+ if (f < -1 || f >= COLORS || b < -1 || b >= COLORS)
237
+ return ERR;
238
+
239
+ if (pdc_color_started)
240
+ {
241
+ short fg, bg, oldfg, oldbg;
242
+
243
+ fg = f;
244
+ bg = b;
245
+
246
+ _normalize(&fg, &bg);
247
+
248
+ PDC_pair_content(0, &oldfg, &oldbg);
249
+
250
+ if (oldfg != fg || oldbg != bg)
251
+ curscr->_clear = TRUE;
252
+
253
+ PDC_init_pair(0, fg, bg);
254
+ }
255
+
256
+ return OK;
257
+ }
258
+
259
+ int use_default_colors(void)
260
+ {
261
+ PDC_LOG(("use_default_colors() - called\n"));
262
+
263
+ default_colors = TRUE;
264
+ first_col = -1;
265
+
266
+ return assume_default_colors(-1, -1);
267
+ }
268
+
269
+ int PDC_set_line_color(short color)
270
+ {
271
+ PDC_LOG(("PDC_set_line_color() - called: %d\n", color));
272
+
273
+ if (color < -1 || color >= COLORS)
274
+ return ERR;
275
+
276
+ SP->line_color = color;
277
+
278
+ return OK;
279
+ }
280
+
281
+ void PDC_init_atrtab(void)
282
+ {
283
+ int i;
284
+ short fg, bg;
285
+
286
+ if (pdc_color_started && !default_colors)
287
+ {
288
+ fg = COLOR_WHITE;
289
+ bg = COLOR_BLACK;
290
+ }
291
+ else
292
+ fg = bg = -1;
293
+
294
+ _normalize(&fg, &bg);
295
+
296
+ for (i = 0; i < PDC_COLOR_PAIRS; i++)
297
+ PDC_init_pair( (short)i, fg, bg);
298
+ }
@@ -0,0 +1,109 @@
1
+ /* Public Domain Curses */
2
+
3
+ #include <curspriv.h>
4
+
5
+ /*man-start**************************************************************
6
+
7
+ debug
8
+ -----
9
+
10
+ ### Synopsis
11
+
12
+ void traceon(void);
13
+ void traceoff(void);
14
+ void PDC_debug(const char *, ...);
15
+
16
+ ### Description
17
+
18
+ traceon() and traceoff() toggle the recording of debugging
19
+ information to the file "trace". Although not standard, similar
20
+ functions are in some other curses implementations.
21
+
22
+ PDC_debug() is the function that writes to the file, based on
23
+ whether traceon() has been called. It's used from the PDC_LOG()
24
+ macro.
25
+
26
+ The environment variable PDC_TRACE_FLUSH controls whether the
27
+ trace file contents are fflushed after each write. The default
28
+ is not. Set it to 1 to enable this (may affect performance).
29
+
30
+ ### Portability
31
+ X/Open BSD SYS V
32
+ traceon - - -
33
+ traceoff - - -
34
+ PDC_debug - - -
35
+
36
+ **man-end****************************************************************/
37
+
38
+ #include <stdlib.h>
39
+ #include <string.h>
40
+ #include <sys/types.h>
41
+ #include <time.h>
42
+
43
+ FILE *pdc_dbfp = NULL;
44
+ static bool trace_on = FALSE;
45
+ static bool want_fflush = FALSE;
46
+
47
+ void PDC_debug(const char *fmt, ...)
48
+ {
49
+ va_list args;
50
+ char hms[9];
51
+ time_t now;
52
+
53
+ if( !trace_on)
54
+ return;
55
+ if (!pdc_dbfp)
56
+ {
57
+ pdc_dbfp = fopen("trace", "a");
58
+ if (!pdc_dbfp)
59
+ {
60
+ fprintf(stderr,
61
+ "PDC_debug(): Unable to open debug log file\n");
62
+ return;
63
+ }
64
+ }
65
+
66
+ time(&now);
67
+ strftime(hms, 9, "%H:%M:%S", localtime(&now));
68
+ fprintf(pdc_dbfp, "At: %8.8ld - %s ", (long) clock(), hms);
69
+
70
+ va_start(args, fmt);
71
+ vfprintf(pdc_dbfp, fmt, args);
72
+ va_end(args);
73
+
74
+ /* If you are crashing and losing debugging information, enable this
75
+ * by setting the environment variable PDC_TRACE_FLUSH to 1. This may
76
+ * impact performance.
77
+ */
78
+ if (want_fflush)
79
+ fflush(pdc_dbfp);
80
+
81
+ /* If with PDC_TRACE_FLUSH enabled you are still losing logging in
82
+ * crashes, you may need to add a platform-dependent mechanism to flush
83
+ * the OS buffers as well (such as fsync() on POSIX) -- but expect
84
+ * terrible performance.
85
+ */
86
+ }
87
+
88
+ void traceon(void)
89
+ {
90
+ char *env;
91
+
92
+ trace_on = TRUE;
93
+ if ((env = getenv("PDC_TRACE_FLUSH")))
94
+ want_fflush = atoi(env);
95
+
96
+ PDC_LOG(("traceon() - called\n"));
97
+ }
98
+
99
+ void traceoff(void)
100
+ {
101
+ if (!pdc_dbfp)
102
+ return;
103
+
104
+ PDC_LOG(("traceoff() - called\n"));
105
+
106
+ fclose(pdc_dbfp);
107
+ pdc_dbfp = NULL;
108
+ want_fflush = trace_on = FALSE;
109
+ }
@@ -0,0 +1,96 @@
1
+ /* Public Domain Curses */
2
+
3
+ #include <curspriv.h>
4
+
5
+ /*man-start**************************************************************
6
+
7
+ delch
8
+ -----
9
+
10
+ ### Synopsis
11
+
12
+ int delch(void);
13
+ int wdelch(WINDOW *win);
14
+ int mvdelch(int y, int x);
15
+ int mvwdelch(WINDOW *win, int y, int x);
16
+
17
+ ### Description
18
+
19
+ The character under the cursor in the window is deleted. All
20
+ characters to the right on the same line are moved to the left
21
+ one position and the last character on the line is filled with
22
+ a blank. The cursor position does not change (after moving to
23
+ y, x if coordinates are specified).
24
+
25
+ ### Return Value
26
+
27
+ All functions return OK on success and ERR on error.
28
+
29
+ ### Portability
30
+ X/Open BSD SYS V
31
+ delch Y Y Y
32
+ wdelch Y Y Y
33
+ mvdelch Y Y Y
34
+ mvwdelch Y Y Y
35
+
36
+ **man-end****************************************************************/
37
+
38
+ #include <string.h>
39
+
40
+ int wdelch(WINDOW *win)
41
+ {
42
+ int y, x, maxx;
43
+ chtype *temp1;
44
+
45
+ PDC_LOG(("wdelch() - called\n"));
46
+
47
+ if (!win)
48
+ return ERR;
49
+
50
+ y = win->_cury;
51
+ x = win->_curx;
52
+ maxx = win->_maxx - 1;
53
+ temp1 = &win->_y[y][x];
54
+
55
+ memmove(temp1, temp1 + 1, (maxx - x) * sizeof(chtype));
56
+
57
+ /* wrs (4/10/93) account for window background */
58
+
59
+ win->_y[y][maxx] = win->_bkgd;
60
+
61
+ win->_lastch[y] = maxx;
62
+
63
+ if ((win->_firstch[y] == _NO_CHANGE) || (win->_firstch[y] > x))
64
+ win->_firstch[y] = x;
65
+
66
+ PDC_sync(win);
67
+
68
+ return OK;
69
+ }
70
+
71
+ int delch(void)
72
+ {
73
+ PDC_LOG(("delch() - called\n"));
74
+
75
+ return wdelch(stdscr);
76
+ }
77
+
78
+ int mvdelch(int y, int x)
79
+ {
80
+ PDC_LOG(("mvdelch() - called\n"));
81
+
82
+ if (move(y, x) == ERR)
83
+ return ERR;
84
+
85
+ return wdelch(stdscr);
86
+ }
87
+
88
+ int mvwdelch(WINDOW *win, int y, int x)
89
+ {
90
+ PDC_LOG(("mvwdelch() - called\n"));
91
+
92
+ if (wmove(win, y, x) == ERR)
93
+ return ERR;
94
+
95
+ return wdelch(win);
96
+ }