See ChangeLog entry 19990527-14:15 EST David G. Holm <dholm@jsd-llc.com>

This commit is contained in:
David G. Holm
1999-05-27 19:23:12 +00:00
parent 01bdc9ab47
commit 5d680b91c5
14 changed files with 301 additions and 76 deletions

View File

@@ -1,3 +1,57 @@
19990527-14:15 EST David G. Holm <dholm@jsd-llc.com>
* makefile.b31
- Added gtdos to terminal library
* include/ctoharb.h
- Added word wDec parameter to PushDouble prototype (needed by C++ compilers)
* include/gtapi.h
- Added $Id$ block at top
- Added gtWhereX()
- Added gtWhereY()
* source/rtl/console.c
- Added GT API support
- Added InitializeConsole() to initialize GT API and device screen position
- Added HARBOUR PROW(), PCOL(), and SETPRC()
- Synchronize dev_row and dev_col with GT API screen position
* source/rtl/files.c
- Borland support now takes into account that older compiler versions
don't have the POSIX S_ flags.
* source/rtl/gtapi.c
- Added $Id$ block at top
- Changed #include <types.h> to #include <extend.h>
- Modified _gtWriteCon() to process control characters
* source/rtl/set.c
- Added default of "PRN" for HB_SET_PRINTFILE
- If SET (_SET_DEVCE, "PRINTER") and printer file not open, then open it
* source/rtl/transfrm.c
- Added use of wDec parameter in calls to PushDouble()
* source/rtl/gt/gtdos.c
- Added $Id$ block at top
- Added gtWhereX()
- Added gtWhereY()
- Removed screen coordinate adjustments (i.e., - 1), because
Clipper (and therefore Harbour) screen origin is (0,0)
* source/rtl/gt/gtos2.c
- Added $Id$ block at top
- Added gtWhereX()
- Added gtWhereY()
- Removed screen coordinate adjustments (i.e., - 1), because
Clipper (and therefore Harbour) screen origin is (0,0)
- Note: Still needs some work - doesn't match output from gtdos.c
* source/rtl/gt/gtwin.c
- Added $Id$ block at top
- Added gtWhereX()
- Added gtWhereY()
- Removed screen coordinate adjustments (i.e., - 1), because
Clipper (and therefore Harbour) screen origin is (0,0)
- Note: Needs to be tested, because I don't have a Windows compiler
* source/rtl/gt/gtxxx.c
- Added $Id$ block at top
- Added gtWhereX()
- Added gtWhereY()
* source/vm/hvm.c
- Added call to InitializeConsole()
- Added prototypes for InitializeConsole() and InitSymbolTable() for C++ compilers
19990527-19:50 CET Eddie Runia
* source/rtl/gt/gtdos.c, source/rtl/gt/gtwin.c, source/rtl/gtapi.c
minor changes

View File

@@ -11,7 +11,7 @@ void PushNil( void ); /* in this case it places nil at self */
/* parameters should come here using Push...() */
void PushInteger( int iNumber );
void PushLong( long lNumber );
void PushDouble( double dNumber );
void PushDouble( double dNumber, WORD wDec );
void PushString( char * szText, WORD wLength ); /* pushes a string on to the stack */
void Do( WORD wParams ); /* invokes the virtual machine */
void Function( WORD wParams ); /* invokes the virtual machine */

View File

