curses 1.4.4 → 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/dependabot.yml +6 -0
- data/.github/workflows/macos.yml +1 -1
- data/.github/workflows/push_gem.yml +48 -0
- data/.github/workflows/ubuntu.yml +2 -2
- data/.github/workflows/windows.yml +2 -2
- data/History.md +23 -0
- data/README.md +7 -0
- data/curses.gemspec +1 -1
- data/ext/curses/curses.c +7 -7
- data/sample/colors.rb +6 -1
- data/sample/form.rb +1 -1
- data/sample/menu.rb +2 -0
- metadata +9 -251
- 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,298 +0,0 @@
|
|
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
|
-
}
|
@@ -1,109 +0,0 @@
|
|
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
|
-
}
|
@@ -1,96 +0,0 @@
|
|
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
|
-
}
|
@@ -1,211 +0,0 @@
|
|
1
|
-
/* Public Domain Curses */
|
2
|
-
|
3
|
-
#include <curspriv.h>
|
4
|
-
|
5
|
-
/*man-start**************************************************************
|
6
|
-
|
7
|
-
deleteln
|
8
|
-
--------
|
9
|
-
|
10
|
-
### Synopsis
|
11
|
-
|
12
|
-
int deleteln(void);
|
13
|
-
int wdeleteln(WINDOW *win);
|
14
|
-
int insdelln(int n);
|
15
|
-
int winsdelln(WINDOW *win, int n);
|
16
|
-
int insertln(void);
|
17
|
-
int winsertln(WINDOW *win);
|
18
|
-
|
19
|
-
int mvdeleteln(int y, int x);
|
20
|
-
int mvwdeleteln(WINDOW *win, int y, int x);
|
21
|
-
int mvinsertln(int y, int x);
|
22
|
-
int mvwinsertln(WINDOW *win, int y, int x);
|
23
|
-
|
24
|
-
### Description
|
25
|
-
|
26
|
-
With the deleteln() and wdeleteln() functions, the line under
|
27
|
-
the cursor in the window is deleted. All lines below the
|
28
|
-
current line are moved up one line. The bottom line of the
|
29
|
-
window is cleared. The cursor position does not change.
|
30
|
-
|
31
|
-
With the insertln() and winsertn() functions, a blank line is
|
32
|
-
inserted above the current line and the bottom line is lost.
|
33
|
-
|
34
|
-
mvdeleteln(), mvwdeleteln(), mvinsertln() and mvwinsertln()
|
35
|
-
allow moving the cursor and inserting/deleting in one call.
|
36
|
-
|
37
|
-
### Return Value
|
38
|
-
|
39
|
-
All functions return OK on success and ERR on error.
|
40
|
-
|
41
|
-
### Portability
|
42
|
-
X/Open BSD SYS V
|
43
|
-
deleteln Y Y Y
|
44
|
-
wdeleteln Y Y Y
|
45
|
-
mvdeleteln - - -
|
46
|
-
mvwdeleteln - - -
|
47
|
-
insdelln Y - 4.0
|
48
|
-
winsdelln Y - 4.0
|
49
|
-
insertln Y Y Y
|
50
|
-
winsertln Y Y Y
|
51
|
-
mvinsertln - - -
|
52
|
-
mvwinsertln - - -
|
53
|
-
|
54
|
-
**man-end****************************************************************/
|
55
|
-
|
56
|
-
int wdeleteln(WINDOW *win)
|
57
|
-
{
|
58
|
-
chtype blank, *temp, *ptr;
|
59
|
-
int y;
|
60
|
-
|
61
|
-
PDC_LOG(("wdeleteln() - called\n"));
|
62
|
-
|
63
|
-
if (!win)
|
64
|
-
return ERR;
|
65
|
-
|
66
|
-
/* wrs (4/10/93) account for window background */
|
67
|
-
|
68
|
-
blank = win->_bkgd;
|
69
|
-
|
70
|
-
temp = win->_y[win->_cury];
|
71
|
-
|
72
|
-
for (y = win->_cury; y < win->_bmarg; y++)
|
73
|
-
{
|
74
|
-
win->_y[y] = win->_y[y + 1];
|
75
|
-
win->_firstch[y] = 0;
|
76
|
-
win->_lastch[y] = win->_maxx - 1;
|
77
|
-
}
|
78
|
-
|
79
|
-
for (ptr = temp; (ptr - temp < win->_maxx); ptr++)
|
80
|
-
*ptr = blank; /* make a blank line */
|
81
|
-
|
82
|
-
if (win->_cury <= win->_bmarg)
|
83
|
-
{
|
84
|
-
win->_firstch[win->_bmarg] = 0;
|
85
|
-
win->_lastch[win->_bmarg] = win->_maxx - 1;
|
86
|
-
win->_y[win->_bmarg] = temp;
|
87
|
-
}
|
88
|
-
|
89
|
-
return OK;
|
90
|
-
}
|
91
|
-
|
92
|
-
int deleteln(void)
|
93
|
-
{
|
94
|
-
PDC_LOG(("deleteln() - called\n"));
|
95
|
-
|
96
|
-
return wdeleteln(stdscr);
|
97
|
-
}
|
98
|
-
|
99
|
-
int mvdeleteln(int y, int x)
|
100
|
-
{
|
101
|
-
PDC_LOG(("mvdeleteln() - called\n"));
|
102
|
-
|
103
|
-
if (move(y, x) == ERR)
|
104
|
-
return ERR;
|
105
|
-
|
106
|
-
return wdeleteln(stdscr);
|
107
|
-
}
|
108
|
-
|
109
|
-
int mvwdeleteln(WINDOW *win, int y, int x)
|
110
|
-
{
|
111
|
-
PDC_LOG(("mvwdeleteln() - called\n"));
|
112
|
-
|
113
|
-
if (wmove(win, y, x) == ERR)
|
114
|
-
return ERR;
|
115
|
-
|
116
|
-
return wdeleteln(win);
|
117
|
-
}
|
118
|
-
|
119
|
-
int winsdelln(WINDOW *win, int n)
|
120
|
-
{
|
121
|
-
int i;
|
122
|
-
|
123
|
-
PDC_LOG(("winsdelln() - called\n"));
|
124
|
-
|
125
|
-
if (!win)
|
126
|
-
return ERR;
|
127
|
-
|
128
|
-
if (n > 0)
|
129
|
-
{
|
130
|
-
for (i = 0; i < n; i++)
|
131
|
-
if (winsertln(win) == ERR)
|
132
|
-
return ERR;
|
133
|
-
}
|
134
|
-
else if (n < 0)
|
135
|
-
{
|
136
|
-
n = -n;
|
137
|
-
for (i = 0; i < n; i++)
|
138
|
-
if (wdeleteln(win) == ERR)
|
139
|
-
return ERR;
|
140
|
-
}
|
141
|
-
|
142
|
-
return OK;
|
143
|
-
}
|
144
|
-
|
145
|
-
int insdelln(int n)
|
146
|
-
{
|
147
|
-
PDC_LOG(("insdelln() - called\n"));
|
148
|
-
|
149
|
-
return winsdelln(stdscr, n);
|
150
|
-
}
|
151
|
-
|
152
|
-
int winsertln(WINDOW *win)
|
153
|
-
{
|
154
|
-
chtype blank, *temp, *end;
|
155
|
-
int y;
|
156
|
-
|
157
|
-
PDC_LOG(("winsertln() - called\n"));
|
158
|
-
|
159
|
-
if (!win)
|
160
|
-
return ERR;
|
161
|
-
|
162
|
-
/* wrs (4/10/93) account for window background */
|
163
|
-
|
164
|
-
blank = win->_bkgd;
|
165
|
-
|
166
|
-
temp = win->_y[win->_maxy - 1];
|
167
|
-
|
168
|
-
for (y = win->_maxy - 1; y > win->_cury; y--)
|
169
|
-
{
|
170
|
-
win->_y[y] = win->_y[y - 1];
|
171
|
-
win->_firstch[y] = 0;
|
172
|
-
win->_lastch[y] = win->_maxx - 1;
|
173
|
-
}
|
174
|
-
|
175
|
-
win->_y[win->_cury] = temp;
|
176
|
-
|
177
|
-
for (end = &temp[win->_maxx - 1]; temp <= end; temp++)
|
178
|
-
*temp = blank;
|
179
|
-
|
180
|
-
win->_firstch[win->_cury] = 0;
|
181
|
-
win->_lastch[win->_cury] = win->_maxx - 1;
|
182
|
-
|
183
|
-
return OK;
|
184
|
-
}
|
185
|
-
|
186
|
-
int insertln(void)
|
187
|
-
{
|
188
|
-
PDC_LOG(("insertln() - called\n"));
|
189
|
-
|
190
|
-
return winsertln(stdscr);
|
191
|
-
}
|
192
|
-
|
193
|
-
int mvinsertln(int y, int x)
|
194
|
-
{
|
195
|
-
PDC_LOG(("mvinsertln() - called\n"));
|
196
|
-
|
197
|
-
if (move(y, x) == ERR)
|
198
|
-
return ERR;
|
199
|
-
|
200
|
-
return winsertln(stdscr);
|
201
|
-
}
|
202
|
-
|
203
|
-
int mvwinsertln(WINDOW *win, int y, int x)
|
204
|
-
{
|
205
|
-
PDC_LOG(("mvwinsertln() - called\n"));
|
206
|
-
|
207
|
-
if (wmove(win, y, x) == ERR)
|
208
|
-
return ERR;
|
209
|
-
|
210
|
-
return winsertln(win);
|
211
|
-
}
|