Merge remote-tracking branch 'origin/master' into HYH

This commit is contained in:
HEYAHONG 2024-10-22 10:15:12 +08:00
commit 7da8a32902
No known key found for this signature in database
GPG Key ID: 45495019025D566D
12 changed files with 146 additions and 51 deletions

View File

@ -14,13 +14,16 @@ extern "C" {
#if defined(__TURBOC__) || defined(__EMX__) || defined(__DJGPP__) || \
defined(PDC_99) || defined(__WATCOMC__)
# ifndef HAVE_VSSCANF
# define HAVE_VSSCANF /* have vsscanf() */
# define HAVE_VSSCANF 1 /* have vsscanf() */
# endif
#endif
#if defined(PDC_99) || defined(__WATCOMC__)
# ifndef HAVE_SNPRINTF
# define HAVE_SNPRINTF 1 /* have snprintf() */
# endif
# ifndef HAVE_VSNPRINTF
# define HAVE_VSNPRINTF /* have vsnprintf() */
# define HAVE_VSNPRINTF 1 /* have vsnprintf() */
# endif
#endif

View File

@ -1,6 +1,6 @@
# This provides for compiling and linking the ncurses test programs.
ncurses_testdir = $(HOME)/ncurses-6.1/test
ncurses_testdir = $(HOME)/ncurses-6.4/test
NCURSES_TESTS = bs$(E) gdc$(E) hanoi$(E) knight$(E) tclock$(E) \
lrtest$(E) ncurses$(E)

View File

@ -1,6 +1,6 @@
/* This file is only used with the ncurses test programs.
*
* Have ncurses-6.1 unpacked in your $(HOME) (you don't need to build
* Have ncurses-6.4 unpacked in your $(HOME) (you don't need to build
* it), or edit ncurses_testdir appropriately in the Makefile or
* nctests.mif. Configure and build PDCurses, and:
*
@ -23,7 +23,7 @@
#define HAVE_UNISTD_H 1
#define HAVE_TERMATTRS 1
#include <curses.h>
#include <curspriv.h>
#define ExitProgram exit
@ -45,8 +45,10 @@
#define HAVE_PUTWIN 1
#define HAVE_SLK_COLOR 1
#define HAVE_SLK_INIT 1
#define HAVE_STRSTR 1
#define HAVE_USE_DEFAULT_COLORS 1
#define HAVE_WRESIZE 1
#define USE_STRING_HACKS 1
#ifdef PDC_WIDE
# define USE_WIDEC_SUPPORT 1

View File

@ -51,16 +51,18 @@ void wait_a_while(long msec)
c = getch();
#ifdef KEY_RESIZE
if (c == KEY_RESIZE)
while (c == KEY_RESIZE || (msec == 1 && c == ERR))
{
# ifdef PDCURSES
resize_term(0, 0);
# endif
sizecheck();
backfill();
pflush();
c = getch();
}
else
#endif
if (c == 'q')
{
endwin();

View File

@ -3,21 +3,21 @@ Definitions and Variables (curses.h)
Define before inclusion (only those needed):
XCURSES True if compiling for X11.
PDC_RGB True if you want to use RGB color definitions
(Red = 1, Green = 2, Blue = 4) instead of BGR.
PDC_WIDE True if building wide-character support.
PDC_DLL_BUILD True if building a Windows DLL.
PDC_NCMOUSE Use the ncurses mouse API instead
of PDCurses' traditional mouse API.
XCURSES if building / built for X11
PDC_RGB if you want to use RGB color definitions
(Red = 1, Green = 2, Blue = 4) instead of BGR
PDC_WIDE if building / built with wide-character support
PDC_DLL_BUILD if building / built as a Windows DLL
PDC_NCMOUSE to use the ncurses mouse API instead
of PDCurses' traditional mouse API
Defined by this header:
PDCURSES Enables access to PDCurses-only routines.
PDC_BUILD Defines API build version.
PDC_VER_MAJOR Major version number
PDC_VER_MINOR Minor version number
PDC_VERDOT Version string
PDCURSES PDCurses-only features are available
PDC_BUILD API build version
PDC_VER_MAJOR major version number
PDC_VER_MINOR minor version number
PDC_VERDOT version string
@ -663,7 +663,10 @@ color
int init_color(short color, short red, short green, short blue);
int color_content(short color, short *red, short *green, short *blue);
int alloc_pair(int fg, int bg);
int assume_default_colors(int f, int b);
int find_pair(int fg, int bg);
int free_pair(int pair);
int use_default_colors(void);
int PDC_set_line_color(short color);
@ -714,6 +717,13 @@ color
variable PDC_ORIGINAL_COLORS is set at the time start_color() is
called, that's equivalent to calling use_default_colors().
alloc_pair(), find_pair() and free_pair() are also from ncurses.
free_pair() marks a pair as unused; find_pair() returns an existing
pair with the specified foreground and background colors, if one
exists. And alloc_pair() returns such a pair whether or not it was
previously set, overwriting the oldest initialized pair if there are
no free pairs.
PDC_set_line_color() is used to set the color, globally, for the
color of the lines drawn for the attributes: A_UNDERLINE, A_LEFT and
A_RIGHT. A value of -1 (the default) indicates that the current
@ -723,8 +733,9 @@ color
### Return Value
All functions return OK on success and ERR on error, except for
has_colors() and can_change_colors(), which return TRUE or FALSE.
Most functions return OK on success and ERR on error. has_colors()
and can_change_colors() return TRUE or FALSE. alloc_pair() and
find_pair() return a pair number, or -1 on error.
### Portability
X/Open ncurses NetBSD
@ -735,7 +746,10 @@ color
can_change_color Y Y Y
init_color Y Y Y
color_content Y Y Y
alloc_pair - Y -
assume_default_colors - Y Y
find_pair - Y -
free_pair - Y -
use_default_colors - Y Y
PDC_set_line_color - - -
@ -1194,7 +1208,7 @@ initscr
### Synopsis
WINDOW *initscr(void);
WINDOW *Xinitscr(int argc, char *argv[]);
WINDOW *Xinitscr(int argc, char **argv);
int endwin(void);
bool isendwin(void);
SCREEN *newterm(const char *type, FILE *outfd, FILE *infd);
@ -1307,12 +1321,15 @@ inopts
void qiflush(void);
void timeout(int delay);
void wtimeout(WINDOW *win, int delay);
int wgetdelay(const WINDOW *win);
int typeahead(int fildes);
int crmode(void);
int nocrmode(void);
bool is_keypad(const WINDOW *win);
bool is_nodelay(const WINDOW *win);
bool is_notimeout(const WINDOW *win);
### Description
@ -1363,6 +1380,8 @@ inopts
delay is given; i.e., 1-99 will wait 50ms, 100-149 will wait 100ms,
etc.
wgetdelay() returns the delay timeout as set in wtimeout().
intrflush(), notimeout(), noqiflush(), qiflush() and typeahead() do
nothing in PDCurses, but are included for compatibility with other
curses implementations.
@ -1372,10 +1391,13 @@ inopts
is_keypad() reports whether the specified window is in keypad mode.
is_nodelay() reports whether the specified window is in nodelay mode.
### Return Value
All functions except is_keypad() and the void functions return OK on
success and ERR on error.
is_keypad() and is_nodelay() return TRUE or FALSE. is_notimeout() is
provided for compatibility with other curses implementations, and
always returns FALSE. All others return OK on success and ERR on error.
### Portability
X/Open ncurses NetBSD
@ -1397,10 +1419,13 @@ inopts
qiflush Y Y Y
timeout Y Y Y
wtimeout Y Y Y
wgetdelay - Y -
typeahead Y Y Y
crmode Y Y Y
nocrmode Y Y Y
is_keypad - Y Y
is_nodelay - Y -
is_notimeout - Y -
@ -1894,11 +1919,17 @@ outopts
int leaveok(WINDOW *win, bool bf);
int setscrreg(int top, int bot);
int wsetscrreg(WINDOW *win, int top, int bot);
int wgetscrreg(const WINDOW *win, int *top, int *bot);
int scrollok(WINDOW *win, bool bf);
int raw_output(bool bf);
bool is_cleared(const WINDOW *win);
bool is_idlok(const WINDOW *win);
bool is_idcok(const WINDOW *win);
bool is_immedok(const WINDOW *win);
bool is_leaveok(const WINDOW *win);
bool is_scrollok(const WINDOW *win);
### Description
@ -1920,19 +1951,31 @@ outopts
will cause all lines in the scrolling region to scroll up one line.
setscrreg() is the stdscr version.
wgetscrreg() gets the top and bottom margins as set in wsetscrreg().
idlok() and idcok() do nothing in PDCurses, but are provided for
compatibility with other curses implementations.
compatibility with other curses implementations, likewise is_idlok()
and is_idcok().
raw_output() enables the output of raw characters using the standard
*add* and *ins* curses functions (that is, it disables translation of
control characters).
is_cleared() reports whether the specified window causes clear at next
refresh.
is_immedok() reports whether the specified window is in immedok mode.
is_leaveok() reports whether the specified window is in leaveok mode.
is_scrollok() reports whether the specified window allows scrolling.
### Return Value
All functions except is_leaveok() return OK on success and ERR on
error.
is_cleared(), is_immedok(), is_leaveok() and is_scrollok() return TRUE
or FALSE. is_idlok() and is_idcok() are provided for compatibility with
other curses implementations, and always return FALSE. All others
return OK on success and ERR on error.
### Portability
X/Open ncurses NetBSD
@ -1943,8 +1986,14 @@ outopts
leaveok Y Y Y
setscrreg Y Y Y
wsetscrreg Y Y Y
wgetscrreg - Y -
scrollok Y Y Y
is_cleared - Y -
is_idlok - Y -
is_idcok - Y -
is_immedok - Y -
is_leaveok - Y Y
is_scrollok - Y -
raw_output - - -
@ -2710,10 +2759,13 @@ window
WINDOW *subwin(WINDOW* orig, int nlines, int ncols,
int begy, int begx);
WINDOW *dupwin(WINDOW *win);
WINDOW *wgetparent(const WINDOW *win);
int delwin(WINDOW *win);
int mvwin(WINDOW *win, int y, int x);
int mvderwin(WINDOW *win, int pary, int parx);
int syncok(WINDOW *win, bool bf);
bool is_subwin(const WINDOW *win);
bool is_syncok(const WINDOW *win);
void wsyncup(WINDOW *win);
void wcursyncup(WINDOW *win);
void wsyncdown(WINDOW *win);
@ -2759,11 +2811,19 @@ window
dupwin() creates an exact duplicate of the window win.
wgetparent() returns the parent WINDOW pointer for subwindows, or NULL
for windows having no parent.
wsyncup() causes a touchwin() of all of the window's parents.
If wsyncok() is called with a second argument of TRUE, this causes a
If syncok() is called with a second argument of TRUE, this causes a
wsyncup() to be called every time the window is changed.
is_subwin() reports whether the specified window is a subwindow,
created by subwin() or derwin().
is_syncok() reports whether the specified window is in syncok mode.
wcursyncup() causes the current cursor position of all of a window's
ancestors to reflect the current cursor position of the current
window.
@ -2796,6 +2856,8 @@ window
syncok() return OK or ERR. wsyncup(), wcursyncup() and wsyncdown()
return nothing.
is_subwin() and is_syncok() returns TRUE or FALSE.
### Errors
It is an error to call resize_window() before calling initscr().
@ -2814,8 +2876,11 @@ window
derwin Y Y Y
mvderwin Y Y Y
dupwin Y Y Y
wgetparent - Y -
wsyncup Y Y Y
syncok Y Y Y
is_subwin - Y -
is_syncok - Y -
wcursyncup Y Y Y
wsyncdown Y Y Y
wresize - Y Y

View File

@ -22,7 +22,7 @@ Building
--------
- To rebuild MANUAL.md from the "man page" sections of the source code,
type "./mkman.sh". Needs a Unix-like shell and a Python interpreter.
type "./mkman.sh". Needs a Unix-like shell and an Awk interpreter.
[User's Guide]: USERS.md

View File

@ -158,7 +158,7 @@ static void _copy(void)
#ifdef PDC_WIDE
wtmp = malloc((len + 1) * sizeof(wchar_t));
len *= 3;
len *= 4;
#endif
tmp = malloc(len + 1);

View File

@ -213,9 +213,22 @@ static void _free_obscure(PANEL *pan)
pan->obscure = (PANELOBS *)0;
}
static void _pairwise_override(PANEL *pan, PANEL *pan2)
{
const int sy1 = pan->wstarty, sy2 = pan2->wstarty;
const int end_y = min(pan->wendy, pan2->wendy);
int y = max(sy1, sy2);
while (y < end_y)
{
if (is_linetouched(pan->win, y - sy1))
Touchline(pan2, y - sy2, 1);
y++;
}
}
static void _override(PANEL *pan, int show)
{
int y;
PANEL *pan2;
PANELOBS *tobs = pan->obscure; /* "this" one */
@ -233,14 +246,11 @@ static void _override(PANEL *pan, int show)
while (tobs)
{
if ((pan2 = tobs->pan) != pan)
for (y = pan->wstarty; y < pan->wendy; y++)
if ((y >= pan2->wstarty) && (y < pan2->wendy) &&
((is_linetouched(pan->win, y - pan->wstarty)) ||
(is_linetouched(stdscr, y))))
Touchline(pan2, y - pan2->wstarty, 1);
_pairwise_override(pan, pan2);
tobs = tobs->above;
}
_pairwise_override(&_stdscr_pseudo_panel, pan);
}
static void _calculate_obscure(void)