@@ -1,3 +1,7 @@
/*
* $Id$
*/
/*
* GTAPI.H; Screen drawing, cursor and keyboard routines for text mode
* 16-bit and 32-bit MS-DOS, 16-bit and 32-bit OS/2, and 32-bit
@@ -126,6 +130,8 @@ void gtDone(void);
char gtGetScreenWidth(void);
char gtGetScreenHeight(void);
void gtGotoXY(char x, char y);
char gtWhereX(void);
char gtWhereY(void);
void gtSetCursorStyle(int style);
int gtGetCursorStyle(void);
void gtPuts(char x, char y, char attr, char *str, int len);

View File

@@ -24,7 +24,7 @@ harbour.lib : arrays.obj asort.obj classes.obj codebloc.obj dates.obj \
hbtools.lib : datesx.obj debug.obj genobj.obj io.obj mathx.obj \
stringp.obj stringsx.obj
terminal.lib : console.obj
terminal.lib : console.obj gtdos.obj
libs\win16\terminal.lib : console.obj
@@ -49,7 +49,8 @@ errorsys.obj : errorsys.prg extend.h types.h init.h harbour.exe
extend.obj : extend.c extend.h types.h
files.obj : extend.c extend.h types.h
genobj.obj : source\tools\genobj.c extend.h types.h
gtapi.obj : gtapi.c extend.h types.h
gtapi.obj : gtapi.c extend.h types.h gtapi.h
gtdos.obj : source\rtl\gt\gtdos.c extend.h types.h gtapi.h
io.obj : source\tools\io.c extend.h types.h
initsymb.obj : source\vm\initsymb.c extend.h types.h
itemapi.obj : itemapi.c extend.h types.h
@@ -83,6 +84,10 @@ transfrm.obj : transfrm.c extend.h types.h
bcc -c $(c_opt) -o$@ $<
tlib .\libs\b16\hbtools.lib -+$@,,
{source\rtl\gt}.c{obj}.obj:
bcc -c $(c_opt) -o$@ $<
tlib .\libs\b16\terminal.lib -+$@,,
{source\compiler}.c{obj}.obj:
bcc -c $(c_opt) -Isource\compiler -o$@ $<

View File

@@ -4,17 +4,6 @@
#ifdef WINDOWS
#include <windows.h>
#else
/* TODO: Remove once the GT API works */
#if defined(__BORLANDC__) || defined(__TURBOC__)
#include <conio.h>
#define console_printf cprintf
#define console_gotoxy gotoxy
#endif
#if defined(__MSC__) || defined(__MSVC__)
#include <conio.h>
#define console_printf _cprintf
#endif
#endif
#include <io.h>
@@ -24,7 +13,15 @@
#include <gtapi.h>
#include <set.h>
static int dev_row = 0, dev_col = 0;
static unsigned short dev_row = 0;
static unsigned short dev_col = 0;
void InitializeConsole( void )
{
dev_row = gtWhereX();
dev_col = gtWhereY();
_gtSetPos( dev_row, dev_col );
}
HARBOUR __ACCEPT( void ) /* Internal Clipper function used in ACCEPT command */
/* Basically the simplest Clipper function to */
@@ -116,17 +113,12 @@ static void hb_outerr( char * fpStr, WORD uiLen )
/* Output an item to the screen and/or printer and/or alternate */
static void hb_altout( char * fpStr, WORD uiLen )
{
WORD uiCount = uiLen;
char * fpPtr = fpStr; /* TODO: delete fpPtr once the GT API works */
if( hb_set.HB_SET_CONSOLE )
/* TODO: Replace with _gtWriteCon( fpStr, uiLen ) once the GT API works */
while( uiCount-- )
/* Display to console unless SET CONSOLE OFF */
#ifdef console_printf
console_printf( "%c", *fpPtr++ );
#else
printf( "%c", *fpPtr++ );
#endif
{
_gtWriteCon( fpStr, uiLen );
if( stricmp( hb_set.HB_SET_DEVICE, "PRINTER" ) || hb_set_printhan < 0 )
_gtGetPos( &dev_row, &dev_col );
}
if( hb_set.HB_SET_ALTERNATE && hb_set_althan >= 0 )
/* Print to alternate file if SET ALTERNATE ON and valid alternate file */
write( hb_set_althan, fpStr, uiLen );
@@ -138,21 +130,19 @@ static void hb_altout( char * fpStr, WORD uiLen )
/* Output an item to the screen and/or printer */
static void hb_devout( char * fpStr, WORD uiLen )
{
WORD uiCount = uiLen;
char * fpPtr = fpStr; /* TODO: Delete fpPtr once the GT API works */
if( stricmp( hb_set.HB_SET_DEVICE, "PRINTER" ) == 0 && hb_set_printhan >= 0 )
{
/* Display to printer if SET DEVICE TO PRINTER and valid printer file */
write( hb_set_printhan, fpStr, uiLen );
dev_col += uiLen;
}
#ifdef console_printf
else
{
/* Otherwise, display to console */
/* TODO: Replace with _gtWrite( fpStr, uiLen ) once the GT API works */
while( uiCount-- )
console_printf( "%c", *fpPtr++ );
#endif
_gtWrite( fpStr, uiLen );
if( stricmp( hb_set.HB_SET_DEVICE, "PRINTER" ) || hb_set_printhan < 0 )
_gtGetPos( &dev_row, &dev_col );
}
}
void hb_devpos( int row, int col )
@@ -174,14 +164,7 @@ void hb_devpos( int row, int col )
dev_col = col;
}
else
{
/*TODO: Replace with _gtSetPos( row, col ) once the GT API works */
#ifdef console_gotoxy
console_gotoxy( col + 1, row + 1);
#else
;
#endif
}
_gtSetPos( row, col );
}
HARBOUR OUTSTD( void ) /* writes a list of values to the standard output device */
@@ -236,9 +219,7 @@ HARBOUR DEVPOS( void ) /* Sets the screen and/or printer position */
pRow = _param( 1, IT_NUMERIC );
pCol = _param( 2, IT_NUMERIC );
if( pRow && pCol )
{
hb_devpos( _parni( 1 ), _parni( 2 ) );
}
}
}
@@ -265,9 +246,33 @@ HARBOUR DEVOUT( void ) /* writes a single values to the current device (screen o
HARBOUR EJECT( void ) /* Ejects the current page from the printer */
{
if( hb_set_printhan )
if( stricmp( hb_set.HB_SET_DEVICE, "PRINTER" ) == 0 && hb_set_printhan >= 0 )
{
write( hb_set_printhan, "\x0C", 1 );
dev_row = dev_col = 0;
}
}
HARBOUR PROW( void ) /* Returns the current printer row position */
{
_retni( dev_row );
}
HARBOUR PCOL( void ) /* Returns the current printer row position */
{
_retni( dev_col );
}
HARBOUR SETPRC( void ) /* Sets the current printer row and column positions */
{
if( _pcount() > 1 )
{
PITEM pRow = _param( 1, IT_NUMERIC );
PITEM pCol = _param( 1, IT_NUMERIC );
if( pRow && pCol )
{
dev_row = _parni( 1 );
dev_col = _parni( 2 );
}
}
}

