diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 2aa29fe161..d3b6c6c4e3 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,22 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-04-24 10:24 UTC+0100 Viktor Szakats (harbour.01 syenar hu) + * contrib/xhb/xhb.ch + * contrib/xhb/xhbfunc.c + ! xhb flavour of __KEYBOARD() synced with current xhb code. + + * contrib/hbmisc/hb_f.c + ! Swapped C file seek constants to Harbour ones. + * Minor cleanups and formatting. + + * source/rtl/tbrowse.prg + ! Committed patch to ::setPosition() + submitted by Prezemek on the devl list. + + * source/rtl/tget.prg + * Minor changes. Copyright updated. + 2008-04-23 22:31 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * contrib/rddads/adsfunc.c + Added these functions: diff --git a/harbour/contrib/hbmisc/hb_f.c b/harbour/contrib/hbmisc/hb_f.c index 51ca98c513..e0d6a874e8 100644 --- a/harbour/contrib/hbmisc/hb_f.c +++ b/harbour/contrib/hbmisc/hb_f.c @@ -72,7 +72,6 @@ static int isEof[10]; HB_FUNC( HB_FUSE ) { - PHB_ITEM arg1_it = hb_param(1,HB_IT_STRING); PHB_ITEM arg2_it = hb_param(2,HB_IT_NUMERIC); int open_flags; @@ -89,22 +88,22 @@ HB_FUNC( HB_FUSE ) recno[area] = 1; b = ( char * )hb_xgrab( b_size ); c = ( char * )hb_xgrab( c_size ); - lastbyte[area] = hb_fsSeek( handles[area], 0L, SEEK_END ); + lastbyte[area] = hb_fsSeek( handles[area], 0L, FS_END ); isEof[area] = (lastbyte[area] == 0); hb_retni( handles[area] ); } else { hb_fsClose( handles[area] ); - hb_xfree( b ) ; - hb_xfree( c ) ; - hb_retni( 1 ) ; - recno[area] = 0L ; - offset[area] = 0L ; - handles[area] = 0 ; - last_rec[area] = 0L ; - last_off[area] = 0L ; - lastbyte[area] = 0L ; - isEof[area] = 0 ; + hb_xfree( b ); + hb_xfree( c ); + hb_retni( 1 ); + recno[area] = 0L; + offset[area] = 0L; + handles[area] = 0; + last_rec[area] = 0L; + last_off[area] = 0L; + lastbyte[area] = 0L; + isEof[area] = 0; } } @@ -117,17 +116,7 @@ HB_FUNC( HB_FRECNO ) HB_FUNC( HB_FSKIP ) { - - PHB_ITEM arg1_it = hb_param(1,HB_IT_NUMERIC); - int nskip; - - if( arg1_it ) - nskip = hb_parni(1); - else - nskip = 1; - - hb_hbfskip(nskip); - + hb_hbfskip( ISNUM( 1 ) ? hb_parni(1) : 1 ); } static long hb_hbfskip( int recs ) @@ -136,12 +125,11 @@ static long hb_hbfskip( int recs ) long read_len; long x, y; - HB_TRACE(HB_TR_DEBUG, ("hb_hbskip(%d)", recs)); if ( recs > 0 ) { for (y = 0; y < recs; y++ ) { - hb_fsSeek( handles[area], offset[area], SEEK_SET ); + hb_fsSeek( handles[area], offset[area], FS_SET ); read_len = hb_fsRead( handles[area], ( BYTE * ) b, b_size ); for (x = 0; x < read_len; x++ ) { if ( ((*(b + x) == 13) && (*(b + x + 1) == 10)) || @@ -175,7 +163,7 @@ static long hb_hbfskip( int recs ) read_len = b_size; } - hb_fsSeek( handles[area], read_pos, SEEK_SET ); + hb_fsSeek( handles[area], read_pos, FS_SET ); read_len = hb_fsRead( handles[area], ( BYTE * ) b, ( USHORT )read_len ); for (x = read_len - 4; x >= 0; x-- ) { @@ -200,11 +188,10 @@ static long hb_hbfskip( int recs ) HB_FUNC( HB_FREADLN ) { - int x; long read; - hb_fsSeek( handles[area], offset[area], SEEK_SET ); + hb_fsSeek( handles[area], offset[area], FS_SET ); read = hb_fsRead( handles[area], ( BYTE * ) b, b_size ); for ( x = 0; x < b_size; x++ ) { @@ -225,7 +212,6 @@ HB_FUNC( HB_FEOF ) HB_FUNC( HB_FGOTO ) { - long target; long last; @@ -265,7 +251,7 @@ HB_FUNC( HB_FGOBOTTOM ) last = offset[area]; do { - hb_fsSeek( handles[area], offset[area], SEEK_SET ); + hb_fsSeek( handles[area], offset[area], FS_SET ); len = hb_fsRead( handles[area], ( BYTE * ) c, c_size ); for ( x = 0; x < len; x++ ) { if ( ((*(c + x) == 13) && (*(c + x + 1) == 10)) || @@ -328,7 +314,6 @@ HB_FUNC( HB_FINFO ) /* used for debugging */ hb_storni( offset[area], -1, 4); hb_storni( lastbyte[area], -1, 5); hb_storl ( isEof[area], -1, 6); - } HB_FUNC( HB_FREADANDSKIP ) @@ -352,7 +337,7 @@ HB_FUNC( HB_FREADANDSKIP ) long read; BOOL bInField = 0, bHasCRLF = FALSE; - hb_fsSeek( handles[area], offset[area], SEEK_SET ); + hb_fsSeek( handles[area], offset[area], FS_SET ); read = hb_fsRead( handles[area], ( BYTE * ) b, b_size ); while ( x < read ) @@ -385,6 +370,4 @@ HB_FUNC( HB_FREADANDSKIP ) isEof[area] = (lastbyte[area] <= offset[area] + 1) ; hb_retclen( b, x - (bHasCRLF ? 2 : 0) ); - } - diff --git a/harbour/contrib/xhb/xhb.ch b/harbour/contrib/xhb/xhb.ch index 1b9fbb8f4f..db6202abe6 100644 --- a/harbour/contrib/xhb/xhb.ch +++ b/harbour/contrib/xhb/xhb.ch @@ -61,7 +61,7 @@ #pragma -ks+ REQUEST XHB_LIB - #xtranslate __Keyboard([]) => xhb__Keyboard() + #xtranslate __Keyboard([]) => xhb__Keyboard() #endif #endif /* __HARBOUR__ */ diff --git a/harbour/contrib/xhb/xhbfunc.c b/harbour/contrib/xhb/xhbfunc.c index 11e688bffa..9fb9e07df4 100644 --- a/harbour/contrib/xhb/xhbfunc.c +++ b/harbour/contrib/xhb/xhbfunc.c @@ -59,30 +59,40 @@ HB_FUNC_EXTERN( __KEYBOARD ); HB_FUNC( XHB__KEYBOARD ) { + /* Clear the typeahead buffer without reallocating the keyboard buffer */ + if( !hb_parl( 2 ) ) + { + hb_inkeyReset(); + } + if( ISCHAR( 1 ) ) { - HB_FUNC_EXEC( __KEYBOARD ); + hb_inkeySetText( hb_parc( 1 ), hb_parclen( 1 ) ); } else if( ISNUM( 1 ) ) { - hb_inkeyReset(); - hb_inkeyPut( hb_parni(1) ); + hb_inkeySetText( NULL, ( ULONG ) hb_parnl( 1 ) ); } else if( ISARRAY( 1 ) ) { PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY ); - ULONG ulElements = hb_arrayLen( pArray ), ulIndex; - - hb_inkeyReset(); + ULONG ulIndex; + ULONG ulElements = hb_arrayLen( pArray ); for( ulIndex = 1; ulIndex <= ulElements; ulIndex++ ) { - if( hb_arrayGetType( pArray, ulIndex ) & HB_IT_NUMERIC ) - hb_inkeyPut( hb_arrayGetNI( pArray, ulIndex ) ); + PHB_ITEM pItem = hb_arrayGetItemPtr( pArray, ulIndex ); + + if ( HB_IS_NUMBER( pItem ) ) + { + hb_inkeySetText( NULL, ( ULONG ) hb_itemGetNL( pItem ) ); + } + else if ( HB_IS_STRING( pItem ) ) + { + hb_inkeySetText( ( const char * ) hb_itemGetCPtr( pItem ), hb_itemGetCLen( pItem ) ); + } } } - else - hb_inkeyReset(); } HB_FUNC_EXTERN( HB_DESERIALIZE ); diff --git a/harbour/source/rtl/tbrowse.prg b/harbour/source/rtl/tbrowse.prg index dc604ae5b9..a384d031d1 100644 --- a/harbour/source/rtl/tbrowse.prg +++ b/harbour/source/rtl/tbrowse.prg @@ -725,7 +725,7 @@ METHOD setPosition( nPos ) CLASS TBROWSE ::nBufferPos := nRowCount ENDIF nPos := 0 - WHILE ( nPos := AScan( ::aCellStatus, _TBR_NONE, nPos, ::nBufferPos - nPos ) ) != 0 + WHILE ( nPos := AScan( ::aCellStatus, _TBR_NONE, nPos + 1, ::nBufferPos - nPos ) ) != 0 ::aCellStatus[ nPos ] := _TBR_UNDEF ::aDispStatus[ nPos ] := .T. ENDDO diff --git a/harbour/source/rtl/tget.prg b/harbour/source/rtl/tget.prg index f04613d7f6..7fa463fc0c 100644 --- a/harbour/source/rtl/tget.prg +++ b/harbour/source/rtl/tget.prg @@ -6,6 +6,7 @@ * Harbour Project source code: * Get Class * + * Copyright 2007-2008 Viktor Szakats * Copyright 1999 Ignacio Ortiz de ZŁniga * www - http://www.harbour-project.org * @@ -50,18 +51,6 @@ * */ -/* - * The following parts are Copyright of the individual authors. - * www - http://www.harbour-project.org - * - * Copyright 2007 Viktor Szakats - * Several smaller methods and lots of fixes using - * regression/unit testing. - * - * See doc/license.txt for licensing terms. - * - */ - #include "hbclass.ch" #include "hblang.ch" @@ -441,6 +430,14 @@ METHOD setFocus() CLASS Get ::cType := ValType( xVarGet ) ::picture := ::cPicture ::cBuffer := ::PutMask( xVarGet, .F. ) + + ::lChanged := .F. + ::lClear := ( "K" $ ::cPicFunc .OR. ::cType == "N" ) + ::lEdit := .F. + ::Pos := 1 + + ::lMinusPrinted := .F. + ::lMinus := .F. IF ::cType == "N" ::decPos := At( iif( ::lPicDecRev .OR. "E" $ ::cPicFunc, ",", "." ), ::cBuffer ) @@ -451,14 +448,6 @@ METHOD setFocus() CLASS Get ELSE ::decPos := 0 /* ; CA-Cl*pper NG says that it contains NIL, but in fact it contains zero. [vszakats] */ ENDIF - - ::lChanged := .F. - ::lClear := ( "K" $ ::cPicFunc .OR. ::cType == "N" ) - ::lEdit := .F. - ::Pos := 1 - - ::lMinusPrinted := .F. - ::lMinus := .F. ::display()