Per the spec, non-macro implementations for COLOR_PAIR(), PAIR_NUMBER(),

getbkgd(), mvgetnstr(), mvwgetnstr(), vw_printw(), and vw_scanw().
This commit is contained in:
William McBrine
2006-01-27 18:41:37 +00:00
parent 7b00053f56
commit 46c9e97efc
8 changed files with 201 additions and 61 deletions

View File

@@ -18,7 +18,7 @@
***************************************************************************
*/
/*
$Id: curses.h,v 1.102 2006/01/26 21:00:18 wmcbrine Exp $
$Id: curses.h,v 1.103 2006/01/27 18:41:37 wmcbrine Exp $
*/
/*
*----------------------------------------------------------------------
@@ -1101,14 +1101,6 @@ currently used.)
#define COLOR_WHITE 7
#ifdef CHTYPE_LONG
# define COLOR_PAIR(n) ((chtype)(n) << 24)
# define PAIR_NUMBER(n) (((n) & A_COLOR) >> 24)
#else
# define COLOR_PAIR(n) (((n) << 11) & A_ATTRIBUTES)
# define PAIR_NUMBER(n) (((n) & A_COLOR) >> 11)
#endif
/*----------------------------------------------------------------------
*
* Function and Keypad Key Definitions.
@@ -1597,6 +1589,14 @@ int PDC_CDECL PDC_set_line_color Args((short));
/*** Functions defined as macros ***/
#ifdef CHTYPE_LONG
# define COLOR_PAIR(n) ((chtype)(n) << 24)
# define PAIR_NUMBER(n) (((n) & A_COLOR) >> 24)
#else
# define COLOR_PAIR(n) (((n) << 11) & A_ATTRIBUTES)
# define PAIR_NUMBER(n) (((n) & A_COLOR) >> 11)
#endif
#define addch(c) waddch(stdscr, c)
#define addchstr(c) addchnstr(c, -1)
#define addstr(str) waddstr(stdscr, str)

View File

@@ -43,7 +43,7 @@
#endif
#ifdef PDCDEBUG
char *rcsid_attr = "$Id: attr.c,v 1.9 2006/01/27 16:18:00 wmcbrine Exp $";
char *rcsid_attr = "$Id: attr.c,v 1.10 2006/01/27 18:41:37 wmcbrine Exp $";
#endif
/*man-start*********************************************************************
@@ -61,6 +61,7 @@ char *rcsid_attr = "$Id: attr.c,v 1.9 2006/01/27 16:18:00 wmcbrine Exp $";
int wstandend(WINDOW *win);
int standout(void);
int wstandout(WINDOW *win);
chtype getattrs(WINDOW *win);
int color_set(short color_pair, void *opts);
int wcolor_set(WINDOW *win, short color_pair, void *opts);
@@ -234,18 +235,6 @@ chtype attrs;
return OK;
}
/***********************************************************************/
#ifdef HAVE_PROTO
chtype PDC_CDECL getattrs(WINDOW* win)
#else
chtype PDC_CDECL getattrs(win)
WINDOW *win;
#endif
/***********************************************************************/
{
return win ? win->_attrs : 0;
}
/***********************************************************************/
#ifdef HAVE_PROTO
int PDC_CDECL standend(void)
@@ -300,6 +289,18 @@ WINDOW *win;
return wattrset(win, A_STANDOUT);
}
/***********************************************************************/
#ifdef HAVE_PROTO
chtype PDC_CDECL getattrs(WINDOW *win)
#else
chtype PDC_CDECL getattrs(win)
WINDOW *win;
#endif
/***********************************************************************/
{
return win ? win->_attrs : 0;
}
/***********************************************************************/
#ifdef HAVE_PROTO
int PDC_CDECL color_set(short color_pair, void *opts)

View File