View File

@ -168,31 +168,40 @@ bool is_wintouched(WINDOW *win)
int touchoverlap(const WINDOW *win1, WINDOW *win2)
{
int y, endy, endx, starty, startx;
int y, endy, endx, starty, startx, begy1, begx1, begy2, begx2;
PDC_LOG(("touchoverlap() - called: win1=%p win2=%p\n", win1, win2));
if (!win1 || !win2)
return ERR;
starty = max(win1->_begy, win2->_begy);
startx = max(win1->_begx, win2->_begx);
endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begy);
endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx);
begy1 = win1->_begy;
begx1 = win1->_begx;
begy2 = win2->_begy;
begx2 = win2->_begy;
starty = max(begy1, begy2);
startx = max(begx1, begx2);
endy = min(win1->_maxy + begy1, win2->_maxy + begy2);
endx = min(win1->_maxx + begx1, win2->_maxx + begx2);
if (starty >= endy || startx >= endx)
return OK;
starty -= win2->_begy;
startx -= win2->_begx;
endy -= win2->_begy;
endx -= win2->_begx;
starty -= begy2;
startx -= begx2;
endy -= begy2;
endx -= begx2;
endx -= 1;
for (y = starty; y < endy; y++)
{
win2->_firstch[y] = startx;
win2->_lastch[y] = endx;
int first = win2->_firstch[y];
if (first == _NO_CHANGE || win2->_lastch[y] < endx)
win2->_lastch[y] = endx;
if (first == _NO_CHANGE || first > startx)
win2->_firstch[y] = startx;
}
return OK;

