curses 1.4.5 → 1.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/push_gem.yml +48 -0
- data/History.md +3 -0
- data/curses.gemspec +1 -1
- metadata +8 -247
- data/vendor/PDCurses/.gitignore +0 -47
- data/vendor/PDCurses/.travis.yml +0 -49
- data/vendor/PDCurses/CMakeLists.txt +0 -68
- data/vendor/PDCurses/HISTORY.md +0 -2036
- data/vendor/PDCurses/IMPLEMNT.md +0 -327
- data/vendor/PDCurses/Makefile +0 -27
- data/vendor/PDCurses/README.md +0 -77
- data/vendor/PDCurses/acs_defs.h +0 -265
- data/vendor/PDCurses/appveyor.yml +0 -218
- data/vendor/PDCurses/cmake/README.md +0 -71
- data/vendor/PDCurses/cmake/build_dependencies.cmake +0 -178
- data/vendor/PDCurses/cmake/build_options.cmake +0 -25
- data/vendor/PDCurses/cmake/dll_version.cmake +0 -26
- data/vendor/PDCurses/cmake/gen_config_header.cmake +0 -43
- data/vendor/PDCurses/cmake/get_version.cmake +0 -17
- data/vendor/PDCurses/cmake/make_uninstall.cmake +0 -19
- data/vendor/PDCurses/cmake/project_common.cmake +0 -121
- data/vendor/PDCurses/cmake/resource.in.cmake +0 -52
- data/vendor/PDCurses/cmake/sdl2_ttf/CMakeLists.txt +0 -83
- data/vendor/PDCurses/cmake/target_arch.cmake +0 -36
- data/vendor/PDCurses/cmake/version.in.cmake +0 -73
- data/vendor/PDCurses/cmake/watcom_open_dos16_toolchain.cmake +0 -96
- data/vendor/PDCurses/cmake/watcom_open_dos32_toolchain.cmake +0 -106
- data/vendor/PDCurses/cmake/watcom_open_os2v2_toolchain.cmake +0 -105
- data/vendor/PDCurses/curses.h +0 -1846
- data/vendor/PDCurses/curspriv.h +0 -134
- data/vendor/PDCurses/demos/README.md +0 -25
- data/vendor/PDCurses/demos/firework.c +0 -144
- data/vendor/PDCurses/demos/newtest.c +0 -581
- data/vendor/PDCurses/demos/ozdemo.c +0 -447
- data/vendor/PDCurses/demos/ptest.c +0 -283
- data/vendor/PDCurses/demos/rain.c +0 -157
- data/vendor/PDCurses/demos/testcurs.c +0 -1607
- data/vendor/PDCurses/demos/tui.c +0 -1048
- data/vendor/PDCurses/demos/tui.h +0 -65
- data/vendor/PDCurses/demos/tuidemo.c +0 -233
- data/vendor/PDCurses/demos/version.c +0 -61
- data/vendor/PDCurses/demos/worm.c +0 -432
- data/vendor/PDCurses/demos/xmas.c +0 -955
- data/vendor/PDCurses/dos/CMakeLists.txt +0 -47
- data/vendor/PDCurses/dos/Makefile +0 -105
- data/vendor/PDCurses/dos/Makefile.bcc +0 -83
- data/vendor/PDCurses/dos/Makefile.dmc +0 -257
- data/vendor/PDCurses/dos/Makefile.msc +0 -113
- data/vendor/PDCurses/dos/Makefile.wcc +0 -107
- data/vendor/PDCurses/dos/README.md +0 -51
- data/vendor/PDCurses/dos/bccdos.lrf +0 -9
- data/vendor/PDCurses/dos/mscdos.lrf +0 -50
- data/vendor/PDCurses/dos/pdcclip.c +0 -132
- data/vendor/PDCurses/dos/pdcdisp.c +0 -135
- data/vendor/PDCurses/dos/pdcdos.h +0 -194
- data/vendor/PDCurses/dos/pdcgetsc.c +0 -98
- data/vendor/PDCurses/dos/pdckbd.c +0 -513
- data/vendor/PDCurses/dos/pdcscrn.c +0 -785
- data/vendor/PDCurses/dos/pdcsetsc.c +0 -101
- data/vendor/PDCurses/dos/pdcutil.c +0 -212
- data/vendor/PDCurses/libobjs.mif +0 -26
- data/vendor/PDCurses/makedist.mif +0 -20
- data/vendor/PDCurses/man/Makefile +0 -37
- data/vendor/PDCurses/man/README.md +0 -21
- data/vendor/PDCurses/man/intro.md +0 -361
- data/vendor/PDCurses/man/manext.c +0 -119
- data/vendor/PDCurses/man/sdl.md +0 -152
- data/vendor/PDCurses/man/sdl2.md +0 -58
- data/vendor/PDCurses/man/x11.md +0 -407
- data/vendor/PDCurses/ncurses/CMakeLists.txt +0 -66
- data/vendor/PDCurses/ncurses/README.md +0 -26
- data/vendor/PDCurses/ncurses/makefile +0 -29
- data/vendor/PDCurses/os2/CMakeLists.txt +0 -41
- data/vendor/PDCurses/os2/Makefile +0 -132
- data/vendor/PDCurses/os2/Makefile.bcc +0 -90
- data/vendor/PDCurses/os2/Makefile.wcc +0 -43
- data/vendor/PDCurses/os2/README.md +0 -43
- data/vendor/PDCurses/os2/iccos2.lrf +0 -50
- data/vendor/PDCurses/os2/iccos2.mak +0 -256
- data/vendor/PDCurses/os2/pdcclip.c +0 -188
- data/vendor/PDCurses/os2/pdcdisp.c +0 -93
- data/vendor/PDCurses/os2/pdcgetsc.c +0 -89
- data/vendor/PDCurses/os2/pdckbd.c +0 -521
- data/vendor/PDCurses/os2/pdcos2.h +0 -55
- data/vendor/PDCurses/os2/pdcscrn.c +0 -449
- data/vendor/PDCurses/os2/pdcsetsc.c +0 -112
- data/vendor/PDCurses/os2/pdcutil.c +0 -52
- data/vendor/PDCurses/panel.h +0 -56
- data/vendor/PDCurses/pdcurses/README.md +0 -25
- data/vendor/PDCurses/pdcurses/addch.c +0 -693
- data/vendor/PDCurses/pdcurses/addchstr.c +0 -245
- data/vendor/PDCurses/pdcurses/addstr.c +0 -240
- data/vendor/PDCurses/pdcurses/attr.c +0 -359
- data/vendor/PDCurses/pdcurses/beep.c +0 -68
- data/vendor/PDCurses/pdcurses/bkgd.c +0 -223
- data/vendor/PDCurses/pdcurses/border.c +0 -411
- data/vendor/PDCurses/pdcurses/clear.c +0 -159
- data/vendor/PDCurses/pdcurses/color.c +0 -298
- data/vendor/PDCurses/pdcurses/debug.c +0 -109
- data/vendor/PDCurses/pdcurses/delch.c +0 -96
- data/vendor/PDCurses/pdcurses/deleteln.c +0 -211
- data/vendor/PDCurses/pdcurses/deprec.c +0 -27
- data/vendor/PDCurses/pdcurses/getch.c +0 -417
- data/vendor/PDCurses/pdcurses/getstr.c +0 -474
- data/vendor/PDCurses/pdcurses/getyx.c +0 -139
- data/vendor/PDCurses/pdcurses/inch.c +0 -127
- data/vendor/PDCurses/pdcurses/inchstr.c +0 -214
- data/vendor/PDCurses/pdcurses/initscr.c +0 -367
- data/vendor/PDCurses/pdcurses/inopts.c +0 -324
- data/vendor/PDCurses/pdcurses/insch.c +0 -271
- data/vendor/PDCurses/pdcurses/insstr.c +0 -264
- data/vendor/PDCurses/pdcurses/instr.c +0 -246
- data/vendor/PDCurses/pdcurses/kernel.c +0 -259
- data/vendor/PDCurses/pdcurses/keyname.c +0 -157
- data/vendor/PDCurses/pdcurses/mouse.c +0 -438
- data/vendor/PDCurses/pdcurses/move.c +0 -57
- data/vendor/PDCurses/pdcurses/outopts.c +0 -159
- data/vendor/PDCurses/pdcurses/overlay.c +0 -214
- data/vendor/PDCurses/pdcurses/pad.c +0 -260
- data/vendor/PDCurses/pdcurses/panel.c +0 -633
- data/vendor/PDCurses/pdcurses/printw.c +0 -126
- data/vendor/PDCurses/pdcurses/refresh.c +0 -279
- data/vendor/PDCurses/pdcurses/scanw.c +0 -578
- data/vendor/PDCurses/pdcurses/scr_dump.c +0 -213
- data/vendor/PDCurses/pdcurses/scroll.c +0 -101
- data/vendor/PDCurses/pdcurses/slk.c +0 -591
- data/vendor/PDCurses/pdcurses/termattr.c +0 -182
- data/vendor/PDCurses/pdcurses/terminfo.c +0 -217
- data/vendor/PDCurses/pdcurses/touch.c +0 -163
- data/vendor/PDCurses/pdcurses/util.c +0 -312
- data/vendor/PDCurses/pdcurses/window.c +0 -569
- data/vendor/PDCurses/sdl1/Makefile +0 -129
- data/vendor/PDCurses/sdl1/Makefile.mng +0 -110
- data/vendor/PDCurses/sdl1/README.md +0 -31
- data/vendor/PDCurses/sdl1/deffont.h +0 -385
- data/vendor/PDCurses/sdl1/deficon.h +0 -23
- data/vendor/PDCurses/sdl1/pdcclip.c +0 -131
- data/vendor/PDCurses/sdl1/pdcdisp.c +0 -373
- data/vendor/PDCurses/sdl1/pdcgetsc.c +0 -30
- data/vendor/PDCurses/sdl1/pdckbd.c +0 -405
- data/vendor/PDCurses/sdl1/pdcscrn.c +0 -414
- data/vendor/PDCurses/sdl1/pdcsdl.h +0 -31
- data/vendor/PDCurses/sdl1/pdcsetsc.c +0 -64
- data/vendor/PDCurses/sdl1/pdcutil.c +0 -40
- data/vendor/PDCurses/sdl1/sdltest.c +0 -79
- data/vendor/PDCurses/sdl2/CMakeLists.txt +0 -76
- data/vendor/PDCurses/sdl2/Makefile +0 -135
- data/vendor/PDCurses/sdl2/Makefile.vc +0 -164
- data/vendor/PDCurses/sdl2/README.md +0 -34
- data/vendor/PDCurses/sdl2/deffont.h +0 -385
- data/vendor/PDCurses/sdl2/deficon.h +0 -23
- data/vendor/PDCurses/sdl2/pdcclip.c +0 -93
- data/vendor/PDCurses/sdl2/pdcdisp.c +0 -534
- data/vendor/PDCurses/sdl2/pdcgetsc.c +0 -30
- data/vendor/PDCurses/sdl2/pdckbd.c +0 -480
- data/vendor/PDCurses/sdl2/pdcscrn.c +0 -443
- data/vendor/PDCurses/sdl2/pdcsdl.h +0 -33
- data/vendor/PDCurses/sdl2/pdcsetsc.c +0 -67
- data/vendor/PDCurses/sdl2/pdcutil.c +0 -39
- data/vendor/PDCurses/sdl2/sdltest.c +0 -81
- data/vendor/PDCurses/term.h +0 -48
- data/vendor/PDCurses/version.mif +0 -7
- data/vendor/PDCurses/vt/CMakeLists.txt +0 -28
- data/vendor/PDCurses/vt/Makefile +0 -135
- data/vendor/PDCurses/vt/Makefile.bcc +0 -111
- data/vendor/PDCurses/vt/Makefile.dmc +0 -258
- data/vendor/PDCurses/vt/Makefile.vc +0 -144
- data/vendor/PDCurses/vt/Makefile.wcc +0 -107
- data/vendor/PDCurses/vt/README.md +0 -64
- data/vendor/PDCurses/vt/pdcclip.c +0 -20
- data/vendor/PDCurses/vt/pdcdisp.c +0 -284
- data/vendor/PDCurses/vt/pdcgetsc.c +0 -27
- data/vendor/PDCurses/vt/pdckbd.c +0 -394
- data/vendor/PDCurses/vt/pdcscrn.c +0 -434
- data/vendor/PDCurses/vt/pdcsetsc.c +0 -45
- data/vendor/PDCurses/vt/pdcutil.c +0 -43
- data/vendor/PDCurses/vt/pdcvt.h +0 -16
- data/vendor/PDCurses/watcom.mif +0 -68
- data/vendor/PDCurses/wincon/CMakeLists.txt +0 -27
- data/vendor/PDCurses/wincon/Makefile.bcc +0 -88
- data/vendor/PDCurses/wincon/Makefile.dmc +0 -256
- data/vendor/PDCurses/wincon/Makefile.lcc +0 -273
- data/vendor/PDCurses/wincon/Makefile.mng +0 -176
- data/vendor/PDCurses/wincon/Makefile.vc +0 -144
- data/vendor/PDCurses/wincon/Makefile.wcc +0 -51
- data/vendor/PDCurses/wincon/README.md +0 -85
- data/vendor/PDCurses/wincon/pdcclip.c +0 -174
- data/vendor/PDCurses/wincon/pdcdisp.c +0 -143
- data/vendor/PDCurses/wincon/pdcgetsc.c +0 -55
- data/vendor/PDCurses/wincon/pdckbd.c +0 -786
- data/vendor/PDCurses/wincon/pdcscrn.c +0 -717
- data/vendor/PDCurses/wincon/pdcsetsc.c +0 -91
- data/vendor/PDCurses/wincon/pdcurses.ico +0 -0
- data/vendor/PDCurses/wincon/pdcurses.rc +0 -28
- data/vendor/PDCurses/wincon/pdcutil.c +0 -41
- data/vendor/PDCurses/wincon/pdcwin.h +0 -31
- data/vendor/PDCurses/wingui/CMakeLists.txt +0 -27
- data/vendor/PDCurses/wingui/Makefile.bcc +0 -85
- data/vendor/PDCurses/wingui/Makefile.dmc +0 -259
- data/vendor/PDCurses/wingui/Makefile.lcc +0 -273
- data/vendor/PDCurses/wingui/Makefile.mng +0 -171
- data/vendor/PDCurses/wingui/Makefile.vc +0 -144
- data/vendor/PDCurses/wingui/Makefile.wcc +0 -51
- data/vendor/PDCurses/wingui/README.md +0 -93
- data/vendor/PDCurses/wingui/pdcclip.c +0 -174
- data/vendor/PDCurses/wingui/pdcdisp.c +0 -718
- data/vendor/PDCurses/wingui/pdcgetsc.c +0 -30
- data/vendor/PDCurses/wingui/pdckbd.c +0 -143
- data/vendor/PDCurses/wingui/pdcscrn.c +0 -2797
- data/vendor/PDCurses/wingui/pdcsetsc.c +0 -89
- data/vendor/PDCurses/wingui/pdcurses.ico +0 -0
- data/vendor/PDCurses/wingui/pdcurses.rc +0 -28
- data/vendor/PDCurses/wingui/pdcutil.c +0 -61
- data/vendor/PDCurses/wingui/pdcwin.h +0 -122
- data/vendor/PDCurses/x11/Makefile.in +0 -754
- data/vendor/PDCurses/x11/PDCurses.spec +0 -82
- data/vendor/PDCurses/x11/README.md +0 -62
- data/vendor/PDCurses/x11/ScrollBox.c +0 -319
- data/vendor/PDCurses/x11/ScrollBox.h +0 -51
- data/vendor/PDCurses/x11/ScrollBoxP.h +0 -70
- data/vendor/PDCurses/x11/aclocal.m4 +0 -994
- data/vendor/PDCurses/x11/big_icon.xbm +0 -46
- data/vendor/PDCurses/x11/compose.h +0 -201
- data/vendor/PDCurses/x11/config.guess +0 -1500
- data/vendor/PDCurses/x11/config.h.in +0 -100
- data/vendor/PDCurses/x11/config.sub +0 -1616
- data/vendor/PDCurses/x11/configure +0 -6700
- data/vendor/PDCurses/x11/configure.ac +0 -295
- data/vendor/PDCurses/x11/debian/changelog +0 -6
- data/vendor/PDCurses/x11/debian/compat +0 -1
- data/vendor/PDCurses/x11/debian/control +0 -11
- data/vendor/PDCurses/x11/debian/copyright +0 -27
- data/vendor/PDCurses/x11/debian/rules +0 -98
- data/vendor/PDCurses/x11/install-sh +0 -253
- data/vendor/PDCurses/x11/little_icon.xbm +0 -14
- data/vendor/PDCurses/x11/ncurses_cfg.h +0 -45
- data/vendor/PDCurses/x11/pdcclip.c +0 -173
- data/vendor/PDCurses/x11/pdcdisp.c +0 -85
- data/vendor/PDCurses/x11/pdcgetsc.c +0 -28
- data/vendor/PDCurses/x11/pdckbd.c +0 -104
- data/vendor/PDCurses/x11/pdcscrn.c +0 -258
- data/vendor/PDCurses/x11/pdcsetsc.c +0 -95
- data/vendor/PDCurses/x11/pdcutil.c +0 -52
- data/vendor/PDCurses/x11/pdcx11.c +0 -316
- data/vendor/PDCurses/x11/pdcx11.h +0 -191
- data/vendor/PDCurses/x11/sb.c +0 -155
- data/vendor/PDCurses/x11/x11.c +0 -3686
- data/vendor/PDCurses/x11/xcurses-config.in +0 -81
@@ -1,312 +0,0 @@
|
|
1
|
-
/* Public Domain Curses */
|
2
|
-
|
3
|
-
#include <curspriv.h>
|
4
|
-
|
5
|
-
/*man-start**************************************************************
|
6
|
-
|
7
|
-
util
|
8
|
-
----
|
9
|
-
|
10
|
-
### Synopsis
|
11
|
-
|
12
|
-
char *unctrl(chtype c);
|
13
|
-
void filter(void);
|
14
|
-
void use_env(bool x);
|
15
|
-
int delay_output(int ms);
|
16
|
-
|
17
|
-
int getcchar(const cchar_t *wcval, wchar_t *wch, attr_t *attrs,
|
18
|
-
short *color_pair, void *opts);
|
19
|
-
int setcchar(cchar_t *wcval, const wchar_t *wch, const attr_t attrs,
|
20
|
-
short color_pair, const void *opts);
|
21
|
-
wchar_t *wunctrl(cchar_t *wc);
|
22
|
-
|
23
|
-
int PDC_mbtowc(wchar_t *pwc, const char *s, size_t n);
|
24
|
-
size_t PDC_mbstowcs(wchar_t *dest, const char *src, size_t n);
|
25
|
-
size_t PDC_wcstombs(char *dest, const wchar_t *src, size_t n);
|
26
|
-
|
27
|
-
### Description
|
28
|
-
|
29
|
-
unctrl() expands the text portion of the chtype c into a
|
30
|
-
printable string. Control characters are changed to the "^X"
|
31
|
-
notation; others are passed through. wunctrl() is the wide-
|
32
|
-
character version of the function.
|
33
|
-
|
34
|
-
filter() and use_env() are no-ops in PDCurses.
|
35
|
-
|
36
|
-
delay_output() inserts an ms millisecond pause in output.
|
37
|
-
|
38
|
-
getcchar() works in two modes: When wch is not NULL, it reads
|
39
|
-
the cchar_t pointed to by wcval and stores the attributes in
|
40
|
-
attrs, the color pair in color_pair, and the text in the
|
41
|
-
wide-character string wch. When wch is NULL, getcchar() merely
|
42
|
-
returns the number of wide characters in wcval. In either mode,
|
43
|
-
the opts argument is unused.
|
44
|
-
|
45
|
-
setcchar constructs a cchar_t at wcval from the wide-character
|
46
|
-
text at wch, the attributes in attr and the color pair in
|
47
|
-
color_pair. The opts argument is unused.
|
48
|
-
|
49
|
-
Currently, the length returned by getcchar() is always 1 or 0.
|
50
|
-
Similarly, setcchar() will only take the first wide character
|
51
|
-
from wch, and ignore any others that it "should" take (i.e.,
|
52
|
-
combining characters). Nor will it correctly handle any
|
53
|
-
character outside the basic multilingual plane (UCS-2).
|
54
|
-
|
55
|
-
### Return Value
|
56
|
-
|
57
|
-
unctrl() and wunctrl() return NULL on failure. delay_output()
|
58
|
-
always returns OK.
|
59
|
-
|
60
|
-
getcchar() returns the number of wide characters wcval points to
|
61
|
-
when wch is NULL; when it's not, getcchar() returns OK or ERR.
|
62
|
-
|
63
|
-
setcchar() returns OK or ERR.
|
64
|
-
|
65
|
-
### Portability
|
66
|
-
X/Open BSD SYS V
|
67
|
-
unctrl Y Y Y
|
68
|
-
filter Y - 3.0
|
69
|
-
use_env Y - 4.0
|
70
|
-
delay_output Y Y Y
|
71
|
-
getcchar Y
|
72
|
-
setcchar Y
|
73
|
-
wunctrl Y
|
74
|
-
PDC_mbtowc - - -
|
75
|
-
PDC_mbstowcs - - -
|
76
|
-
PDC_wcstombs - - -
|
77
|
-
|
78
|
-
**man-end****************************************************************/
|
79
|
-
|
80
|
-
#ifdef PDC_WIDE
|
81
|
-
# ifdef PDC_FORCE_UTF8
|
82
|
-
# include <string.h>
|
83
|
-
# else
|
84
|
-
# include <stdlib.h>
|
85
|
-
# endif
|
86
|
-
#endif
|
87
|
-
|
88
|
-
char *unctrl(chtype c)
|
89
|
-
{
|
90
|
-
static char strbuf[3] = {0, 0, 0};
|
91
|
-
|
92
|
-
chtype ic;
|
93
|
-
|
94
|
-
PDC_LOG(("unctrl() - called\n"));
|
95
|
-
|
96
|
-
ic = c & A_CHARTEXT;
|
97
|
-
|
98
|
-
if (ic >= 0x20 && ic != 0x7f) /* normal characters */
|
99
|
-
{
|
100
|
-
strbuf[0] = (char)ic;
|
101
|
-
strbuf[1] = '\0';
|
102
|
-
return strbuf;
|
103
|
-
}
|
104
|
-
|
105
|
-
strbuf[0] = '^'; /* '^' prefix */
|
106
|
-
|
107
|
-
if (ic == 0x7f) /* 0x7f == DEL */
|
108
|
-
strbuf[1] = '?';
|
109
|
-
else /* other control */
|
110
|
-
strbuf[1] = (char)(ic + '@');
|
111
|
-
|
112
|
-
return strbuf;
|
113
|
-
}
|
114
|
-
|
115
|
-
void filter(void)
|
116
|
-
{
|
117
|
-
PDC_LOG(("filter() - called\n"));
|
118
|
-
}
|
119
|
-
|
120
|
-
void use_env(bool x)
|
121
|
-
{
|
122
|
-
PDC_LOG(("use_env() - called: x %d\n", x));
|
123
|
-
}
|
124
|
-
|
125
|
-
int delay_output(int ms)
|
126
|
-
{
|
127
|
-
PDC_LOG(("delay_output() - called: ms %d\n", ms));
|
128
|
-
|
129
|
-
return napms(ms);
|
130
|
-
}
|
131
|
-
|
132
|
-
#ifdef PDC_WIDE
|
133
|
-
int getcchar(const cchar_t *wcval, wchar_t *wch, attr_t *attrs,
|
134
|
-
short *color_pair, void *opts)
|
135
|
-
{
|
136
|
-
if (!wcval)
|
137
|
-
return ERR;
|
138
|
-
|
139
|
-
if (wch)
|
140
|
-
{
|
141
|
-
if (!attrs || !color_pair)
|
142
|
-
return ERR;
|
143
|
-
|
144
|
-
*wch = (wchar_t)(*wcval & A_CHARTEXT);
|
145
|
-
*attrs = (*wcval & (A_ATTRIBUTES & ~A_COLOR));
|
146
|
-
*color_pair = (short)( PAIR_NUMBER(*wcval & A_COLOR));
|
147
|
-
|
148
|
-
if (*wch)
|
149
|
-
*++wch = L'\0';
|
150
|
-
|
151
|
-
return OK;
|
152
|
-
}
|
153
|
-
else
|
154
|
-
return ((*wcval & A_CHARTEXT) != L'\0');
|
155
|
-
}
|
156
|
-
|
157
|
-
int setcchar(cchar_t *wcval, const wchar_t *wch, const attr_t attrs,
|
158
|
-
short color_pair, const void *opts)
|
159
|
-
{
|
160
|
-
if (!wcval || !wch)
|
161
|
-
return ERR;
|
162
|
-
|
163
|
-
*wcval = *wch | attrs | COLOR_PAIR(color_pair);
|
164
|
-
|
165
|
-
return OK;
|
166
|
-
}
|
167
|
-
|
168
|
-
wchar_t *wunctrl(cchar_t *wc)
|
169
|
-
{
|
170
|
-
static wchar_t strbuf[3] = {0, 0, 0};
|
171
|
-
|
172
|
-
cchar_t ic;
|
173
|
-
|
174
|
-
PDC_LOG(("wunctrl() - called\n"));
|
175
|
-
|
176
|
-
ic = *wc & A_CHARTEXT;
|
177
|
-
|
178
|
-
if (ic >= 0x20 && ic != 0x7f) /* normal characters */
|
179
|
-
{
|
180
|
-
strbuf[0] = (wchar_t)ic;
|
181
|
-
strbuf[1] = L'\0';
|
182
|
-
return strbuf;
|
183
|
-
}
|
184
|
-
|
185
|
-
strbuf[0] = '^'; /* '^' prefix */
|
186
|
-
|
187
|
-
if (ic == 0x7f) /* 0x7f == DEL */
|
188
|
-
strbuf[1] = '?';
|
189
|
-
else /* other control */
|
190
|
-
strbuf[1] = (wchar_t)(ic + '@');
|
191
|
-
|
192
|
-
return strbuf;
|
193
|
-
}
|
194
|
-
|
195
|
-
int PDC_mbtowc(wchar_t *pwc, const char *s, size_t n)
|
196
|
-
{
|
197
|
-
# ifdef PDC_FORCE_UTF8
|
198
|
-
wchar_t key;
|
199
|
-
int i = -1;
|
200
|
-
const unsigned char *string;
|
201
|
-
|
202
|
-
if (!s || (n < 1))
|
203
|
-
return -1;
|
204
|
-
|
205
|
-
if (!*s)
|
206
|
-
return 0;
|
207
|
-
|
208
|
-
string = (const unsigned char *)s;
|
209
|
-
|
210
|
-
key = string[0];
|
211
|
-
|
212
|
-
/* Simplistic UTF-8 decoder -- only does the BMP, minimal validation */
|
213
|
-
|
214
|
-
if (key & 0x80)
|
215
|
-
{
|
216
|
-
if ((key & 0xe0) == 0xc0)
|
217
|
-
{
|
218
|
-
if (1 < n)
|
219
|
-
{
|
220
|
-
key = ((key & 0x1f) << 6) | (string[1] & 0x3f);
|
221
|
-
i = 2;
|
222
|
-
}
|
223
|
-
}
|
224
|
-
else if ((key & 0xe0) == 0xe0)
|
225
|
-
{
|
226
|
-
if (2 < n)
|
227
|
-
{
|
228
|
-
key = ((key & 0x0f) << 12) | ((string[1] & 0x3f) << 6) |
|
229
|
-
(string[2] & 0x3f);
|
230
|
-
i = 3;
|
231
|
-
}
|
232
|
-
}
|
233
|
-
}
|
234
|
-
else
|
235
|
-
i = 1;
|
236
|
-
|
237
|
-
if (i)
|
238
|
-
*pwc = key;
|
239
|
-
|
240
|
-
return i;
|
241
|
-
# else
|
242
|
-
return mbtowc(pwc, s, n);
|
243
|
-
# endif
|
244
|
-
}
|
245
|
-
|
246
|
-
size_t PDC_mbstowcs(wchar_t *dest, const char *src, size_t n)
|
247
|
-
{
|
248
|
-
# ifdef PDC_FORCE_UTF8
|
249
|
-
size_t i = 0, len;
|
250
|
-
|
251
|
-
if (!src || !dest)
|
252
|
-
return 0;
|
253
|
-
|
254
|
-
len = strlen(src);
|
255
|
-
|
256
|
-
while (*src && i < n)
|
257
|
-
{
|
258
|
-
int retval = PDC_mbtowc(dest + i, src, len);
|
259
|
-
|
260
|
-
if (retval < 1)
|
261
|
-
return -1;
|
262
|
-
|
263
|
-
src += retval;
|
264
|
-
len -= retval;
|
265
|
-
i++;
|
266
|
-
}
|
267
|
-
# else
|
268
|
-
size_t i = mbstowcs(dest, src, n);
|
269
|
-
# endif
|
270
|
-
dest[i] = 0;
|
271
|
-
return i;
|
272
|
-
}
|
273
|
-
|
274
|
-
size_t PDC_wcstombs(char *dest, const wchar_t *src, size_t n)
|
275
|
-
{
|
276
|
-
# ifdef PDC_FORCE_UTF8
|
277
|
-
size_t i = 0;
|
278
|
-
|
279
|
-
if (!src || !dest)
|
280
|
-
return 0;
|
281
|
-
|
282
|
-
while (*src && i < n)
|
283
|
-
{
|
284
|
-
chtype code = *src++;
|
285
|
-
|
286
|
-
if (code < 0x80)
|
287
|
-
{
|
288
|
-
dest[i] = (char)code;
|
289
|
-
i++;
|
290
|
-
}
|
291
|
-
else
|
292
|
-
if (code < 0x800)
|
293
|
-
{
|
294
|
-
dest[i] = (char)((code & 0x07c0) >> 6) | 0xc0;
|
295
|
-
dest[i + 1] = (char)( (code & 0x003f) | 0x80);
|
296
|
-
i += 2;
|
297
|
-
}
|
298
|
-
else
|
299
|
-
{
|
300
|
-
dest[i] = (char)( ((code & 0xf000) >> 12) | 0xe0);
|
301
|
-
dest[i + 1] = (char)((code & 0x0fc0) >> 6) | 0x80;
|
302
|
-
dest[i + 2] = (char)( (code & 0x003f) | 0x80);
|
303
|
-
i += 3;
|
304
|
-
}
|
305
|
-
}
|
306
|
-
# else
|
307
|
-
size_t i = wcstombs(dest, src, n);
|
308
|
-
# endif
|
309
|
-
dest[i] = '\0';
|
310
|
-
return i;
|
311
|
-
}
|
312
|
-
#endif
|