2000-03-16 02:30 GMT-5 David G. Holm <dholm@ sd-llc.com>

This commit is contained in:
David G. Holm
2000-03-16 07:34:51 +00:00
parent f900647f3f
commit a2b16a1cf6
14 changed files with 706 additions and 191 deletions

View File

@@ -1,3 +1,25 @@
2000-03-16 02:30 GMT-5 David G. Holm <dholm@ sd-llc.com>
* include/hbapigt.h
* include/hbsetup.h
* source/rtl/console.c
* source/rtl/gtapi.c
* source/rtl/gtxxx.c
* source/rtl/gt/gt_tpl.c
* source/rtl/gt/gtcrs.c
* source/rtl/gt/gtdos.c
* source/rtl/gt/gtos2.c
* source/rtl/gt/gtsln.c
* source/rtl/gt/gtstd.c
* source/rtl/gt/gtwin.c
- Removed all occurrences of HARBOUR_USE_GTAPI from console.c.
+ Added hb_gtAdjustPos() to console.c, gtapi.c and hbapigt.h.
+ Added hb_gt_AdjustPos() to all gt/ sources and hbapigt.h.
+ Added rudimentary PC ANSI.SYS low-level driver (gtpca.c,
which is missing stuff such as scrolling screen regions).
+ Added HB_GT_PCA to hbsetup.h and gtxxx.c (in fact, I replaced
HB_GT_STD with HB_GT_PCA in gtxxx.c, because the default case
is to use HB_GT_STD).
20000316-02:04 GMT+1 Victor Szakats <info@szelvesz.hu>
* source/pp/ppcore.c
! C++ comment changed to ANSI C

View File

@@ -81,9 +81,10 @@ typedef enum
/* Public interface. These should never change, only be added to. */
extern void hb_gtInit( void );
extern void hb_gtInit( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr );
extern void hb_gtExit( void );
extern int hb_gtReadKey( void );
extern void hb_gtAdjustPos( int iHandle, char * pStr, ULONG ulLen );
extern USHORT hb_gtBox( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE * pbyBoxString );
extern USHORT hb_gtBoxD( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight );
extern USHORT hb_gtBoxS( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight );
@@ -119,9 +120,10 @@ extern USHORT hb_gtWriteCon( BYTE * pbyStr, ULONG ulLen );
/* Private interface listed below. these are common to all platforms */
extern void hb_gt_Init( void );
extern void hb_gt_Init( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr );
extern BOOL hb_gt_IsColor( void );
extern void hb_gt_Done( void );
extern BOOL hb_gt_AdjustPos( BYTE * pStr, ULONG ulLen );
extern int hb_gt_ReadKey( void );
extern USHORT hb_gt_GetScreenWidth( void );
extern USHORT hb_gt_GetScreenHeight( void );

View File

@@ -149,6 +149,9 @@
/* Short version are also good */
#ifdef HB_GT_PCA
#define HARBOUR_USE_PCA_GTAPI
#endif
#ifdef HB_GT_STD
#define HARBOUR_USE_STD_GTAPI
#endif
@@ -174,7 +177,8 @@
defined(HARBOUR_USE_OS2_GTAPI) || \
defined(HARBOUR_USE_WIN_GTAPI) || \
defined(HARBOUR_USE_CRS_GTAPI) || \
defined(HARBOUR_USE_SLN_GTAPI)
defined(HARBOUR_USE_SLN_GTAPI) || \
defined(HARBOUR_USE_PCA_GTAPI)
#define HARBOUR_USE_GTAPI
#endif

View File

