home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega Top 1
/
os2_top1.zip
/
os2_top1
/
APPS
/
UTILS
/
H-O
/
LESS177
/
SCR.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-01-10
|
1KB
|
55 lines
#include <stdio.h>
#define INCL_NOPMAPI
#define INCL_VIO
#include <os2.h>
extern void clear_eol(), lower_left();
extern int sc_height,sc_width;
unsigned char scrcell[2];
void savescr () {
VIOMODEINFO vmi;
USHORT scr_n;
scr_n=2;
VioGetMode(&vmi,0); /* need screen h,w now */
/* get color/attribute of last cell on screen */
VioReadCellStr(scrcell, &scr_n, vmi.row-1, vmi.col-1, 0);
sc_height=vmi.row; /* in case we never reach part where screen */
sc_width=vmi.col; /* width and height are read */
}
void restorescr () {
unsigned char fore,back,k;
int bri=0,bli=0;
char endstr[6];
char colors[] = {0, 4, 2, 6, 1, 5, 3, 7};
k=scrcell[1];
fore=(k & 0x0f);
back=k >> 4;
if ( back > 7 ) {
back = (back & 0x07);
bli = 5;
}
if (fore > 7 ) {
fore = (fore & 0x07);
bri = 1;
}
if (bli != 0) {
if (bri != 0) {
strcpy(endstr, ";1;5m");
} else {
strcpy(endstr, ";5m");
}
} else {
if (bri != 0) {
strcpy(endstr, ";1m");
} else {
strcpy(endstr, "m");
}
}
lower_left(); flush();
fprintf(stderr,"\033[0;%d;%d%s\033[K\033[=7h",
colors[fore]+30, colors[back]+40, endstr);
}