@@ -26,11 +26,12 @@
/* undefine any macros for functions defined in this module */
#undef bkgd
#undef bkgdset
#undef getbkgd
#undef wbkgd
#undef wbkgdset
#ifdef PDCDEBUG
char *rcsid_bkgd = "$Id: bkgd.c,v 1.6 2006/01/27 16:18:00 wmcbrine Exp $";
char *rcsid_bkgd = "$Id: bkgd.c,v 1.7 2006/01/27 18:41:37 wmcbrine Exp $";
#endif
/*man-start*********************************************************************
@@ -40,6 +41,7 @@ char *rcsid_bkgd = "$Id: bkgd.c,v 1.6 2006/01/27 16:18:00 wmcbrine Exp $";
Synopsis:
int bkgd(chtype ch);
void bkgdset(chtype ch);
chtype getbkgd(WINDOW *win);
int wbkgd(WINDOW *win, chtype ch);
void wbkgdset(WINDOW *win, chtype ch);
@@ -85,6 +87,7 @@ char *rcsid_bkgd = "$Id: bkgd.c,v 1.6 2006/01/27 16:18:00 wmcbrine Exp $";
Dec '88
bkgd - - 4.0
bkgdset - - 4.0
getbkgd
wbkgd - - 4.0
wbkgdset - - 4.0
@@ -104,6 +107,32 @@ chtype ch;
return wbkgd(stdscr, ch);
}
/***********************************************************************/
#ifdef HAVE_PROTO
void PDC_CDECL bkgdset(chtype ch)
#else
void PDC_CDECL bkgdset(ch)
chtype ch;
#endif
/***********************************************************************/
{
PDC_LOG(("bkgdset() - called\n"));
wbkgdset(stdscr, ch);
}
/***********************************************************************/
#ifdef HAVE_PROTO
chtype PDC_CDECL getbkgd(WINDOW *win)
#else
chtype PDC_CDECL getbkgd(win)
WINDOW *win;
#endif
/***********************************************************************/
{
return win ? win->_bkgd : (chtype)ERR;
}
/***********************************************************************/
#ifdef HAVE_PROTO
int PDC_CDECL wbkgd(WINDOW *win, chtype ch)
@@ -199,20 +228,6 @@ chtype ch;
return OK;
}
/***********************************************************************/
#ifdef HAVE_PROTO
void PDC_CDECL bkgdset(chtype ch)
#else
void PDC_CDECL bkgdset(ch)
chtype ch;
#endif
/***********************************************************************/
{
PDC_LOG(("bkgdset() - called\n"));
wbkgdset(stdscr, ch);
}
/***********************************************************************/
#ifdef HAVE_PROTO
void PDC_CDECL wbkgdset(WINDOW *win, chtype ch)

View File

@@ -28,9 +28,13 @@
#undef wborder
#undef box
#undef hline
#undef whline
#undef vline
#undef whline
#undef wvline
#undef mvhline
#undef mvvline
#undef mvwhline
#undef mvwvline
#undef PDC_wunderline
#undef PDC_leftline
#undef PDC_rightline
@@ -40,7 +44,7 @@
#endif
#ifdef PDCDEBUG
char *rcsid_border = "$Id: border.c,v 1.9 2006/01/27 16:18:00 wmcbrine Exp $";
char *rcsid_border = "$Id: border.c,v 1.10 2006/01/27 18:41:37 wmcbrine Exp $";
#endif
/*man-start*********************************************************************

View File

@@ -25,6 +25,8 @@
#include <string.h>
/* undefine any macros for functions defined in this module */
#undef COLOR_PAIR
#undef PAIR_NUMBER
#undef start_color
#undef init_pair
#undef init_color
@@ -45,7 +47,7 @@ static void PDC_init_pair();
#endif
#ifdef PDCDEBUG
char *rcsid_color = "$Id: color.c,v 1.21 2006/01/27 16:18:00 wmcbrine Exp $";
char *rcsid_color = "$Id: color.c,v 1.22 2006/01/27 18:41:37 wmcbrine Exp $";
#endif
/*man-start*********************************************************************
@@ -53,6 +55,8 @@ char *rcsid_color = "$Id: color.c,v 1.21 2006/01/27 16:18:00 wmcbrine Exp $";
Name: color
Synopsis:
chtype COLOR_PAIR(int n);
int PAIR_NUMBER(chtype value);
int start_color(void);
int init_pair(short pair, short fg, short bg);
int init_color(short color, short red, short green, short blue);
@@ -68,9 +72,8 @@ char *rcsid_color = "$Id: color.c,v 1.21 2006/01/27 16:18:00 wmcbrine Exp $";
immediately after initscr(). Colors are always used in pairs
refered to as color-pairs. A color-pair consists of a foreground
color and a background color. A color-pair is initialized with
init_pair(). After it has been initialized, COLOR_PAIR(n), a
macro defined in <curses.h>, can be used like any other video
attribute.
init_pair(). After it has been initialized, COLOR_PAIR(n) can be
used like any other video attribute.
start_color() initializes eight basic colors (black, red, green,
yellow, blue, magenta, cyan, and white), and two global
@@ -102,7 +105,8 @@ char *rcsid_color = "$Id: color.c,v 1.21 2006/01/27 16:18:00 wmcbrine Exp $";
color of the lines drawn for the attributes: A_UNDERLINE,
A_OVERLINE, A_LEFTLINE and A_RIGHTLINE. PDCurses only feature.
NOTE: has_colors() is implemented as a macro.
NOTE: COLOR_PAIR(), PAIR_NUMBER() and has_colors() are
implemented as macros.
X/Open Return Value:
All functions return OK on success and ERR on error except for
@@ -177,6 +181,38 @@ unsigned char atrtab[MAX_ATRTAB] =
unsigned char colorset[PDC_COLOR_PAIRS];
/***********************************************************************/
#ifdef HAVE_PROTO
chtype PDC_CDECL COLOR_PAIR(int n)
#else
chtype PDC_CDECL COLOR_PAIR(n)
int n;
#endif
/***********************************************************************/
{
#ifdef CHTYPE_LONG
return (chtype)n << 24;
#else
return (n << 11) & A_ATTRIBUTES;
#endif
}
/***********************************************************************/
#ifdef HAVE_PROTO
int PDC_CDECL PAIR_NUMBER(chtype value)
#else
int PDC_CDECL PAIR_NUMBER(value)
chtype value;
#endif
/***********************************************************************/
{
#ifdef CHTYPE_LONG
return (value & A_COLOR) >> 24;
#else
return (value & A_COLOR) >> 11;
#endif
}
/***********************************************************************/
#ifdef HAVE_PROTO
int PDC_CDECL start_color(void)