@@ -100,6 +100,7 @@ static USHORT s_uiPRow;
static USHORT s_uiPCol;
static char s_szCrLf[ CRLF_BUFFER_LEN ];
static char s_szAcceptResult[ ACCEPT_BUFFER_LEN ];
static int s_iFilenoStdin;
static int s_iFilenoStdout;
static int s_iFilenoStderr;
@@ -125,6 +126,7 @@ void hb_consoleInitialize( void )
/* Some compilers open stdout and stderr in text mode, but
Harbour needs them to be open in binary mode. */
s_iFilenoStdin = fileno( stdin );
s_iFilenoStdout = fileno( stdout );
hb_fsSetDevMode( s_iFilenoStdout, FD_BINARY );
@@ -140,7 +142,7 @@ void hb_consoleInitialize( void )
hb_fsSetDevMode( s_iFilenoStderr, FD_BINARY );
hb_mouseInit();
hb_gtInit();
hb_gtInit( s_iFilenoStdin, s_iFilenoStdout, s_iFilenoStderr );
hb_gtSetCursor( SC_NORMAL );
s_bInit = TRUE;
@@ -174,64 +176,6 @@ HARBOUR HB_HB_OSNEWLINE( void )
hb_retc( s_szCrLf );
}
#ifndef HARBOUR_USE_GTAPI
static void adjust_pos( char * pStr, ULONG ulLen )
{
USHORT max_row;
USHORT max_col;
SHORT row;
SHORT col;
ULONG ulCount;
HB_TRACE(HB_TR_DEBUG, ("adjust_pos(%s, %lu)", pStr, ulLen ));
max_row = hb_gtMaxRow();
max_col = hb_gtMaxCol();
hb_gtGetPos( &row, &col );
for( ulCount = 0; ulCount < ulLen; ulCount++ )
{
switch( *pStr++ )
{
case HB_CHAR_BEL:
break;
case HB_CHAR_BS:
if( col )
col--;
else
{
col = max_col;
if( row )
row--;
}
break;
case HB_CHAR_LF:
if( row < max_row )
row++;
break;
case HB_CHAR_CR:
col = 0;
break;
default:
if( col < max_col )
col++;
else
{
col = 0;
if( row < max_row )
row++;
}
}
}
hb_gtSetPos( row, col );
}
#endif
typedef void hb_out_func_typedef( char *, ULONG );
/* Format items for output, then call specified output function */
@@ -272,15 +216,7 @@ void hb_outstd( char * pStr, ULONG ulLen )
if( s_bInit )
{
#ifdef HARBOUR_USE_GTAPI
#ifndef __CYGWIN__
if( isatty( s_iFilenoStdout ) )
#endif
/* TOFIX: Violation of API calling rules! */
hb_gtSetPos( hb_gt_Row(), hb_gt_Col() );
#else
adjust_pos( pStr, ulLen );
#endif
hb_gtAdjustPos( s_iFilenoStdout, pStr, ulLen );
hb_gtPostExt();
}
}
@@ -304,15 +240,7 @@ void hb_outerr( char * pStr, ULONG ulLen )
if( s_bInit )
{
#ifdef HARBOUR_USE_GTAPI
#ifndef __CYGWIN__
if( isatty( s_iFilenoStdout ) )
#endif
/* TOFIX: Violation of API calling rules! */
hb_gtSetPos( hb_gt_Row(), hb_gt_Col() );
#else
adjust_pos( pStr, ulLen );
#endif
hb_gtAdjustPos( s_iFilenoStderr, pStr, ulLen );
hb_gtPostExt();
}
}
@@ -323,16 +251,7 @@ static void hb_altout( char * pStr, ULONG ulLen )
HB_TRACE(HB_TR_DEBUG, ("hb_altout(%s, %lu)", pStr, ulLen));
if( hb_set.HB_SET_CONSOLE )
{
#ifdef HARBOUR_USE_GTAPI
hb_gtWriteCon( ( BYTE * ) pStr, ulLen );
#else
USHORT user_ferror = hb_fsError(); /* Save current user file error code */
hb_fsWriteLarge( s_iFilenoStdout, ( BYTE * ) pStr, ulLen );
hb_fsSetError( user_ferror ); /* Restore last user file error code */
adjust_pos( pStr, ulLen );
#endif
}
if( hb_set.HB_SET_ALTERNATE && hb_set.hb_set_althan != FS_ERROR )
{
@@ -375,16 +294,8 @@ static void hb_devout( char * pStr, ULONG ulLen )
}
else
{
#ifdef HARBOUR_USE_GTAPI
/* Otherwise, display to console */
/* TOFIX: Violation of API calling rules! */
hb_gtWriteAt( hb_gt_Row(), hb_gt_Col(), ( BYTE * ) pStr, ulLen );
#else
USHORT user_ferror = hb_fsError(); /* Save current user file error code */
hb_fsWriteLarge( s_iFilenoStdout, ( BYTE * ) pStr, ulLen );
hb_fsSetError( user_ferror ); /* Restore last user file error code */
adjust_pos( pStr, ulLen );
#endif
hb_gtWrite( ( BYTE * ) pStr, ulLen );
}
}
@@ -392,18 +303,7 @@ static void hb_devout( char * pStr, ULONG ulLen )
static void hb_dispout( char * pStr, ULONG ulLen )
{
HB_TRACE(HB_TR_DEBUG, ("hb_dispout(%s, %lu)", pStr, ulLen));
#ifdef HARBOUR_USE_GTAPI
/* TOFIX: Violation of API calling rules! */
hb_gtWriteAt( hb_gt_Row(), hb_gt_Col(), ( BYTE * ) pStr, ulLen );
#else
{
USHORT user_ferror = hb_fsError(); /* Save current user file error code */
hb_fsWriteLarge( s_iFilenoStdout, ( BYTE * ) pStr, ulLen );
hb_fsSetError( user_ferror ); /* Restore last user file error code */
adjust_pos( pStr, ulLen );
}
#endif
hb_gtWrite( ( BYTE * ) pStr, ulLen );
}
void hb_devpos( SHORT row, SHORT col )

