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