View File

@@ -28,9 +28,10 @@
#undef wgetstr
#undef mvgetstr
#undef mvwgetstr
#undef ungetstr
#undef getnstr
#undef wgetnstr
#undef mvgetnstr
#undef mvwgetnstr
/* undefine any macros for functions called by this module if in debug mode */
#ifdef PDCDEBUG
@@ -43,7 +44,7 @@
#endif
#ifdef PDCDEBUG
char *rcsid_getstr = "$Id: getstr.c,v 1.13 2006/01/14 06:42:03 wmcbrine Exp $";
char *rcsid_getstr = "$Id: getstr.c,v 1.14 2006/01/27 18:41:37 wmcbrine Exp $";
#endif
/*man-start*********************************************************************
@@ -55,9 +56,10 @@ char *rcsid_getstr = "$Id: getstr.c,v 1.13 2006/01/14 06:42:03 wmcbrine Exp $";
int wgetstr(WINDOW *win, char *str);
int mvgetstr(int y, int x, char *str);
int mvwgetstr(WINDOW *win, int y, int x, char *str);
int getnstr(char *str, int ch);
int wgetnstr(WINDOW *win, char *str, int ch);
int mvwgetnstr(WINDOW *win, int y, int x, char *str, int ch);
int getnstr(char *str, int n);
int wgetnstr(WINDOW *win, char *str, int n);
int mvgetnstr(int y, int x, char *str, int n);
int mvwgetnstr(WINDOW *win, int y, int x, char *str, int n);
X/Open Description:
The effect of getstr() is as though a series of calls to getch()
@@ -73,8 +75,8 @@ char *rcsid_getstr = "$Id: getstr.c,v 1.13 2006/01/14 06:42:03 wmcbrine Exp $";
wgetstr() in that the number of characters read is limited by a
passed argument.
NOTE: getstr(), getnstr(), mvgetstr(), mvwgetstr(), mwwgetnstr()
are implemented as macros.
NOTE: getstr(), getnstr(), mvgetstr(), mvwgetstr(), mvgetnstr()
and mvwgetnstr() are implemented as macros.
WARNING: There is no way to know how long the buffer passed to
wgetstr() is, so it is possible to overwrite wrong memory or
@@ -333,3 +335,44 @@ int n;
return OK;
}
/***********************************************************************/
#ifdef HAVE_PROTO
int PDC_CDECL mvgetnstr(int y, int x, char *str, int n)
#else
int PDC_CDECL mvgetnstr(y, x, str, n)
int y;
int x;
char *str;
int n;
#endif
/***********************************************************************/
{
PDC_LOG(("mvgetnstr() - called\n"));
if (move(y, x) == ERR)
return ERR;
return wgetnstr(stdscr, str, n);
}
/***********************************************************************/
#ifdef HAVE_PROTO
int PDC_CDECL mvwgetnstr(WINDOW *win, int y, int x, char *str, int n)
#else
int PDC_CDECL mvwgetnstr(win, y, x, str, n)
WINDOW *win;
int y;
int x;
char *str;
int n;
#endif
/***********************************************************************/
{
PDC_LOG(("mvwgetnstr() - called\n"));
if (wmove(win, y, x) == ERR)
return ERR;
return wgetnstr(win, str, n);
}

View File

