ChangeLogTag:Fri Jul 16 17:53:35 1999 Gonzalo A. Diethelm <Gonzalo.Diethelm@jda.cl>
This commit is contained in:
@@ -1,3 +1,15 @@
|
||||
Fri Jul 16 17:53:35 1999 Gonzalo A. Diethelm <Gonzalo.Diethelm@jda.cl>
|
||||
|
||||
* source/rtl/gt/gtwin.c:
|
||||
Added the possibility to log everything to a file; this made it
|
||||
possible for me to find out what was wrong with GTwin (which is,
|
||||
noone was calling gtInit()).
|
||||
|
||||
* source/rtl/console.c:
|
||||
Call gtInit() as the first console initialization. This finally
|
||||
made it possible to have a working GT on Win32 with gcc (it should
|
||||
work with other compilers too).
|
||||
|
||||
19990716-20:43 Alexander Kresin
|
||||
* source\hbpp\hbpp.c
|
||||
* Problem with C++ Builder resolved
|
||||
|
||||
@@ -136,6 +136,7 @@ HB_CALL_ON_STARTUP_BEGIN( InitializeConsole )
|
||||
#endif
|
||||
|
||||
#ifdef HARBOUR_USE_GTAPI
|
||||
gtInit();
|
||||
dev_row = gtWhereY();
|
||||
dev_col = gtWhereX();
|
||||
hb_gtSetPos( dev_row, dev_col );
|
||||
|
||||
@@ -30,226 +30,264 @@ typedef WORD far *LPWORD;
|
||||
static HANDLE HInput = INVALID_HANDLE_VALUE;
|
||||
static HANDLE HOutput = INVALID_HANDLE_VALUE;
|
||||
|
||||
#define HB_LOG 0
|
||||
|
||||
#if (defined(HB_LOG) && (HB_LOG != 0))
|
||||
static FILE* flog = 0;
|
||||
int line = 0;
|
||||
#define LOG(x) \
|
||||
do { \
|
||||
flog = fopen("c:/tmp/gt.log", "a"); \
|
||||
fprintf(flog, "%5d> GT: %s\n", line++, x); \
|
||||
fflush(flog); \
|
||||
fclose(flog); \
|
||||
} while (0)
|
||||
#else
|
||||
#define LOG(x)
|
||||
#endif /* #if (defined(HB_LOG) && (HB_LOG != 0)) */
|
||||
|
||||
void gtInit(void)
|
||||
{
|
||||
HInput = GetStdHandle(STD_INPUT_HANDLE);
|
||||
HOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
LOG("Initializing");
|
||||
HInput = GetStdHandle(STD_INPUT_HANDLE);
|
||||
HOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
}
|
||||
|
||||
HARBOUR GTINIT( void )
|
||||
{
|
||||
gtInit();
|
||||
gtInit();
|
||||
}
|
||||
|
||||
void gtDone(void)
|
||||
{
|
||||
CloseHandle(HInput);
|
||||
HInput = INVALID_HANDLE_VALUE;
|
||||
CloseHandle(HOutput);
|
||||
HOutput = INVALID_HANDLE_VALUE;
|
||||
CloseHandle(HInput);
|
||||
HInput = INVALID_HANDLE_VALUE;
|
||||
CloseHandle(HOutput);
|
||||
HOutput = INVALID_HANDLE_VALUE;
|
||||
LOG("Ending");
|
||||
}
|
||||
|
||||
char gtGetScreenWidth(void)
|
||||
{
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
GetConsoleScreenBufferInfo(HOutput, &csbi);
|
||||
return (char)csbi.dwSize.X;
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
|
||||
LOG("GetScreenWidth");
|
||||
GetConsoleScreenBufferInfo(HOutput, &csbi);
|
||||
return (char)csbi.dwSize.X;
|
||||
}
|
||||
|
||||
char gtGetScreenHeight(void)
|
||||
{
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
GetConsoleScreenBufferInfo(HOutput, &csbi);
|
||||
return (char)csbi.dwSize.Y;
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
|
||||
LOG("GetScreenWidth");
|
||||
GetConsoleScreenBufferInfo(HOutput, &csbi);
|
||||
return (char)csbi.dwSize.Y;
|
||||
}
|
||||
|
||||
void gtGotoXY(char x, char y)
|
||||
{
|
||||
COORD dwCursorPosition;
|
||||
dwCursorPosition.X = (SHORT) (x);
|
||||
dwCursorPosition.Y = (SHORT) (y);
|
||||
SetConsoleCursorPosition(HOutput, dwCursorPosition);
|
||||
COORD dwCursorPosition;
|
||||
|
||||
LOG("GotoXY");
|
||||
dwCursorPosition.X = (SHORT) (x);
|
||||
dwCursorPosition.Y = (SHORT) (y);
|
||||
LOG(".. Calling SetConsoleCursorPosition()");
|
||||
SetConsoleCursorPosition(HOutput, dwCursorPosition);
|
||||
LOG(".. Called SetConsoleCursorPosition()");
|
||||
}
|
||||
|
||||
void gtSetCursorStyle(int style)
|
||||
{
|
||||
CONSOLE_CURSOR_INFO cci;
|
||||
CONSOLE_CURSOR_INFO cci;
|
||||
|
||||
GetConsoleCursorInfo(HOutput, &cci);
|
||||
switch (style)
|
||||
LOG("SetCursorStyle");
|
||||
GetConsoleCursorInfo(HOutput, &cci);
|
||||
switch (style)
|
||||
{
|
||||
case SC_NONE:
|
||||
cci.bVisible = 0;
|
||||
SetConsoleCursorInfo(HOutput, &cci);
|
||||
break;
|
||||
cci.bVisible = 0;
|
||||
SetConsoleCursorInfo(HOutput, &cci);
|
||||
break;
|
||||
|
||||
case SC_NORMAL:
|
||||
cci.bVisible = 1;
|
||||
cci.dwSize = 12;
|
||||
SetConsoleCursorInfo(HOutput, &cci);
|
||||
break;
|
||||
cci.bVisible = 1;
|
||||
cci.dwSize = 12;
|
||||
SetConsoleCursorInfo(HOutput, &cci);
|
||||
break;
|
||||
|
||||
case SC_INSERT:
|
||||
cci.bVisible = 1;
|
||||
cci.dwSize = 99;
|
||||
SetConsoleCursorInfo(HOutput, &cci);
|
||||
break;
|
||||
cci.bVisible = 1;
|
||||
cci.dwSize = 99;
|
||||
SetConsoleCursorInfo(HOutput, &cci);
|
||||
break;
|
||||
|
||||
case SC_SPECIAL1:
|
||||
cci.bVisible = 1;
|
||||
cci.dwSize = 49;
|
||||
SetConsoleCursorInfo(HOutput, &cci);
|
||||
break;
|
||||
cci.bVisible = 1;
|
||||
cci.dwSize = 49;
|
||||
SetConsoleCursorInfo(HOutput, &cci);
|
||||
break;
|
||||
|
||||
case SC_SPECIAL2:
|
||||
/* TODO: Why wasn't this implemented ? */
|
||||
break;
|
||||
/* TODO: Why wasn't this implemented ? */
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int gtGetCursorStyle(void)
|
||||
{
|
||||
CONSOLE_CURSOR_INFO cci;
|
||||
int rc;
|
||||
CONSOLE_CURSOR_INFO cci;
|
||||
int rc;
|
||||
|
||||
GetConsoleCursorInfo(HOutput, &cci);
|
||||
LOG("GetCursorStyle");
|
||||
GetConsoleCursorInfo(HOutput, &cci);
|
||||
|
||||
if(cci.bVisible)
|
||||
if(cci.bVisible)
|
||||
{
|
||||
/* QUESTION: Is this really correct ? IF _VISIBLE_ -> NONE */
|
||||
rc=SC_NONE;
|
||||
/* QUESTION: Is this really correct ? IF _VISIBLE_ -> NONE */
|
||||
rc=SC_NONE;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
switch(cci.dwSize)
|
||||
switch(cci.dwSize)
|
||||
{
|
||||
case 12:
|
||||
rc=SC_NORMAL;
|
||||
break;
|
||||
rc=SC_NORMAL;
|
||||
break;
|
||||
|
||||
case 99:
|
||||
rc=SC_INSERT;
|
||||
break;
|
||||
rc=SC_INSERT;
|
||||
break;
|
||||
|
||||
case 49:
|
||||
rc=SC_SPECIAL1;
|
||||
break;
|
||||
rc=SC_SPECIAL1;
|
||||
break;
|
||||
|
||||
/* TODO: cannot tell if the block is upper or lower for cursor */
|
||||
/* TODO: cannot tell if the block is upper or lower for cursor */
|
||||
default:
|
||||
rc=SC_SPECIAL2;
|
||||
rc=SC_SPECIAL2;
|
||||
}
|
||||
}
|
||||
|
||||
return(rc);
|
||||
return(rc);
|
||||
}
|
||||
|
||||
void gtPuts(char x, char y, char attr, char *str, int len)
|
||||
{
|
||||
DWORD i, dwlen;
|
||||
COORD coord;
|
||||
LPWORD pwattr;
|
||||
pwattr = (LPWORD) hb_xgrab(len * sizeof(*pwattr));
|
||||
if (!pwattr)
|
||||
DWORD i, dwlen;
|
||||
COORD coord;
|
||||
LPWORD pwattr;
|
||||
|
||||
LOG("Puts");
|
||||
pwattr = (LPWORD) hb_xgrab(len * sizeof(*pwattr));
|
||||
if (!pwattr)
|
||||
{
|
||||
return;
|
||||
return;
|
||||
}
|
||||
coord.X = (DWORD) (x);
|
||||
coord.Y = (DWORD) (y);
|
||||
for (i = 0; i < len; i++)
|
||||
coord.X = (DWORD) (x);
|
||||
coord.Y = (DWORD) (y);
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
*(pwattr + i) = attr;
|
||||
*(pwattr + i) = attr;
|
||||
}
|
||||
WriteConsoleOutputCharacterA(HOutput, str, (DWORD) len, coord, &dwlen);
|
||||
WriteConsoleOutputAttribute(HOutput, pwattr, (DWORD) len, coord, &dwlen);
|
||||
free(pwattr);
|
||||
WriteConsoleOutputCharacterA(HOutput, str, (DWORD) len, coord, &dwlen);
|
||||
WriteConsoleOutputAttribute(HOutput, pwattr, (DWORD) len, coord, &dwlen);
|
||||
hb_xfree(pwattr);
|
||||
}
|
||||
|
||||
void gtGetText(char x1, char y1, char x2, char y2, char *dest)
|
||||
{
|
||||
DWORD i, len, width;
|
||||
COORD coord;
|
||||
LPWORD pwattr;
|
||||
char y, *pstr;
|
||||
width = (x2 - x1 + 1);
|
||||
pwattr = (LPWORD) hb_xgrab(width * sizeof(*pwattr));
|
||||
if (!pwattr)
|
||||
DWORD i, len, width;
|
||||
COORD coord;
|
||||
LPWORD pwattr;
|
||||
char y, *pstr;
|
||||
|
||||
LOG("GetText");
|
||||
width = (x2 - x1 + 1);
|
||||
pwattr = (LPWORD) hb_xgrab(width * sizeof(*pwattr));
|
||||
if (!pwattr)
|
||||
{
|
||||
return;
|
||||
return;
|
||||
}
|
||||
pstr = (char *)hb_xgrab(width);
|
||||
if (!pstr)
|
||||
pstr = (char *)hb_xgrab(width);
|
||||
if (!pstr)
|
||||
{
|
||||
free(pwattr);
|
||||
return;
|
||||
hb_xfree(pwattr);
|
||||
return;
|
||||
}
|
||||
for (y = y1; y <= y2; y++)
|
||||
for (y = y1; y <= y2; y++)
|
||||
{
|
||||
coord.X = (DWORD) (x1);
|
||||
coord.Y = (DWORD) (y);
|
||||
ReadConsoleOutputCharacterA(HOutput, pstr, width, coord, &len);
|
||||
ReadConsoleOutputAttribute(HOutput, pwattr, width, coord, &len);
|
||||
for (i = 0; i < width; i++)
|
||||
coord.X = (DWORD) (x1);
|
||||
coord.Y = (DWORD) (y);
|
||||
ReadConsoleOutputCharacterA(HOutput, pstr, width, coord, &len);
|
||||
ReadConsoleOutputAttribute(HOutput, pwattr, width, coord, &len);
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
*dest = *(pstr + i);
|
||||
dest++;
|
||||
*dest = (char)*(pwattr + i);
|
||||
dest++;
|
||||
*dest = *(pstr + i);
|
||||
dest++;
|
||||
*dest = (char)*(pwattr + i);
|
||||
dest++;
|
||||
}
|
||||
}
|
||||
free(pwattr);
|
||||
free(pstr);
|
||||
hb_xfree(pwattr);
|
||||
hb_xfree(pstr);
|
||||
}
|
||||
|
||||
void gtPutText(char x1, char y1, char x2, char y2, char *srce)
|
||||
{
|
||||
DWORD i, len, width;
|
||||
COORD coord;
|
||||
LPWORD pwattr;
|
||||
char y, *pstr;
|
||||
width = (x2 - x1 + 1);
|
||||
pwattr = (LPWORD) hb_xgrab(width * sizeof(*pwattr));
|
||||
if (!pwattr)
|
||||
DWORD i, len, width;
|
||||
COORD coord;
|
||||
LPWORD pwattr;
|
||||
char y, *pstr;
|
||||
|
||||
LOG("PutText");
|
||||
width = (x2 - x1 + 1);
|
||||
pwattr = (LPWORD) hb_xgrab(width * sizeof(*pwattr));
|
||||
if (!pwattr)
|
||||
{
|
||||
return;
|
||||
return;
|
||||
}
|
||||
pstr = (char *)hb_xgrab(width);
|
||||
if (!pstr)
|
||||
pstr = (char *)hb_xgrab(width);
|
||||
if (!pstr)
|
||||
{
|
||||
free(pwattr);
|
||||
return;
|
||||
hb_xfree(pwattr);
|
||||
return;
|
||||
}
|
||||
for (y = y1; y <= y2; y++)
|
||||
for (y = y1; y <= y2; y++)
|
||||
{
|
||||
for (i = 0; i < width; i++)
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
*(pstr + i) = *srce;
|
||||
srce++;
|
||||
*(pwattr + i) = *srce;
|
||||
srce++;
|
||||
*(pstr + i) = *srce;
|
||||
srce++;
|
||||
*(pwattr + i) = *srce;
|
||||
srce++;
|
||||
}
|
||||
coord.X = (DWORD) (x1);
|
||||
coord.Y = (DWORD) (y);
|
||||
WriteConsoleOutputCharacterA(HOutput, pstr, width, coord, &len);
|
||||
WriteConsoleOutputAttribute(HOutput, pwattr, width, coord, &len);
|
||||
coord.X = (DWORD) (x1);
|
||||
coord.Y = (DWORD) (y);
|
||||
WriteConsoleOutputCharacterA(HOutput, pstr, width, coord, &len);
|
||||
WriteConsoleOutputAttribute(HOutput, pwattr, width, coord, &len);
|
||||
}
|
||||
free(pwattr);
|
||||
free(pstr);
|
||||
hb_xfree(pwattr);
|
||||
hb_xfree(pstr);
|
||||
}
|
||||
|
||||
char gtWhereX(void)
|
||||
{
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
GetConsoleScreenBufferInfo(HOutput, &csbi);
|
||||
return csbi.dwCursorPosition.X;
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
|
||||
LOG("WhereX");
|
||||
GetConsoleScreenBufferInfo(HOutput, &csbi);
|
||||
return csbi.dwCursorPosition.X;
|
||||
}
|
||||
|
||||
char gtWhereY(void)
|
||||
{
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
GetConsoleScreenBufferInfo(HOutput, &csbi);
|
||||
return csbi.dwCursorPosition.Y;
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
|
||||
LOG("WhereY");
|
||||
GetConsoleScreenBufferInfo(HOutput, &csbi);
|
||||
return csbi.dwCursorPosition.Y;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user