Skip to content

Commit

Permalink
Remaining ncurses extensions for opaque WINDOW structs. See wmcbrine/…
Browse files Browse the repository at this point in the history
…PDCurses#106 and the preceding commit.
  • Loading branch information
uhlin authored and Bill-Gray committed Nov 18, 2022
1 parent 22fecc1 commit 7bb822b
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 15 deletions.
15 changes: 14 additions & 1 deletion curses.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Defined by this header:
#define PDC_VER_CHANGE 4
#define PDC_VER_YEAR 2022
#define PDC_VER_MONTH 11
#define PDC_VER_DAY 04
#define PDC_VER_DAY 18

#define PDC_STRINGIZE( x) #x
#define PDC_stringize( x) PDC_STRINGIZE( x)
Expand Down Expand Up @@ -1708,12 +1708,25 @@ PDCEX const char *curses_version(void);
PDCEX int find_pair(int, int);
PDCEX int free_pair( int);
PDCEX bool has_key(int);
PDCEX bool is_cleared(const WINDOW *);
PDCEX bool is_idcok(const WINDOW *);
PDCEX bool is_idlok(const WINDOW *);
PDCEX bool is_immedok(const WINDOW *);
PDCEX bool is_keypad(const WINDOW *);
PDCEX bool is_leaveok(const WINDOW *);
PDCEX bool is_leaveok(const WINDOW *);
PDCEX bool is_nodelay(const WINDOW *);
PDCEX bool is_notimeout(const WINDOW *);
PDCEX bool is_pad(const WINDOW *);
PDCEX void reset_color_pairs( void);
PDCEX bool is_scrollok(const WINDOW *);
PDCEX bool is_subwin(const WINDOW *);
PDCEX bool is_syncok(const WINDOW *);
PDCEX int set_tabsize(int);
PDCEX int use_default_colors(void);
PDCEX int wgetdelay(const WINDOW *);
PDCEX WINDOW *wgetparent(const WINDOW *);
PDCEX int wgetscrreg(const WINDOW *, int *, int *);
PDCEX int wresize(WINDOW *, int, int);

PDCEX bool has_mouse(void);
Expand Down
52 changes: 49 additions & 3 deletions pdcurses/inopts.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* PDCurses */
/* PDCursesMod */

#include <curspriv.h>
#include <assert.h>
Expand Down Expand Up @@ -28,6 +28,7 @@ inopts
void qiflush(void);
void timeout(int delay);
void wtimeout(WINDOW *win, int delay);
int wgetdelay(const WINDOW *win);
int typeahead(int fildes);
bool PDC_getcbreak(void);
bool PDC_getecho(void);
Expand All @@ -36,6 +37,8 @@ inopts
int nocrmode(void);
bool is_keypad(const WINDOW *win);
bool is_nodelay(const WINDOW *win);
bool is_notimeout(const WINDOW *win);
### Description
Expand Down Expand Up @@ -89,6 +92,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.
Expand All @@ -98,10 +103,16 @@ 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.
All functions that return integers 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. It has no real meaning in PDCursesMod and will
always return FALSE.
### Portability
X/Open ncurses NetBSD
Expand All @@ -125,10 +136,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 -
**man-end****************************************************************/

Expand Down Expand Up @@ -298,6 +312,17 @@ int notimeout(WINDOW *win, bool flag)
return OK;
}

int wgetdelay(const WINDOW *win)
{
PDC_LOG(("wgetdelay() - called\n"));

assert( win);
if (!win)
return 0;

return win->_delayms;
}

int raw(void)
{
PDC_LOG(("raw() - called\n"));
Expand Down Expand Up @@ -410,3 +435,24 @@ bool is_keypad(const WINDOW *win)

return win->_use_keypad;
}

bool is_nodelay(const WINDOW *win)
{
PDC_LOG(("is_nodelay() - called\n"));

assert( win);
if (!win)
return FALSE;

return win->_nodelay;
}

bool is_notimeout(const WINDOW *win)
{
PDC_LOG(("is_notimeout() - called - returning FALSE...\n"));

assert( win);
INTENTIONALLY_UNUSED_PARAMETER( win);

return FALSE;
}
119 changes: 108 additions & 11 deletions pdcurses/outopts.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* PDCurses */
/* PDCursesMod */

#include <curspriv.h>
#include <assert.h>
Expand All @@ -17,11 +17,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
Expand All @@ -43,20 +49,36 @@ outopts
will cause all lines in the scrolling region to scroll up one line.
setscrreg() is the stdscr version.
idlok() and idcok() do nothing in PDCurses, but are provided for
compatibility with other curses implementations.
wgetscrreg() gets the top and bottom margins as set in wsetscrreg().
idlok(), idcok(), is_idlok() and is_idcok() do nothing in PDCursesMod,
but are provided for compatibility with other curses implementations.
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
All functions returning integers return OK on success and ERR on
error.
is_cleared(), is_immedok(), is_leaveok() and is_scrollok() are
booleans and return TRUE or FALSE.
is_idlok() and is_idcok() are provided for compatibility with other
curses implementations. They have no real meaning in PDCursesMod and
will always return FALSE.
### Portability
X/Open ncurses NetBSD
clearok Y Y Y
Expand All @@ -66,8 +88,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 - - -
**man-end****************************************************************/
Expand Down Expand Up @@ -148,6 +176,22 @@ int wsetscrreg(WINDOW *win, int top, int bottom)
return ERR;
}

int wgetscrreg(const WINDOW *win, int *top, int *bot)
{
PDC_LOG(("wgetscrreg() - called\n"));

assert( win);
assert( top);
assert( bot);
if (!win || !top || !bot)
return ERR;

*top = win->_tmarg;
*bot = win->_bmarg;

return OK;
}

int scrollok(WINDOW *win, bool bf)
{
PDC_LOG(("scrollok() - called\n"));
Expand All @@ -161,17 +205,46 @@ int scrollok(WINDOW *win, bool bf)
return OK;
}

int raw_output(bool bf)
bool is_cleared(const WINDOW *win)
{
PDC_LOG(("raw_output() - called\n"));
PDC_LOG(("is_cleared() - called\n"));

assert( SP);
if (!SP)
return ERR;
assert( win);
if (!win)
return FALSE;

SP->raw_out = bf;
return win->_clear;
}

return OK;
bool is_idlok(const WINDOW *win)
{
PDC_LOG(("is_idlok() - called\n"));

INTENTIONALLY_UNUSED_PARAMETER( win);
assert( win);

return FALSE;
}

bool is_idcok(const WINDOW *win)
{
PDC_LOG(("is_idcok() - called\n"));

INTENTIONALLY_UNUSED_PARAMETER( win);
assert( win);

return FALSE;
}

bool is_immedok(const WINDOW *win)
{
PDC_LOG(("is_immedok() - called\n"));

assert( win);
if (!win)
return FALSE;

return win->_immed;
}

bool is_leaveok(const WINDOW *win)
Expand All @@ -184,3 +257,27 @@ bool is_leaveok(const WINDOW *win)

return win->_leaveit;
}

bool is_scrollok(const WINDOW *win)
{
PDC_LOG(("is_scrollok() - called\n"));

assert( win);
if (!win)
return FALSE;

return win->_scroll;
}

int raw_output(bool bf)
{
PDC_LOG(("raw_output() - called\n"));

assert( SP);
if (!SP)
return ERR;

SP->raw_out = bf;

return OK;
}

0 comments on commit 7bb822b

Please sign in to comment.