diff --git a/curses.h b/curses.h index 9e98fb53..4fa3b09e 100644 --- a/curses.h +++ b/curses.h @@ -15,7 +15,7 @@ * See the file maintain.er for details of the current maintainer. * ************************************************************************/ -/* $Id: curses.h,v 1.138 2006/02/27 21:48:03 wmcbrine Exp $ */ +/* $Id: curses.h,v 1.139 2006/02/28 02:04:56 wmcbrine Exp $ */ /*----------------------------------------------------------------------* * PDCurses * @@ -615,10 +615,10 @@ typedef struct bool bogus_adapter; /* TRUE if adapter has insane values */ bool shell; /* TRUE if reset_prog_mode() needs to be called. */ + bool orig_attr; /* TRUE if we have the original colors */ + short orig_fore; /* Original screen foreground color */ + short orig_back; /* Original screen foreground color */ chtype blank; /* Background character */ - chtype orig_attr; /* Original screen attributes - - top 16 bits background, - bottom 16 bits foreground */ int cursrow; /* position of physical cursor */ int curscol; /* position of physical cursor */ int cursor; /* Current Cursor definition */ diff --git a/dos/pdcscrn.c b/dos/pdcscrn.c index 5192b989..639f4020 100644 --- a/dos/pdcscrn.c +++ b/dos/pdcscrn.c @@ -29,7 +29,7 @@ #ifdef PDCDEBUG const char *rcsid_PDCscrn = - "$Id: pdcscrn.c,v 1.21 2006/02/23 01:46:52 wmcbrine Exp $"; + "$Id: pdcscrn.c,v 1.22 2006/02/28 02:04:57 wmcbrine Exp $"; #endif static unsigned short *saved_screen = NULL; @@ -156,7 +156,7 @@ int PDC_scr_open(SCREEN *internal, bool echo) #endif PDC_LOG(("PDC_scr_open() - called\n")); - internal->orig_attr = 0; + internal->orig_attr = FALSE; internal->orig_emulation = getdosmembyte (0x487); PDC_get_cursor_pos(&internal->cursrow, &internal->curscol); diff --git a/os2/pdcscrn.c b/os2/pdcscrn.c index cb5464fe..f273cc16 100644 --- a/os2/pdcscrn.c +++ b/os2/pdcscrn.c @@ -22,7 +22,7 @@ #ifdef PDCDEBUG const char *rcsid_PDCscrn = - "$Id: pdcscrn.c,v 1.18 2006/02/23 01:46:52 wmcbrine Exp $"; + "$Id: pdcscrn.c,v 1.19 2006/02/28 02:04:57 wmcbrine Exp $"; #endif #ifdef EMXVIDEO @@ -152,7 +152,7 @@ int PDC_scr_open(SCREEN *internal, bool echo) PDC_LOG(("PDC_scr_open() - called. internal: %x, echo: %d\n", internal, echo)); - internal->orig_attr = 0; + internal->orig_attr = FALSE; internal->orig_emulation = 0; PDC_get_cursor_pos(&internal->cursrow, &internal->curscol); diff --git a/pdcurses/color.c b/pdcurses/color.c index 21d5acef..c457bb72 100644 --- a/pdcurses/color.c +++ b/pdcurses/color.c @@ -17,6 +17,7 @@ #define CURSES_LIBRARY 1 #include +#include #include /* undefine any macros for functions defined in this module */ @@ -35,7 +36,7 @@ static void PDC_init_pair(short, short, short); #ifdef PDCDEBUG const char *rcsid_color = - "$Id: color.c,v 1.42 2006/02/23 01:46:52 wmcbrine Exp $"; + "$Id: color.c,v 1.43 2006/02/28 02:04:57 wmcbrine Exp $"; #endif /*man-start************************************************************** @@ -148,7 +149,11 @@ int start_color(void) if (SP->mono) return ERR; - /* PDC_init_atrtab(); - already done in initscr() */ + if (SP->orig_attr && !getenv("PDC_ORIGINAL_COLORS")) + { + SP->orig_attr = FALSE; + PDC_init_atrtab(); + } memset(colorset, 0, PDC_COLOR_PAIRS); @@ -250,21 +255,16 @@ int PDC_set_line_color(short color) void PDC_init_atrtab(void) { - int i, orig_fore, orig_back; + int i; - if (SP->orig_attr == 0) + if (!SP->orig_attr) { - orig_fore = COLOR_WHITE; - orig_back = COLOR_BLACK; - } - else - { - orig_fore = SP->orig_attr & A_CHARTEXT; - orig_back = (SP->orig_attr & A_ATTRIBUTES) >> 16; + SP->orig_fore = COLOR_WHITE; + SP->orig_back = COLOR_BLACK; } for (i = 0; i < PDC_COLOR_PAIRS; i++) - PDC_init_pair(i, orig_fore, orig_back); + PDC_init_pair(i, SP->orig_fore, SP->orig_back); } static void PDC_init_pair(short pairnum, short fg, short bg) diff --git a/win32/pdcscrn.c b/win32/pdcscrn.c index 11f75542..af07821f 100644 --- a/win32/pdcscrn.c +++ b/win32/pdcscrn.c @@ -21,7 +21,7 @@ #ifdef PDCDEBUG const char *rcsid_PDCscrn = - "$Id: pdcscrn.c,v 1.26 2006/02/23 01:46:52 wmcbrine Exp $"; + "$Id: pdcscrn.c,v 1.27 2006/02/28 02:04:57 wmcbrine Exp $"; #endif #define PDC_RESTORE_NONE 0 @@ -203,17 +203,10 @@ int PDC_scr_open(SCREEN *internal, bool echo) return ERR; } - if (getenv("PDC_ORIGINAL_COLORS") != NULL) - { - chtype orig_back, orig_fore; + internal->orig_fore = csbi.wAttributes & 0x0f; + internal->orig_back = (csbi.wAttributes & 0xf0) >> 4; - orig_fore = csbi.wAttributes & 0x0f; - orig_back = (csbi.wAttributes & 0xf0) >> 4; - - internal->orig_attr = (orig_back << 16) | orig_fore; - } - else - internal->orig_attr = 0; + internal->orig_attr = TRUE; internal->_restore = PDC_RESTORE_NONE; diff --git a/x11/pdcscrn.c b/x11/pdcscrn.c index 4e82eb1b..4c39f31d 100644 --- a/x11/pdcscrn.c +++ b/x11/pdcscrn.c @@ -20,7 +20,7 @@ #ifdef PDCDEBUG const char *rcsid_PDCscrn = - "$Id: pdcscrn.c,v 1.17 2006/02/23 01:46:52 wmcbrine Exp $"; + "$Id: pdcscrn.c,v 1.18 2006/02/28 02:04:57 wmcbrine Exp $"; #endif bool GLOBAL_sb_on = FALSE; @@ -123,7 +123,7 @@ int PDC_scr_open(SCREEN *internal, bool echo) internal->audible = TRUE; internal->visibility = 1; internal->orig_cursor = internal->cursor; - internal->orig_attr = 0; + internal->orig_attr = FALSE; internal->orgcbr = 0; internal->blank = ' '; internal->resized = FALSE;