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,157 @@
1
+ /* Public Domain Curses */
2
+
3
+ #include <curspriv.h>
4
+
5
+ /*man-start**************************************************************
6
+
7
+ keyname
8
+ -------
9
+
10
+ ### Synopsis
11
+
12
+ char *keyname(int key);
13
+
14
+ char *key_name(wchar_t c);
15
+
16
+ bool has_key(int key);
17
+
18
+ ### Description
19
+
20
+ keyname() returns a string corresponding to the argument key.
21
+ key may be any key returned by wgetch().
22
+
23
+ key_name() is the wide-character version. It takes a wchar_t
24
+ parameter, but still returns a char *.
25
+
26
+ has_key() returns TRUE for recognized keys, FALSE otherwise.
27
+ This function is an ncurses extension.
28
+
29
+ ### Portability
30
+ X/Open BSD SYS V
31
+ keyname Y - 3.0
32
+ key_name Y
33
+ has_key - - -
34
+
35
+ **man-end****************************************************************/
36
+
37
+ #include <string.h>
38
+
39
+ char *keyname(int key)
40
+ {
41
+ static char _keyname[14];
42
+
43
+ /* Key names must be in exactly the same order as in curses.h */
44
+
45
+ static char *key_names[] =
46
+ {
47
+ "KEY_BREAK", "KEY_DOWN", "KEY_UP", "KEY_LEFT", "KEY_RIGHT",
48
+ "KEY_HOME", "KEY_BACKSPACE", "KEY_F0", "KEY_F(1)", "KEY_F(2)",
49
+ "KEY_F(3)", "KEY_F(4)", "KEY_F(5)", "KEY_F(6)", "KEY_F(7)",
50
+ "KEY_F(8)", "KEY_F(9)", "KEY_F(10)", "KEY_F(11)", "KEY_F(12)",
51
+ "KEY_F(13)", "KEY_F(14)", "KEY_F(15)", "KEY_F(16)", "KEY_F(17)",
52
+ "KEY_F(18)", "KEY_F(19)", "KEY_F(20)", "KEY_F(21)", "KEY_F(22)",
53
+ "KEY_F(23)", "KEY_F(24)", "KEY_F(25)", "KEY_F(26)", "KEY_F(27)",
54
+ "KEY_F(28)", "KEY_F(29)", "KEY_F(30)", "KEY_F(31)", "KEY_F(32)",
55
+ "KEY_F(33)", "KEY_F(34)", "KEY_F(35)", "KEY_F(36)", "KEY_F(37)",
56
+ "KEY_F(38)", "KEY_F(39)", "KEY_F(40)", "KEY_F(41)", "KEY_F(42)",
57
+ "KEY_F(43)", "KEY_F(44)", "KEY_F(45)", "KEY_F(46)", "KEY_F(47)",
58
+ "KEY_F(48)", "KEY_F(49)", "KEY_F(50)", "KEY_F(51)", "KEY_F(52)",
59
+ "KEY_F(53)", "KEY_F(54)", "KEY_F(55)", "KEY_F(56)", "KEY_F(57)",
60
+ "KEY_F(58)", "KEY_F(59)", "KEY_F(60)", "KEY_F(61)", "KEY_F(62)",
61
+ "KEY_F(63)", "KEY_DL", "KEY_IL", "KEY_DC", "KEY_IC", "KEY_EIC",
62
+ "KEY_CLEAR", "KEY_EOS", "KEY_EOL", "KEY_SF", "KEY_SR",
63
+ "KEY_NPAGE", "KEY_PPAGE", "KEY_STAB", "KEY_CTAB", "KEY_CATAB",
64
+ "KEY_ENTER", "KEY_SRESET", "KEY_RESET", "KEY_PRINT", "KEY_LL",
65
+ "KEY_ABORT", "KEY_SHELP", "KEY_LHELP", "KEY_BTAB", "KEY_BEG",
66
+ "KEY_CANCEL", "KEY_CLOSE", "KEY_COMMAND", "KEY_COPY",
67
+ "KEY_CREATE", "KEY_END", "KEY_EXIT", "KEY_FIND", "KEY_HELP",
68
+ "KEY_MARK", "KEY_MESSAGE", "KEY_MOVE", "KEY_NEXT", "KEY_OPEN",
69
+ "KEY_OPTIONS", "KEY_PREVIOUS", "KEY_REDO", "KEY_REFERENCE",
70
+ "KEY_REFRESH", "KEY_REPLACE", "KEY_RESTART", "KEY_RESUME",
71
+ "KEY_SAVE", "KEY_SBEG", "KEY_SCANCEL", "KEY_SCOMMAND",
72
+ "KEY_SCOPY", "KEY_SCREATE", "KEY_SDC", "KEY_SDL", "KEY_SELECT",
73
+ "KEY_SEND", "KEY_SEOL", "KEY_SEXIT", "KEY_SFIND", "KEY_SHOME",
74
+ "KEY_SIC", "UNKNOWN KEY", "KEY_SLEFT", "KEY_SMESSAGE",
75
+ "KEY_SMOVE", "KEY_SNEXT", "KEY_SOPTIONS", "KEY_SPREVIOUS",
76
+ "KEY_SPRINT", "KEY_SREDO", "KEY_SREPLACE", "KEY_SRIGHT",
77
+ "KEY_SRSUME", "KEY_SSAVE", "KEY_SSUSPEND", "KEY_SUNDO",
78
+ "KEY_SUSPEND", "KEY_UNDO", "ALT_0", "ALT_1", "ALT_2", "ALT_3",
79
+ "ALT_4", "ALT_5", "ALT_6", "ALT_7", "ALT_8", "ALT_9", "ALT_A",
80
+ "ALT_B", "ALT_C", "ALT_D", "ALT_E", "ALT_F", "ALT_G", "ALT_H",
81
+ "ALT_I", "ALT_J", "ALT_K", "ALT_L", "ALT_M", "ALT_N", "ALT_O",
82
+ "ALT_P", "ALT_Q", "ALT_R", "ALT_S", "ALT_T", "ALT_U", "ALT_V",
83
+ "ALT_W", "ALT_X", "ALT_Y", "ALT_Z", "CTL_LEFT", "CTL_RIGHT",
84
+ "CTL_PGUP", "CTL_PGDN", "CTL_HOME", "CTL_END", "KEY_A1",
85
+ "KEY_A2", "KEY_A3", "KEY_B1", "KEY_B2", "KEY_B3", "KEY_C1",
86
+ "KEY_C2", "KEY_C3", "PADSLASH", "PADENTER", "CTL_PADENTER",
87
+ "ALT_PADENTER", "PADSTOP", "PADSTAR", "PADMINUS", "PADPLUS",
88
+ "CTL_PADSTOP", "CTL_PADCENTER", "CTL_PADPLUS", "CTL_PADMINUS",
89
+ "CTL_PADSLASH", "CTL_PADSTAR", "ALT_PADPLUS", "ALT_PADMINUS",
90
+ "ALT_PADSLASH", "ALT_PADSTAR", "ALT_PADSTOP", "CTL_INS",
91
+ "ALT_DEL", "ALT_INS", "CTL_UP", "CTL_DOWN", "CTL_TAB",
92
+ "ALT_TAB", "ALT_MINUS", "ALT_EQUAL", "ALT_HOME", "ALT_PGUP",
93
+ "ALT_PGDN", "ALT_END", "ALT_UP", "ALT_DOWN", "ALT_RIGHT",
94
+ "ALT_LEFT", "ALT_ENTER", "ALT_ESC", "ALT_BQUOTE",
95
+ "ALT_LBRACKET", "ALT_RBRACKET", "ALT_SEMICOLON", "ALT_FQUOTE",
96
+ "ALT_COMMA", "ALT_STOP", "ALT_FSLASH", "ALT_BKSP", "CTL_BKSP",
97
+ "PAD0", "CTL_PAD0", "CTL_PAD1", "CTL_PAD2", "CTL_PAD3",
98
+ "CTL_PAD4", "CTL_PAD5", "CTL_PAD6", "CTL_PAD7","CTL_PAD8",
99
+ "CTL_PAD9", "ALT_PAD0", "ALT_PAD1", "ALT_PAD2", "ALT_PAD3",
100
+ "ALT_PAD4", "ALT_PAD5", "ALT_PAD6", "ALT_PAD7", "ALT_PAD8",
101
+ "ALT_PAD9", "CTL_DEL", "ALT_BSLASH", "CTL_ENTER",
102
+ "SHF_PADENTER", "SHF_PADSLASH", "SHF_PADSTAR", "SHF_PADPLUS",
103
+ "SHF_PADMINUS", "SHF_UP", "SHF_DOWN", "SHF_IC", "SHF_DC",
104
+ "KEY_MOUSE", "KEY_SHIFT_L", "KEY_SHIFT_R", "KEY_CONTROL_L",
105
+ "KEY_CONTROL_R", "KEY_ALT_L", "KEY_ALT_R", "KEY_RESIZE",
106
+ "KEY_SUP", "KEY_SDOWN",
107
+ /* Win32a extras: */
108
+ "CTL_SEMICOLON", "CTL_EQUAL", "CTL_COMMA",
109
+ "CTL_MINUS", "CTL_STOP", "CTL_FSLASH",
110
+ "CTL_BQUOTE", "KEY_APPS", "KEY_SAPPS", "CTL_APPS",
111
+ "ALT_APPS", "KEY_PAUSE", "KEY_SPAUSE",
112
+ "CTL_PAUSE", "KEY_PRINTSCREEN", "ALT_PRINTSCREEN",
113
+ "KEY_SCROLLLOCK", "ALT_SCROLLLOCK",
114
+ "CTL_0", "CTL_1", "CTL_2", "CTL_3", "CTL_4",
115
+ "CTL_5", "CTL_6", "CTL_7", "CTL_8", "CTL_9",
116
+ "BROWSER_BACK", "SBROWSER_BACK", "CBROWSER_BACK", "ABROWSER_BACK",
117
+ "BROWSER_FWD", "SBROWSER_FWD", "CBROWSER_FWD", "ABROWSER_FWD",
118
+ "BROWSER_REF", "SBROWSER_REF", "CBROWSER_REF", "ABROWSER_REF",
119
+ "BROWSER_STOP", "SBROWSER_STOP", "CBROWSER_STOP", "ABROWSER_STOP",
120
+ "SEARCH", "SSEARCH", "CSEARCH", "ASEARCH",
121
+ "FAVORITES", "SFAVORITES", "CFAVORITES", "AFAVORITES",
122
+ "BROWSER_HOME", "SBROWSER_HOME", "CBROWSER_HOME", "ABROWSER_HOME",
123
+ "VOLUME_MUTE", "SVOLUME_MUTE", "CVOLUME_MUTE", "AVOLUME_MUTE",
124
+ "VOLUME_DOWN", "SVOLUME_DOWN", "CVOLUME_DOWN", "AVOLUME_DOWN",
125
+ "VOLUME_UP", "SVOLUME_UP", "CVOLUME_UP", "AVOLUME_UP",
126
+ "NEXT_TRACK", "SNEXT_TRACK", "CNEXT_TRACK", "ANEXT_TRACK",
127
+ "PREV_TRACK", "SPREV_TRACK", "CPREV_TRACK", "APREV_TRACK",
128
+ "MEDIA_STOP", "SMEDIA_STOP", "CMEDIA_STOP", "AMEDIA_STOP",
129
+ "PLAY_PAUSE", "SPLAY_PAUSE", "CPLAY_PAUSE", "APLAY_PAUSE",
130
+ "LAUNCH_MAIL", "SLAUNCH_MAIL", "CLAUNCH_MAIL", "ALAUNCH_MAIL",
131
+ "MEDIA_SELECT", "SMEDIA_SELECT", "CMEDIA_SELECT", "AMEDIA_SELECT",
132
+ "LAUNCH_APP1", "SLAUNCH_APP1", "CLAUNCH_APP1", "ALAUNCH_APP1",
133
+ "LAUNCH_APP2", "SLAUNCH_APP2", "CLAUNCH_APP2", "ALAUNCH_APP2" };
134
+
135
+ PDC_LOG(("keyname() - called: key %d\n", key));
136
+
137
+ strcpy(_keyname, ((key >= 0) && (key < 0x80)) ? unctrl((chtype)key) :
138
+ has_key(key) ? key_names[key - KEY_MIN] : "UNKNOWN KEY");
139
+
140
+ return _keyname;
141
+ }
142
+
143
+ bool has_key(int key)
144
+ {
145
+ PDC_LOG(("has_key() - called: key %d\n", key));
146
+
147
+ return (key >= KEY_MIN && key <= KEY_MAX);
148
+ }
149
+
150
+ #ifdef PDC_WIDE
151
+ char *key_name(wchar_t c)
152
+ {
153
+ PDC_LOG(("key_name() - called\n"));
154
+
155
+ return keyname((int)c);
156
+ }
157
+ #endif
@@ -0,0 +1,438 @@
1
+ /* Public Domain Curses */
2
+
3
+ #include <curspriv.h>
4
+
5
+ /*man-start**************************************************************
6
+
7
+ mouse
8
+ -----
9
+
10
+ ### Synopsis
11
+
12
+ int mouse_set(unsigned long mbe);
13
+ int mouse_on(unsigned long mbe);
14
+ int mouse_off(unsigned long mbe);
15
+ int request_mouse_pos(void);
16
+ int map_button(unsigned long button);
17
+ void wmouse_position(WINDOW *win, int *y, int *x);
18
+ unsigned long getmouse(void);
19
+ unsigned long getbmap(void);
20
+
21
+ int mouseinterval(int wait);
22
+ bool wenclose(const WINDOW *win, int y, int x);
23
+ bool wmouse_trafo(const WINDOW *win, int *y, int *x, bool to_screen);
24
+ bool mouse_trafo(int *y, int *x, bool to_screen);
25
+ mmask_t mousemask(mmask_t mask, mmask_t *oldmask);
26
+ int nc_getmouse(MEVENT *event);
27
+ int ungetmouse(MEVENT *event);
28
+
29
+ ### Description
30
+
31
+ As of PDCurses 3.0, there are two separate mouse interfaces: the
32
+ classic interface, which is based on the undocumented Sys V
33
+ mouse functions; and an ncurses-compatible interface. Both are
34
+ active at all times, and you can mix and match functions from
35
+ each, though it's not recommended. The ncurses interface is
36
+ essentially an emulation layer built on top of the classic
37
+ interface; it's here to allow easier porting of ncurses apps.
38
+
39
+ The classic interface: mouse_set(), mouse_on(), mouse_off(),
40
+ request_mouse_pos(), map_button(), wmouse_position(),
41
+ getmouse(), and getbmap(). An application using this interface
42
+ would start by calling mouse_set() or mouse_on() with a non-zero
43
+ value, often ALL_MOUSE_EVENTS. Then it would check for a
44
+ KEY_MOUSE return from getch(). If found, it would call
45
+ request_mouse_pos() to get the current mouse status.
46
+
47
+ mouse_set(), mouse_on() and mouse_off() are analagous to
48
+ attrset(), attron() and attroff(). These functions set the
49
+ mouse button events to trap. The button masks used in these
50
+ functions are defined in curses.h and can be or'ed together.
51
+ They are the group of masks starting with BUTTON1_RELEASED.
52
+
53
+ request_mouse_pos() requests curses to fill in the Mouse_status
54
+ structure with the current state of the mouse.
55
+
56
+ map_button() enables the specified mouse action to activate the
57
+ Soft Label Keys if the action occurs over the area of the screen
58
+ where the Soft Label Keys are displayed. The mouse actions are
59
+ defined in curses.h in the group that starts with BUTTON_RELEASED.
60
+
61
+ wmouse_position() determines if the current mouse position is
62
+ within the window passed as an argument. If the mouse is
63
+ outside the current window, -1 is returned in the y and x
64
+ arguments; otherwise the y and x coordinates of the mouse
65
+ (relative to the top left corner of the window) are returned in
66
+ y and x.
67
+
68
+ getmouse() returns the current status of the trapped mouse
69
+ buttons as set by mouse_set() or mouse_on().
70
+
71
+ getbmap() returns the current status of the button action used
72
+ to map a mouse action to the Soft Label Keys as set by the
73
+ map_button() function.
74
+
75
+ The ncurses interface: mouseinterval(), wenclose(),
76
+ wmouse_trafo(), mouse_trafo(), mousemask(), nc_getmouse(), and
77
+ ungetmouse(). A typical application using this interface would
78
+ start by calling mousemask() with a non-zero value, often
79
+ ALL_MOUSE_EVENTS. Then it would check for a KEY_MOUSE return
80
+ from getch(). If found, it would call nc_getmouse() to get the
81
+ current mouse status.
82
+
83
+ mouseinterval() sets the timeout for a mouse click. On all
84
+ current platforms, PDCurses receives mouse button press and
85
+ release events, but must synthesize click events. It does this
86
+ by checking whether a release event is queued up after a press
87
+ event. If it gets a press event, and there are no more events
88
+ waiting, it will wait for the timeout interval, then check again
89
+ for a release. A press followed by a release is reported as
90
+ BUTTON_CLICKED; otherwise it's passed through as BUTTON_PRESSED.
91
+ The default timeout is 150ms; valid values are 0 (no clicks
92
+ reported) through 1000ms. In x11, the timeout can also be set
93
+ via the clickPeriod resource. The return value from
94
+ mouseinterval() is the old timeout. To check the old value
95
+ without setting a new one, call it with a parameter of -1. Note
96
+ that although there's no classic equivalent for this function
97
+ (apart from the clickPeriod resource), the value set applies in
98
+ both interfaces.
99
+
100
+ wenclose() reports whether the given screen-relative y, x
101
+ coordinates fall within the given window.
102
+
103
+ wmouse_trafo() converts between screen-relative and window-
104
+ relative coordinates. A to_screen parameter of TRUE means to
105
+ convert from window to screen; otherwise the reverse. The
106
+ function returns FALSE if the coordinates aren't within the
107
+ window, or if any of the parameters are NULL. The coordinates
108
+ have been converted when the function returns TRUE.
109
+
110
+ mouse_trafo() is the stdscr version of wmouse_trafo().
111
+
112
+ mousemask() is nearly equivalent to mouse_set(), but instead of
113
+ OK/ERR, it returns the value of the mask after setting it. (This
114
+ isn't necessarily the same value passed in, since the mask could
115
+ be altered on some platforms.) And if the second parameter is a
116
+ non-null pointer, mousemask() stores the previous mask value
117
+ there. Also, since the ncurses interface doesn't work with
118
+ PDCurses' BUTTON_MOVED events, mousemask() filters them out.
119
+
120
+ nc_getmouse() returns the current mouse status in an MEVENT
121
+ struct. This is equivalent to ncurses' getmouse(), renamed to
122
+ avoid conflict with PDCurses' getmouse(). But if you define
123
+ PDC_NCMOUSE before including curses.h, it defines getmouse() to
124
+ nc_getmouse(), along with a few other redefintions needed for
125
+ compatibility with ncurses code. nc_getmouse() calls
126
+ request_mouse_pos(), which (not getmouse()) is the classic
127
+ equivalent.
128
+
129
+ ungetmouse() is the mouse equivalent of ungetch(). However,
130
+ PDCurses doesn't maintain a queue of mouse events; only one can
131
+ be pushed back, and it can overwrite or be overwritten by real
132
+ mouse events.
133
+
134
+ ### Portability
135
+ X/Open BSD SYS V
136
+ mouse_set - - 4.0
137
+ mouse_on - - 4.0
138
+ mouse_off - - 4.0
139
+ request_mouse_pos - - 4.0
140
+ map_button - - 4.0
141
+ wmouse_position - - 4.0
142
+ getmouse - - 4.0
143
+ getbmap - - 4.0
144
+ mouseinterval - - -
145
+ wenclose - - -
146
+ wmouse_trafo - - -
147
+ mouse_trafo - - -
148
+ mousemask - - -
149
+ nc_getmouse - - -
150
+ ungetmouse - - -
151
+
152
+ **man-end****************************************************************/
153
+
154
+ #include <string.h>
155
+
156
+ static bool ungot = FALSE;
157
+
158
+ int mouse_set(unsigned long mbe)
159
+ {
160
+ PDC_LOG(("mouse_set() - called: event %x\n", mbe));
161
+
162
+ SP->_trap_mbe = mbe;
163
+ return PDC_mouse_set();
164
+ }
165
+
166
+ int mouse_on(unsigned long mbe)
167
+ {
168
+ PDC_LOG(("mouse_on() - called: event %x\n", mbe));
169
+
170
+ SP->_trap_mbe |= mbe;
171
+ return PDC_mouse_set();
172
+ }
173
+
174
+ int mouse_off(unsigned long mbe)
175
+ {
176
+ PDC_LOG(("mouse_off() - called: event %x\n", mbe));
177
+
178
+ SP->_trap_mbe &= ~mbe;
179
+ return PDC_mouse_set();
180
+ }
181
+
182
+ int map_button(unsigned long button)
183
+ {
184
+ PDC_LOG(("map_button() - called: button %x\n", button));
185
+
186
+ /****************** this does nothing at the moment ***************/
187
+ SP->_map_mbe_to_key = button;
188
+
189
+ return OK;
190
+ }
191
+
192
+ int request_mouse_pos(void)
193
+ {
194
+ PDC_LOG(("request_mouse_pos() - called\n"));
195
+
196
+ Mouse_status = pdc_mouse_status;
197
+
198
+ return OK;
199
+ }
200
+
201
+ void wmouse_position(WINDOW *win, int *y, int *x)
202
+ {
203
+ PDC_LOG(("wmouse_position() - called\n"));
204
+
205
+ if (win && wenclose(win, MOUSE_Y_POS, MOUSE_X_POS))
206
+ {
207
+ if (y)
208
+ *y = MOUSE_Y_POS - win->_begy;
209
+ if (x)
210
+ *x = MOUSE_X_POS - win->_begx;
211
+ }
212
+ else
213
+ {
214
+ if (y)
215
+ *y = -1;
216
+ if (x)
217
+ *x = -1;
218
+ }
219
+ }
220
+
221
+ unsigned long getmouse(void)
222
+ {
223
+ PDC_LOG(("getmouse() - called\n"));
224
+
225
+ return SP->_trap_mbe;
226
+ }
227
+
228
+ unsigned long getbmap(void)
229
+ {
230
+ PDC_LOG(("getbmap() - called\n"));
231
+
232
+ return SP->_map_mbe_to_key;
233
+ }
234
+
235
+ /* ncurses mouse interface */
236
+
237
+ int mouseinterval(int wait)
238
+ {
239
+ int old_wait;
240
+
241
+ PDC_LOG(("mouseinterval() - called: %d\n", wait));
242
+
243
+ old_wait = SP->mouse_wait;
244
+
245
+ if (wait >= 0 && wait <= 1000)
246
+ SP->mouse_wait = wait;
247
+
248
+ return old_wait;
249
+ }
250
+
251
+ bool wenclose(const WINDOW *win, int y, int x)
252
+ {
253
+ PDC_LOG(("wenclose() - called: %p %d %d\n", win, y, x));
254
+
255
+ return (win && y >= win->_begy && y < win->_begy + win->_maxy
256
+ && x >= win->_begx && x < win->_begx + win->_maxx);
257
+ }
258
+
259
+ bool wmouse_trafo(const WINDOW *win, int *y, int *x, bool to_screen)
260
+ {
261
+ int newy, newx;
262
+
263
+ PDC_LOG(("wmouse_trafo() - called\n"));
264
+
265
+ if (!win || !y || !x)
266
+ return FALSE;
267
+
268
+ newy = *y;
269
+ newx = *x;
270
+
271
+ if (to_screen)
272
+ {
273
+ newy += win->_begy;
274
+ newx += win->_begx;
275
+
276
+ if (!wenclose(win, newy, newx))
277
+ return FALSE;
278
+ }
279
+ else
280
+ {
281
+ if (wenclose(win, newy, newx))
282
+ {
283
+ newy -= win->_begy;
284
+ newx -= win->_begx;
285
+ }
286
+ else
287
+ return FALSE;
288
+ }
289
+
290
+ *y = newy;
291
+ *x = newx;
292
+
293
+ return TRUE;
294
+ }
295
+
296
+ bool mouse_trafo(int *y, int *x, bool to_screen)
297
+ {
298
+ PDC_LOG(("mouse_trafo() - called\n"));
299
+
300
+ return wmouse_trafo(stdscr, y, x, to_screen);
301
+ }
302
+
303
+ mmask_t mousemask(mmask_t mask, mmask_t *oldmask)
304
+ {
305
+ PDC_LOG(("mousemask() - called\n"));
306
+
307
+ if (oldmask)
308
+ *oldmask = SP->_trap_mbe;
309
+
310
+ /* The ncurses interface doesn't work with our move events, so
311
+ filter them here */
312
+
313
+ mask &= ~(BUTTON1_MOVED | BUTTON2_MOVED | BUTTON3_MOVED);
314
+
315
+ mouse_set(mask);
316
+
317
+ return SP->_trap_mbe;
318
+ }
319
+
320
+ int nc_getmouse(MEVENT *event)
321
+ {
322
+ int i;
323
+ mmask_t bstate = 0;
324
+
325
+ PDC_LOG(("nc_getmouse() - called\n"));
326
+
327
+ if (!event)
328
+ return ERR;
329
+
330
+ ungot = FALSE;
331
+
332
+ request_mouse_pos();
333
+
334
+ event->id = 0;
335
+
336
+ event->x = Mouse_status.x;
337
+ event->y = Mouse_status.y;
338
+ event->z = 0;
339
+
340
+ for (i = 0; i < 3; i++)
341
+ {
342
+ if (Mouse_status.changes & (1 << i))
343
+ {
344
+ int shf = i * 5;
345
+ short button = Mouse_status.button[i] & BUTTON_ACTION_MASK;
346
+
347
+ if (button == BUTTON_RELEASED)
348
+ bstate |= (BUTTON1_RELEASED << shf);
349
+ else if (button == BUTTON_PRESSED)
350
+ bstate |= (BUTTON1_PRESSED << shf);
351
+ else if (button == BUTTON_CLICKED)
352
+ bstate |= (BUTTON1_CLICKED << shf);
353
+ else if (button == BUTTON_DOUBLE_CLICKED)
354
+ bstate |= (BUTTON1_DOUBLE_CLICKED << shf);
355
+ else if (button == BUTTON_TRIPLE_CLICKED)
356
+ bstate |= (BUTTON1_TRIPLE_CLICKED << shf);
357
+
358
+ button = Mouse_status.button[i] & BUTTON_MODIFIER_MASK;
359
+
360
+ if (button & PDC_BUTTON_SHIFT)
361
+ bstate |= BUTTON_MODIFIER_SHIFT;
362
+ if (button & PDC_BUTTON_CONTROL)
363
+ bstate |= BUTTON_MODIFIER_CONTROL;
364
+ if (button & PDC_BUTTON_ALT)
365
+ bstate |= BUTTON_MODIFIER_ALT;
366
+ }
367
+ }
368
+
369
+ if (MOUSE_WHEEL_UP)
370
+ bstate |= BUTTON4_PRESSED;
371
+ else if (MOUSE_WHEEL_DOWN)
372
+ bstate |= BUTTON5_PRESSED;
373
+ if( MOUSE_MOVED)
374
+ bstate |= REPORT_MOUSE_POSITION;
375
+
376
+ /* extra filter pass -- mainly for button modifiers */
377
+
378
+ event->bstate = bstate & SP->_trap_mbe;
379
+
380
+ return OK;
381
+ }
382
+
383
+ int ungetmouse(MEVENT *event)
384
+ {
385
+ int i;
386
+ unsigned long bstate;
387
+
388
+ PDC_LOG(("ungetmouse() - called\n"));
389
+
390
+ if (!event || ungot)
391
+ return ERR;
392
+
393
+ ungot = TRUE;
394
+
395
+ pdc_mouse_status.x = event->x;
396
+ pdc_mouse_status.y = event->y;
397
+
398
+ pdc_mouse_status.changes = 0;
399
+ bstate = event->bstate;
400
+
401
+ for (i = 0; i < 3; i++)
402
+ {
403
+ int shf = i * 5;
404
+ short button = 0;
405
+
406
+ if (bstate & ((BUTTON1_RELEASED | BUTTON1_PRESSED |
407
+ BUTTON1_TRIPLE_CLICKED |
408
+ BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED) << shf))
409
+ {
410
+ pdc_mouse_status.changes |= 1 << i;
411
+
412
+ if (bstate & (BUTTON1_PRESSED << shf))
413
+ button = BUTTON_PRESSED;
414
+ if (bstate & (BUTTON1_CLICKED << shf))
415
+ button = BUTTON_CLICKED;
416
+ if (bstate & (BUTTON1_DOUBLE_CLICKED << shf))
417
+ button = BUTTON_DOUBLE_CLICKED;
418
+ if (bstate & (BUTTON1_TRIPLE_CLICKED << shf))
419
+ button = BUTTON_TRIPLE_CLICKED;
420
+
421
+ if (bstate & BUTTON_MODIFIER_SHIFT)
422
+ button |= PDC_BUTTON_SHIFT;
423
+ if (bstate & BUTTON_MODIFIER_CONTROL)
424
+ button |= PDC_BUTTON_CONTROL;
425
+ if (bstate & BUTTON_MODIFIER_ALT)
426
+ button |= PDC_BUTTON_ALT;
427
+ }
428
+
429
+ pdc_mouse_status.button[i] = button;
430
+ }
431
+
432
+ if (bstate & BUTTON4_PRESSED)
433
+ pdc_mouse_status.changes |= PDC_MOUSE_WHEEL_UP;
434
+ else if (bstate & BUTTON5_PRESSED)
435
+ pdc_mouse_status.changes |= PDC_MOUSE_WHEEL_DOWN;
436
+
437
+ return ungetch(KEY_MOUSE);
438
+ }