@@ -29,6 +29,8 @@
#undef wprintw
#undef mvprintw
#undef mvwprintw
#undef vwprintw
#undef vw_printw
/* undefine any macros for functions called by this module if in debug mode */
#ifdef PDCDEBUG
@@ -37,7 +39,7 @@
#endif
#ifdef PDCDEBUG
char *rcsid_printw = "$Id: printw.c,v 1.8 2006/01/25 14:32:35 wmcbrine Exp $";
char *rcsid_printw = "$Id: printw.c,v 1.9 2006/01/27 18:41:37 wmcbrine Exp $";
#endif
/*man-start*********************************************************************
@@ -50,6 +52,7 @@ char *rcsid_printw = "$Id: printw.c,v 1.8 2006/01/25 14:32:35 wmcbrine Exp $";
int mvprintw(int y, int x, char *fmt, ...);
int mvwprintw(WINDOW *win, int y, int x, char *fmt,...);
int vwprintw(WINDOW *win, char *fmt, va_list varglist);
int vw_printw(WINDOW *win, char *fmt, va_list varglist);
X/Open Description:
The printw() routine adds a string to the default window
@@ -76,10 +79,6 @@ char *rcsid_printw = "$Id: printw.c,v 1.8 2006/01/25 14:32:35 wmcbrine Exp $";
to use the field width options of printf() to avoid leaving
unwanted characters on the screen from earlier calls.
PDCurses Description:
The old Bjorn Larssen code for the 68K platform has been removed
from this module.
X/Open Return Value:
All functions return OK on success and ERR on error.
@@ -236,3 +235,25 @@ va_dcl
return (waddstr(win, printbuf) == ERR) ? ERR : len;
}
/***********************************************************************/
#ifdef HAVE_STDARG_H_HAVE_PROTO
int PDC_CDECL vw_printw(WINDOW *win, char *fmt, va_list varglist)
#else
int PDC_CDECL vw_printw(win, fmt, va_alist)
WINDOW *win;
char *fmt;
va_dcl
#endif
/***********************************************************************/
{
#if !defined(HAVE_STDARG_H_HAVE_PROTO)
va_list varglist;
#endif
PDC_LOG(("vw_printw() - called\n"));
#if !defined(HAVE_STDARG_H_HAVE_PROTO)
va_start(varglist);
#endif
return vwprintw(win, fmt, varglist);
}

View File

@@ -30,6 +30,7 @@
#undef mvscanw
#undef mvwscanw
#undef vwscanw
#undef vw_scanw
/* undefine any macros for functions called by this module if in debug mode */
#ifdef PDCDEBUG
@@ -43,7 +44,7 @@
#endif
#ifdef PDCDEBUG
char *rcsid_scanw = "$Id: scanw.c,v 1.9 2006/01/27 16:18:00 wmcbrine Exp $";
char *rcsid_scanw = "$Id: scanw.c,v 1.10 2006/01/27 18:41:37 wmcbrine Exp $";
#endif
/*man-start*********************************************************************
@@ -56,6 +57,7 @@ char *rcsid_scanw = "$Id: scanw.c,v 1.9 2006/01/27 16:18:00 wmcbrine Exp $";
int mvscanw(int y, int x, char *fmt, ...);
int mvwscanw(WINDOW *win, int y, int x, char *fmt, ...);
int vwscanw(WINDOW *win, char *fmt, va_list varglist);
int vw_scanw(WINDOW *win, char *fmt, va_list varglist);
X/Open Description:
These routines correspond to scanf(). The function scanw() reads
@@ -71,10 +73,6 @@ char *rcsid_scanw = "$Id: scanw.c,v 1.9 2006/01/27 16:18:00 wmcbrine Exp $";
input for the scan. All character interpretation is carried
out according to the scanf function rules.
PDCurses Description:
The old Bjorn Larssen code for the 68K platform has been removed
from this module.
X/Open Return Value:
Upon successful completion, the scanw, mvscanw, mvwscanw and
wscanw functions return the number of items successfully
@@ -234,3 +232,25 @@ va_dcl
#endif
return vsscanf(scanbuf, fmt, varglist);
}
/***********************************************************************/
#ifdef HAVE_STDARG_H_HAVE_PROTO
int PDC_CDECL vw_scanw(WINDOW *win, char *fmt, va_list varglist)
#else
int PDC_CDECL vw_scanw(win, fmt, va_alist)
WINDOW *win;
char *fmt;
va_dcl
#endif
/***********************************************************************/
{
#if !defined(HAVE_STDARG_H_HAVE_PROTO)
va_list varglist;
#endif
PDC_LOG(("vw_scanw() - called\n"));
#if !defined(HAVE_STDARG_H_HAVE_PROTO)
va_start(varglist);
#endif
return vwscanw(win, fmt, varglist);
}