View File

@@ -39,7 +39,7 @@
#include "hbapigt.h"
void hb_gt_Init( void )
void hb_gt_Init( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_Init()"));
@@ -62,6 +62,56 @@ int hb_gt_ReadKey( void )
return 0;
}
BOOL hb_gt_AdjustPos( BYTE * pStr, ULONG ulLen )
{
USHORT row = s_usRow;
USHORT col = s_usCol;
ULONG ulCount;
HB_TRACE(HB_TR_DEBUG, ("hb_gt_AdjustPos(%s, %lu)", pStr, ulLen ));
for( ulCount = 0; ulCount < ulLen; ulCount++ )
{
switch( *pStr++ )
{
case HB_CHAR_BEL:
break;
case HB_CHAR_BS:
if( col )
col--;
else
{
col = s_usMaxCol;
if( row )
row--;
}
break;
case HB_CHAR_LF:
if( row < s_usMaxRow )
row++;
break;
case HB_CHAR_CR:
col = 0;
break;
default:
if( col < s_usMaxCol )
col++;
else
{
col = 0;
if( row < s_usMaxRow )
row++;
}
}
}
hb_gt_SetPos( row, col );
return TRUE;
}
BOOL hb_gt_IsColor( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_IsColor()"));

View File

@@ -42,7 +42,7 @@ static void gt_GetRC(int* r, int* c);
static void gt_SetRC(int r, int c);
void hb_gt_Init( void )
void hb_gt_Init( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_Init()"));
@@ -74,6 +74,57 @@ int hb_gt_ReadKey( void )
return ch;
}
BOOL hb_gt_AdjustPos( BYTE * pStr, ULONG ulLen )
{
int row, col, max_row, max_col;
ULONG ulCount;
HB_TRACE(HB_TR_DEBUG, ("hb_gt_AdjustPos(%s, %lu)", pStr, ulLen ));
gt_GetRC( &row, &col );
gt_GetMaxRC( &max_row, &max_col );
for( ulCount = 0; ulCount < ulLen; ulCount++ )
{
switch( *pStr++ )
{
case HB_CHAR_BEL:
break;
case HB_CHAR_BS:
if( col )
col--;
else
{
col = max_col;
if( row )
row--;
}
break;
case HB_CHAR_LF:
if( row < max_row )
row++;
break;
case HB_CHAR_CR:
col = 0;
break;
default:
if( col < max_col )
col++;
else
{
col = 0;
if( row < max_row )
row++;
}
}
}
hb_gtSetRC( row, col );
return TRUE;
}
BOOL hb_gt_IsColor( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_IsColor()"));

View File

@@ -130,7 +130,7 @@ static void hb_gt_CtrlBrkRestore( void )
}
#endif
void hb_gt_Init( void )
void hb_gt_Init( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_Init()"));
@@ -178,6 +178,33 @@ int hb_gt_ReadKey( void )
return 0;
}
BOOL hb_gt_AdjustPos( BYTE * pStr, ULONG ulLen )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_AdjustPos()"));
#if defined(__TURBOC__)
{
_AH = 0x03;
_BH = 0;
geninterrupt( 0x10 );
hb_gtSetPos( _DH, _DL );
}
#else
{
union REGS regs;
regs.h.ah = 0x03;
regs.h.bh = 0;
#if defined(__WATCOMC__) && defined(__386__)
int386( 0x10, &regs, &regs );
#else
int86( 0x10, &regs, &regs );
#endif
hb_gtSetPos( regs.h.dh, regs.h.dl );
}
#endif
return TRUE;
}
BOOL hb_gt_IsColor( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_IsColor()"));

View File

@@ -53,7 +53,7 @@ static void hb_gt_SetCursorSize( char start, char end, int visible );
static void hb_gt_GetCursorSize( char * start, char * end );
*/
void hb_gt_Init( void )
void hb_gt_Init( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_Init()"));
@@ -67,6 +67,18 @@ void hb_gt_Done( void )
/* TODO: */
}
BOOL hb_gt_AdjustPos( BYTE * pStr, ULONG ulLen )
{
USHORT x, y;
HB_TRACE(HB_TR_DEBUG, ("hb_gt_AdjustPos()"));
VioGetCurPos( &y, &x, 0 );
hb_gtSetPos( ( SHORT ) y, ( SHORT ) x );
return TRUE;
}
int hb_gt_ReadKey( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_ReadKey()"));

View File

@@ -0,0 +1,369 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Video subsystem for ANSI terminals
*
* Copyright 2000 David G. Holm <dholm@jsd-llc.com>
* www - http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version, with one exception:
*
* The exception is that if you link the Harbour Runtime Library (HRL)
* and/or the Harbour Virtual Machine (HVM) with other files to produce
* an executable, this does not by itself cause the resulting executable
* to be covered by the GNU General Public License. Your use of that
* executable is in no way restricted on account of linking the HRL
* and/or HVM code into it.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
* their web site at http://www.gnu.org/).
*
*/
/*
* This module is partially based on VIDMGR by Andrew Clarke and modified
* for the Harbour project
*/
/* NOTE: User programs should never call this layer directly! */
#if defined(__GNUC__) && ! defined(__MINGW32__)
#include <unistd.h>
#if defined(__DJGPP__) || defined(__CYGWIN__) || defined(HARBOUR_GCC_OS2)
#include <io.h>
#endif
#else
#include <io.h>
#endif
#include <ctype.h>
#include <string.h>
#include "hbapigt.h"
#include "hbset.h"
static USHORT s_usRow, s_usCol, s_usMaxRow, s_usMaxCol;
static int s_iFilenoStdin, s_iFilenoStdout, s_iFilenoStderr;
static int s_iAttribute;
static BOOL s_bColor;
static char s_szSpaces[] = " "; /* 84 spaces */
void hb_gt_AnsiGetCurPos( USHORT * row, USHORT * col );
void hb_gt_Init( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_Init()"));
s_iAttribute = 0;
s_iFilenoStdin = iFilenoStdin;
s_iFilenoStdout = iFilenoStdout;
s_iFilenoStderr = iFilenoStderr;
s_usRow = s_usCol = 0;
hb_gt_AnsiGetCurPos( &s_usRow, &s_usCol );
#ifdef OS_UNIX_COMPATIBLE
s_usMaxRow = 23;
s_bColor = FALSE;
#else
s_usMaxRow = 24;
s_bColor = TRUE;
#endif
s_usMaxCol = 79;
fprintf( stdout, "\x1B[=7h" ); /* Enable line wrap (for OUTSTD() and OUTERR()) */
}
void hb_gt_Done( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_Done()"));
/* TODO: */
}
void hb_gt_AnsiGetCurPos( USHORT * row, USHORT * col )
{
if( isatty( s_iFilenoStdin ) && isatty( s_iFilenoStdout ) )
{
USHORT ch, value = 0, index = 0;
fprintf( stdout, "\x1B[6n" );
do
{
ch = getc( stdin );
if( isdigit( ch ) )
{
value = ( value * 10 ) + ( ch - '0' );
}
else if( ch == ';' )
{
*row = value - 1;
value = 0;
}
}
while( ch != 'R' && index < 10 );
*col = value - 1;
}
}
void hb_gt_AnsiSetAttributes( BYTE attr )
{
static const int color[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
int bg_color = 40 + color[ ( attr & 0x70 ) >> 4 ];
int fg_color = 30 + color[ attr & 0x07 ];
int special = 0;
if( attr & 0x08 ) special = 1;
else if( attr & 0x80 )
{
if( hb_set.HB_SET_INTENSITY ) special = 1;
else special = 5;
}
fprintf( stdout, "\x1B[%d;%d;%dm", special, fg_color, bg_color );
}
BOOL hb_gt_AdjustPos( BYTE * pStr, ULONG ulLen )
{
USHORT row = s_usRow;
USHORT col = s_usCol;
ULONG ulCount;
HB_TRACE(HB_TR_DEBUG, ("hb_gt_AdjustPos(%s, %lu)", pStr, ulLen ));
for( ulCount = 0; ulCount < ulLen; ulCount++ )
{
switch( *pStr++ )
{
case HB_CHAR_BEL:
break;
case HB_CHAR_BS:
if( col )
col--;
else
{
col = s_usMaxCol;
if( row )
row--;
}
break;
case HB_CHAR_LF:
if( row < s_usMaxRow )
row++;
break;
case HB_CHAR_CR:
col = 0;
break;
default:
if( col < s_usMaxCol )
col++;
else
{
col = 0;
if( row < s_usMaxRow )
row++;
}
}
}
hb_gt_SetPos( row, col );
return TRUE;
}
int hb_gt_ReadKey( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_ReadKey()"));
/* TODO: */
return 0;
}
BOOL hb_gt_IsColor( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_IsColor()"));
/* TODO: */
return s_bColor;
}
USHORT hb_gt_GetScreenWidth( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetScreenWidth()"));
/* TODO: */
return s_usMaxCol + 1;
}
USHORT hb_gt_GetScreenHeight( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetScreenHeight()"));
/* TODO: */
return s_usMaxRow + 1;
}
void hb_gt_SetPos( SHORT iRow, SHORT iCol )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetPos(%hd, %hd)", iRow, iCol));
if( iRow < 0 ) iRow = 0;
else if( iRow > s_usMaxRow ) iRow = s_usMaxRow;
if( iCol < 0 ) iCol = 0;
else if( iCol > s_usMaxCol ) iCol = s_usMaxCol;
s_usRow = iRow;
s_usCol = iCol;
fprintf( stdout, "\x1B[%d;%dH", s_usRow + 1, s_usCol + 1 );
}
SHORT hb_gt_Row( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_Row()"));
return s_usRow;
}
SHORT hb_gt_Col( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_Col()"));
return s_usCol;
}
void hb_gt_Scroll( USHORT usTop, USHORT usLeft, USHORT usBottom, USHORT usRight, BYTE attr, SHORT sVert, SHORT sHoriz )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_Scroll(%hu, %hu, %hu, %hu, %d, %hd, %hd)", usTop, usLeft, usBottom, usRight, (int) attr, sVert, sHoriz));
if( sVert == 0 && sHoriz == 0 )
{
/* Clear */
if( usTop == 0 && usLeft == 0 && usBottom >= s_usMaxRow && usRight >= s_usMaxCol )
{
/* Clear the entire screen */
fprintf( stdout, "\x1B[2J" );
}
else
{
/* Clear a screen region */
USHORT i;
for( i = usTop; i <= usBottom; i++ )
{
hb_gt_Puts( i, usLeft, s_iAttribute, s_szSpaces, (usRight - usLeft ) + 1 );
}
}
}
else
{
if( usTop == 0 && usLeft == 0 && usBottom >= s_usMaxRow && usRight >= s_usMaxCol )
{
if( sVert > 0 && sHoriz == 0 )
{
/* Scroll the entire screen up */
fprintf( stdout, "\x1B[25;80" );
while( sVert-- ) fputc( '\n', stdout );
}
else
{
/* TODO: Scroll the entire screen any direction other than up */
}
}
else
{
/* TODO: Scroll a screen region */
}
}
}
USHORT hb_gt_GetCursorStyle( void )
{
/* TODO: What shape is the cursor? */
USHORT uiStyle = 0;
HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetCursorStyle()"));
return uiStyle;
}
void hb_gt_SetCursorStyle( USHORT style )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetCursorStyle(%hu)", style));
}
void hb_gt_Puts( USHORT usRow, USHORT usCol, BYTE attr, BYTE * str, ULONG len )
{
/* Because Clipper strings don't have to be null terminated, add a null
terminating character after saving what used to be at the termination
position, because it might not even be part of the string object */
char save = str[ len ];
HB_TRACE(HB_TR_DEBUG, ("hb_gt_Puts(%hu, %hu, %d, %p, %lu, %s)", usRow, usCol, (int) attr, str, len, str));
str[ len ] = '\0';
/* Disable line wrap, set the new cursor position, send the string, then
enable line wrap (for OUTSTD() and OUTERR() ) */
hb_gt_AnsiSetAttributes( attr );
fprintf( stdout, "\x1B[=7l\x1B[%d;%dH%s\x1B[=7h", usRow + 1, usCol + 1, str );
/* Restore whatever used to be at the termination position */
str[ len ] = save;
/* Update the cursor position */
s_usRow = usRow;
s_usCol = usCol + len;
if( s_usCol > s_usMaxCol ) s_usCol = s_usMaxCol;
}
void hb_gt_GetText( USHORT usTop, USHORT usLeft, USHORT usBottom, USHORT usRight, BYTE *dest )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetText(%hu, %hu, %hu, %hu, %p)", usTop, usLeft, usBottom, usRight, dest));
/* TODO: */
}
void hb_gt_PutText( USHORT usTop, USHORT usLeft, USHORT usBottom, USHORT usRight, BYTE *srce )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_PutText(%hu, %hu, %hu, %hu, %p)", usTop, usLeft, usBottom, usRight, srce));
/* TODO: */
}
void hb_gt_SetAttribute( USHORT usTop, USHORT usLeft, USHORT usBottom, USHORT usRight, BYTE attr )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetAttribute(%hu, %hu, %hu, %hu, %d)", usTop, usLeft, usBottom, usRight, (int) attr));
/* TODO: */
s_iAttribute = attr;
}
void hb_gt_DispBegin( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_DispBegin()"));
/* TODO: */
}
void hb_gt_DispEnd( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_DispEnd()"));
/* TODO: here we flush the buffer, and restore normal screen writes */
}
BOOL hb_gt_SetMode( USHORT uiRows, USHORT uiCols )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetMode(%hu, %hu)", uiRows, uiCols));
/* TODO: */
return 0; /* 0 = Ok, other = Fail */
}
void hb_gt_Replicate( BYTE c, ULONG ulLen )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_Replicate(%d, %lu)", (int) c, ulLen));
/* TODO: this will write character c nlength times to the screen.
Note that it is not used yet
If there is no native function that supports this, it is
already handled in a generic way by higher level functions.
*/
}
BOOL hb_gt_GetBlink()
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetBlink()"));
/* TODO: */
return 1; /* 0 = blink, 1 = intens */
}
void hb_gt_SetBlink( BOOL bBlink )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetBlink(%d)", (int) bBlink));
/* TODO: */
}