View File

@@ -45,6 +45,21 @@
#if !defined(HAVE_POSIX_IO)
#define HAVE_POSIX_IO
#ifndef S_IEXEC
#define S_IEXEC 0x0040 /* owner may execute <directory search> */
#endif
#ifndef S_IRWXU
#define S_IRWXU 0x01c0 /* RWE permissions mask for owner */
#endif
#ifndef S_IRUSR
#define S_IRUSR 0x0100 /* owner may read */
#endif
#ifndef S_IWUSR
#define S_IWUSR 0x0080 /* owner may write */
#endif
#ifndef S_IXUSR
#define S_IXUSR 0x0040 /* owner may execute <directory search> */
#endif
#endif
#define PATH_SEPARATOR '\\'
@@ -151,14 +166,10 @@ static int convert_seek_flags( int flags )
static int convert_create_flags( int flags )
{
/* by default FC_NORMAL is set */
#if ! defined( __WATCOMC__ ) && ! defined( __BORLANDC__ )
int result_flags=S_IWUSR;
if( flags & FC_READONLY )
result_flags = result_flags & ~(S_IWUSR);
#else
int result_flags=0;
#endif
if( flags & FC_HIDDEN )
result_flags |= 0;

View File

@@ -1,3 +1,7 @@
/*
* $Id$
*/
/*
* GTDOS.C: Video subsystem for DOS compilers.
*
@@ -112,15 +116,15 @@ void gtGotoXY(char x, char y)
#if defined(__TURBOC__)
_AH = 0x02;
_BH = 0;
_DH = y - 1;
_DL = x - 1;
_DH = y;
_DL = x;
geninterrupt(0x10);
#else
union REGS regs;
regs.h.ah = 0x02;
regs.h.bh = 0;
regs.h.dh = (unsigned char)(y - 1);
regs.h.dl = (unsigned char)(x - 1);
regs.h.dh = (unsigned char)(y);
regs.h.dl = (unsigned char)(x);
#if defined(__WATCOMC__) && defined(__386__)
int386(0x10, &regs, &regs);
#else
@@ -238,7 +242,7 @@ void gtSetCursorStyle(int style)
static void gtxGetXY(char x, char y, char *attr, char *ch)
{
char FAR *p;
p = gtScreenPtr((char)(x - 1), (char)(y - 1));
p = gtScreenPtr((char)(x), (char)(y));
*ch = *p;
*attr = *(p + 1);
}
@@ -246,7 +250,7 @@ static void gtxGetXY(char x, char y, char *attr, char *ch)
void gtxPutch(char x, char y, char attr, char ch)
{
char FAR *p;
p = gtScreenPtr((char)(x - 1), (char)(y - 1));
p = gtScreenPtr((char)(x), (char)(y));
*p = ch;
*(p + 1) = attr;
}
@@ -256,7 +260,7 @@ void gtPuts(char x, char y, char attr, char *str, int len)
char FAR *p;
int i;
p = gtScreenPtr((char)(x - 1), (char)(y - 1));
p = gtScreenPtr((char)(x), (char)(y));
for(i=0; i<len; i++)
{
*p++ = *str++;
@@ -289,3 +293,43 @@ void gtPutText(char x1, char y1, char x2, char y2, char *srce)
}
}
}
char gtWhereX(void)
{
#if defined(__TURBOC__)
_AH = 0x03;
_BH = 0;
geninterrupt(0x10);
return _DH;
#else
union REGS regs;
regs.h.ah = 0x02;
regs.h.bh = 0;
#if defined(__WATCOMC__) && defined(__386__)
int386(0x10, &regs, &regs);
#else
int86(0x10, &regs, &regs);
#endif
return regs.h.dh;
#endif
}
char gtWhereY(void)
{
#if defined(__TURBOC__)
_AH = 0x03;
_BH = 0;
geninterrupt(0x10);
return _DL;
#else
union REGS regs;
regs.h.ah = 0x02;
regs.h.bh = 0;
#if defined(__WATCOMC__) && defined(__386__)
int386(0x10, &regs, &regs);
#else
int86(0x10, &regs, &regs);
#endif
return regs.h.dl;
#endif
}

View File

@@ -1,3 +1,7 @@
/*
* $Id$
*/
/*
* GTOS2.C: Video subsystem for OS/2 compilers.
*
@@ -46,7 +50,21 @@ char gtGetScreenHeight(void)
void gtGotoXY(char x, char y)
{
VioSetCurPos((USHORT) (y - 1), (USHORT) (x - 1), 0);
VioSetCurPos((USHORT) y, (USHORT) x, 0);
}
char gtWhereX(void)
{
USHORT x, y;
VioGetCurPos(&y, &x, 0);
return x;
}
char gtWhereY()
{
USHORT x, y;
VioGetCurPos(&y, &x, 0);
return y;
}
static void gtSetCursorSize(char start, char end)
@@ -80,9 +98,9 @@ int gtGetCursorStyle(void)
return(rc);
}
void gtPuts(char x, char y, char attr, char *str)
void gtPuts(char x, char y, char attr, char *str, int len)
{
VioWrtCharStrAtt(str, (USHORT) strlen(str), (USHORT) (y - 1), (USHORT) (x - 1), (PBYTE) &attr, 0);
VioWrtCharStrAtt(str, (USHORT) strlen(str), (USHORT) y, (USHORT) x, (PBYTE) &attr, 0);
}
void gtGetText(char x1, char y1, char x2, char y2, char *dest)
@@ -92,7 +110,7 @@ void gtGetText(char x1, char y1, char x2, char y2, char *dest)
width = (USHORT) ((x2 - x1 + 1) * 2);
for (y = y1; y <= y2; y++)
{
VioReadCellStr((PBYTE) dest, &width, (USHORT) (y - 1), (USHORT) (x1 - 1), 0);
VioReadCellStr((PBYTE) dest, &width, (USHORT) y, (USHORT) x1, 0);
dest += width;
}
}
@@ -104,7 +122,7 @@ void gtPutText(char x1, char y1, char x2, char y2, char *srce)
width = (USHORT) ((x2 - x1 + 1) * 2);
for (y = y1; y <= y2; y++)
{
VioWrtCellStr((PBYTE) srce, width, (USHORT) (y - 1), (USHORT) (x1 - 1), 0);
VioWrtCellStr((PBYTE) srce, width, (USHORT) y, (USHORT) x1, 0);
srce += width;
}
}

View File

@@ -1,3 +1,7 @@
/*
* $Id$
*/
/*
* GTWIN.C: Video subsystem for Windows 95/NT compilers.
*
@@ -57,8 +61,8 @@ char gtGetScreenHeight(void)
void gtGotoXY(char x, char y)
{
COORD dwCursorPosition;
dwCursorPosition.X = (SHORT) (x - 1);
dwCursorPosition.Y = (SHORT) (y - 1);
dwCursorPosition.X = (SHORT) (x);
dwCursorPosition.Y = (SHORT) (y);
SetConsoleCursorPosition(HOutput, dwCursorPosition);
}
@@ -143,8 +147,8 @@ void gtPuts(char x, char y, char attr, char *str, int len)
{
return;
}
coord.X = (DWORD) (x - 1);
coord.Y = (DWORD) (y - 1);
coord.X = (DWORD) (x);
coord.Y = (DWORD) (y);
for (i = 0; i < strlen(str); i++)
{
*(pwattr + i) = attr;
@@ -174,8 +178,8 @@ void gtGetText(char x1, char y1, char x2, char y2, char *dest)
}
for (y = y1; y <= y2; y++)
{
coord.X = (DWORD) (x1 - 1);
coord.Y = (DWORD) (y - 1);
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++)
@@ -217,8 +221,8 @@ void gtPutText(char x1, char y1, char x2, char y2, char *srce)
*(pwattr + i) = *srce;
srce++;
}
coord.X = (DWORD) (x1 - 1);
coord.Y = (DWORD) (y - 1);
coord.X = (DWORD) (x1);
coord.Y = (DWORD) (y);
WriteConsoleOutputCharacterA(HOutput, pstr, width, coord, &len);
WriteConsoleOutputAttribute(HOutput, pwattr, width, coord, &len);
}
@@ -226,3 +230,16 @@ void gtPutText(char x1, char y1, char x2, char y2, char *srce)
free(pstr);
}
char gtWhereX(void)
{
COORD dwCursorPosition;
GetConsoleCursorPosition(HOutput, &dwCursorPosition);
return dwCursorPosition.X;
}
char gtWhereX(void)
{
COORD dwCursorPosition;
GetConsoleCursorPosition(HOutput, &dwCursorPosition);
return dwCursorPosition.Y;
}

View File

@@ -1,3 +1,7 @@
/*
* $Id$
*/
/*
* GTXXX.C: Video subsystem template.
*
@@ -31,6 +35,14 @@ void gtGotoXY(char x, char y)
{
}
char gtWhereX(void)
{
}
char gtWhereY(void)
{
}
void gtSetCursorStyle(int style)
{
}

View File

@@ -1,8 +1,12 @@
/*
* $Id$
*/
/*
* GTAPI.C: Generic Terminal for Harbour
*/
#include <types.h>
#include <extend.h>
#include <gtapi.h>
/* TODO: functions not implemented yet
@@ -358,10 +362,46 @@ int _gtWriteAt(USHORT uiRow, USHORT uiCol, char * fpStr, USHORT uiLen)
int _gtWriteCon(char * fpStr, USHORT uiLen)
{
int rc;
USHORT count;
char ch[2];
if((rc=_gtWrite(fpStr, uiLen)) != 0)
return(rc);
ch[1] = 0;
for(count = 0; count < uiLen; count++)
{
*ch = fpStr[count];
switch(*ch)
{
case 7:
break;
case 8:
if(s_uiCurrentCol > 0) s_uiCurrentCol--;
else if(s_uiCurrentRow > 0)
{
s_uiCurrentRow--;
s_uiCurrentCol=_gtMaxCol();
}
else
{
_gtScroll(0, 0, _gtMaxRow(), _gtMaxCol(), -1, 0);
s_uiCurrentCol=_gtMaxCol();
}
break;
case 10:
if(s_uiCurrentRow < _gtMaxRow()) s_uiCurrentRow++;
else
{
_gtScroll(0, 0, _gtMaxRow(), _gtMaxCol(), 1, 0);
}
break;
case 13:
s_uiCurrentCol = 0;
break;
default:
rc = _gtWrite(ch, 1);
}
if(rc)
return(rc);
}
return(0);
}

View File

@@ -293,7 +293,14 @@ HARBOUR SET (void)
case HB_SET_DEVICE :
if (hb_set.HB_SET_DEVICE) _retc (hb_set.HB_SET_DEVICE);
else _retc ("");
if (args > 1) hb_set.HB_SET_DEVICE = set_string (pArg2, hb_set.HB_SET_DEVICE);
if (args > 1)
{
/* If the print file is not already open, open it. */
hb_set.HB_SET_DEVICE = set_string (pArg2, hb_set.HB_SET_DEVICE);
if (stricmp (hb_set.HB_SET_DEVICE, "PRINTER") == 0 && hb_set_printhan < 0
&& hb_set.HB_SET_PRINTFILE && strlen (hb_set.HB_SET_PRINTFILE) > 0)
hb_set_printhan = open_handle (hb_set.HB_SET_PRINTFILE, bFlag, ".prn");
}
break;
case HB_SET_EPOCH :
_retni (hb_set.HB_SET_EPOCH);
@@ -445,7 +452,8 @@ void InitializeSets (void)
hb_set.HB_SET_PATH = (char*)_xgrab (1);
*hb_set.HB_SET_PATH = 0;
hb_set.HB_SET_PRINTER = FALSE;
hb_set.HB_SET_PRINTFILE = 0; /* NULL pointer */
hb_set.HB_SET_PRINTFILE = (char*)_xgrab (4);
memcpy (hb_set.HB_SET_PRINTFILE, "PRN", 4); /* Default printer device */
hb_set.HB_SET_SCOREBOARD = TRUE;
hb_set.HB_SET_SCROLLBREAK = TRUE;
hb_set.HB_SET_SOFTSEEK = FALSE;