View File

@ -344,9 +344,9 @@ WINDOW *subwin(WINDOW *orig, int nlines, int ncols, int begy, int begx)
k = begx - orig->_begx;
if (!nlines)
nlines = orig->_maxy - 1 - j;
nlines = orig->_maxy - j;
if (!ncols)
ncols = orig->_maxx - 1 - k;
ncols = orig->_maxx - k;
win = PDC_makenew(nlines, ncols, begy, begx);
if (!win)

View File

@ -10,7 +10,11 @@
#ifdef PDC_WIDE
# ifndef PDC_FONT_PATH
# define PDC_FONT_PATH "/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf"
# if defined(__APPLE__)
# define PDC_FONT_PATH "/System/Library/Fonts/Menlo.ttc"
# else
# define PDC_FONT_PATH "/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf"
# endif
# endif
TTF_Font *pdc_ttffont = NULL;
int pdc_font_size = 17;

View File

@ -508,7 +508,7 @@ xmas.o: $(demodir)/xmas.c
# This section provides for compiling and linking the
# ncurses test programs.
ncurses_testdir = $(HOME)/ncurses-6.1/test
ncurses_testdir = $(HOME)/ncurses-6.4/test
NCURSES_TESTS = bs gdc hanoi knight tclock lrtest ncurses