Merged upstream PDCurses changes.

This commit is contained in:
casey langen 2020-02-16 19:52:22 -08:00
parent fdced4b5c0
commit cd4d31bfe1
15 changed files with 90 additions and 3 deletions

View File

@ -1,6 +1,7 @@
/* PDCurses */
#include <curspriv.h>
#include <assert.h>
/*man-start**************************************************************
@ -119,7 +120,6 @@ addch
#ifdef USING_COMBINING_CHARACTER_SCHEME
#include <stdlib.h>
#include <assert.h>
/*
* A greatly stripped-down version of Markus Kuhn's excellent
* wcwidth implementation. For his latest version and many
@ -379,6 +379,8 @@ int waddch( WINDOW *win, const chtype ch)
PDC_LOG(("waddch() - called: win=%p ch=%x (text=%c attr=0x%x)\n",
win, ch, ch & A_CHARTEXT, ch & A_ATTRIBUTES));
assert( SP);
assert( win);
if (!win || !SP)
return ERR;

View File

@ -1,6 +1,7 @@
/* PDCurses */
#include <curspriv.h>
#include <assert.h>
/*man-start**************************************************************
@ -36,6 +37,7 @@ int beep(void)
{
PDC_LOG(("beep() - called\n"));
assert( SP);
if (!SP)
return ERR;

View File

@ -117,6 +117,7 @@ int start_color(void)
{
PDC_LOG(("start_color() - called\n"));
assert( SP);
if (!SP || SP->mono)
return ERR;
@ -199,6 +200,7 @@ int init_extended_pair(int pair, int fg, int bg)
{
PDC_LOG(("init_pair() - called: pair %d fg %d bg %d\n", pair, fg, bg));
assert( SP);
if (!SP || !SP->color_started || pair < 1 || pair >= COLOR_PAIRS ||
fg < first_col || fg >= COLORS || bg < first_col || bg >= COLORS)
return ERR;
@ -219,6 +221,7 @@ int init_extended_color(int color, int red, int green, int blue)
{
PDC_LOG(("init_color() - called\n"));
assert( SP);
if (!SP || color < 0 || color >= COLORS || !PDC_can_change_color() ||
red < -1 || red > 1000 || green < -1 || green > 1000 ||
blue < -1 || blue > 1000)
@ -310,6 +313,7 @@ int PDC_set_line_color(short color)
{
PDC_LOG(("PDC_set_line_color() - called: %d\n", color));
assert( SP);
if (!SP || color < -1 || color >= COLORS)
return ERR;
@ -322,6 +326,7 @@ int PDC_init_atrtab(void)
{
int i;
assert( SP);
if( !SP->atrtab)
{
atrtab_size_alloced = PDC_COLOR_PAIRS;

View File

@ -1,6 +1,7 @@
/* PDCurses */
#include <curspriv.h>
#include <assert.h>
/*man-start**************************************************************
@ -47,6 +48,7 @@ void PDC_debug(const char *fmt, ...)
char hms[9];
time_t now;
assert( SP);
if (!SP || !SP->dbfp)
return;
@ -73,6 +75,7 @@ void PDC_debug(const char *fmt, ...)
void traceon(void)
{
assert( SP);
if (!SP)
return;
@ -95,6 +98,7 @@ void traceon(void)
void traceoff(void)
{
assert( SP);
if (!SP || !SP->dbfp)
return;

View File

@ -1,6 +1,7 @@
/* PDCurses */
#include <curspriv.h>
#include <assert.h>
/*man-start**************************************************************
@ -342,6 +343,8 @@ int wgetch(WINDOW *win)
PDC_LOG(("wgetch() - called\n"));
assert( SP);
assert( win);
if (!win || !SP)
return ERR;
@ -507,6 +510,7 @@ int flushinp(void)
{
PDC_LOG(("flushinp() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -523,6 +527,7 @@ unsigned long PDC_get_key_modifiers(void)
{
PDC_LOG(("PDC_get_key_modifiers() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -533,6 +538,7 @@ int PDC_return_key_modifiers(bool flag)
{
PDC_LOG(("PDC_return_key_modifiers() - called\n"));
assert( SP);
if (!SP)
return ERR;

View File

@ -1,6 +1,7 @@
/* PDCurses */
#include <curspriv.h>
#include <assert.h>
/*man-start**************************************************************
@ -87,6 +88,9 @@ int wgetnstr(WINDOW *win, char *str, int n)
PDC_LOG(("wgetnstr() - called\n"));
assert( win);
assert( str);
assert( SP);
if (!win || !str)
return ERR;
@ -284,6 +288,9 @@ int wgetn_wstr(WINDOW *win, wint_t *wstr, int n)
PDC_LOG(("wgetn_wstr() - called\n"));
assert( win);
assert( wstr);
assert( SP);
if (!win || !wstr)
return ERR;

View File

@ -1,6 +1,7 @@
/* PDCurses */
#include <curspriv.h>
#include <assert.h>
/*man-start**************************************************************
@ -125,6 +126,7 @@ WINDOW *initscr(void)
if (SP && SP->alive)
return NULL;
SP = calloc(1, sizeof(SCREEN));
assert( SP);
if (!SP)
return NULL;
@ -274,6 +276,7 @@ int endwin(void)
def_prog_mode();
PDC_scr_close();
assert( SP);
SP->alive = FALSE;
return OK;
@ -306,6 +309,7 @@ void delscreen(SCREEN *sp)
{
PDC_LOG(("delscreen() - called\n"));
assert( SP);
if (!SP || sp != SP)
return;

View File

@ -1,6 +1,7 @@
/* PDCurses */
#include <curspriv.h>
#include <assert.h>
/*man-start**************************************************************
@ -128,6 +129,7 @@ int cbreak(void)
{
PDC_LOG(("cbreak() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -140,6 +142,7 @@ int nocbreak(void)
{
PDC_LOG(("nocbreak() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -153,6 +156,7 @@ int echo(void)
{
PDC_LOG(("echo() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -165,6 +169,7 @@ int noecho(void)
{
PDC_LOG(("noecho() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -177,6 +182,7 @@ int halfdelay(int tenths)
{
PDC_LOG(("halfdelay() - called\n"));
assert( SP);
if (!SP || tenths < 1 || tenths > 255)
return ERR;
@ -208,6 +214,7 @@ int meta(WINDOW *win, bool bf)
{
PDC_LOG(("meta() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -220,6 +227,7 @@ int nl(void)
{
PDC_LOG(("nl() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -232,6 +240,7 @@ int nonl(void)
{
PDC_LOG(("nonl() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -263,6 +272,7 @@ int raw(void)
{
PDC_LOG(("raw() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -276,6 +286,7 @@ int noraw(void)
{
PDC_LOG(("noraw() - called\n"));
assert( SP);
if (!SP)
return ERR;

View File

@ -1,6 +1,7 @@
/* PDCurses */
#include <curspriv.h>
#include <assert.h>
/*man-start**************************************************************
@ -137,6 +138,7 @@ int def_prog_mode(void)
{
PDC_LOG(("def_prog_mode() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -149,6 +151,7 @@ int def_shell_mode(void)
{
PDC_LOG(("def_shell_mode() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -161,6 +164,7 @@ int reset_prog_mode(void)
{
PDC_LOG(("reset_prog_mode() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -174,6 +178,7 @@ int reset_shell_mode(void)
{
PDC_LOG(("reset_shell_mode() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -187,6 +192,7 @@ int resetty(void)
{
PDC_LOG(("resetty() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -197,6 +203,7 @@ int savetty(void)
{
PDC_LOG(("savetty() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -225,10 +232,14 @@ int curs_set(int visibility)
return ret_vis;
}
/* TODO : must initscr() be called for napms to work? Certainly not
on some platforms, but is it true for all? */
int napms(int ms)
{
PDC_LOG(("napms() - called: ms=%d\n", ms));
assert( SP);
if (!SP)
return ERR;

View File

@ -1,6 +1,7 @@
/* PDCurses */
#include <curspriv.h>
#include <assert.h>
/*man-start**************************************************************
@ -146,6 +147,7 @@ int mouse_set(mmask_t mbe)
{
PDC_LOG(("mouse_set() - called: event %x\n", mbe));
assert( SP);
if (!SP)
return ERR;
@ -157,6 +159,7 @@ int mouse_on(mmask_t mbe)
{
PDC_LOG(("mouse_on() - called: event %x\n", mbe));
assert( SP);
if (!SP)
return ERR;
@ -168,6 +171,7 @@ int mouse_off(mmask_t mbe)
{
PDC_LOG(("mouse_off() - called: event %x\n", mbe));
assert( SP);
if (!SP)
return ERR;
@ -208,11 +212,14 @@ mmask_t getmouse(void)
{
PDC_LOG(("getmouse() - called\n"));
assert( SP);
return SP ? SP->_trap_mbe : (mmask_t)0;
}
/* ncurses mouse interface */
const int max_mouse_interval = 32767; /* 32.767 seconds */
int mouseinterval(int wait)
{
int old_wait;
@ -220,11 +227,11 @@ int mouseinterval(int wait)
PDC_LOG(("mouseinterval() - called: %d\n", wait));
if (!SP)
return ERR;
return max_mouse_interval;
old_wait = SP->mouse_wait;
if (wait >= 0 && wait <= 1000)
if (wait >= 0 && wait <= max_mouse_interval)
SP->mouse_wait = wait;
return old_wait;
@ -286,6 +293,7 @@ mmask_t mousemask(mmask_t mask, mmask_t *oldmask)
{
PDC_LOG(("mousemask() - called\n"));
assert( SP);
if (!SP)
return (mmask_t)0;
@ -309,6 +317,8 @@ int nc_getmouse(MEVENT *event)
PDC_LOG(("nc_getmouse() - called\n"));
assert( SP);
assert( event);
if (!event || !SP)
return ERR;

View File

@ -1,6 +1,7 @@
/* PDCurses */
#include <curspriv.h>
#include <assert.h>
/*man-start**************************************************************
@ -39,6 +40,7 @@ int move(int y, int x)
{
PDC_LOG(("move() - called: y=%d x=%d\n", y, x));
assert( stdscr);
if (!stdscr || x < 0 || y < 0 || x >= stdscr->_maxx || y >= stdscr->_maxy)
return ERR;
@ -53,6 +55,7 @@ int mvcur(int oldrow, int oldcol, int newrow, int newcol)
PDC_LOG(("mvcur() - called: oldrow %d oldcol %d newrow %d newcol %d\n",
oldrow, oldcol, newrow, newcol));
assert( SP);
if (!SP || newrow < 0 || newrow >= LINES || newcol < 0 || newcol >= COLS)
return ERR;
@ -67,6 +70,7 @@ int wmove(WINDOW *win, int y, int x)
{
PDC_LOG(("wmove() - called: y=%d x=%d\n", y, x));
assert( win);
if (!win || x < 0 || y < 0 || x >= win->_maxx || y >= win->_maxy)
return ERR;

View File

@ -1,6 +1,7 @@
/* PDCurses */
#include <curspriv.h>
#include <assert.h>
/*man-start**************************************************************
@ -156,6 +157,7 @@ int raw_output(bool bf)
{
PDC_LOG(("raw_output() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -168,6 +170,7 @@ bool is_leaveok(const WINDOW *win)
{
PDC_LOG(("is_leaveok() - called\n"));
assert( win);
if (!win)
return FALSE;

View File

@ -1,6 +1,7 @@
/* PDCurses */
#include <curspriv.h>
#include <assert.h>
/*man-start**************************************************************
@ -132,6 +133,8 @@ int doupdate(void)
PDC_LOG(("doupdate() - called\n"));
assert( SP);
assert( curscr);
if (!SP || !curscr)
return ERR;

View File

@ -1,6 +1,7 @@
/* PDCurses */
#include <curspriv.h>
#include <assert.h>
/*man-start**************************************************************
@ -304,6 +305,7 @@ int slk_noutrefresh(void)
{
PDC_LOG(("slk_noutrefresh() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -338,6 +340,7 @@ int slk_clear(void)
{
PDC_LOG(("slk_clear() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -350,6 +353,7 @@ int slk_restore(void)
{
PDC_LOG(("slk_restore() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -362,6 +366,7 @@ int slk_touch(void)
{
PDC_LOG(("slk_touch() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -374,6 +379,7 @@ int slk_attron(const chtype attrs)
PDC_LOG(("slk_attron() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -396,6 +402,7 @@ int slk_attroff(const chtype attrs)
PDC_LOG(("slk_attroff() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -418,6 +425,7 @@ int slk_attrset(const chtype attrs)
PDC_LOG(("slk_attrset() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -433,6 +441,7 @@ int slk_color(short color_pair)
PDC_LOG(("slk_color() - called\n"));
assert( SP);
if (!SP)
return ERR;
@ -484,6 +493,7 @@ void PDC_slk_initialize(void)
{
if (slk)
{
assert( SP);
if (label_fmt < 0)
{
SP->slklines = 2;
@ -538,6 +548,7 @@ int PDC_mouse_in_slk(int y, int x)
/* If the line on which the mouse was clicked is NOT the last line
of the screen, or the SLKs are hidden, we are not interested in it. */
assert( SP);
if (!slk || hidden || !SP->slk_winptr
|| (y != SP->slk_winptr->_begy + label_line))
return 0;

View File

@ -1,6 +1,7 @@
/* PDCurses */
#include <curspriv.h>
#include <assert.h>
/*man-start**************************************************************
@ -248,6 +249,7 @@ WINDOW *newwin(int nlines, int ncols, int begy, int begx)
if (!ncols)
ncols = COLS - begx;
assert( SP);
if (!SP || begy + nlines > SP->lines || begx + ncols > SP->cols)
return (WINDOW *)NULL;
@ -446,6 +448,8 @@ WINDOW *resize_window(WINDOW *win, int nlines, int ncols)
PDC_LOG(("resize_window() - called: nlines %d ncols %d\n",
nlines, ncols));
assert( SP);
assert( win);
if (!win || !SP)
return (WINDOW *)NULL;