View File

@@ -5,6 +5,7 @@
#include <extend.h>
#include <ctoharb.h>
#include <ctype.h>
#include <set.h>
/* */
/* Transform( xValue, cPicture ) */
@@ -182,7 +183,7 @@ char *NumPicture( char *szPic, long lPic, int iPicFlags, double dValue,
PushSymbol ( GetDynSym( "STR" )->pSymbol ); /* Push STR function */
PushNil (); /* Function call. No object */
PushDouble ( dPush ); /* Push value to transform */
PushDouble ( dPush, iDecimals ); /* Push value to transform */
PushInteger( iWidth ); /* Push numbers width */
PushInteger( iDecimals ); /* Push decimals */
Function( 3 ); /* 3 Parameters */
@@ -312,7 +313,7 @@ PITEM NumDefault( double dValue )
PushSymbol ( GetDynSym( "STR" )->pSymbol ); /* Push STR function */
PushNil (); /* Function call. No object */
PushDouble ( dValue ); /* Push value to transform */
PushDouble ( dValue, hb_set.HB_SET_DECIMALS ); /* Push value to transform */
Function ( 1 ); /* 1 Parameter */
StackPop (); /* Pop return value */
if( stack.pPos->wType != IT_STRING ) /* Is it a string */

View File

@@ -31,6 +31,9 @@ HARBOUR EVAL( void ); /* Evaluates a codeblock from Harbour */
HARBOUR MAIN( void ); /* fixed entry point by now */
HARBOUR VALTYPE( void ); /* returns a string description of a value */
extern void InitializeConsole(void); /* This prototype is needed by C++ compilers */
extern void InitSymbolTable(void); /* This prototype is needed by C++ compilers */
/* currently supported virtual machine actions */
void And( void ); /* performs the logical AND on the latest two values, removes them and leaves result on the stack */
void ArrayAt( void ); /* pushes an array element to the stack, removing the array and the index from the stack */
@@ -189,7 +192,8 @@ BYTE bErrorLevel = 0; /* application exit errorlevel */
stack.Return.wType = IT_NIL;
StackInit();
NewDynSym( &symEval ); /* initialize dynamic symbol for evaluating codeblocks */
InitializeSets(); /* initialize Sets */
InitializeSets(); /* initialize Sets */
InitializeConsole(); /* initialize Console */
#ifdef HARBOUR_OBJ_GENERATION
ProcessObjSymbols(); /* initialize Harbour generated OBJs symbols */
#endif