20000412-10:06 GMT+1 Victor Szakats <info@szelvesz.hu>
This commit is contained in:
@@ -1,7 +1,25 @@
|
||||
20000412-10:06 GMT+1 Victor Szakats <info@szelvesz.hu>
|
||||
|
||||
* include/inkey.ch
|
||||
* source/rtl/inkey.c
|
||||
* source/rtl/gtdos/gtdos.c
|
||||
* source/rtl/gtos2/gtos2.c
|
||||
* source/rtl/gtwin/gtwin.c
|
||||
* tests/inkeytst.prg
|
||||
* INKEY_EXTENDED renamed to INKEY_RAW to better show its purpose.
|
||||
|
||||
* source/rtl/console.c
|
||||
% hb_conOut() one variable removed.
|
||||
% DISPOUT(), DISPOUTAT() optimized for speed, they got larger though.
|
||||
hb_conOutDisp() removed.
|
||||
|
||||
* source/rtl/dateshb.c
|
||||
* Some code put in blocks.
|
||||
|
||||
20000412-04:39 GMT+1 Victor Szakats <info@szelvesz.hu>
|
||||
|
||||
* source/rtl/gtapi.c
|
||||
+ hb_gtGetColorStr() fixed.
|
||||
! hb_gtGetColorStr() fixed.
|
||||
|
||||
20000412-03:14 GMT+1 Victor Szakats <info@szelvesz.hu>
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
#define INKEY_RUP 16
|
||||
#define INKEY_KEYBOARD 128
|
||||
#define INKEY_ALL 159
|
||||
#define INKEY_EXTENDED 256
|
||||
#define INKEY_RAW 256
|
||||
|
||||
/* Mouse events */
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
*
|
||||
* Copyright 1999 David G. Holm <dholm@jsd-llc.com>
|
||||
* hb_conOutAlt(), hb_conOutDev(), DEVOUT(), hb_conDevPos(),
|
||||
* DEVPOS(), hb_conOutDisp(), __EJECT(),
|
||||
* DEVPOS(), __EJECT(),
|
||||
* hb_conOut(), hb_conOutErr(), OUTERR(),
|
||||
* hb_conOutStd(), OUTSTD(), PCOL(), PROW(),
|
||||
* SETPRC(), and hb_conInit()
|
||||
@@ -159,15 +159,13 @@ typedef void hb_out_func_typedef( char *, ULONG );
|
||||
/* Format items for output, then call specified output function */
|
||||
static void hb_conOut( USHORT uiParam, hb_out_func_typedef * pOutFunc )
|
||||
{
|
||||
PHB_ITEM pItem;
|
||||
char * pszString;
|
||||
ULONG ulLen;
|
||||
BOOL bFreeReq;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_conOut(%hu, %p)", uiParam, pOutFunc));
|
||||
|
||||
pItem = hb_param( uiParam, HB_IT_ANY );
|
||||
pszString = hb_itemString( pItem, &ulLen, &bFreeReq );
|
||||
pszString = hb_itemString( hb_param( uiParam, HB_IT_ANY ), &ulLen, &bFreeReq );
|
||||
|
||||
pOutFunc( pszString, ulLen );
|
||||
|
||||
@@ -271,18 +269,8 @@ static void hb_conOutDev( char * pStr, ULONG ulLen )
|
||||
s_uiPCol += ( USHORT ) ulLen;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Otherwise, display to console */
|
||||
hb_gtWrite( ( BYTE * ) pStr, ulLen );
|
||||
}
|
||||
}
|
||||
|
||||
/* Output an item to the screen */
|
||||
static void hb_conOutDisp( char * pStr, ULONG ulLen )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_conOutDisp(%s, %lu)", pStr, ulLen));
|
||||
|
||||
hb_gtWrite( ( BYTE * ) pStr, ulLen );
|
||||
}
|
||||
|
||||
HB_FUNC( OUTSTD ) /* writes a list of values to the standard output device */
|
||||
@@ -445,6 +433,10 @@ HB_FUNC( DEVOUT ) /* writes a single value to the current device (screen or prin
|
||||
|
||||
HB_FUNC( DISPOUT ) /* writes a single value to the screen, but is not affected by SET ALTERNATE */
|
||||
{
|
||||
char * pszString;
|
||||
ULONG ulLen;
|
||||
BOOL bFreeReq;
|
||||
|
||||
if( ISCHAR( 2 ) )
|
||||
{
|
||||
char szOldColor[ CLR_STRLEN ];
|
||||
@@ -452,20 +444,35 @@ HB_FUNC( DISPOUT ) /* writes a single value to the screen, but is not affected b
|
||||
hb_gtGetColorStr( szOldColor );
|
||||
hb_gtSetColorStr( hb_parc( 2 ) );
|
||||
|
||||
hb_conOut( 1, hb_conOutDisp );
|
||||
pszString = hb_itemString( hb_param( 1, HB_IT_ANY ), &ulLen, &bFreeReq );
|
||||
|
||||
hb_gtWrite( ( BYTE * ) pszString, ulLen );
|
||||
|
||||
if( bFreeReq )
|
||||
hb_xfree( pszString );
|
||||
|
||||
hb_gtSetColorStr( szOldColor );
|
||||
}
|
||||
else if( hb_pcount() >= 1 )
|
||||
hb_conOut( 1, hb_conOutDisp );
|
||||
{
|
||||
pszString = hb_itemString( hb_param( 1, HB_IT_ANY ), &ulLen, &bFreeReq );
|
||||
|
||||
hb_gtWrite( ( BYTE * ) pszString, ulLen );
|
||||
|
||||
if( bFreeReq )
|
||||
hb_xfree( pszString );
|
||||
}
|
||||
}
|
||||
|
||||
/* Undocumented Clipper function */
|
||||
|
||||
/* NOTE: Clipper does no checks about the screen positions. [vszakats] */
|
||||
|
||||
HB_FUNC( DISPOUTAT ) /* writes a single value to the screen at speficic position, but is not affected by SET ALTERNATE */
|
||||
{
|
||||
/* NOTE: Clipper does no checks here. [vszakats] */
|
||||
hb_gtSetPos( hb_parni( 1 ), hb_parni( 2 ) );
|
||||
char * pszString;
|
||||
ULONG ulLen;
|
||||
BOOL bFreeReq;
|
||||
|
||||
if( ISCHAR( 4 ) )
|
||||
{
|
||||
@@ -473,12 +480,23 @@ HB_FUNC( DISPOUTAT ) /* writes a single value to the screen at speficic position
|
||||
|
||||
hb_gtGetColorStr( szOldColor );
|
||||
hb_gtSetColorStr( hb_parc( 4 ) );
|
||||
|
||||
hb_conOut( 3, hb_conOutDisp );
|
||||
|
||||
pszString = hb_itemString( hb_param( 3, HB_IT_ANY ), &ulLen, &bFreeReq );
|
||||
|
||||
hb_gtWriteAt( hb_parni( 1 ), hb_parni( 2 ), ( BYTE * ) pszString, ulLen );
|
||||
|
||||
if( bFreeReq )
|
||||
hb_xfree( pszString );
|
||||
|
||||
hb_gtSetColorStr( szOldColor );
|
||||
}
|
||||
else if( hb_pcount() >= 3 )
|
||||
hb_conOut( 3, hb_conOutDisp );
|
||||
{
|
||||
pszString = hb_itemString( hb_param( 3, HB_IT_ANY ), &ulLen, &bFreeReq );
|
||||
|
||||
hb_gtWriteAt( hb_parni( 1 ), hb_parni( 2 ), ( BYTE * ) pszString, ulLen );
|
||||
|
||||
if( bFreeReq )
|
||||
hb_xfree( pszString );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -301,18 +301,22 @@ HB_FUNC( TIME )
|
||||
{
|
||||
char szResult[ 9 ];
|
||||
|
||||
#if defined(HB_OS_WIN_32)
|
||||
#if defined(HB_OS_WIN_32)
|
||||
{
|
||||
SYSTEMTIME st;
|
||||
GetLocalTime( &st );
|
||||
sprintf( szResult, "%02d:%02d:%02d", st.wHour, st.wMinute, st.wSecond );
|
||||
#else
|
||||
}
|
||||
#else
|
||||
{
|
||||
time_t t;
|
||||
struct tm * oTime;
|
||||
|
||||
time( &t );
|
||||
oTime = localtime( &t );
|
||||
sprintf( szResult, "%02d:%02d:%02d", oTime->tm_hour, oTime->tm_min, oTime->tm_sec );
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
hb_retclen( szResult, 8 );
|
||||
}
|
||||
@@ -321,18 +325,22 @@ HB_FUNC( DATE )
|
||||
{
|
||||
char szResult[ 9 ];
|
||||
|
||||
#if defined(HB_OS_WIN_32)
|
||||
#if defined(HB_OS_WIN_32)
|
||||
{
|
||||
SYSTEMTIME st;
|
||||
GetLocalTime( &st );
|
||||
sprintf( szResult, "%04d%02d%02d", st.wYear, st.wMonth, st.wDay );
|
||||
#else
|
||||
}
|
||||
#else
|
||||
{
|
||||
time_t t;
|
||||
struct tm * oTime;
|
||||
|
||||
time( &t );
|
||||
oTime = localtime( &t );
|
||||
sprintf( szResult, "%04d%02d%02d", oTime->tm_year + 1900, oTime->tm_mon + 1, oTime->tm_mday );
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
hb_retds( szResult );
|
||||
}
|
||||
|
||||
@@ -279,8 +279,6 @@ USHORT hb_gtColorSelect( USHORT uiColorIndex )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_gtColorSelect(%hu)", uiColorIndex));
|
||||
|
||||
/* NOTE: CA-Cl*pper is not checking the limits here. [vszakats] */
|
||||
|
||||
if( uiColorIndex <= s_uiColorCount )
|
||||
{
|
||||
s_uiColorIndex = uiColorIndex;
|
||||
|
||||
@@ -245,7 +245,7 @@ int hb_gt_ReadKey( HB_inkey_enum eventmask )
|
||||
{
|
||||
/* A key code is available in the BIOS keyboard buffer, so read it */
|
||||
#if defined(__DJGPP__)
|
||||
if( eventmask & INKEY_EXTENDED ) ch = getxkey();
|
||||
if( eventmask & INKEY_RAW ) ch = getxkey();
|
||||
else ch = getkey();
|
||||
if( ch == 256 )
|
||||
/* Ignore Ctrl+Break, because it is being handled as soon as it
|
||||
@@ -267,7 +267,7 @@ int hb_gt_ReadKey( HB_inkey_enum eventmask )
|
||||
the actual function key and then offset it by 256,
|
||||
unless extended keyboard events are allowed, in which
|
||||
case offset it by 512 */
|
||||
if( eventmask & INKEY_EXTENDED ) ch = getch() + 512;
|
||||
if( eventmask & INKEY_RAW ) ch = getch() + 512;
|
||||
else ch = getch() + 256;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -178,7 +178,7 @@ int hb_gt_ReadKey( HB_inkey_enum eventmask )
|
||||
the actual function key and then offset it by 256,
|
||||
unless extended keyboard events are allowed, in which
|
||||
case offset it by 512 */
|
||||
if( eventmask & INKEY_EXTENDED ) ch = getch() + 512;
|
||||
if( eventmask & INKEY_RAW ) ch = getch() + 512;
|
||||
else ch = getch() + 256;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,12 +328,12 @@ int hb_gt_ReadKey( HB_inkey_enum eventmask )
|
||||
{
|
||||
/* Process non-ASCII key codes */
|
||||
WORD wKey;
|
||||
if( eventmask & INKEY_EXTENDED )
|
||||
if( eventmask & INKEY_RAW )
|
||||
wKey = s_irInBuf[ s_cNumIndex ].Event.KeyEvent.wVirtualKeyCode;
|
||||
else
|
||||
wKey = s_irInBuf[ s_cNumIndex ].Event.KeyEvent.wVirtualScanCode;
|
||||
/* Discard standalone state key presses for normal mode only */
|
||||
if( ( eventmask & INKEY_EXTENDED ) == 0 ) switch( wKey )
|
||||
if( ( eventmask & INKEY_RAW ) == 0 ) switch( wKey )
|
||||
{
|
||||
/* Virtual scan codes to ignore */
|
||||
case 29: /* Ctrl */
|
||||
@@ -347,7 +347,7 @@ int hb_gt_ReadKey( HB_inkey_enum eventmask )
|
||||
if( wKey == 0 ) ch = 0;
|
||||
else
|
||||
{
|
||||
if( eventmask & INKEY_EXTENDED )
|
||||
if( eventmask & INKEY_RAW )
|
||||
{
|
||||
/* Pass along all virtual key codes with all
|
||||
enhanced and state indicators accounted for */
|
||||
@@ -599,7 +599,7 @@ int hb_gt_ReadKey( HB_inkey_enum eventmask )
|
||||
else
|
||||
{
|
||||
WORD wKey;
|
||||
if( eventmask & INKEY_EXTENDED )
|
||||
if( eventmask & INKEY_RAW )
|
||||
wKey = s_irInBuf[ s_cNumIndex ].Event.KeyEvent.wVirtualKeyCode;
|
||||
else
|
||||
wKey = s_irInBuf[ s_cNumIndex ].Event.KeyEvent.wVirtualScanCode;
|
||||
@@ -608,7 +608,7 @@ int hb_gt_ReadKey( HB_inkey_enum eventmask )
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if( eventmask & ~( INKEY_KEYBOARD | INKEY_EXTENDED )
|
||||
else if( eventmask & ~( INKEY_KEYBOARD | INKEY_RAW )
|
||||
&& s_irInBuf[ s_cNumIndex ].EventType == MOUSE_EVENT )
|
||||
{
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ int hb_inkey( BOOL bWait, double dSeconds, HB_inkey_enum event_mask )
|
||||
if( ( dSeconds * CLOCKS_PER_SEC ) < 1 ) /* Wait forever ? */
|
||||
{
|
||||
/* There is no point in waiting forever for no input events! */
|
||||
if( ( event_mask & ( INKEY_ALL + INKEY_EXTENDED ) ) != 0 )
|
||||
if( ( event_mask & ( INKEY_ALL + INKEY_RAW ) ) != 0 )
|
||||
{
|
||||
while( hb_inkeyNext() == 0 )
|
||||
hb_releaseCPU();
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "inkey.ch"
|
||||
|
||||
PROCEDURE main( cSkip, cExtended )
|
||||
PROCEDURE main( cSkip, cRaw )
|
||||
|
||||
IF EMPTY( cSkip )
|
||||
|
||||
@@ -38,7 +38,7 @@ IF EMPTY( cSkip )
|
||||
NextTest()
|
||||
ENDIF
|
||||
|
||||
TEST7( cSkip, cExtended )
|
||||
TEST7( cSkip, cRaw )
|
||||
?
|
||||
QUIT
|
||||
|
||||
@@ -191,7 +191,7 @@ RETURN
|
||||
|
||||
|
||||
|
||||
PROCEDURE TEST7( cSkip, cExtended )
|
||||
PROCEDURE TEST7( cSkip, cRaw )
|
||||
LOCAL nKey, nMask, cText
|
||||
CLS
|
||||
? "For the last test, a loop is started and all keyboard and mouse"
|
||||
@@ -202,8 +202,8 @@ LOCAL nKey, nMask, cText
|
||||
? "Press any key."
|
||||
nMask := INKEY_ALL
|
||||
|
||||
IF ! EMPTY( cExtended )
|
||||
nMask += INKEY_EXTENDED
|
||||
IF ! EMPTY( cRaw )
|
||||
nMask += INKEY_RAW
|
||||
END IF
|
||||
|
||||
SET(_SET_EVENTMASK, nMask)
|
||||
|
||||
Reference in New Issue
Block a user