curses 1.4.4 → 1.4.6

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