View File

@@ -39,7 +39,7 @@
#include "hbapigt.h"
void hb_gt_Init( void )
void hb_gt_Init( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_Init()"));
@@ -70,6 +70,56 @@ int hb_gt_ReadKey( void )
return 0;
}
BOOL hb_gt_AdjustPos( BYTE * pStr, ULONG ulLen )
{
USHORT row = SLsmg_get_row();
USHORT col = SLsmg_get_column();
ULONG ulCount;
HB_TRACE(HB_TR_DEBUG, ("hb_gt_AdjustPos(%s, %lu)", pStr, ulLen ));
for( ulCount = 0; ulCount < ulLen; ulCount++ )
{
switch( *pStr++ )
{
case HB_CHAR_BEL:
break;
case HB_CHAR_BS:
if( col )
col--;
else
{
col = SLtt_Screen_Cols - 1;
if( row )
row--;
}
break;
case HB_CHAR_LF:
if( row < SLtt_Screen_Rows - 1 )
row++;
break;
case HB_CHAR_CR:
col = 0;
break;
default:
if( col < SLtt_Screen_Cols - 1 )
col++;
else
{
col = 0;
if( row < SLtt_Screen_Rows - 1 )
row++;
}
}
}
hb_gt_SetPos( row, col );
return TRUE;
}
BOOL hb_gt_IsColor( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_IsColor()"));

View File

@@ -47,9 +47,8 @@ static USHORT s_uiMaxCol;
static USHORT s_uiCursorStyle;
static BOOL s_bBlink;
static int s_iFilenoStdout;
static int s_iFilenoStderr;
void hb_gt_Init( void )
void hb_gt_Init( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_Init()"));
@@ -63,7 +62,7 @@ void hb_gt_Init( void )
s_uiMaxCol = 80;
s_uiCursorStyle = SC_NORMAL;
s_bBlink = FALSE;
s_iFilenoStdout = fileno( stdout );
s_iFilenoStdout = iFilenoStdout;
hb_fsSetDevMode( s_iFilenoStdout, FD_BINARY );
}
@@ -81,6 +80,56 @@ int hb_gt_ReadKey( void )
return 0;
}
BOOL hb_gt_AdjustPos( BYTE * pStr, ULONG ulLen )
{
USHORT row = s_iRow;
USHORT col = s_iCol;
ULONG ulCount;
HB_TRACE(HB_TR_DEBUG, ("hb_gt_AdjustPos(%s, %lu)", pStr, ulLen ));
for( ulCount = 0; ulCount < ulLen; ulCount++ )
{
switch( *pStr++ )
{
case HB_CHAR_BEL:
break;
case HB_CHAR_BS:
if( col )
col--;
else
{
col = s_uiMaxCol;
if( row )
row--;
}
break;
case HB_CHAR_LF:
if( row < s_uiMaxRow )
row++;
break;
case HB_CHAR_CR:
col = 0;
break;
default:
if( col < s_uiMaxCol )
col++;
else
{
col = 0;
if( row < s_uiMaxRow )
row++;
}
}
}
hb_gt_SetPos( row, col );
return TRUE;
}
BOOL hb_gt_IsColor( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_IsColor()"));
@@ -114,7 +163,7 @@ void hb_gt_SetPos( SHORT iRow, SHORT iCol )
if( iRow < iDevRow || iCol < iDevCol )
{
fputs( hb_consoleGetNewLine(), stdout );
fputs( szCrLf, stdout );
iDevCol = 0;
iDevRow++;
}
@@ -122,7 +171,7 @@ void hb_gt_SetPos( SHORT iRow, SHORT iCol )
iDevCol = 0;
for( iCount = iDevRow; iCount < iRow; iCount++ )
fputs( hb_consoleGetNewLine(), stdout );
fputs( szCrLf, stdout );
for( iCount = iDevCol; iCount < iCol; iCount++ )
fputc( ' ', stdout );

View File

@@ -118,9 +118,12 @@ static BOOL WINAPI hb_gt_CtrlHandler( DWORD dwCtrlType )
return bHandled;
}
void hb_gt_Init( void )
void hb_gt_Init( int iFilenoStdin, int iFilenoStdout, int iFilenoStderr )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_Init()"));
HB_TRACE(HB_TR_DEBUG, ("hb_gt_Init(): %d, %d, %d", iFilenoStdin, iFilenoStdout, iFilenoStderr));
HB_SYMBOL_UNUSED( iFilenoStdin );
HB_SYMBOL_UNUSED( iFilenoStdout );
HB_SYMBOL_UNUSED( iFilenoStderr );
/* Add Ctrl+Break handler [vszakats] */
SetConsoleCtrlHandler( hb_gt_CtrlHandler, TRUE );
@@ -220,6 +223,21 @@ int hb_gt_ReadKey( void )
return 0;
}
BOOL hb_gt_AdjustPos( BYTE * pStr, ULONG ulLen )
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
HB_SYMBOL_UNUSED( pStr );
HB_SYMBOL_UNUSED( ulLen );
HB_TRACE(HB_TR_DEBUG, ("hb_gt_Adjust(): %s, %l", pStr, ulLen));
GetConsoleScreenBufferInfo( s_HActive, &csbi );
hb_gtSetPos( csbi.dwCursorPosition.Y, csbi.dwCursorPosition.X );
return TRUE;
}
BOOL hb_gt_IsColor( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_IsColor()"));

View File

@@ -33,71 +33,6 @@
*
*/
/*
* ChangeLog:
*
* 1.83 19991006 ptucker Enable dispbegin/end calls in gtBox
* 1.81 19991005 dholm Made the hb_gtWrite(), hb_gtWriteAt(), and
* hb_gtWriteCon() functions and the cursor
* positioning more compatible with Clipper.
* 1.66 19990830 vszel Reformatted using Harbour standard. Some
* small cleanups.
* 1.65 19990830 ptucker Handle nesting of gtPre/PostExt - corrected
* s_uiPreCount handling in gtDispEnd
* 1.63 19990811 ptucker Implimented gtPre and PostExt to be used when
* writing to screen via printf.
* 1.58 19990811 ptucker changes to gtWriteCon and gtWrite to improve
* speed.
* 1.56 19990811 ptucker Corrected initial MaxRow/col
* 1.53 19990807 ptucker Modified Dispbegin/end support
* 1.47 19990802 ptucker DispBegin/End and SetMode for gtWin
* 1.46 19990801 ptucker simplified hb_gtScroll if gtWin
* 1.44 19990730 ptucker simplified gtputs and gtSetAttribute
* corrected gtGetCursorStyle for !cci.bVisible
* return SC_NONE - other cases should be handled
* by the switch that follows.
* changed 'case 8:' in gtWriteCon to check
* against uiCol instead of uiRow
* 1.43 19990729 ptucker Corrected a number of calls so params are
* in top,left,bottom,right or row,col order.
* removed call to gtrectsize in gtputtext.
* This should be handled by the caller.
* 1.41 19990728 ptucker Minor correction for inverted coords
* 1.40 19990726 vszel Allowing Top > Bottom and Right > Left
* cases again. Clipper allows these, too.
* Cursor positioning fixed to support these cases.
* uMRow renamed to uiMRow
* uMCol renamed to uiMCol
* 1.39 19990726 ptucker Position cursor inside top-left corner
* after drawing box - compatibility
* 1.35 19990726 ptucker Much improved box drawing speed
* Modifed some if statments to test for != 0
* 1.34 19990721 ptucker Corrected _Color mask descriptions
* 1.33 19990721 ptucker Improved Clipper color compatibility
* 1.31 19990720 ptucker Implimented color selection in gtWrite and
* gtScroll
* 1.30 19990719 ptucker Removed temp init hack
* call gtDone from hb_gtExit
* 1.29 19990719 ptucker Minor change to catch last color parameter
* that may be empty
* 1.28 19990719 ptucker Added support for numeric color strings
* like "1/7,8/15"
* 1.26 19990719 ptucker Changed call in hb_gtinit() to pass the
* literal initial color setting in case
* the GT system is initialised prior to Set.
* Skipped color params in a string now keep
* their previous value. ie ",,,r/b"
* 1.25 19990718 dholm Moved calls to various gtFunctions out of
* InitializeConsole() in console.c and put
* them in hb_gtInit() in this module. Use
* hb_set.HB_SET_COLOR to initialize the GT
* API color string. Converted // comments.
* 1.24 19990718 ptucker corrected returned color strings so ordering
* is the same as clipper.
* 1.23 19990718 ptucker implimented surface for gtGet/SetColorStr()
* changed to allow unlimited color pairs.
*/
/*
* The following parts are Copyright of the individual authors.
* www - http://www.harbour-project.org
@@ -120,6 +55,15 @@
*
*/
#if defined(__GNUC__) && ! defined(__MINGW32__)
#include <unistd.h>
#if defined(__DJGPP__) || defined(__CYGWIN__) || defined(HARBOUR_GCC_OS2)
#include <io.h>
#endif
#else
#include <io.h>
#endif
#include <ctype.h>
#include "hbapigt.h"
@@ -144,14 +88,14 @@ static int s_ColorCount;
/* gt API functions */
void hb_gtInit( void )
void hb_gtInit( int s_iFilenoStdin, int s_iFilenoStdout, int s_iFilenoStderr )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gtInit()"));
s_Color = ( int * ) hb_xgrab( 5 * sizeof( int ) );
s_ColorCount = 5;
hb_gt_Init();
hb_gt_Init( s_iFilenoStdin, s_iFilenoStdout, s_iFilenoStderr );
hb_gtSetColorStr( hb_set.HB_SET_COLOR );
s_iCurrentRow = hb_gt_Row();
@@ -176,6 +120,23 @@ int hb_gtReadKey( void )
return hb_gt_ReadKey();
}
void hb_gtAdjustPos( int iHandle, char * pStr, ULONG ulLen )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gtAdjustPos()"));
#ifndef __CYGWIN__
/* If the output is going to a file instead of to the console,
then there is no need to adjust the cursor position. */
if( isatty( iHandle ) )
#endif
if( hb_gt_AdjustPos( ( BYTE * ) pStr, ulLen ) );
{
/* Adjust the console cursor position to match the device driver */
s_iCurrentRow = hb_gt_Row();
s_iCurrentCol = hb_gt_Col();
}
}
USHORT hb_gtBox( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE * pbyFrame )
{
BYTE pszBox[ 10 ];

View File

@@ -35,8 +35,8 @@
#include "hbsetup.h"
#if defined(HARBOUR_USE_STD_GTAPI)
#include "gt/gtstd.c"
#if defined(HARBOUR_USE_PCA_GTAPI)
#include "gt/gtpca.c"
#elif defined(HARBOUR_USE_DOS_GTAPI)
#include "gt/gtdos.c"
#elif defined(HARBOUR_USE_OS2_GTAPI)