diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b191a0ae9b..ed45a657bd 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,32 @@ +20000311-17:54 GMT+1 Victor Szakats + - include/hbcursor.h + - include/hbbox.h + * include/hbapigt.h + include/Makefile + source/rtl/console.c + source/rtl/gtapi.c + * Two header files merged to the mainstream GT header. + ! B_* box #defines renamed to _B_* to be CA-Cl*pper compatible. + * include/hbapigt.h + source/rtl/gt/*.c + * Low-level hb_gt_SetPos(), hb_gt_Row(), hb_gt_Col() uses SHORT instead + of USHORT, to be in sync with the GT API. + WARNING! Please test the different API drivers. GTWIN was the only + one tested. + * source/rtl/console.c + source/rtl/gt/gtstd.c + * hb_setpos() removed, non-GT API functionality moved to gtstd.c, all + hb_setpos() calls changed to hb_gtSetPos(). + * source/rtl/console.c + % QOUT() small optim., variable scope adjusted. + ! __EJECT() fixed to always reset PROW() and PCOL() + + TOFIX added for __EJECT() since in Clipper it always prints a eject, + regardless of the SET DEVICE setting. + % SAVESCREEN() optimized. + ! RESTSCREEM() fixed to check the fifth parameter, like in CA-Cl*pper. + * source/rtl/console.c + % hb_gtSetPos() small optim. + 20000311-19:16 GMT+3 Alexander Kresin + contrib/rdd_ads/make_vc.bat + contrib/rdd_ads/makefile.vc diff --git a/harbour/include/Makefile b/harbour/include/Makefile index 4ea143a9e8..85385bb106 100644 --- a/harbour/include/Makefile +++ b/harbour/include/Makefile @@ -15,9 +15,7 @@ C_HEADERS=\ hbapilng.h \ hbapimou.h \ hbapirdd.h \ - hbbox.h \ hbcomp.h \ - hbcursor.h \ hbdate.h \ hbdefs.h \ hberrors.h \ diff --git a/harbour/include/hbapigt.h b/harbour/include/hbapigt.h index e5bfd2694d..e329cb2648 100644 --- a/harbour/include/hbapigt.h +++ b/harbour/include/hbapigt.h @@ -37,9 +37,8 @@ #define HB_APIGT_H_ #include "hbapi.h" + #include "color.ch" -#include "hbcursor.h" -#include "hbbox.h" /* NOTE: The declaration of hb_gtSetPos(), hb_gtGetPos(), hb_gtWrite(), hb_gtWriteAt(), hb_gtRepChar() differs in parameter types from the @@ -48,6 +47,24 @@ /* maximum length of color string */ #define CLR_STRLEN 64 +/* strings for borders (same as box.ch, but defined for use by C) */ + /*01234567*/ +#define _B_SINGLE "ÚÄ¿³ÙÄÀ³" +#define _B_DOUBLE "ÉÍ»º¼ÍȺ" +#define _B_SINGLE_DOUBLE "ÖÄ·º½ÄÓº" +#define _B_DOUBLE_SINGLE "Õ͸³¾ÍÔ³" + +/* Cursor style constants */ + +typedef enum +{ + SC_NONE = 0, /* None */ + SC_NORMAL = 1, /* Underline */ + SC_INSERT = 2, /* Lower half block */ + SC_SPECIAL1 = 3, /* Full block */ + SC_SPECIAL2 = 4 /* Upper half block */ +} HB_cursor_enum; + /* Public interface. These should never change, only be added to. */ extern void hb_gtInit( void ); @@ -94,9 +111,9 @@ extern void hb_gt_Done( void ); extern int hb_gt_ReadKey( void ); extern USHORT hb_gt_GetScreenWidth( void ); extern USHORT hb_gt_GetScreenHeight( void ); -extern void hb_gt_SetPos( USHORT uiRow, USHORT uiCol ); -extern USHORT hb_gt_Col( void ); -extern USHORT hb_gt_Row( void ); +extern void hb_gt_SetPos( SHORT iRow, SHORT iCol ); +extern SHORT hb_gt_Col( void ); +extern SHORT hb_gt_Row( void ); extern void hb_gt_Scroll( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE byAttr, SHORT iRows, SHORT iCols ); extern void hb_gt_SetCursorStyle( USHORT uiCursorShape ); extern USHORT hb_gt_GetCursorStyle( void ); diff --git a/harbour/include/hbbox.h b/harbour/include/hbbox.h deleted file mode 100644 index d4e8022194..0000000000 --- a/harbour/include/hbbox.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * Header file for box drawing - * - * Copyright 1999 {list of individual authors and e-mail addresses} - * 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/). - * - */ - -#ifndef HB_BOX_H_ -#define HB_BOX_H_ - -/* strings for borders (same as box.ch, but defined for use by C) */ - /*01234567*/ -#define B_NONE " " -#define B_SINGLE "ÚÄ¿³ÙÄÀ³" -#define B_DOUBLE "ÉÍ»º¼ÍȺ" -#define B_SINGLE_DOUBLE "ÖÄ·º½ÄÓº" -#define B_DOUBLE_SINGLE "Õ͸³¾ÍÔ³" -#define B_THIN "ÛßÛÛÛÜÛÛ" -#define B_FAT "ÛÛÛÛÛÛÛÛ" - -#endif /* HB_BOX_H_ */ diff --git a/harbour/include/hbcursor.h b/harbour/include/hbcursor.h deleted file mode 100644 index fb8c8352bf..0000000000 --- a/harbour/include/hbcursor.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * Header file for the Cursor style constants - * - * Copyright 1999 David G. Holm - * 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/). - * - */ - -#ifndef HB_CURSOR_H_ -#define HB_CURSOR_H_ - -typedef enum -{ - SC_NONE = 0, /* None */ - SC_NORMAL = 1, /* Underline */ - SC_INSERT = 2, /* Lower half block */ - SC_SPECIAL1 = 3, /* Full block */ - SC_SPECIAL2 = 4 /* Upper half block */ -} HB_cursor_enum; - -#endif /* HB_CURSOR_H_ */ diff --git a/harbour/source/rtl/console.c b/harbour/source/rtl/console.c index 92f9bc67c6..951f482a06 100644 --- a/harbour/source/rtl/console.c +++ b/harbour/source/rtl/console.c @@ -44,7 +44,7 @@ * adjust_pos(), hb_altout(), hb_devout(), HB_DEVOUT(), hb_devpos(), * HB_DEVPOS(), hb_dispout(), HB___EJECT(), HB_MAXCOL(), * HB_MAXROW(), hb_out(), hb_outerr(), HB_OUTERR(), - * hb_outstd(), HB_OUTSTD(), HB_PCOL(), HB_PROW(), hb_setpos(), + * hb_outstd(), HB_OUTSTD(), HB_PCOL(), HB_PROW(), * HB_SETPOS(), HB_SETPRC(), HB_SCROLL(), and hb_consoleInitialize() * * Copyright 1999 Victor Szakats @@ -409,41 +409,6 @@ static void hb_dispout( char * pStr, ULONG ulLen ) #endif } -void hb_setpos( SHORT row, SHORT col ) -{ - HB_TRACE(HB_TR_DEBUG, ("hb_setpos(%hd, %hd)", row, col)); - -#ifndef HARBOUR_USE_GTAPI - { - SHORT iCount; - /* TOFIX: Violation of API calling rules! */ - SHORT iDevRow = hb_gt_Row(); - SHORT iDevCol = hb_gt_Col(); - - if( row < iDevRow || col < iDevCol ) - { - fputs( s_szCrLf, stdout ); - iDevCol = 0; - iDevRow++; - } - else if( row > iDevRow ) - iDevCol = 0; - - for( iCount = iDevRow; iCount < row; iCount++ ) - fputs( s_szCrLf, stdout ); - for( iCount = iDevCol; iCount < col; iCount++ ) - fputc( ' ', stdout ); - - fflush( stdout ); - - row = iDevRow; - col = iDevCol; - } -#endif - - hb_gtSetPos( row, col ); -} - void hb_devpos( SHORT row, SHORT col ) { HB_TRACE(HB_TR_DEBUG, ("hb_devpos(%hd, %hd)", row, col)); @@ -454,6 +419,7 @@ void hb_devpos( SHORT row, SHORT col ) { USHORT uiCount, uiProw = ( USHORT ) row, uiPcol = ( USHORT ) col; USHORT user_ferror = hb_fsError(); /* Save current user file error code */ + if( uiProw < s_uiPRow ) { hb_fsWrite( hb_set.hb_set_printhan, ( BYTE * ) "\x0C\x0D", 2 ); @@ -474,12 +440,27 @@ void hb_devpos( SHORT row, SHORT col ) hb_fsSetError( user_ferror ); /* Restore last user file error code */ } else - hb_setpos( row, col ); + hb_gtSetPos( row, col ); +} + +/* NOTE: This should be placed after the hb_devpos() definition. */ + +HARBOUR HB_DEVPOS( void ) /* Sets the screen and/or printer position */ +{ + if( ISNUM( 1 ) && ISNUM( 2 ) ) + hb_devpos( hb_parni( 1 ), hb_parni( 2 ) ); +} + +HARBOUR HB_SETPOS( void ) /* Sets the screen position */ +{ + if( ISNUM( 1 ) && ISNUM( 2 ) ) + hb_gtSetPos( hb_parni( 1 ), hb_parni( 2 ) ); } HARBOUR HB_OUTSTD( void ) /* writes a list of values to the standard output device */ { - USHORT uiParam, uiPCount = hb_pcount(); + USHORT uiPCount = hb_pcount(); + USHORT uiParam; for( uiParam = 1; uiParam <= uiPCount; uiParam++ ) { @@ -491,7 +472,8 @@ HARBOUR HB_OUTSTD( void ) /* writes a list of values to the standard output devi HARBOUR HB_OUTERR( void ) /* writes a list of values to the standard error device */ { - USHORT uiParam, uiPCount = hb_pcount(); + USHORT uiPCount = hb_pcount(); + USHORT uiParam; for( uiParam = 1; uiParam <= uiPCount; uiParam++ ) { @@ -503,7 +485,8 @@ HARBOUR HB_OUTERR( void ) /* writes a list of values to the standard error devic HARBOUR HB_QQOUT( void ) /* writes a list of values to the current device (screen or printer) and is affected by SET ALTERNATE */ { - USHORT uiParam, uiPCount = hb_pcount(); + USHORT uiPCount = hb_pcount(); + USHORT uiParam; for( uiParam = 1; uiParam <= uiPCount; uiParam++ ) { @@ -515,30 +498,24 @@ HARBOUR HB_QQOUT( void ) /* writes a list of values to the current device (scree HARBOUR HB_QOUT( void ) { - USHORT uiCount; - hb_altout( s_szCrLf, CRLF_BUFFER_LEN - 1 ); if( hb_set.HB_SET_PRINTER && hb_set.hb_set_printhan != FS_ERROR ) { USHORT user_ferror = hb_fsError(); /* Save current user file error code */ + USHORT uiCount; + s_uiPRow++; - s_uiPCol = hb_set.HB_SET_MARGIN; - uiCount = s_uiPCol; + uiCount = s_uiPCol = hb_set.HB_SET_MARGIN; while( uiCount-- > 0 ) hb_fsWrite( hb_set.hb_set_printhan, ( BYTE * ) " ", 1 ); + hb_fsSetError( user_ferror ); /* Restore last user file error code */ } HB_QQOUT(); } -HARBOUR HB_SETPOS( void ) /* Sets the screen position */ -{ - if( ISNUM( 1 ) && ISNUM( 2 ) ) - hb_setpos( hb_parni( 1 ), hb_parni( 2 ) ); -} - /* Move the screen position to the right by one column */ HARBOUR HB_SETPOSBS( void ) { @@ -550,12 +527,6 @@ HARBOUR HB_SETPOSBS( void ) hb_gtSetPos( iRow, iCol + 1 ); } -HARBOUR HB_DEVPOS( void ) /* Sets the screen and/or printer position */ -{ - if( ISNUM( 1 ) && ISNUM( 2 ) ) - hb_devpos( hb_parni( 1 ), hb_parni( 2 ) ); -} - HARBOUR HB_DEVOUT( void ) /* writes a single value to the current device (screen or printer), but is not affected by SET ALTERNATE */ { if( hb_pcount() >= 1 ) @@ -603,7 +574,7 @@ HARBOUR HB_DISPOUTAT( void ) /* writes a single value to the screen at speficic if( hb_pcount() >= 3 ) { /* NOTE: Clipper does no checks here. [vszakats] */ - hb_setpos( hb_parni( 1 ), hb_parni( 2 ) ); + hb_gtSetPos( hb_parni( 1 ), hb_parni( 2 ) ); if( ISCHAR( 4 ) ) { @@ -621,15 +592,18 @@ HARBOUR HB_DISPOUTAT( void ) /* writes a single value to the screen at speficic } } +/* TOFIX: CA-Cl*pper will print an eject even if SET DEVICE=SCREEN */ + HARBOUR HB___EJECT( void ) /* Ejects the current page from the printer */ { if( hb_stricmp( hb_set.HB_SET_DEVICE, "PRINTER" ) == 0 && hb_set.hb_set_printhan != FS_ERROR ) { USHORT user_ferror = hb_fsError(); /* Save current user file error code */ hb_fsWrite( hb_set.hb_set_printhan, ( BYTE * ) "\x0C\x0D", 2 ); - s_uiPRow = s_uiPCol = 0; hb_fsSetError( user_ferror ); /* Restore last user file error code */ } + + s_uiPRow = s_uiPCol = 0; } HARBOUR HB_PROW( void ) /* Returns the current printer row position */ @@ -738,12 +712,12 @@ HARBOUR HB_DISPBOX( void ) #else if( ISNUM( 1 ) && ISNUM( 2 ) && ISNUM( 3 ) && ISNUM( 4 ) ) { - char * szBorderStyle = B_SINGLE; + char * szBorderStyle = _B_SINGLE; int i_top = hb_parni( 1 ); int i_left = hb_parni( 2 ); int i_bottom = hb_parni( 3 ); int i_right = hb_parni( 4 ); - USHORT top, left, bottom, right, size = strlen( B_SINGLE ); + USHORT top, left, bottom, right, size = strlen( _B_SINGLE ); USHORT row, col, width, height; char Borders[ 9 ]; @@ -786,16 +760,16 @@ HARBOUR HB_DISPBOX( void ) switch( hb_parni( 5 ) ) { case 2: - szBorderStyle = B_DOUBLE; + szBorderStyle = _B_DOUBLE; break; case 3: - szBorderStyle = B_SINGLE_DOUBLE; + szBorderStyle = _B_SINGLE_DOUBLE; break; case 4: - szBorderStyle = B_DOUBLE_SINGLE; + szBorderStyle = _B_DOUBLE_SINGLE; break; default: - szBorderStyle = B_SINGLE; + szBorderStyle = _B_SINGLE; } size = strlen( szBorderStyle ); } @@ -820,7 +794,7 @@ HARBOUR HB_DISPBOX( void ) Borders[ 8 ] = ' '; /* Draw the box */ - hb_setpos( top, left ); + hb_gtSetPos( top, left ); if( height > 1 && width > 1 ) fputc( Borders[ 0 ], stdout ); /* Upper left corner */ for( col = ( height > 1 ? left + 1 : left ); col < ( height > 1 ? right : right + 1 ); col++ ) @@ -829,7 +803,7 @@ HARBOUR HB_DISPBOX( void ) fputc( Borders[ 2 ], stdout ); /* Upper right corner */ for( row = ( height > 1 ? top + 1 : top ); row < ( width > 1 ? bottom : bottom + 1 ); row++ ) { - hb_setpos( row, left ); + hb_gtSetPos( row, left ); if( height > 1 ) fputc( Borders[ 3 ], stdout ); /* Left side */ if( height > 1 && width > 1 ) for( col = left + 1; col < right; col++ ) @@ -839,7 +813,7 @@ HARBOUR HB_DISPBOX( void ) } if( height > 1 && width > 1 ) { - hb_setpos( bottom, left ); + hb_gtSetPos( bottom, left ); col = left; fputc( Borders[ 6 ], stdout ); /* Bottom left corner */ for( col = left + 1; col < right; col++ ) @@ -847,7 +821,7 @@ HARBOUR HB_DISPBOX( void ) fputc( Borders[ 4 ], stdout ); /* Bottom right corner */ } fflush( stdout ); - hb_setpos( bottom + 1, right + 1 ); + hb_gtSetPos( bottom + 1, right + 1 ); } #endif } @@ -901,14 +875,10 @@ HARBOUR HB_SAVESCREEN( void ) USHORT uiCoords[ 4 ]; void * pBuffer; - uiCoords[ 0 ] = 0; - uiCoords[ 1 ] = 0; - uiCoords[ 2 ] = hb_gtMaxRow(); - uiCoords[ 3 ] = hb_gtMaxCol(); - - for( uiX = 1; uiX <= 4; uiX++ ) - if( ISNUM( uiX ) ) - uiCoords[ uiX - 1 ] = hb_parni( uiX ); + uiCoords[ 0 ] = ISNUM( 1 ) ? hb_parni( 1 ) : 0; + uiCoords[ 1 ] = ISNUM( 2 ) ? hb_parni( 2 ) : 0; + uiCoords[ 2 ] = ISNUM( 3 ) ? hb_parni( 3 ) : hb_gtMaxRow(); + uiCoords[ 3 ] = ISNUM( 4 ) ? hb_parni( 4 ) : hb_gtMaxCol(); hb_gtRectSize( uiCoords[ 0 ], uiCoords[ 1 ], uiCoords[ 2 ], uiCoords[ 3 ], &uiX ); pBuffer = hb_xgrab( uiX ); @@ -919,21 +889,12 @@ HARBOUR HB_SAVESCREEN( void ) HARBOUR HB_RESTSCREEN( void ) { - if( hb_pcount() >= 5 ) + if( ISCHAR( 5 ) ) { - USHORT uiX; - USHORT uiCoords[ 4 ]; - - uiCoords[ 0 ] = 0; - uiCoords[ 1 ] = 0; - uiCoords[ 2 ] = hb_gtMaxRow(); - uiCoords[ 3 ] = hb_gtMaxCol(); - - for( uiX = 1; uiX < 5; uiX++ ) - if( ISNUM( uiX ) ) - uiCoords[ uiX - 1 ] = hb_parni( uiX ); - - hb_gtRest( uiCoords[ 0 ], uiCoords[ 1 ], uiCoords[ 2 ], uiCoords[ 3 ], + hb_gtRest( ISNUM( 1 ) ? hb_parni( 1 ) : 0, + ISNUM( 2 ) ? hb_parni( 2 ) : 0, + ISNUM( 3 ) ? hb_parni( 3 ) : hb_gtMaxRow(), + ISNUM( 4 ) ? hb_parni( 4 ) : hb_gtMaxCol(), ( void * ) hb_parc( 5 ) ); } } @@ -1033,16 +994,16 @@ HARBOUR HB_HB_COLORINDEX( void ) { if( ISCHAR( 1 ) && ISNUM( 2 ) ) { - char * szColor = hb_parc( 1 ); + char * pszColor = hb_parc( 1 ); ULONG ulColorPos; ULONG ulColorLen; USHORT uiColorIndex = ( USHORT ) hb_parni( 2 ); /* Skip the given number of commas */ - for( ulColorPos = 0 ; szColor[ ulColorPos ] != '\0' && uiColorIndex > 0 ; ulColorPos++ ) + for( ulColorPos = 0 ; pszColor[ ulColorPos ] != '\0' && uiColorIndex > 0 ; ulColorPos++ ) { - if( szColor[ ulColorPos ] == ',' ) + if( pszColor[ ulColorPos ] == ',' ) uiColorIndex--; } @@ -1052,23 +1013,23 @@ HARBOUR HB_HB_COLORINDEX( void ) { /* Skip the spaces after the comma */ - while( szColor[ ulColorPos ] == ' ' ) ulColorPos++; + while( pszColor[ ulColorPos ] == ' ' ) ulColorPos++; /* Search for next comma or end of string */ ulColorLen = 0; - while( szColor[ ulColorPos + ulColorLen ] != '\0' && - szColor[ ulColorPos + ulColorLen ] != ',' ) ulColorLen++; + while( pszColor[ ulColorPos + ulColorLen ] != '\0' && + pszColor[ ulColorPos + ulColorLen ] != ',' ) ulColorLen++; /* Skip the trailing spaces */ while( ulColorLen > 0 && - szColor[ ulColorPos + ulColorLen - 1 ] == ' ' ) ulColorLen--; + pszColor[ ulColorPos + ulColorLen - 1 ] == ' ' ) ulColorLen--; /* Return the string */ - hb_retclen( szColor + ulColorPos, ulColorLen ); + hb_retclen( pszColor + ulColorPos, ulColorLen ); } else hb_retc( "" ); diff --git a/harbour/source/rtl/gt/gt_tpl.c b/harbour/source/rtl/gt/gt_tpl.c index 2bc80e937f..ca0961b458 100644 --- a/harbour/source/rtl/gt/gt_tpl.c +++ b/harbour/source/rtl/gt/gt_tpl.c @@ -86,17 +86,17 @@ USHORT hb_gt_GetScreenHeight( void ) return 0; } -void hb_gt_SetPos( USHORT uiRow, USHORT uiCol ) +void hb_gt_SetPos( SHORT iRow, SHORT iCol ) { - HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetPos(%hu, %hu)", uiRow, uiCol)); + HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetPos(%hd, %hd)", iRow, iCol)); /* TODO: How to reposition the cursor? */ - HB_SYMBOL_UNUSED( uiRow ); - HB_SYMBOL_UNUSED( uiCol ); + HB_SYMBOL_UNUSED( iRow ); + HB_SYMBOL_UNUSED( iCol ); } -USHORT hb_gt_Col( void ) +SHORT hb_gt_Col( void ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_Col()")); @@ -104,7 +104,7 @@ USHORT hb_gt_Col( void ) return 0; } -USHORT hb_gt_Row( void ) +SHORT hb_gt_Row( void ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_Row()")); diff --git a/harbour/source/rtl/gt/gtcrs.c b/harbour/source/rtl/gt/gtcrs.c index 56b3c69429..b44adbe7b9 100644 --- a/harbour/source/rtl/gt/gtcrs.c +++ b/harbour/source/rtl/gt/gtcrs.c @@ -44,20 +44,20 @@ static void gt_SetRC(int r, int c); void hb_gt_Init( void ) { - HB_TRACE(HB_TR_DEBUG, ("hb_gt_Init()")); + HB_TRACE(HB_TR_DEBUG, ("hb_gt_Init()")); - initscr(); - cbreak(); - noecho(); - nodelay(stdscr, 1); + initscr(); + cbreak(); + noecho(); + nodelay(stdscr, 1); } void hb_gt_Done( void ) { - HB_TRACE(HB_TR_DEBUG, ("hb_gt_Done()")); + HB_TRACE(HB_TR_DEBUG, ("hb_gt_Done()")); - refresh(); - endwin(); + refresh(); + endwin(); } int hb_gt_ReadKey( void ) @@ -76,72 +76,72 @@ int hb_gt_ReadKey( void ) BOOL hb_gt_IsColor( void ) { - HB_TRACE(HB_TR_DEBUG, ("hb_gt_IsColor()")); + HB_TRACE(HB_TR_DEBUG, ("hb_gt_IsColor()")); - /* TODO: How to detect this? */ - return TRUE; + /* TODO: How to detect this? */ + return TRUE; } USHORT hb_gt_GetScreenWidth( void ) { - int r, c; - - HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetScreenWidth()")); - - gt_GetMaxRC(&r, &c); - return c; + int r, c; + + HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetScreenWidth()")); + + gt_GetMaxRC(&r, &c); + return c; } USHORT hb_gt_GetScreenHeight( void ) { - int r, c; - - HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetScreenHeight()")); - - gt_GetMaxRC(&r, &c); - return r; + int r, c; + + HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetScreenHeight()")); + + gt_GetMaxRC(&r, &c); + return r; } -void hb_gt_SetPos( USHORT uiRow, USHORT uiCol ) +void hb_gt_SetPos( SHORT iRow, SHORT iCol ) { - HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetPos(%hu, %hu)", uiRow, uiCol)); - - gt_SetRC(uiRow, uiCol); + HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetPos(%hd, %hd)", iRow, iCol)); + + gt_SetRC(iRow, iCol); } -USHORT hb_gt_Col( void ) +SHORT hb_gt_Col( void ) { - int r, c; - - HB_TRACE(HB_TR_DEBUG, ("hb_gt_Col()")); - - gt_GetRC(&r, &c); - return c; + int r, c; + + HB_TRACE(HB_TR_DEBUG, ("hb_gt_Col()")); + + gt_GetRC(&r, &c); + return c; } -USHORT hb_gt_Row( void ) +SHORT hb_gt_Row( void ) { - int r, c; - - HB_TRACE(HB_TR_DEBUG, ("hb_gt_Row()")); - - gt_GetRC(&r, &c); - return r; + int r, c; + + HB_TRACE(HB_TR_DEBUG, ("hb_gt_Row()")); + + gt_GetRC(&r, &c); + return r; } USHORT hb_gt_GetCursorStyle( void ) { - HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetCursorStyle()")); - - /* TODO: What shape is the cursor? */ - return 0; + HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetCursorStyle()")); + + /* TODO: What shape is the cursor? */ + return 0; } void hb_gt_SetCursorStyle( USHORT uiStyle ) { - HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetCursorStyle(%hu)", uiStyle)); - - /* TODO: How to set the cursor shape? */ + HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetCursorStyle(%hu)", uiStyle)); + + /* TODO: How to set the cursor shape? */ } void hb_gt_Puts( USHORT uiRow, @@ -150,14 +150,13 @@ void hb_gt_Puts( USHORT uiRow, BYTE * pbyStr, ULONG ulLen ) { - ULONG i; - - HB_TRACE(HB_TR_DEBUG, ("hb_gt_Puts(%hu, %hu, %d, %p, %lu)", uiRow, uiCol, (int) byAttr, pbyStr, ulLen)); - - move(uiRow, uiCol); - for (i = 0; i < ulLen; ++i) { - addch(pbyStr[i]); - } + ULONG i; + + HB_TRACE(HB_TR_DEBUG, ("hb_gt_Puts(%hu, %hu, %d, %p, %lu)", uiRow, uiCol, (int) byAttr, pbyStr, ulLen)); + + move( uiRow, uiCol ); + for( i = 0; i < ulLen; ++i ) + addch( pbyStr[ i ] ); } void hb_gt_GetText( USHORT uiTop, @@ -166,9 +165,9 @@ void hb_gt_GetText( USHORT uiTop, USHORT uiRight, BYTE * pbyDst ) { - HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetText(%hu, %hu, %hu, %hu, %p)", uiTop, uiLeft, uiBottom, uiRight, pbyDst)); - - /* TODO */ + HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetText(%hu, %hu, %hu, %hu, %p)", uiTop, uiLeft, uiBottom, uiRight, pbyDst)); + + /* TODO */ } void hb_gt_PutText( USHORT uiTop, @@ -177,9 +176,9 @@ void hb_gt_PutText( USHORT uiTop, USHORT uiRight, BYTE * pbySrc ) { - HB_TRACE(HB_TR_DEBUG, ("hb_gt_PutText(%hu, %hu, %hu, %hu, %p)", uiTop, uiLeft, uiBottom, uiRight, pbySrc)); + HB_TRACE(HB_TR_DEBUG, ("hb_gt_PutText(%hu, %hu, %hu, %hu, %p)", uiTop, uiLeft, uiBottom, uiRight, pbySrc)); - /* TODO */ + /* TODO */ } void hb_gt_SetAttribute( USHORT uiTop, @@ -188,12 +187,12 @@ void hb_gt_SetAttribute( USHORT uiTop, USHORT uiRight, BYTE byAttr ) { - HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetAttribute(%hu, %hu, %hu, %hu, %d)", uiTop, uiLeft, uiBottom, uiRight, (int) byAttr)); - - /* TODO: we want to take a screen that is say bright white on blue, - and change the attributes only for a section of the screen - to white on black. - */ + HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetAttribute(%hu, %hu, %hu, %hu, %d)", uiTop, uiLeft, uiBottom, uiRight, (int) byAttr)); + + /* TODO: we want to take a screen that is say bright white on blue, + and change the attributes only for a section of the screen + to white on black. + */ } void hb_gt_Scroll( USHORT uiTop, @@ -204,86 +203,86 @@ void hb_gt_Scroll( USHORT uiTop, SHORT iRows, SHORT iCols ) { - HB_TRACE(HB_TR_DEBUG, ("hb_gt_Scroll(%hu, %hu, %hu, %hu, %d, %hd, %hd)", uiTop, uiLeft, uiBottom, uiRight, (int) byAttr, iRows, iCols)); - - /* TODO */ + HB_TRACE(HB_TR_DEBUG, ("hb_gt_Scroll(%hu, %hu, %hu, %hu, %d, %hd, %hd)", uiTop, uiLeft, uiBottom, uiRight, (int) byAttr, iRows, iCols)); + + /* TODO */ } void hb_gt_DispBegin( void ) { - HB_TRACE(HB_TR_DEBUG, ("hb_gt_DispBegin()")); - - /* TODO: Is there a way to change screen buffers? - ie: can we write somewhere without it going to the screen - and then update the screen from this buffer at a later time? - We will initially want to copy the current screen to this buffer. - */ + HB_TRACE(HB_TR_DEBUG, ("hb_gt_DispBegin()")); + + /* TODO: Is there a way to change screen buffers? + ie: can we write somewhere without it going to the screen + and then update the screen from this buffer at a later time? + We will initially want to copy the current screen to this buffer. + */ } void hb_gt_DispEnd() { - HB_TRACE(HB_TR_DEBUG, ("hb_gt_DispEnd()")); - - /* TODO: here we flush the buffer, and restore normal screen writes */ + 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: How to change the size of the screen? */ - return TRUE; + HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetMode(%hu, %hu)", uiRows, uiCols)); + + /* TODO: How to change the size of the screen? */ + return TRUE; } void hb_gt_Replicate( BYTE byChar, ULONG ulLen ) { - HB_TRACE(HB_TR_DEBUG, ("hb_gt_Replicate(%d, %lu)", (int) byChar, 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. - */ - + HB_TRACE(HB_TR_DEBUG, ("hb_gt_Replicate(%d, %lu)", (int) byChar, 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: under dos, the background 'intensity' bit can be switched - from intensity to 'blinking' - does this work under your platform? - */ - return FALSE; + HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetBlink()")); + + /* TODO: under dos, the background 'intensity' bit can be switched + from intensity to 'blinking' + does this work under your platform? + */ + return FALSE; } void hb_gt_SetBlink( BOOL bBlink ) { - HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetBlink(%d)", (int) bBlink)); - - /* TODO: set the bit if it's supported */ + HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetBlink(%d)", (int) bBlink)); + + /* TODO: set the bit if it's supported */ } static void gt_GetMaxRC(int* r, int* c) { - int y, x; - getmaxyx(stdscr, y, x); - *r = y; - *c = x; + int y, x; + getmaxyx(stdscr, y, x); + *r = y; + *c = x; } static void gt_GetRC(int* r, int* c) { - int y, x; - getyx(stdscr, y, x); - *r = y; - *c = x; + int y, x; + getyx(stdscr, y, x); + *r = y; + *c = x; } static void gt_SetRC(int r, int c) { - move(r, c); - refresh(); + move(r, c); + refresh(); } diff --git a/harbour/source/rtl/gt/gtdos.c b/harbour/source/rtl/gt/gtdos.c index f568de5844..01c3ba3769 100644 --- a/harbour/source/rtl/gt/gtdos.c +++ b/harbour/source/rtl/gt/gtdos.c @@ -264,15 +264,15 @@ USHORT hb_gt_GetScreenHeight( void ) #endif } -void hb_gt_SetPos( USHORT usRow, USHORT usCol ) +void hb_gt_SetPos( SHORT iRow, SHORT iCol ) { - HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetPos(%hu, %hu)", usRow, usCol)); + HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetPos(%hd, %hd)", iRow, iCol)); #if defined(__TURBOC__) { BYTE cRow, cCol; - cRow = ( BYTE ) usRow; - cCol = ( BYTE ) usCol; + cRow = ( BYTE ) iRow; + cCol = ( BYTE ) iCol; _AH = 0x02; _BH = 0; @@ -285,8 +285,8 @@ void hb_gt_SetPos( USHORT usRow, USHORT usCol ) union REGS regs; regs.h.ah = 0x02; regs.h.bh = 0; - regs.h.dh = ( BYTE ) usRow; - regs.h.dl = ( BYTE ) usCol; + regs.h.dh = ( BYTE ) iRow; + regs.h.dl = ( BYTE ) iCol; #if defined(__WATCOMC__) && defined(__386__) int386( 0x10, ®s, ®s ); #else @@ -578,7 +578,7 @@ void hb_gt_SetAttribute( USHORT usTop, USHORT usLeft, USHORT usBottom, USHORT us } } -USHORT hb_gt_Col( void ) +SHORT hb_gt_Col( void ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_Col()")); @@ -604,7 +604,7 @@ USHORT hb_gt_Col( void ) #endif } -USHORT hb_gt_Row( void ) +SHORT hb_gt_Row( void ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_Row()")); diff --git a/harbour/source/rtl/gt/gtos2.c b/harbour/source/rtl/gt/gtos2.c index 01561c903e..12c1e9b144 100644 --- a/harbour/source/rtl/gt/gtos2.c +++ b/harbour/source/rtl/gt/gtos2.c @@ -110,31 +110,31 @@ USHORT hb_gt_GetScreenHeight( void ) return vi.row; } -void hb_gt_SetPos( USHORT uiRow, USHORT uiCol ) +void hb_gt_SetPos( SHORT iRow, SHORT iCol ) { - HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetPos(%hu, %hu)", uiRow, uiCol)); + HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetPos(%hd, %hd)", iRow, iCol)); - VioSetCurPos( uiRow, uiCol, 0 ); + VioSetCurPos( ( USHORT ) iRow, ( USHORT ) iCol, 0 ); } -USHORT hb_gt_Row( void ) +SHORT hb_gt_Row( void ) { USHORT x, y; HB_TRACE(HB_TR_DEBUG, ("hb_gt_Row()")); VioGetCurPos( &y, &x, 0 ); - return y; + return ( SHORT ) y; } -USHORT hb_gt_Col( void ) +SHORT hb_gt_Col( void ) { USHORT x, y; HB_TRACE(HB_TR_DEBUG, ("hb_gt_Col()")); VioGetCurPos( &y, &x, 0 ); - return x; + return ( SHORT ) x; } diff --git a/harbour/source/rtl/gt/gtsln.c b/harbour/source/rtl/gt/gtsln.c index 9cd8782ee3..5c44080e2b 100644 --- a/harbour/source/rtl/gt/gtsln.c +++ b/harbour/source/rtl/gt/gtsln.c @@ -92,21 +92,21 @@ USHORT hb_gt_GetScreenHeight( void ) return SLtt_Screen_Rows; } -void hb_gt_SetPos( USHORT uiRow, USHORT uiCol ) +void hb_gt_SetPos( SHORT iRow, SHORT iCol ) { - HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetPos(%hu, %hu)", uiRow, uiCol)); + HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetPos(%hd, %hd)", iRow, iCol)); - SLsmg_gotorc(uiRow, uiCol); + SLsmg_gotorc(iRow, iCol); } -USHORT hb_gt_Col( void ) +SHORT hb_gt_Col( void ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_Col()")); return SLsmg_get_column(); } -USHORT hb_gt_Row( void ) +SHORT hb_gt_Row( void ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_Row()")); diff --git a/harbour/source/rtl/gt/gtstd.c b/harbour/source/rtl/gt/gtstd.c index e78bfb3d95..f0f1c08e27 100644 --- a/harbour/source/rtl/gt/gtstd.c +++ b/harbour/source/rtl/gt/gtstd.c @@ -37,6 +37,7 @@ /* TODO: include any standard headers here */ +#include "hbapifs.h" #include "hbapigt.h" static SHORT s_iRow; @@ -45,6 +46,8 @@ static USHORT s_uiMaxRow; 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 ) { @@ -60,6 +63,8 @@ void hb_gt_Init( void ) s_uiMaxCol = 80; s_uiCursorStyle = SC_NORMAL; s_bBlink = FALSE; + s_iFilenoStdout = fileno( stdout ); + hb_fsSetDevMode( s_iFilenoStdout, FD_BINARY ); } void hb_gt_Done( void ) @@ -97,22 +102,44 @@ USHORT hb_gt_GetScreenHeight( void ) return s_uiMaxRow; } -void hb_gt_SetPos( USHORT uiRow, USHORT uiCol ) +void hb_gt_SetPos( SHORT iRow, SHORT iCol ) { - HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetPos(%hu, %hu)", uiRow, uiCol)); + SHORT iCount; + SHORT iDevRow = s_iRow; + SHORT iDevCol = s_iCol; - s_iCol = ( SHORT ) uiCol; - s_iRow = ( SHORT ) uiRow; + char * szCrLf = hb_consoleGetNewLine(); + + HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetPos(%hd, %hd)", iRow, iCol)); + + if( iRow < iDevRow || iCol < iDevCol ) + { + fputs( hb_consoleGetNewLine(), stdout ); + iDevCol = 0; + iDevRow++; + } + else if( iRow > iDevRow ) + iDevCol = 0; + + for( iCount = iDevRow; iCount < iRow; iCount++ ) + fputs( hb_consoleGetNewLine(), stdout ); + for( iCount = iDevCol; iCount < iCol; iCount++ ) + fputc( ' ', stdout ); + + fflush( stdout ); + + s_iRow = iRow; + s_iCol = iCol; } -USHORT hb_gt_Col( void ) +SHORT hb_gt_Col( void ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_Col()")); return s_iCol; } -USHORT hb_gt_Row( void ) +SHORT hb_gt_Row( void ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_Row()")); diff --git a/harbour/source/rtl/gt/gtwin.c b/harbour/source/rtl/gt/gtwin.c index 21017801e0..0ff61507aa 100644 --- a/harbour/source/rtl/gt/gtwin.c +++ b/harbour/source/rtl/gt/gtwin.c @@ -257,14 +257,14 @@ USHORT hb_gt_GetScreenHeight( void ) return max( csbi.dwSize.Y, 25 ); } -void hb_gt_SetPos( USHORT uiRow, USHORT uiCol ) +void hb_gt_SetPos( SHORT iRow, SHORT iCol ) { COORD dwCursorPosition; - HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetPos(%hu, %hu)", uiRow, uiCol)); + HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetPos(%hd, %hd)", iRow, iCol)); - dwCursorPosition.X = ( SHORT ) uiCol; - dwCursorPosition.Y = ( SHORT ) uiRow; + dwCursorPosition.X = iCol; + dwCursorPosition.Y = iRow; SetConsoleCursorPosition( s_HActive, dwCursorPosition ); } @@ -459,7 +459,7 @@ void hb_gt_SetAttribute( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT ui } } -USHORT hb_gt_Col( void ) +SHORT hb_gt_Col( void ) { CONSOLE_SCREEN_BUFFER_INFO csbi; @@ -470,7 +470,7 @@ USHORT hb_gt_Col( void ) return csbi.dwCursorPosition.X; } -USHORT hb_gt_Row( void ) +SHORT hb_gt_Row( void ) { CONSOLE_SCREEN_BUFFER_INFO csbi; diff --git a/harbour/source/rtl/gtapi.c b/harbour/source/rtl/gtapi.c index 41f9b08b03..e1995d15f1 100644 --- a/harbour/source/rtl/gtapi.c +++ b/harbour/source/rtl/gtapi.c @@ -34,9 +34,8 @@ */ /* - * GTAPI.C: Generic Terminal for Harbour + * ChangeLog: * - * Latest mods: * 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 @@ -153,6 +152,7 @@ void hb_gtInit( void ) hb_gt_Init(); hb_gtSetColorStr( hb_set.HB_SET_COLOR ); + s_iCurrentRow = hb_gt_Row(); s_iCurrentCol = hb_gt_Col(); } @@ -285,12 +285,12 @@ USHORT hb_gtBox( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, B USHORT hb_gtBoxD( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight ) { - return hb_gtBox( uiTop, uiLeft, uiBottom, uiRight, ( BYTE * ) B_DOUBLE ); + return hb_gtBox( uiTop, uiLeft, uiBottom, uiRight, ( BYTE * ) _B_DOUBLE ); } USHORT hb_gtBoxS( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight ) { - return hb_gtBox( uiTop, uiLeft, uiBottom, uiRight, ( BYTE * ) B_SINGLE ); + return hb_gtBox( uiTop, uiLeft, uiBottom, uiRight, ( BYTE * ) _B_SINGLE ); } USHORT hb_gtColorSelect( USHORT uiColorIndex ) @@ -670,7 +670,7 @@ USHORT hb_gtGetPos( SHORT * piRow, SHORT * piCol ) USHORT hb_gtSetPos( SHORT iRow, SHORT iCol ) { - BOOL set_cursor = TRUE; + BOOL set_cursor; HB_TRACE(HB_TR_DEBUG, ("hb_gtSetPos(%hd, %hd)", iRow, iCol)); @@ -681,6 +681,8 @@ USHORT hb_gtSetPos( SHORT iRow, SHORT iCol ) hb_gt_SetCursorStyle( SC_NONE ); set_cursor = FALSE; } + else + set_cursor = TRUE; if( set_cursor ) hb_gt_SetPos( iRow, iCol ); @@ -805,7 +807,7 @@ USHORT hb_gtSetSnowFlag( BOOL bNoSnow ) { HB_TRACE(HB_TR_DEBUG, ("hb_gtSetSnowFlag(%d)", (int) bNoSnow)); - /* COMMENT: This is a compatibility function. + /* NOTE: This is a compatibility function. If you're running on a CGA and snow is a problem speak up! */