Various fixes, mostly for win32 console

This commit is contained in:
Alexander S. Aganichev
2000-11-06 14:26:34 +00:00
parent c3374170a9
commit f0b3dea792
25 changed files with 473 additions and 625 deletions

View File

@@ -132,9 +132,7 @@ void GKbd::Init() {
osversion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osversion);
gkbd_nt = (osversion.dwPlatformId & VER_PLATFORM_WIN32_NT) ? true : false;
gkbd_hin = CreateFile("CONIN$", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, 0, NULL);
gkbd_hin = GetStdHandle(STD_INPUT_HANDLE);
GetConsoleMode(gkbd_hin, &gkbd_kbdmode);
if(gkbd_kbdmode & KBD_TEXTMODE)
SetConsoleMode(gkbd_hin, gkbd_kbdmode & ~KBD_TEXTMODE);
@@ -878,7 +876,7 @@ bool is_numpad_key(const INPUT_RECORD& inp) {
if(not (inp.Event.KeyEvent.dwControlKeyState & ENHANCED_KEY)) {
switch(inp.Event.KeyEvent.wVirtualKeyCode) {
case 0x0C:
case VK_CLEAR:
case VK_PRIOR:
case VK_NEXT:
case VK_END:
@@ -1168,6 +1166,10 @@ gkey kbxget_raw(int mode) {
}
else {
DWORD &CKS = inp.Event.KeyEvent.dwControlKeyState;
WORD &VKC = inp.Event.KeyEvent.wVirtualKeyCode;
char &ascii = inp.Event.KeyEvent.uChar.AsciiChar;
// Get next key
inp.Event.KeyEvent.bKeyDown = false;
while(1) {
@@ -1179,53 +1181,88 @@ gkey kbxget_raw(int mode) {
}
if(inp.EventType == KEY_EVENT and inp.Event.KeyEvent.bKeyDown) {
bool alt_pressed = (inp.Event.KeyEvent.dwControlKeyState & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED)) ? true : false;
// bool right_alt_pressed = (inp.Event.KeyEvent.dwControlKeyState & RIGHT_ALT_PRESSED) ? true : false;
bool enhanced_key = (inp.Event.KeyEvent.dwControlKeyState & ENHANCED_KEY) ? true : false;
bool numpad_key = is_numpad_key(inp);
int vk = inp.Event.KeyEvent.wVirtualKeyCode;
char raw_ch = inp.Event.KeyEvent.uChar.AsciiChar;
int kc;
int test;
char ch;
bool alt_pressed = (CKS & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED)) ? true : false;
bool ctrl_pressed = (CKS & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED)) ? true : false;
bool shift_pressed = (CKS & SHIFT_PRESSED) ? true : false;
bool special_key = false;
if(enhanced_key and (raw_ch == 0xE0))
inp.Event.KeyEvent.uChar.AsciiChar = raw_ch = 0;
if(gkbd_nt)
test = (inp.Event.KeyEvent.uChar.AsciiChar and not alt_pressed and vk != -1) or (alt_pressed and vk == -1) or (alt_pressed and numpad_key);
else
test = (inp.Event.KeyEvent.uChar.AsciiChar and not alt_pressed and vk != -1) or (alt_pressed and vk == -1) or (alt_pressed and numpad_key) or (vk == 0xBA);
if(test) {
// Ascii char
if(gkbd_nt and not (alt_pressed and numpad_key)) {
ch = raw_ch;
ReadConsoleInput(gkbd_hin, &inp, 1, &nread);
}
else {
ReadConsole(gkbd_hin, &ch, 1, &nread, NULL);
}
k = 0;
if(alt_pressed)
special_key = is_numpad_key(inp); // Alt-<numpad key>
else if(isalnum(ascii) and not ctrl_pressed)
special_key = not gkbd_nt; // It is alphanumeric key under Win9x
if(special_key) {
ReadConsole(gkbd_hin, &ascii, 1, &nread, NULL);
if(alt_pressed) {
k = (gkey)ch;
k = (gkey)ascii;
break;
}
if(gkbd_nt) {
if(ch == '\x5E' or ch == '\x7E' or ch == '\x60' or ch == '\xF9' or ch == '\xEF')
inp.Event.KeyEvent.wVirtualKeyCode = (word)(ch << 8);
}
else {
if(ch == '\x5E' or ch == '\x7E' or ch == '\x60' or ch == '\x27' or ch == '\x2E')
inp.Event.KeyEvent.wVirtualKeyCode = (word)(ch << 8);
}
inp.Event.KeyEvent.uChar.AsciiChar = ch;
}
else {
// Control keycode
else
ReadConsoleInput(gkbd_hin, &inp, 1, &nread);
}
kc = gkbd_nt2bios(inp);
if(kc != -1) {
k = (gkey)kc;
break;
switch(VKC) {
// Not meanful keys
case VK_SHIFT:
case VK_CONTROL:
case VK_MENU:
case VK_CAPITAL:
case VK_NUMLOCK:
case VK_SCROLL:
return (gkey)k; // Return empty key
case VK_NUMPAD0:
case VK_NUMPAD1:
case VK_NUMPAD2:
case VK_NUMPAD3:
case VK_NUMPAD4:
case VK_NUMPAD5:
case VK_NUMPAD6:
case VK_NUMPAD7:
case VK_NUMPAD8:
case VK_NUMPAD9:
if(shift_pressed) {
WORD keytrans[10][2] = {
{VK_NUMPAD0, VK_INSERT},
{VK_NUMPAD1, VK_END},
{VK_NUMPAD2, VK_DOWN},
{VK_NUMPAD3, VK_NEXT},
{VK_NUMPAD4, VK_LEFT},
{VK_NUMPAD5, VK_CLEAR},
{VK_NUMPAD6, VK_RIGHT},
{VK_NUMPAD7, VK_HOME},
{VK_NUMPAD8, VK_UP},
{VK_NUMPAD9, VK_PRIOR},
};
for(int i = 0; i < 10; i++)
if(VKC == keytrans[i][0]) {
VKC = keytrans[i][1];
break;
}
}
// fall through
default:
{
int kc = gkbd_nt2bios(inp);
if(kc != -1)
return (gkey)kc;
}
break;
// OEM specific keys
case 0x2a:
case 0xba: case 0xbb: case 0xbc: case 0xbd: case 0xbe:
case 0xbf: case 0xc0:
case 0xdb: case 0xdc: case 0xdd: case 0xde: case 0xdf:
case 0xe0: case 0xe1: case 0xe2: case 0xe3: case 0xe4:
case 0xe6:
case 0xe9: case 0xea: case 0xeb: case 0xec: case 0xed:
case 0xef: case 0xf0: case 0xf1: case 0xf2: case 0xf3:
case 0xf4: case 0xf5:
if(ascii)
return (gkey)ascii;
break;
}
}
else {

View File

@@ -56,7 +56,7 @@ GMTsk::GMTsk() {
detected = GMTSK_NONE;
name = "";
#if defined(__DJGPP__)
_get_dos_version(true);
detected = GMTSK_DOS;
name = "DPMI32";
#elif defined(__UNIX__)
detected = GMTSK_LINUX;

View File

@@ -113,6 +113,12 @@ char tl[256] = {
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
};
WCHAR oem2unicode[256] = {
0x0000, 0x263a, 0x263b, 0x2665, 0x2666, 0x2663, 0x2660, 0x2219,
0x25d8, 0x25cb, 0x25d9, 0x2642, 0x2640, 0x266a, 0x266b, 0x263c,
0x25ba, 0x25c4, 0x2195, 0x203c, 0x00b6, 0x00a7, 0x25a0, 0x21a8,
0x2191, 0x2193, 0x2192, 0x2190, 0x221f, 0x2194, 0x25b2, 0x25bc
};
// ------------------------------------------------------------------
@@ -129,6 +135,10 @@ int g_init_os(int flags) {
for(i = 0; i < 256; i++) {
tu[i] = (toupper)(i);
tl[i] = (tolower)(i);
if(i >= ' ') {
CHAR chr = (CHAR)i;
MultiByteToWideChar(CP_OEMCP, 0, &chr, 1, oem2unicode+i, 1);
}
}
return 0;
}
@@ -224,7 +234,7 @@ char* g_get_clip_text(void) {
int Format = 0;
int ReadType = CF_OEMTEXT;
while((Format = EnumClipboardFormats(Format)) != 0) {
if(Format == CF_UNICODETEXT && WinVer.dwPlatformId == VER_PLATFORM_WIN32_NT) {
if((Format == CF_UNICODETEXT) and (WinVer.dwPlatformId == VER_PLATFORM_WIN32_NT)) {
Unicode = true;
break;
}
@@ -287,7 +297,15 @@ int g_put_clip_text(const char *Data) {
if(WinVer.dwPlatformId == VER_PLATFORM_WIN32_NT)
if((hData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, BufferSize * 2)) != NULL)
if((GData = GlobalLock(hData)) != NULL) {
MultiByteToWideChar(CP_OEMCP, 0, Data, -1, (LPWSTR)GData, BufferSize);
WCHAR *UData = (WCHAR *)GData;
while(*Data) {
if((*Data == '\r') or (*Data == '\n') or (*Data == '\t'))
*UData++ = *Data++; // no translation for real control chars
else
*UData++ = oem2unicode[*Data++];
}
*UData = 0;
GlobalUnlock(hData);
SetClipboardData(CF_UNICODETEXT, (HANDLE)hData);
}

View File

@@ -39,6 +39,9 @@
#define ACS_BOARD '<27>'
#define ACS_BLOCK '<27>'
#endif
#if defined(__WIN32__)
#include <windows.h>
#endif
// ------------------------------------------------------------------
@@ -258,6 +261,9 @@ typedef word* gdma; // Video DMA pointer
#if defined(__USE_NCURSES__)
typedef chtype vchar; // Type of characters on-screen
typedef chtype vatch; // Type of character-attribute groups
#elif defined(__WIN32__)
typedef char vchar; // Type of characters on-screen
typedef CHAR_INFO vatch; // Type of character-attribute groups
#else
typedef char vchar; // Type of characters on-screen
typedef word vatch; // Type of character-attribute groups
@@ -379,9 +385,12 @@ void vposset (int row, int col);
void vclrscr ();
void vclrscr (int atr); // Overloaded
vatch* vsave (int srow=-1, int scol=-1, int erow=-1, int ecol=-1);
void vredraw (vatch* buf, int srow=-1, int scol=-1, int erow=-1, int ecol=-1);
void vrestore (vatch* buf, int srow=-1, int scol=-1, int erow=-1, int ecol=-1);
typedef struct _vsavebuf {
int top, left, right, bottom;
__extension__ vatch data[0];
} vsavebuf;
vsavebuf* vsave (int srow=-1, int scol=-1, int erow=-1, int ecol=-1);
void vrestore (vsavebuf* buf, int srow=-1, int scol=-1, int erow=-1, int ecol=-1);
void vcurget (int* sline, int* eline);
void vcurset (int sline, int eline);
@@ -396,17 +405,45 @@ void vcursmall ();
void vbox (int srow, int scol, int erow, int ecol, int box, int hiattr, int loattr=-1);
void vfill (int srow, int scol, int erow, int ecol, vchar chr, int atr);
#if not defined(__USE_NCURSES__)
inline vchar vgetc (int row, int col) { return (vchar)(0xFF & vgetw(row, col)); }
#else
inline vchar vgetc (int row, int col) { return (vchar)((A_CHARTEXT|A_ALTCHARSET) & vgetw(row, col)); }
#endif
vchar vgetc (int row, int col); // Gets the character from position
vchar vgchar (vatch chat); // Gets the character part of a character-attribute group
int vgattr (vatch chat); // Gets the attribute part of a character-attribute group
vatch vschar (vatch chat, vchar chr); // Sets the given character in a character-attribute group
vatch vsattr (vatch chat, int atr); // Sets the given attribute in a character-attribute group
vatch vcatch (vchar chr, int atr); // Compose character-attribute group from character and attribute
vchar vgchar (vatch chat);
int vgattr (vatch chat);
vatch vschar (vatch chat, vchar chr);
vatch vsattr (vatch chat, int atr);
vatch vcatch (vchar chr, int atr);
// inline implementation of functions above
inline vchar vgetc (int row, int col) { return vgchar(vgetw(row, col)); }
#if defined(__USE_NCURSES__)
int gvid_dosattrcalc (int ourattr);
int gvid_attrcalc (int dosattr);
inline vchar vgchar (vatch chat) { return chat & (A_CHARTEXT | A_ALTCHARSET); }
inline int vgattr (vatch chat) { return gvid_dosattrcalc(chat & ~(A_CHARTEXT | A_ALTCHARSET)); }
inline vatch vschar (vatch chat, vchar chr) { return (chr & (A_CHARTEXT | A_ALTCHARSET)) | (chat & ~(A_CHARTEXT | A_ALTCHARSET)); }
inline vatch vsattr (vatch chat, int atr) { return (chat & (A_CHARTEXT | A_ALTCHARSET)) | gvid_attrcalc(atr); }
inline vatch vcatch (vchar chr, int atr) { return chr | gvid_attrcalc(atr); }
#elif defined(__WIN32__)
inline vchar vgchar (vatch chat) { return chat.Char.AsciiChar; }
inline int vgattr (vatch chat) { return chat.Attributes; }
inline vatch vschar (vatch chat, vchar chr) { chat.Char.UnicodeChar = 0; chat.Char.AsciiChar = chr; return chat; }
inline vatch vsattr (vatch chat, int atr) { chat.Attributes = atr; return chat; }
inline vatch vcatch (vchar chr, int atr) { vatch chat; chat.Char.UnicodeChar = 0; chat.Char.AsciiChar = chr; chat.Attributes = atr; return chat; }
#else
inline vchar vgchar (vatch chat) { return chat & 0xff; }
inline int vgattr (vatch chat) { return (chat >> 8) & 0xff; }
inline vatch vschar (vatch chat, vchar chr) { return (chat & 0xff00) | chr; }
inline vatch vsattr (vatch chat, int atr) { return (chat & 0xff) | (atr << 8); }
inline vatch vcatch (vchar chr, int atr) { return (chr & 0xff) | ((atr << 8) & 0xff00); }
#endif
typedef void (*VidPutStrCP)(int,int,int,const char*);

View File

@@ -86,6 +86,18 @@ static bool __vcurhidden = false;
#ifdef __WIN32__
extern HANDLE gvid_hout;
extern OSVERSIONINFO WinVer; // defined in gutlwin.cpp
extern WCHAR oem2unicode[]; // defined in gutlwin.cpp
// ------------------------------------------------------------------
// Transform character < 32 into printable Unicode equivalent
inline WCHAR gvid_tcpr(vchar chr) {
return oem2unicode[chr];
}
#endif
@@ -93,6 +105,10 @@ extern HANDLE gvid_hout;
#if defined(__MSDOS__) or defined(__UNIX__)
#if defined(__MSDOS__)
extern int __gdvdetected;
#endif
#ifndef __DJGPP__
const unsigned short _dos_ds = 0;
@@ -344,11 +360,6 @@ void vputansi(int row, int col, word* buf, int len) {
#endif // not defined(__USE_NCURSES__)
// ------------------------------------------------------------------
extern int __gdvdetected;
// ------------------------------------------------------------------
// Converts an attribute to monochrome equivalent
@@ -494,7 +505,7 @@ static USHORT VioWrtCharStrAtt_(PCCH str, USHORT cb, USHORT row, USHORT col, PBY
// ------------------------------------------------------------------
// Compute our attributes from DOS attributes
int gvid_attrcalc (int dosattr) {
int gvid_attrcalc(int dosattr) {
// DOS attrs: XRGBxrgb
// color pair definition: 00RGBrgb, with last 3 bits negated
@@ -511,7 +522,7 @@ int gvid_attrcalc (int dosattr) {
// ------------------------------------------------------------------
// Compute DOS attributes from our attributes
int gvid_dosattrcalc (int ourattr) {
int gvid_dosattrcalc(int ourattr) {
int attr = 0;
attr = PAIR_NUMBER(ourattr);
@@ -528,18 +539,18 @@ int gvid_dosattrcalc (int ourattr) {
// Transform character < 32 into printable equivalent
chtype gvid_tcpr (vchar chr) {
chtype gvid_tcpr(vchar chr) {
chtype gvid_cpr[] = {
(chtype)' ', (chtype)'@', (chtype)'@', (chtype)'x',
(chtype) ACS_DIAMOND, (chtype)'x', (chtype)'x', ACS_BULLET,
ACS_BULLET, ACS_BULLET, ACS_BULLET, (chtype)'x',
(chtype)'x', (chtype)'x', (chtype)'x', ACS_LANTERN,
ACS_LARROW, (chtype) ACS_RARROW, (chtype)'x', (chtype)'!',
(chtype)'x', (chtype)'x', ACS_S1, (chtype)'x',
ACS_UARROW, ACS_DARROW, ACS_LARROW, (chtype)ACS_RARROW,
(chtype)'x', (chtype)'x', ACS_UARROW, ACS_DARROW
};
const chtype gvid_cpr[] = {
(chtype)' ', (chtype)'@', (chtype)'@', (chtype)'x',
(chtype) ACS_DIAMOND, (chtype)'x', (chtype)'x', ACS_BULLET,
ACS_BULLET, ACS_BULLET, ACS_BULLET, (chtype)'x',
(chtype)'x', (chtype)'x', (chtype)'x', ACS_LANTERN,
(chtype)ACS_RARROW, ACS_LARROW, (chtype)'x', (chtype)'!',
(chtype)'x', (chtype)'x', ACS_S1, (chtype)'x',
ACS_UARROW, ACS_DARROW, ACS_LARROW, (chtype)ACS_RARROW,
(chtype)'x', (chtype)'x', ACS_UARROW, ACS_DARROW
};
chtype ch = chr & A_CHARTEXT;
chtype at = chr & (~A_CHARTEXT);
@@ -587,37 +598,39 @@ void vputw(int row, int col, vatch chat) {
cpu.dl((byte)col);
cpu.genint(0x10);
cpu.ah(9);
cpu.al((byte)(chat&0xFF));
cpu.al(vgchar(chat));
cpu.bh(0);
cpu.bl((byte)(chat>>8));
cpu.bl(vgattr(chat));
cpu.cx(1);
cpu.genint(0x10);
}
#elif defined(__OS2__)
BYTE tmp[2];
tmp[0] = (BYTE)(chat & 0xFF);
tmp[1] = (BYTE)(chat >> 8);
VioWrtNCell(tmp, 1, (USHORT)row, (USHORT)col, 0);
VioWrtNCell(&chat, 1, (USHORT)row, (USHORT)col, 0);
#elif defined(__WIN32__)
COORD coord;
DWORD x;
word atr = (word) (chat >> 8);
const COORD coord = {0, 0};
const COORD size = {1, 1};
SMALL_RECT rect;
coord.X = (SHORT) col;
coord.Y = (SHORT) row;
WriteConsoleOutputAttribute(gvid_hout, &atr, 1, coord, &x);
WriteConsoleOutputCharacter(gvid_hout, (char* ) &chat, 1, coord, &x);
rect.Top = row;
rect.Left = col;
rect.Bottom = row+size.Y-1;
rect.Right = col+size.X-1;
if(WinVer.dwPlatformId == VER_PLATFORM_WIN32_NT) {
chat.Char.UnicodeChar = gvid_tcpr(vgchar(chat));
WriteConsoleOutputW(gvid_hout, &chat, size, coord, &rect);
}
else
WriteConsoleOutputA(gvid_hout, &chat, size, coord, &rect);
#elif defined(__UNIX__)
char chr = (char)(chat & 0xFF);
int atr = chat >> 8;
char chr = vgchar(chat);
int atr = vgattr(chat);
char* color = gvid_newattr(atr);
chat = (word)(chr | (atr << 8));
gvid_cvtstr(&chat, 1);
_vputw(row, col, chat);
@@ -669,23 +682,22 @@ void vputws(int row, int col, vatch* buf, uint len) {
#elif defined(__WIN32__)
COORD coord;
DWORD x;
const COORD coord = {0, 0};
COORD size = {len, 1};
SMALL_RECT rect;
coord.X = (SHORT) col;
coord.Y = (SHORT) row;
char* p = (char *) buf;
word* q = gvid->bufwrd;
char* c = gvid->bufchr;
for(int i = 0; i < len; i++) {
*c++ = *p++;
*q++ = *p++;
rect.Top = row;
rect.Left = col;
rect.Bottom = row+size.Y-1;
rect.Right = col+size.X-1;
if(WinVer.dwPlatformId == VER_PLATFORM_WIN32_NT) {
for(int i = 0; i < len; i++) {
buf[i].Char.UnicodeChar = gvid_tcpr(vgchar(buf[i]));
}
WriteConsoleOutputW(gvid_hout, buf, size, coord, &rect);
}
WriteConsoleOutputAttribute(gvid_hout, gvid->bufwrd, len, coord, &x);
WriteConsoleOutputCharacter(gvid_hout, gvid->bufchr, len, coord, &x);
else
WriteConsoleOutputA(gvid_hout, buf, size, coord, &rect);
#elif defined(__UNIX__)
@@ -704,13 +716,13 @@ void vputc(int row, int col, int atr, vchar chr) {
#if defined(__USE_NCURSES__)
mvaddch(row, col, gvid_tcpr(chr) | gvid_attrcalc(atr));
mvaddch(row, col, vcatch(gvid_tcpr(chr), atr));
refresh();
#elif defined(__MSDOS__)
if(gvid->isdma()) {
_vputw(row, col, (word)((atr << 8) | chr));
_vputw(row, col, vcatch(chr, atr));
}
else if(gvid->isbios() or gvid->iscga()) {
i86 cpu;
@@ -727,28 +739,15 @@ void vputc(int row, int col, int atr, vchar chr) {
cpu.genint(0x10);
}
#elif defined(__OS2__)
#elif defined(__OS2__) or defined(__WIN32__)
BYTE tmp[2];
tmp[0] = chr;
tmp[1] = (BYTE)atr;
VioWrtNCell(tmp, 1, (USHORT)row, (USHORT)col, 0);
#elif defined(__WIN32__)
COORD coord;
DWORD x;
coord.X = (SHORT) col;
coord.Y = (SHORT) row;
WriteConsoleOutputAttribute(gvid_hout, (word *) &atr, 1, coord, &x);
WriteConsoleOutputCharacter(gvid_hout, (char *) &chr, 1, coord, &x);
vputw(row, col, vcatch(chr, atr));
#elif defined(__UNIX__)
char* color = gvid_newattr(atr);
gvid_cvtstr(&chr, 1);
_vputw(row, col, (word)((atr << 8) | chr));
_vputw(row, col, vcatch(chr, atr));
gvid_printf("\033[%u;%uH%s%c", row+1, col+1, color, chr);
@@ -770,11 +769,11 @@ void vputvs(int row, int col, int atr, const vchar* str) {
addch(gvid_tcpr(str[counter]) | attr);
refresh();
#else
#else
vputs(row, col, atr, str);
#endif
#endif
}
@@ -799,7 +798,7 @@ void vputs(int row, int col, int atr, const char* str) {
gdma p = gdmaptr(col, row);
_farsetsel(_dos_ds);
while(*str) {
_farnspokew(p, (atr << 8) | *str++);
_farnspokew(p, vcatch(*str++, atr));
p += ATTRSIZE;
}
}
@@ -827,15 +826,12 @@ void vputs(int row, int col, int atr, const char* str) {
#elif defined(__WIN32__)
COORD coord;
DWORD x;
int len = strlen(str);
int i;
coord.X = (SHORT) col;
coord.Y = (SHORT) row;
FillConsoleOutputAttribute(gvid_hout, (word) atr, len, coord, &x);
WriteConsoleOutputCharacter(gvid_hout, str, len, coord, &x);
for(i = 0; *str; i++)
gvid->bufwrd[i] = vcatch(*str++, atr);
if(i)
vputws(row, col, gvid->bufwrd, i);
#elif defined(__UNIX__)
@@ -846,7 +842,7 @@ void vputs(int row, int col, int atr, const char* str) {
gdma p = gdmaptr(col, row);
_farsetsel(_dos_ds);
while(*str) {
_farnspokew(p, (atr << 8) | *str++);
_farnspokew(p, vcatch(*str++, atr));
p += ATTRSIZE;
}
@@ -925,29 +921,20 @@ void vputns(int row, int col, int atr, const char* str, uint width) {
VioWrtCharStrAtt((PCCH)str, (USHORT)minimum_of_two(len,width), (USHORT)row, (USHORT)col, (PBYTE)&atr, 0);
if(width > len) {
BYTE tmp[2];
tmp[0] = fillchar;
tmp[1] = (BYTE)atr;
VioWrtNCell(tmp, (USHORT)(width-len), (USHORT)row, (USHORT)(col+len), 0);
vatch filler = vcatch(fillchar, atr);
VioWrtNCell((CHAR *)&filler, (USHORT)(width-len), (USHORT)row, (USHORT)(col+len), 0);
}
#elif defined(__WIN32__)
COORD coord;
DWORD x;
int len = minimum_of_two(strlen(str), width);
int i;
coord.X = (SHORT) col;
coord.Y = (SHORT) row;
FillConsoleOutputAttribute(gvid_hout, (word) atr, width, coord, &x);
WriteConsoleOutputCharacter(gvid_hout, str, len, coord, &x);
if(width > len) {
coord.X += (SHORT) len;
len = width - len;
FillConsoleOutputCharacter(gvid_hout, fillchar, len, coord, &x);
}
for(i = 0; (i < width) and *str; i++)
gvid->bufwrd[i] = vcatch(*str++, atr);
vatch filler = vcatch(fillchar, atr);
for(; i < width; i++)
gvid->bufwrd[i] = filler;
vputws(row, col, gvid->bufwrd, width);
#elif defined(__UNIX__)
@@ -985,7 +972,7 @@ void vputns(int row, int col, int atr, const char* str, uint width) {
void _vputx(int row, int col, int atr, char chr, uint len) {
gdma p = gdmaptr(col, row);
word tmp = (word)((atr << 8) | chr);
word tmp = vcatch(chr, atr);
_farsetsel(_dos_ds);
for(uint n=0; n<len; n++) {
_farnspokew(p, tmp);
@@ -1002,8 +989,7 @@ void vputx(int row, int col, int atr, vchar chr, uint len) {
#if defined(__USE_NCURSES__)
int attr = gvid_attrcalc(atr);
mvhline(row, col, gvid_tcpr(chr) | attr, len);
mvhline(row, col, vcatch(gvid_tcpr(chr), atr), len);
refresh();
#elif defined(__MSDOS__)
@@ -1028,19 +1014,15 @@ void vputx(int row, int col, int atr, vchar chr, uint len) {
#elif defined(__OS2__)
BYTE tmp[2];
tmp[0] = chr;
tmp[1] = (BYTE)atr;
VioWrtNCell(tmp, (USHORT)len, (USHORT)row, (USHORT)col, 0);
vatch filler = vcatch(chr, atr);
VioWrtNCell((CHAR *)&filler, (USHORT)len, (USHORT)row, (USHORT)col, 0);
#elif defined(__WIN32__)
COORD c;
c.X = (SHORT)col;
c.Y = (SHORT)row;
DWORD wr;
FillConsoleOutputCharacter(gvid_hout, chr, len, c, &wr);
FillConsoleOutputAttribute(gvid_hout, (WORD)atr, len, c, &wr);
vatch filler = vcatch(chr, atr);
for(int i = 0; i < len; i++)
gvid->bufwrd[i] = filler;
vputws(row, col, gvid->bufwrd, len);
#elif defined(__UNIX__)
@@ -1063,7 +1045,7 @@ void vputx(int row, int col, int atr, vchar chr, uint len) {
inline void _vputy(int row, int col, int atr, char chr, uint len) {
gdma p = gdmaptr(col, row);
word tmp = (word)((atr<<8) | chr);
word tmp = vcatch(chr, atr);
_farsetsel(_dos_ds);
for(uint n=0; n<len; n++) {
_farnspokew(p, tmp);
@@ -1080,8 +1062,7 @@ void vputy(int row, int col, int atr, vchar chr, uint len) {
#if defined(__USE_NCURSES__)
int attr = gvid_attrcalc(atr);
mvvline(row, col, gvid_tcpr(chr) | attr, len);
mvvline(row, col, vcatch(gvid_tcpr(chr), atr), len);
refresh();
#elif defined(__MSDOS__)
@@ -1108,24 +1089,15 @@ void vputy(int row, int col, int atr, vchar chr, uint len) {
#elif defined(__OS2__)
BYTE tmp[2];
tmp[0] = chr;
tmp[1] = (BYTE)atr;
vatch filler = vcatch(chr, atr);
for(int n=0; n<len; n++)
VioWrtNCell(tmp, 1, (USHORT)row++, (USHORT)col, 0);
VioWrtNCell((CHAR *)&filler, 1, (USHORT)row++, (USHORT)col, 0);
#elif defined(__WIN32__)
COORD coord;
DWORD x;
coord.X = (SHORT) col;
for(int i=0; i < len; i++) {
coord.Y = (SHORT) row++;
WriteConsoleOutputAttribute(gvid_hout, (word *) &atr, 1, coord, &x);
WriteConsoleOutputCharacter(gvid_hout, (char *) &chr, 1, coord, &x);
}
vatch filler = vcatch(chr, atr);
for(int i=0; i < len; i++)
vputw(row++, col, filler);
#elif defined(__UNIX__)
@@ -1197,31 +1169,27 @@ vatch vgetw(int row, int col) {
#elif defined(__OS2__)
word chat;
USHORT _row=(USHORT)row, _col=(USHORT)col, len=sizeof(chat);
vatch chat;
USHORT len=sizeof(chat);
#if defined(__EMX__)
VioReadCellStr((PCH)&chat, &len, _row, _col, 0);
#else
VioReadCellStr((CHAR*)&chat, &len, _row, _col, 0);
#endif
VioReadCellStr((CHAR *)&chat, &len, (USHORT)row, (USHORT)col, 0);
return chat;
#elif defined(__WIN32__)
COORD coord;
DWORD x;
word atr;
char chr;
vatch chat;
const COORD coord = {0, 0};
const COORD size = {1, 1};
SMALL_RECT rect;
coord.X = (SHORT) col;
coord.Y = (SHORT) row;
rect.Top = row;
rect.Left = col;
rect.Bottom = row+size.Y-1;
rect.Right = col+size.X-1;
ReadConsoleOutput(gvid_hout, &chat, size, coord, &rect);
ReadConsoleOutputAttribute(gvid_hout, &atr, 1, coord, &x);
ReadConsoleOutputCharacter(gvid_hout, &chr, 1, coord, &x);
return (word)((atr << 8) | chr);
return chat;
#elif defined(__UNIX__)
@@ -1231,79 +1199,15 @@ vatch vgetw(int row, int col) {
}
// ------------------------------------------------------------------
// Get character and attribute at cursor position
#if (defined(__MSDOS__) or defined(__UNIX__)) and not defined(__USE_NCURSES__)
inline void _vgetc(int row, int col, int* atr, char* chr) {
word w = _vgetw(row, col);
*chr = (char)(w & 0xFF);
*atr = (int)(w >> 8);
}
#endif
// ------------------------------------------------------------------
// Get character and attribute at cursor position
void vgetc(int row, int col, int* atr, vchar* chr) {
#if defined(__USE_NCURSES__)
vatch tmp = vgetw(row, col);
chtype charead = mvinch(row, col);
*chr = (charead & A_CHARTEXT);
*atr = gvid_dosattrcalc(charead & (A_ATTRIBUTES | A_COLOR));
#elif defined(__MSDOS__)
if(gvid->isdma()) {
_vgetc(row, col, atr, chr);
}
else if(gvid->isbios() or gvid->iscga()) {
i86 cpu;
cpu.ah(2);
cpu.bh(0);
cpu.dh((byte)row);
cpu.dl((byte)col);
cpu.genint(0x10);
cpu.ah(8);
cpu.bh(0);
cpu.genint(0x10);
*chr = cpu.al();
*atr = cpu.ah();
}
#elif defined(__OS2__)
CHAR tmp[2];
USHORT _row=(USHORT)row, _col=(USHORT)col, len=sizeof(tmp);
#if defined(__EMX__)
VioReadCellStr((PCH)tmp, &len, _row, _col, 0);
#else
VioReadCellStr(tmp, &len, _row, _col, 0);
#endif
*chr = tmp[0];
*atr = tmp[1];
#elif defined(__WIN32__)
COORD coord;
DWORD x;
coord.X = (SHORT) col;
coord.Y = (SHORT) row;
ReadConsoleOutputAttribute(gvid_hout, (word* ) atr, 1, coord, &x);
ReadConsoleOutputCharacter(gvid_hout, (char* ) chr, 1, coord, &x);
#elif defined(__UNIX__)
_vgetc(row, col, atr, chr);
#endif
*chr = vgchar(tmp);
*atr = vgattr(tmp);
}
@@ -1357,12 +1261,14 @@ void vscroll(int srow, int scol, int erow, int ecol, int atr, int lines) {
#if defined(__USE_NCURSES__)
vatch filler = vcatch(' ', atr);
// Currently implemented with vsave/vrestore
// Does anyone know a better solution?
if(lines >= 0) {
if(lines <= 1 + erow - srow) {
vatch *buf = vsave(srow + lines, scol, erow, ecol);
vsavebuf *buf = vsave(srow + lines, scol, erow, ecol);
vrestore(buf, srow, scol, erow - lines, ecol);
throw_xfree(buf);
}
@@ -1370,13 +1276,13 @@ void vscroll(int srow, int scol, int erow, int ecol, int atr, int lines) {
lines = 1 + erow - srow;
for(int counter = 0; counter < lines; counter++)
mvhline(1 + erow + counter - lines, scol, ' ' | gvid_attrcalc(atr), 1 + ecol - scol);
mvhline(1 + erow + counter - lines, scol, filler, 1 + ecol - scol);
refresh();
}
else {
lines*=-1;
if(lines <= 1 + erow - srow) {
vatch *buf = vsave(srow, scol, erow - lines, ecol);
vsavebuf *buf = vsave(srow, scol, erow - lines, ecol);
vrestore(buf, srow + lines, scol, erow, ecol);
throw_xfree(buf);
}
@@ -1384,7 +1290,7 @@ void vscroll(int srow, int scol, int erow, int ecol, int atr, int lines) {
lines = 1 + erow - srow;
for(int counter = 0; counter < lines; counter++)
mvhline(srow + counter, scol, ' ' | gvid_attrcalc(atr), 1 + ecol - scol);
mvhline(srow + counter, scol, filler, 1 + ecol - scol);
refresh();
}
@@ -1407,32 +1313,25 @@ void vscroll(int srow, int scol, int erow, int ecol, int atr, int lines) {
#elif defined(__OS2__)
BYTE tmp[2];
tmp[0] = ' ';
tmp[1] = (BYTE)atr;
vatch filler = vcatch(' ', atr);
if(lines > 0)
VioScrollUp((USHORT)srow, (USHORT)scol, (USHORT)erow, (USHORT)ecol, (USHORT)lines, tmp, 0);
VioScrollUp((USHORT)srow, (USHORT)scol, (USHORT)erow, (USHORT)ecol, (USHORT)lines, (CHAR *)&filler, 0);
else
VioScrollDn((USHORT)srow, (USHORT)scol, (USHORT)erow, (USHORT)ecol, (USHORT)-lines, tmp, 0);
VioScrollDn((USHORT)srow, (USHORT)scol, (USHORT)erow, (USHORT)ecol, (USHORT)-lines, (CHAR *)&filler, 0);
#elif defined(__WIN32__)
CHAR_INFO fill;
fill.Char.UnicodeChar = 0;
fill.Char.AsciiChar = ' ';
fill.Attributes = (WORD)atr;
SMALL_RECT r;
COORD c = {scol, srow - lines};
vatch filler = vcatch(' ', atr);
r.Left = (SHORT)scol;
r.Top = (SHORT)srow;
r.Right = (SHORT)ecol;
r.Bottom = (SHORT)erow;
COORD c;
c.X = (SHORT)scol;
c.Y = (SHORT)(srow - lines);
ScrollConsoleScreenBuffer(gvid_hout, &r, &r, c, &fill);
ScrollConsoleScreenBuffer(gvid_hout, &r, &r, c, &filler);
#elif defined(__UNIX__)
@@ -1528,15 +1427,13 @@ void vposset(int row, int col) {
#elif defined(__WIN32__)
// No need to set the cursor position if its not visible
// Strangely, this is a major speedup to screen-output
// No need to set the cursor position if its not visible
// Strangely, this is a major speedup to screen-output
if(__vcurhidden)
return;
if(__vcurhidden)
return;
COORD c;
c.X = (SHORT)col;
c.Y = (SHORT)row;
COORD c = {col, row};
SetConsoleCursorPosition(gvid_hout, c);
#elif defined(__UNIX__)
@@ -1552,11 +1449,7 @@ void vposset(int row, int col) {
void vclrscr() {
#if defined(__USE_NCURSES__)
vclrscr((byte)gvid_dosattrcalc(vgetw(gvid->currow, gvid->curcol)));
#else
vclrscr((byte)(vgetw(gvid->currow, gvid->curcol) >> 8));
#endif
vclrscr(vgattr(vgetw(gvid->currow, gvid->curcol)));
}
@@ -1582,8 +1475,9 @@ void vclrscr(int atr) {
#if defined(__USE_NCURSES__)
clearok(stdscr, TRUE);
vatch filler = vcatch(' ', atr);
for(int row = 0; row < LINES; row++)
mvhline(row, 0, ' ' | gvid_attrcalc(atr), COLS);
mvhline(row, 0, filler, COLS);
move(0, 0);
refresh();
@@ -1604,16 +1498,14 @@ void vclrscr(int atr) {
#elif defined(__OS2__)
BYTE tmp[2];
tmp[0] = ' ';
tmp[1] = (BYTE)atr;
VioScrollUp(0, 0, 0xFFFF, 0xFFFF, 0xFFFF, tmp, 0);
vatch filler = vcatch(' ', atr);
VioScrollUp(0, 0, 0xFFFF, 0xFFFF, 0xFFFF, (CHAR *)&filler, 0);
#elif defined(__WIN32__)
COORD c;
c.X = c.Y = 0;
COORD c = {0, 0};
DWORD wr, len = gvid->numrows * gvid->numcols;
// Filling with space seems to work for both Unicode and regular functions
FillConsoleOutputCharacter(gvid_hout, ' ', len, c, &wr);
FillConsoleOutputAttribute(gvid_hout, (WORD)atr, len, c, &wr);
@@ -1649,42 +1541,32 @@ static void _vsave(word* buf, int len1, int srow, int scol, int erow) {
// ------------------------------------------------------------------
// Saves the current screen and returns pointer to buffer
vatch* vsave(int __srow, int __scol, int __erow, int __ecol) {
vsavebuf* vsave(int srow, int scol, int erow, int ecol) {
if(__srow == -1) __srow = 0;
if(__scol == -1) __scol = 0;
if(__erow == -1) __erow = gvid->numrows-1;
if(__ecol == -1) __ecol = gvid->numcols-1;
if(srow == -1) srow = 0;
if(scol == -1) scol = 0;
if(erow == -1) erow = gvid->numrows-1;
if(ecol == -1) ecol = gvid->numcols-1;
vatch* sbuf = (vatch*)throw_xcalloc((((__erow-__srow+1)*(__ecol-__scol+1))+4), sizeof(vatch));
vsavebuf* sbuf = (vsavebuf*)throw_xmalloc(sizeof(vsavebuf) + (erow - srow + 1) * (ecol - scol + 1) * sizeof(vatch));
if(sbuf) {
vatch* buf = sbuf;
vatch* buf = sbuf->data;
buf[0] = (vatch)__srow;
buf[1] = (vatch)__scol;
buf[2] = (vatch)__erow;
buf[3] = (vatch)__ecol;
sbuf->top = srow;
sbuf->left = scol;
sbuf->bottom = erow;
sbuf->right = ecol;
#if defined(__USE_NCURSES__)
int srow = *buf++;
int scol = *buf++;
int erow = *buf++;
int ecol = *buf++;
for(int row=srow; row<=erow; row++)
for(int col=scol; col<=ecol; col++)
*buf++ = mvinch(row, col);
#elif defined(__MSDOS__)
int srow = *buf++;
int scol = *buf++;
int erow = *buf++;
int ecol = *buf++;
int len1 = ecol-scol+1;
if(gvid->isdma()) {
@@ -1711,12 +1593,7 @@ vatch* vsave(int __srow, int __scol, int __erow, int __ecol) {
#elif defined(__OS2__)
USHORT srow = *buf++;
USHORT scol = *buf++;
USHORT erow = *buf++;
USHORT ecol = *buf++;
USHORT len1 = (USHORT)(ecol-scol+1);
int len1 = (int)(ecol-scol+1);
#if defined(__BORLANDC__)
PCHAR16 ptr = (PCHAR16)buf;
@@ -1725,46 +1602,30 @@ vatch* vsave(int __srow, int __scol, int __erow, int __ecol) {
#endif
USHORT len2 = (USHORT)(len1*sizeof(word));
for(USHORT nrow=srow; nrow<=erow; nrow++) {
for(int nrow=srow; nrow<=erow; nrow++) {
VioReadCellStr(ptr, &len2, nrow, scol, 0);
ptr += len2;
}
#elif defined(__WIN32__)
COORD coord;
DWORD x;
SHORT srow = *buf++;
SHORT scol = *buf++;
SHORT erow = *buf++;
SHORT ecol = *buf++;
const COORD coord = {0, 0};
COORD size = {ecol-scol+1, erow-srow+1};
SMALL_RECT r;
coord.X = scol;
// Set the source rectangle.
r.Top = srow;
r.Left = scol;
r.Bottom = erow;
r.Right = ecol;
SHORT len1 = (SHORT)(ecol-scol+1);
char* p = (char *) buf;
for(SHORT nrow=srow; nrow<=erow; nrow++) {
coord.Y = nrow;
ReadConsoleOutputAttribute(gvid_hout, gvid->bufwrd, len1, coord, &x);
ReadConsoleOutputCharacter(gvid_hout, gvid->bufchr, len1, coord, &x);
word* q = gvid->bufwrd;
char* c = gvid->bufchr;
for(int i = 0; i < len1; i++) {
*p++ = *c++;
*p++ = (byte) *q++;
}
}
if(WinVer.dwPlatformId == VER_PLATFORM_WIN32_NT)
ReadConsoleOutputW(gvid_hout, buf, size, coord, &r);
else
ReadConsoleOutputA(gvid_hout, buf, size, coord, &r);
#elif defined(__UNIX__)
int srow = *buf++;
int scol = *buf++;
int erow = *buf++;
int ecol = *buf++;
int len1 = ecol-scol+1;
_vsave(buf, len1, srow, scol, erow);
@@ -1796,33 +1657,30 @@ static void _vredraw(word* buf, int len1, int srow, int scol, int erow) {
// ------------------------------------------------------------------
// Redraws a previously saved screen
void vredraw(vatch* buf, int __srow, int __scol, int __erow, int __ecol) {
void vrestore(vsavebuf* sbuf, int srow, int scol, int erow, int ecol) {
if(__srow != -1) buf[0] = (vatch)__srow;
if(__scol != -1) buf[1] = (vatch)__scol;
if(__erow != -1) buf[2] = (vatch)__erow;
if(__ecol != -1) buf[3] = (vatch)__ecol;
if(srow != -1) sbuf->top = srow;
if(scol != -1) sbuf->left = scol;
if(erow != -1) sbuf->bottom = erow;
if(ecol != -1) sbuf->right = ecol;
srow = sbuf->top;
scol = sbuf->left;
erow = sbuf->bottom;
ecol = sbuf->right;
vatch *buf = sbuf->data;
#if defined(__USE_NCURSES__)
int srow = *buf++;
int scol = *buf++;
int erow = *buf++;
int ecol = *buf++;
for(int row=srow; row<=erow; row++)
for(int col=scol; col<=ecol; col++)
mvaddch(row, col, *buf++);
for(int row=srow; row<=erow; row++)
for(int col=scol; col<=ecol; col++)
mvaddch(row, col, *buf++);
refresh();
refresh();
#elif defined(__MSDOS__)
int srow = *buf++;
int scol = *buf++;
int erow = *buf++;
int ecol = *buf++;
int len1 = ecol-scol+1;
if(gvid->isdma()) {
@@ -1850,11 +1708,6 @@ void vredraw(vatch* buf, int __srow, int __scol, int __erow, int __ecol) {
#elif defined(__OS2__)
USHORT srow = *buf++;
USHORT scol = *buf++;
USHORT erow = *buf++;
USHORT ecol = *buf++;
USHORT len1 = (USHORT)(ecol-scol+1);
USHORT len2 = (USHORT)(len1*sizeof(word));
@@ -1871,30 +1724,28 @@ void vredraw(vatch* buf, int __srow, int __scol, int __erow, int __ecol) {
#elif defined(__WIN32__)
SHORT srow = *buf++;
SHORT scol = *buf++;
SHORT erow = *buf++;
SHORT ecol = *buf++;
const COORD coord = {0, 0};
COORD size = {ecol-scol+1, erow-srow+1};
SMALL_RECT r;
SHORT len1 = (SHORT)(ecol-scol+1);
// Set the source rectangle.
r.Top = srow;
r.Left = scol;
r.Bottom = erow;
r.Right = ecol;
for(SHORT nrow=srow; nrow<=erow; nrow++) {
vputws(nrow, scol, buf, len1);
buf += len1;
}
if(WinVer.dwPlatformId == VER_PLATFORM_WIN32_NT)
WriteConsoleOutputW(gvid_hout, buf, size, coord, &r);
else
WriteConsoleOutputA(gvid_hout, buf, size, coord, &r);
#elif defined(__UNIX__)
int srow = *buf++;
int scol = *buf++;
int erow = *buf++;
int ecol = *buf++;
int len1 = ecol-scol+1;
_vredraw(buf, len1, srow, scol, erow);
int atr = *buf >> 8;
int atr = vgattr(*buf);
char* color = gvid_newattr(atr);
gvid_printf("%s", color);
@@ -1907,15 +1758,6 @@ void vredraw(vatch* buf, int __srow, int __scol, int __erow, int __ecol) {
}
// ------------------------------------------------------------------
// Restores a previously saved screen and frees buffer
void vrestore(vatch* buf, int srow, int scol, int erow, int ecol) {
vredraw(buf, srow, scol, erow, ecol);
}
// ------------------------------------------------------------------
// Sets the cursor shape/size
@@ -2282,69 +2124,4 @@ void vfill(int srow, int scol, int erow, int ecol, vchar chr, int atr) {
}
// ------------------------------------------------------------------
// Gets the character part of a character-attribute group
vchar vgchar (vatch chat) {
#if defined(__USE_NCURSES__)
return chat & (A_CHARTEXT | A_ALTCHARSET);
#else
return chat & 0xff;
#endif
}
// ------------------------------------------------------------------
// Gets the attribute part of a character-attribute group
int vgattr (vatch chat) {
#if defined(__USE_NCURSES__)
return gvid_dosattrcalc(chat);
#else
return (chat >> 8) & 0xff;
#endif
}
// ------------------------------------------------------------------
// Sets the given character in a character-attribute group
vatch vschar (vatch chat, vchar chr) {
#if defined(__USE_NCURSES__)
return (chr&(A_CHARTEXT|A_ALTCHARSET))|(chat&~(A_CHARTEXT|A_ALTCHARSET));
#else
return (chat & 0xff00) | chr;
#endif
}
// ------------------------------------------------------------------
// Sets the given attribute in a character-attribute group
vatch vsattr (vatch chat, int atr) {
#if defined(__USE_NCURSES__)
return (chat & (A_CHARTEXT | A_ALTCHARSET)) | gvid_attrcalc(atr);
#else
return (chat & 0xff) | (atr << 8);
#endif
}
// ------------------------------------------------------------------
// Compose character-attribute group from character and attribute
vatch vcatch (vchar chr, int atr) {
#if defined(__USE_NCURSES__)
return chr | gvid_attrcalc(atr);
#else
return (chr & 0xff) | ((atr << 8) & 0xff00) ;
#endif
}
// ------------------------------------------------------------------

View File

@@ -83,14 +83,8 @@
// ------------------------------------------------------------------
// Global video data
#ifdef __WIN32__
HANDLE gvid_hout;
#endif
GVid *gvid;
int __gdvdetected = false;
#if defined(__USE_NCURSES__)
// add statics here
@@ -105,6 +99,14 @@ const char* gvid_acs_disable;
void _vputx(int row, int col, int atr, char chr, uint len);
void gvid_printf(const char* fmt, ...) __attribute__ ((format (printf, 1, 2)));
#elif defined(__WIN32__)
HANDLE gvid_hout = INVALID_HANDLE_VALUE;
#elif defined(__MSDOS__)
int __gdvdetected = false;
#endif
@@ -138,12 +140,13 @@ GVid::~GVid() {
endwin();
#elif defined(__UNIX__)
// "\033<" Enter ANSI mode
// "\033[?5l" Normal screen
// "\033[0m" Normal character attributes
gvid_printf("\033<\033[?5l\033[0m");
#endif
#ifndef __DJGPP__
if(dmaptr != dmadir) throw_xfree(dmaptr);
@@ -390,12 +393,7 @@ int GVid::detectadapter() {
#elif defined(__WIN32__)
gvid_hout = CreateFile("CONOUT$", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_WRITE | FILE_SHARE_READ, NULL,
OPEN_EXISTING,
FILE_FLAG_NO_BUFFERING|FILE_FLAG_WRITE_THROUGH, NULL);
SetFileApisToOEM();
gvid_hout = GetStdHandle(STD_OUTPUT_HANDLE);
adapter = V_VGA;
@@ -1014,8 +1012,8 @@ void GVid::resize_screen(int columns, int rows) {
numcols = curr.screen.columns = columns;
numrows = curr.screen.rows = rows;
bufchr = (vchar*)throw_xrealloc(bufchr, numcols);
bufwrd = (vatch*)throw_xrealloc(bufwrd, numcols*2);
bufchr = (vchar*)throw_xrealloc(bufchr, numcols+1);
bufwrd = (vatch*)throw_xrealloc(bufwrd, (numcols+1)*sizeof(vatch));
bufansi = (vchar*)throw_xrealloc(bufansi, 1+(11*numcols));
#if defined(__UNIX__) and not defined(__USE_NCURSES__)

View File

@@ -214,7 +214,7 @@ struct _wrec_t {
_wrec_t* prev; // pointer to previous window record
_wrec_t* next; // pointer to next window record
_form_t* form; // pointer to head form record
vatch* wbuf; // address of window's buffer
vsavebuf* wbuf; // address of window's buffer
vatch* wsbuf; // address of window shadow's buffer
const char* title; // address of window's title string
int whandle; // window's handle
@@ -423,8 +423,6 @@ inline int wclear () { return wcclear(gwin.active->wattr); }
inline void wfillch (vchar a) { gwin.fillch=a; }
inline vchar wgetc (int wrow, int wcol) { return vgetc(gwin.active->srow+wrow+gwin.active->border,gwin.active->scol+wcol+gwin.active->border); }
inline int wisactiv (int a) { return a == gwin.active->whandle; }
inline void wrestore (vatch* wbuf) { vrestore(wbuf); }
inline vatch* wsave (int srow, int scol, int erow, int ecol) { return vsave(srow, scol, erow, ecol); }
inline int wsetesc (int a) { int t=gwin.esc; gwin.esc=a; return t; }
inline void wsetstyle (int a) { gwin.style = a; }
inline int wstyle () { return gwin.style; }

View File

@@ -149,7 +149,7 @@ int wopen(int srow, int scol, int erow, int ecol, int btype, int battr, int watt
}
// save affected area of screen
vatch* wbuf = vsave(srow,scol,erow,ecol);
vsavebuf* wbuf = vsave(srow,scol,erow,ecol);
if(wbuf==NULL) {
throw_xrelease(wrec);
gwin.werrno=W_ALLOCERR;
@@ -1003,7 +1003,7 @@ _wrec_t* wfindrec(int whandle) {
int whide() {
vatch* p;
vsavebuf* p;
int shattr;
_wrec_t *temp;
@@ -1060,7 +1060,7 @@ int whide() {
int wunhide(int whandle) {
vatch* p;
vsavebuf* p;
_wrec_t* found;
// check pointer to hidden window linked list ; must not be NULL
@@ -1238,7 +1238,7 @@ static GOLD_INLINE int rshadow_blocking() {
static GOLD_INLINE vatch* calc_window(_wrec_t *wrec) {
return wrec->wbuf+4+((__crow-wrec->srow)*(wrec->ecol-wrec->scol+1))+(__ccol-wrec->scol);
return wrec->wbuf->data+((__crow-wrec->srow)*(wrec->ecol-wrec->scol+1))+(__ccol-wrec->scol);
}
@@ -1273,7 +1273,7 @@ static void swap_contents(vatch* pfound, vatch* pcurr, int shadow) {
temp = vgetw(__crow, __ccol);
if(shadow&2)
*pcurr = vschar(*pcurr, vgchar(temp));
chat = ((vgattr(temp) & 0x80) and shadow) ? vsattr(*pcurr, vgattr(*pcurr | 0x80)) : *pcurr;
chat = ((vgattr(temp) & BLINK) and shadow) ? vsattr(*pcurr, vgattr(*pcurr) | BLINK) : *pcurr;
vputw(__crow, __ccol, chat);
// let window position directly above position
@@ -1559,7 +1559,8 @@ static void update_buffers(vatch* pcurr, int shadow) {
if(shadow) {
if(__curr->next==NULL) {
vputc(__crow, __ccol, vgattr(*pcurr)&0x80 ? (__curr->wsattr|BLINK) : __curr->wsattr, (vchar)*pcurr);
// vputc(__crow, __ccol, vgattr(*pcurr) & BLINK ? (__curr->wsattr | BLINK) : __curr->wsattr, vgchar(*pcurr));
vputc(__crow, __ccol, __gattr & BLINK ? (__curr->wsattr | BLINK) : __curr->wsattr, *__p);
}
else {
tcurr = __curr;

View File

@@ -215,7 +215,6 @@ public:
void drag(int direction, int howmuch=1);
void slide(int row, int col);
void putx(int wrow, int wcol, int color, char chr, uint len);
void printws(int wrow, int wcol, vatch* buf, uint len);
void print_center(int row, int color, const char* text);
};

View File

@@ -137,8 +137,8 @@ int wdrag(int direction) {
int nsrow, nscol, nerow, necol, shad_attr=-1;
int chars_per_line, lines_per_win;
int vert_movement, horz_movement;
vatch* win_image;
vatch* wp;
vsavebuf* win_image;
vsavebuf* wp;
vatch* p;
register vatch* src;
register vatch* dest;
@@ -202,18 +202,13 @@ int wdrag(int direction) {
return(gwin.werrno=W_ALLOCERR);
}
// change coordinates in saved window's buffer
// and restore window to new coordinates
win_image[0] = (vatch)nsrow;
win_image[1] = (vatch)nscol;
win_image[2] = (vatch)nerow;
win_image[3] = (vatch)necol;
vrestore(win_image);
// restore window to new coordinates
vrestore(win_image, nsrow, nscol, nerow, necol);
throw_xfree(win_image);
// start buffer positions past coordinates
src = gwin.active->wbuf + 4;
dest = wp + 4;
src = gwin.active->wbuf->data;
dest = wp->data;
if(direction==D_DOWN)
src += chars_per_line;
@@ -240,7 +235,7 @@ int wdrag(int direction) {
}
// erase the trail that was left-over
p = gwin.active->wbuf + 4;
p = gwin.active->wbuf->data;
if(vert_movement) {
if(direction==D_DOWN)
fill_row=srow;