From fd2ee1720e51bd1b29e176f0070ea034d946880f Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 26 Nov 1999 00:17:38 +0000 Subject: [PATCH] 19991126-01:06 GMT+1 Victor Szel --- harbour/ChangeLog | 18 +++ harbour/include/hbtrace.h | 4 +- harbour/source/common/hbtrace.c | 204 +++++++++++++++----------- harbour/source/rtl/gt/gtwin.c | 249 +++++++++++++++++--------------- harbour/source/rtl/set.c | 2 +- harbour/source/rtl/trace.c | 38 ++--- 6 files changed, 292 insertions(+), 223 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 541d4aa2a6..9c7f66c9df 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,21 @@ +19991126-01:06 GMT+1 Victor Szel + * source/rtl/gt/gtwin.c + % DispBegin()/DispEnd() switching code optimized. The only "stepback" is + that now the second screen buffer gets allocated right at the startup + and not at the first DispBegin() call. + ! DispBegin() now hides cursor as in Clipper. + * source/rtl/set.c + ! One value changed to BOOL. + * source/rtl/trace.c + + Added HB_ prefix to the nonstandard Clipper function names. + % Optimized one function. + ! Fixed indentation level. + * source/common/hbtrace.c + include/hbtrace.h + + Some new interface added (to query enabled state for example) + * Trace code variable scopes and code optimized. + * Variable naming and formatting. + Wed Nov 24 12:45:36 1999 Gonzalo A. Diethelm * include/hbtrace.h: diff --git a/harbour/include/hbtrace.h b/harbour/include/hbtrace.h index 415c4b1cdb..f0b98ac260 100644 --- a/harbour/include/hbtrace.h +++ b/harbour/include/hbtrace.h @@ -122,10 +122,12 @@ extern char * hb_tr_file_; extern int hb_tr_line_; extern int hb_tr_level_; +extern int hb_traceenabled( void ); +extern void hb_traceenable( int state ); extern void hb_traceon( void ); extern void hb_traceoff( void ); extern int hb_tracelevel( int new_level ); extern int hb_tr_level( void ); -extern void hb_tr_trace( char* fmt, ... ); +extern void hb_tr_trace( char * fmt, ... ); #endif /* HB_TRACE_H_ */ diff --git a/harbour/source/common/hbtrace.c b/harbour/source/common/hbtrace.c index 9f3cc052b0..ee2f7e1dce 100644 --- a/harbour/source/common/hbtrace.c +++ b/harbour/source/common/hbtrace.c @@ -33,6 +33,18 @@ * */ +/* + * The following parts are Copyright of the individual authors. + * www - http://www.harbour-project.org + * + * Copyright 1999 Victor Szel + * hb_traceenable() + * hb_traceenabled() + * + * See doc/license.txt for licensing terms. + * + */ + #include #include #include @@ -43,125 +55,141 @@ char * hb_tr_file_ = ""; int hb_tr_line_ = 0; int hb_tr_level_ = 0; -static int hb_tr_state_ = 1; -static FILE* hb_tr_fp_ = 0; -static char* slevel[HB_TR_LAST] = +static int s_enabled = 1; +static FILE * s_fp = 0; +static char * s_slevel[ HB_TR_LAST ] = { - "HB_TR_ALWAYS", - "HB_TR_FATAL", - "HB_TR_ERROR", - "HB_TR_WARNING", - "HB_TR_INFO", - "HB_TR_DEBUG" + "HB_TR_ALWAYS", + "HB_TR_FATAL", + "HB_TR_ERROR", + "HB_TR_WARNING", + "HB_TR_INFO", + "HB_TR_DEBUG" }; +int hb_traceenabled( void ) +{ + return s_enabled; +} + +void hb_traceenable( int enabled ) +{ + s_enabled = enabled; +} void hb_traceon( void ) { - hb_tr_state_ = 1; + s_enabled = 1; } void hb_traceoff( void ) { - hb_tr_state_ = 0; + s_enabled = 0; } int hb_tracelevel( int new_level ) { - int old_level = hb_tr_level_; + int old_level = hb_tr_level_; - if (new_level >= HB_TR_ALWAYS && - new_level < HB_TR_LAST) { - hb_tr_level_ = new_level; - } + if( new_level >= HB_TR_ALWAYS && + new_level < HB_TR_LAST ) + hb_tr_level_ = new_level; - return old_level; + return old_level; } -int hb_tr_level(void) +int hb_tr_level( void ) { - static int level = -1; - int i; - char* env; - char* out; + static int s_level = -1; - if (level != -1) { - return level; - } + if( s_level == -1 ) + { + char * out; + char * env; - hb_tr_fp_ = stderr; - out = getenv("HB_TR_OUTPUT"); - if (out != 0 && out[0] != '\0') { - hb_tr_fp_ = fopen(out, "w"); - if (hb_tr_fp_ == NULL) { - hb_tr_fp_ = stderr; - } - } + out = getenv( "HB_TR_OUTPUT" ); + if( out != NULL && out[ 0 ] != '\0' ) + { + s_fp = fopen( out, "w" ); - level = HB_TR_DEFAULT; - env = getenv("HB_TR_LEVEL"); - if (env != 0 && env[0] != '\0') { - for (i = 0; i < HB_TR_LAST; ++i) { - if (strcmp(env, slevel[i]) == 0) { - level = i; - break; + if( s_fp == NULL ) + s_fp = stderr; } - } - } + else + s_fp = stderr; - return level; + env = getenv( "HB_TR_LEVEL" ); + if( env != NULL && env[ 0 ] != '\0' ) + { + int i; + + for( i = 0; i < HB_TR_LAST; ++i ) + { + if( strcmp( env, s_slevel[ i ] ) == 0 ) + { + s_level = i; + break; + } + } + } + else + s_level = HB_TR_DEFAULT; + } + + return s_level; } void hb_tr_trace( char * fmt, ... ) { - int i; - va_list ap; + /* + * If tracing is disabled, do nothing. + */ + if( s_enabled ) + { + int i; + va_list ap; - /* - * If tracing is disabled, do nothing. - */ - if( ! hb_tr_state_ ) { - return; - } + /* + * Clean up the file, so that instead of showing + * + * ../../../foo/bar/baz.c + * + * we just show + * + * foo/bar/baz.c + */ + for( i = 0; hb_tr_file_[ i ] != '\0'; ++i ) + { + if( hb_tr_file_[ i ] != '.' && + hb_tr_file_[ i ] != '/' && + hb_tr_file_[ i ] != '\\' ) + break; + } - /* - * Clean up the file, so that instead of showing - * - * ../../../foo/bar/baz.c - * - * we just show - * - * foo/bar/baz.c - */ - for (i = 0; hb_tr_file_[i] != '\0'; ++i) { - if (hb_tr_file_[i] != '.' && - hb_tr_file_[i] != '/' && - hb_tr_file_[i] != '\\') - break; - } + /* + * Print file and line. + */ + fprintf( s_fp, "%s:%d: %s ", + hb_tr_file_ + i, hb_tr_line_, s_slevel[ hb_tr_level_ ] ); - /* - * Print file and line. - */ - fprintf(hb_tr_fp_, "%s:%d: %s ", - hb_tr_file_ + i, hb_tr_line_, slevel[hb_tr_level_]); + /* + * Print the name and arguments for the function. + */ + va_start( ap, fmt ); + vfprintf( s_fp, fmt, ap ); + va_end( ap ); - /* - * Print the name and arguments for the function. - */ - va_start(ap, fmt); - vfprintf(hb_tr_fp_, fmt, ap); - va_end(ap); + /* + * Print a new-line. + */ + fprintf( s_fp, "\n" ); - /* - * Print a new-line. - */ - fprintf(hb_tr_fp_, "\n"); - - /* - * Reset file and line. - */ - hb_tr_file_ = ""; - hb_tr_line_ = -1; - hb_tr_level_ = -1; + /* + * Reset file and line. + */ + hb_tr_file_ = ""; + hb_tr_line_ = -1; + hb_tr_level_ = -1; + } } + diff --git a/harbour/source/rtl/gt/gtwin.c b/harbour/source/rtl/gt/gtwin.c index 230937fcf7..d43680c8c2 100644 --- a/harbour/source/rtl/gt/gtwin.c +++ b/harbour/source/rtl/gt/gtwin.c @@ -79,30 +79,23 @@ #endif #endif -#if ! defined(__GNUC__) -#ifdef __CYGWIN__ -typedef WORD far * LPWORD; +#if ! defined(__GNUC__) && defined(__CYGWIN__) + typedef WORD far * LPWORD; #endif -#endif /* __GNUC__ */ -static BOOL hb_gt_SetScreenBuffer( HANDLE HNew, HANDLE HOld ); +static HANDLE s_HOsave; +/* static HANDLE s_HSsave; */ +static HANDLE s_HDOutput = INVALID_HANDLE_VALUE; +/* static HANDLE s_HDStealth = INVALID_HANDLE_VALUE; */ -static HANDLE HOsave; -/* static HANDLE HSsave; */ -static HANDLE HDOutput = INVALID_HANDLE_VALUE; -/* static HANDLE HDStealth = INVALID_HANDLE_VALUE; */ - HANDLE hb_gtHInput = INVALID_HANDLE_VALUE; /* hb_inkeyPoll() needs this */ - BOOL hb_gtBreak = FALSE; /* Used to signal Ctrl+Break to hb_inkeyPoll() */ -static HANDLE HOutput = INVALID_HANDLE_VALUE; -static HANDLE HStealth = INVALID_HANDLE_VALUE; /* DispBegin buffer */ -static HANDLE HOriginal; /* used to restore before quit */ -static HANDLE HCursor; /* When DispBegin is in effect, all cursor related - functions must refer to the active handle! - Otherwise turds are left on the screen when - running in a window. This handle will always - refer to the currently _active_ buffer which could - be different than the one being written to. - */ +static HANDLE s_HOriginal = INVALID_HANDLE_VALUE; +static HANDLE s_HOutput = INVALID_HANDLE_VALUE; +static HANDLE s_HActive = INVALID_HANDLE_VALUE; +static HANDLE s_HInactive = INVALID_HANDLE_VALUE; +static BOOL s_bOldCursor = TRUE; + +HANDLE hb_gtHInput = INVALID_HANDLE_VALUE; +BOOL hb_gtBreak = FALSE; /* Used to signal Ctrl+Break to hb_inkeyPoll() */ static BOOL WINAPI hb_gt_CtrlHandler( DWORD dwCtrlType ) { @@ -135,6 +128,9 @@ void hb_gt_Init( void ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_Init()")); + /* Add Ctrl+Break handler [vszel] */ + SetConsoleCtrlHandler( hb_gt_CtrlHandler, TRUE ); + if( ( hb_gtHInput = GetStdHandle( STD_INPUT_HANDLE ) ) == INVALID_HANDLE_VALUE ) { if( hb_dynsymFindName( "__DBGENTRY" ) ) /* the debugger is linked */ @@ -145,23 +141,51 @@ void hb_gt_Init( void ) } SetConsoleMode( hb_gtHInput, 0 ); + /* ptucker */ - HOriginal = HOutput = HCursor = CreateFile( "CONOUT$", /* filename */ + s_HOriginal = CreateFile( "CONOUT$", /* filename */ GENERIC_READ | GENERIC_WRITE, /* Access flag */ FILE_SHARE_READ | FILE_SHARE_WRITE, /* share mode */ NULL, /* security attributes */ OPEN_EXISTING, /* create mode */ 0, 0 ); - /* Add Ctrl+Break handler [vszel] */ - SetConsoleCtrlHandler( hb_gt_CtrlHandler, TRUE ); + s_HOutput = s_HOriginal; + s_HActive = s_HOutput; + + { + CONSOLE_SCREEN_BUFFER_INFO csbi; + SMALL_RECT srWin; + + s_HInactive = CreateConsoleScreenBuffer( + GENERIC_READ | GENERIC_WRITE, /* Access flag */ + FILE_SHARE_READ | FILE_SHARE_WRITE, /* Buffer share mode */ + NULL, /* Security attribute */ + CONSOLE_TEXTMODE_BUFFER, /* Type of buffer */ + NULL ); /* reserved */ + + GetConsoleScreenBufferInfo( s_HOriginal, &csbi ); + + /* new console window size and scroll position */ + srWin.Top = srWin.Left = 0; + srWin.Bottom = csbi.dwSize.Y - 1; + srWin.Right = csbi.dwSize.X - 1; + + SetConsoleScreenBufferSize( s_HInactive, csbi.dwSize ); + SetConsoleWindowInfo( s_HInactive, TRUE, &csbi.srWindow ); + SetConsoleWindowInfo( s_HInactive, FALSE, &srWin ); + } + +/* + SetConsoleActiveScreenBuffer( s_HActive ); +*/ } void hb_gt_Done( void ) { HB_TRACE(HB_TR_DEBUG, ("hb_gt_Done()")); - if( HOutput != HOriginal ) + if( s_HOutput != s_HOriginal ) { /* ptucker */ /* because the current screen may not be the one that was active @@ -176,14 +200,11 @@ void hb_gt_Done( void ) functions using stdout will not show anything. CloseHandle( hb_gtHInput ); hb_gtHInput = INVALID_HANDLE_VALUE; - CloseHandle( HOutput ); - HOutput = INVALID_HANDLE_VALUE; + CloseHandle( s_HOutput ); + s_HOutput = INVALID_HANDLE_VALUE; */ - if( HStealth != INVALID_HANDLE_VALUE ) - { - CloseHandle( HStealth ); - HStealth = INVALID_HANDLE_VALUE; - } + CloseHandle( s_HInactive ); + s_HInactive = INVALID_HANDLE_VALUE; /* Remove Ctrl+Break handler [vszel] */ SetConsoleCtrlHandler( hb_gt_CtrlHandler, FALSE ); @@ -203,7 +224,7 @@ USHORT hb_gt_GetScreenWidth( void ) HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetScreenWidth()")); - GetConsoleScreenBufferInfo( HOutput, &csbi ); + GetConsoleScreenBufferInfo( s_HOutput, &csbi ); /* return csbi.dwMaximumWindowSize.X; */ /* return max( csbi.srWindow.Right - csbi.srWindow.Left + 1, 40 ); */ return max( csbi.dwSize.X, 40 ); @@ -215,7 +236,7 @@ USHORT hb_gt_GetScreenHeight( void ) HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetScreenHeight()")); - GetConsoleScreenBufferInfo( HOutput, &csbi ); + GetConsoleScreenBufferInfo( s_HOutput, &csbi ); /* return csbi.dwMaximumWindowSize.Y; */ /* return max( csbi.srWindow.Bottom - csbi.srWindow.Top + 1, 25 ); */ return max( csbi.dwSize.Y, 25 ); @@ -230,7 +251,7 @@ void hb_gt_SetPos( USHORT uiRow, USHORT uiCol ) dwCursorPosition.X = ( SHORT ) uiCol; dwCursorPosition.Y = ( SHORT ) uiRow; - SetConsoleCursorPosition( HCursor, dwCursorPosition ); + SetConsoleCursorPosition( s_HActive, dwCursorPosition ); } USHORT hb_gt_GetCursorStyle( void ) @@ -240,7 +261,7 @@ USHORT hb_gt_GetCursorStyle( void ) HB_TRACE(HB_TR_DEBUG, ("hb_gt_GetCursorStyle()")); - GetConsoleCursorInfo( HCursor, &cci ); + GetConsoleCursorInfo( s_HActive, &cci ); if( ! cci.bVisible ) { @@ -279,7 +300,7 @@ void hb_gt_SetCursorStyle( USHORT style ) HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetCursorStyle(%hu)", style)); - GetConsoleCursorInfo( HCursor, &cci ); + GetConsoleCursorInfo( s_HActive, &cci ); switch( style ) { @@ -312,7 +333,9 @@ void hb_gt_SetCursorStyle( USHORT style ) break; } - SetConsoleCursorInfo( HCursor, &cci ); + s_bOldCursor = cci.bVisible; + + SetConsoleCursorInfo( s_HActive, &cci ); } void hb_gt_Puts( USHORT uiRow, USHORT uiCol, BYTE attr, BYTE * str, ULONG len ) @@ -325,8 +348,8 @@ void hb_gt_Puts( USHORT uiRow, USHORT uiCol, BYTE attr, BYTE * str, ULONG len ) coord.X = ( DWORD ) uiCol; coord.Y = ( DWORD ) uiRow; - FillConsoleOutputAttribute( HOutput, ( WORD )( attr & 0xFF ), ( DWORD ) len, coord, &dwWritten ); - WriteConsoleOutputCharacterA( HOutput, ( char * ) str, ( DWORD ) len, coord, &dwWritten ); + FillConsoleOutputAttribute( s_HOutput, ( WORD )( attr & 0xFF ), ( DWORD ) len, coord, &dwWritten ); + WriteConsoleOutputCharacterA( s_HOutput, ( char * ) str, ( DWORD ) len, coord, &dwWritten ); } void hb_gt_GetText( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, BYTE * dest ) @@ -349,8 +372,8 @@ void hb_gt_GetText( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight coord.X = ( DWORD ) uiLeft; coord.Y = ( DWORD ) uiTop; - ReadConsoleOutputCharacterA( HOutput, ( char * ) pstr, width, coord, &dwWritten ); - ReadConsoleOutputAttribute( HOutput, pwattr, width, coord, &dwWritten ); + ReadConsoleOutputCharacterA( s_HOutput, ( char * ) pstr, width, coord, &dwWritten ); + ReadConsoleOutputAttribute( s_HOutput, pwattr, width, coord, &dwWritten ); for( i = 0; i < width; i++ ) { *dest = *( pstr + i ); @@ -391,8 +414,8 @@ void hb_gt_PutText( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight } coord.X = ( DWORD ) uiLeft; coord.Y = ( DWORD ) uiTop; - WriteConsoleOutputAttribute( HOutput, pwattr, width, coord, &dwWritten ); - WriteConsoleOutputCharacterA( HOutput, ( char * ) pstr, width, coord, &dwWritten ); + WriteConsoleOutputAttribute( s_HOutput, pwattr, width, coord, &dwWritten ); + WriteConsoleOutputCharacterA( s_HOutput, ( char * ) pstr, width, coord, &dwWritten ); } hb_xfree( pstr ); @@ -417,7 +440,7 @@ void hb_gt_SetAttribute( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT ui DWORD dwWritten; coord.Y = uiTop; - FillConsoleOutputAttribute( HOutput, ( WORD )( attr & 0xFF ), width, coord, &dwWritten ); + FillConsoleOutputAttribute( s_HOutput, ( WORD )( attr & 0xFF ), width, coord, &dwWritten ); } } @@ -427,7 +450,7 @@ USHORT hb_gt_Col( void ) HB_TRACE(HB_TR_DEBUG, ("hb_gt_Col()")); - GetConsoleScreenBufferInfo( HCursor, &csbi ); + GetConsoleScreenBufferInfo( s_HActive, &csbi ); return csbi.dwCursorPosition.X; } @@ -438,7 +461,7 @@ USHORT hb_gt_Row( void ) HB_TRACE(HB_TR_DEBUG, ("hb_gt_Row()")); - GetConsoleScreenBufferInfo( HCursor, &csbi ); + GetConsoleScreenBufferInfo( s_HActive, &csbi ); return csbi.dwCursorPosition.Y; } @@ -461,8 +484,8 @@ void hb_gt_Scroll( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, DWORD dwWritten; coord.Y = uiTop; - FillConsoleOutputAttribute( HOutput, ( WORD )( attr & 0xFF ), width, coord, &dwWritten ); - FillConsoleOutputCharacter( HOutput, ' ', width, coord, &dwWritten ); + FillConsoleOutputAttribute( s_HOutput, ( WORD )( attr & 0xFF ), width, coord, &dwWritten ); + FillConsoleOutputCharacter( s_HOutput, ' ', width, coord, &dwWritten ); } } else @@ -484,7 +507,7 @@ void hb_gt_Scroll( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRight, FillChar.Char.AsciiChar = ' '; FillChar.Attributes = ( WORD )( attr & 0xFF ); - ScrollConsoleScreenBuffer( HOutput, &Source, &Clip, Target, &FillChar ); + ScrollConsoleScreenBuffer( s_HOutput, &Source, &Clip, Target, &FillChar ); } } @@ -501,7 +524,7 @@ void hb_gt_DispBegin( void ) SMALL_RECT srWin; /* source rectangle to read from */ CONSOLE_SCREEN_BUFFER_INFO csbi; - GetConsoleScreenBufferInfo( HCursor, &csbi ); + GetConsoleScreenBufferInfo( s_HOutput, &csbi ); srWin.Top = srWin.Left = 0; srWin.Bottom = ( coBuf.Y = csbi.dwSize.Y ) - 1; srWin.Right = ( coBuf.X = csbi.dwSize.X ) - 1; @@ -510,32 +533,29 @@ void hb_gt_DispBegin( void ) pCharInfo = ( CHAR_INFO * ) hb_xgrab( coBuf.Y * coBuf.X * sizeof( CHAR_INFO ) ); /* read the screen rectangle into the buffer */ - ReadConsoleOutput( HOutput, /* current screen handle */ - pCharInfo, /* transfer area */ - coBuf, /* size of destination buffer */ - coDest, /* upper-left cell to write data to */ - &srWin ); /* screen buffer rectangle to read from */ + ReadConsoleOutput( s_HOutput, /* current screen handle */ + pCharInfo, /* transfer area */ + coBuf, /* size of destination buffer */ + coDest, /* upper-left cell to write data to */ + &srWin ); /* screen buffer rectangle to read from */ + + WriteConsoleOutput( s_HInactive, /* output handle */ + pCharInfo, /* data to write */ + coBuf, /* col/row size of source buffer */ + coDest, /* upper-left cell to write data from in src */ + &srWin ); /* screen buffer rect to write data to */ + + s_HOutput = s_HInactive; - if( HStealth == INVALID_HANDLE_VALUE ) { - HStealth = CreateConsoleScreenBuffer( - GENERIC_READ | GENERIC_WRITE, /* Access flag */ - FILE_SHARE_READ | FILE_SHARE_WRITE, /* Buffer share mode */ - NULL, /* Security attribute */ - CONSOLE_TEXTMODE_BUFFER, /* Type of buffer */ - NULL ); /* reserved */ + CONSOLE_CURSOR_INFO cci; + GetConsoleCursorInfo( s_HActive, &cci ); + s_bOldCursor = cci.bVisible; + cci.bVisible = FALSE; + SetConsoleCursorInfo( s_HActive, &cci ); } - hb_gt_SetScreenBuffer( HStealth, HOutput ); - - HOutput = HStealth; - WriteConsoleOutput( HOutput, /* output handle */ - pCharInfo, /* data to write */ - coBuf, /* col/row size of source buffer */ - coDest, /* upper-left cell to write data from in src */ - &srWin ); /* screen buffer rect to write data to */ - hb_xfree( pCharInfo ); } } @@ -548,38 +568,21 @@ void hb_gt_DispEnd( void ) if( hb_gtDispCount() == 1 ) { - HANDLE htmp = HStealth; + s_HOutput = s_HInactive; + s_HInactive = s_HActive; + s_HActive = s_HOutput; + SetConsoleActiveScreenBuffer( s_HActive ); - HStealth = HCursor; - hb_gt_DispBegin(); - HStealth = htmp; + { + CONSOLE_CURSOR_INFO cci; + + GetConsoleCursorInfo( s_HActive, &cci ); + cci.bVisible = s_bOldCursor; + SetConsoleCursorInfo( s_HActive, &cci ); + } } } -static BOOL hb_gt_SetScreenBuffer( HANDLE HNew, HANDLE HOld ) -{ -/* ptucker */ - -/* set a new buffer to have the same characteristics as an existing buffer */ - CONSOLE_SCREEN_BUFFER_INFO csbi; - SMALL_RECT srWin; - - HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetScreenBuffer(%p, %p)", HNew, HOld)); - - GetConsoleScreenBufferInfo( HOld, &csbi ); - - /* new console window size and scroll position */ - srWin.Top = srWin.Left = 0; - srWin.Bottom = csbi.dwSize.Y - 1; - srWin.Right = csbi.dwSize.X - 1; - - SetConsoleScreenBufferSize( HNew, csbi.dwSize ); - SetConsoleWindowInfo( HNew, TRUE, &csbi.srWindow ); - SetConsoleWindowInfo( HNew, FALSE, &srWin ); - - return TRUE; -} - BOOL hb_gt_SetMode( USHORT uiRows, USHORT uiCols ) { /* ptucker */ @@ -590,8 +593,8 @@ BOOL hb_gt_SetMode( USHORT uiRows, USHORT uiCols ) HB_TRACE(HB_TR_DEBUG, ("hb_gt_SetMode(%hu, %hu)", uiRows, uiCols)); - GetConsoleScreenBufferInfo( HOutput, &csbi ); - coBuf = GetLargestConsoleWindowSize( HOutput ); + GetConsoleScreenBufferInfo( s_HOutput, &csbi ); + coBuf = GetLargestConsoleWindowSize( s_HOutput ); /* new console window size and scroll position */ srWin.Top = srWin.Left = 0; @@ -606,14 +609,14 @@ BOOL hb_gt_SetMode( USHORT uiRows, USHORT uiCols ) /* console window first, then the buffer */ if( ( DWORD ) csbi.dwSize.X * csbi.dwSize.Y > ( DWORD ) uiCols * uiRows ) { - if( !SetConsoleWindowInfo( HOutput, TRUE, &srWin ) || - !SetConsoleScreenBufferSize( HOutput, coBuf ) ) + if( !SetConsoleWindowInfo( s_HOutput, TRUE, &srWin ) || + !SetConsoleScreenBufferSize( s_HOutput, coBuf ) ) bRetVal = FALSE; } else if( ( DWORD ) csbi.dwSize.X * csbi.dwSize.Y < ( DWORD ) uiCols * uiRows ) { - if( !SetConsoleScreenBufferSize( HOutput, coBuf ) || - !SetConsoleWindowInfo( HOutput, TRUE, &srWin ) ) + if( !SetConsoleScreenBufferSize( s_HOutput, coBuf ) || + !SetConsoleWindowInfo( s_HOutput, TRUE, &srWin ) ) bRetVal = FALSE; } @@ -631,7 +634,7 @@ void hb_gt_Replicate( BYTE c, ULONG ulLength ) /* TODO: This is not used and may be eliminated after further review */ FillConsoleOutputCharacter( - HOutput, /* handle to screen buffer */ + s_HOutput, /* handle to screen buffer */ c, /* character to write */ ( DWORD ) ulLength, /* number of cells to write */ coBuf, /* coordinates of first cell */ @@ -652,7 +655,7 @@ 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 */ + /* TODO: set the bit if it's supported */ HB_SYMBOL_UNUSED( bBlink ); } @@ -664,26 +667,40 @@ void hb_gt_DebugScreen( BOOL bActivate ) /* TODO: This is not used and is still a work in progress */ if( bActivate ) { - if( HDOutput == INVALID_HANDLE_VALUE ) + if( s_HDOutput == INVALID_HANDLE_VALUE ) { - HDOutput = CreateConsoleScreenBuffer( + CONSOLE_SCREEN_BUFFER_INFO csbi; + SMALL_RECT srWin; + + s_HDOutput = CreateConsoleScreenBuffer( GENERIC_READ | GENERIC_WRITE, /* Access flag */ FILE_SHARE_READ | FILE_SHARE_WRITE, /* Buffer share mode */ NULL, /* Security attribute */ CONSOLE_TEXTMODE_BUFFER, /* Type of buffer */ NULL ); /* reserved */ - hb_gt_SetScreenBuffer( HDOutput, HOutput ); + + GetConsoleScreenBufferInfo( s_HOutput, &csbi ); + + /* new console window size and scroll position */ + srWin.Top = srWin.Left = 0; + srWin.Bottom = csbi.dwSize.Y - 1; + srWin.Right = csbi.dwSize.X - 1; + + SetConsoleScreenBufferSize( s_HDOutput, csbi.dwSize ); + SetConsoleWindowInfo( s_HDOutput, TRUE, &csbi.srWindow ); + SetConsoleWindowInfo( s_HDOutput, FALSE, &srWin ); } - HOsave = HOutput; - HOutput = HCursor = HDOutput; + s_HOsave = s_HOutput; + s_HOutput = s_HActive = s_HDOutput; hb_gtDispBegin(); hb_gtDispEnd(); } else { - HOutput = HOsave; - HCursor = HOriginal; + s_HOutput = s_HOsave; + s_HActive = s_HOriginal; } - SetConsoleActiveScreenBuffer( HOutput ); + SetConsoleActiveScreenBuffer( s_HOutput ); } + diff --git a/harbour/source/rtl/set.c b/harbour/source/rtl/set.c index 26c989f6be..4becb0cc33 100644 --- a/harbour/source/rtl/set.c +++ b/harbour/source/rtl/set.c @@ -1055,7 +1055,7 @@ void hb_setInitialize( void ) hb_set.HB_SET_DEVICE = ( char * ) hb_xgrab( 7 ); memcpy( hb_set.HB_SET_DEVICE, "SCREEN", 7 ); hb_set.HB_SET_EPOCH = 1900; - hb_set.HB_SET_ESCAPE = 1; + hb_set.HB_SET_ESCAPE = TRUE; hb_set.HB_SET_EVENTMASK = INKEY_KEYBOARD; hb_set.HB_SET_EXACT = FALSE; hb_set.HB_SET_EXCLUSIVE = TRUE; diff --git a/harbour/source/rtl/trace.c b/harbour/source/rtl/trace.c index cd9e3c9f8b..dbf1b94431 100644 --- a/harbour/source/rtl/trace.c +++ b/harbour/source/rtl/trace.c @@ -33,35 +33,39 @@ * */ + /* - * This code is based on a suggestion made by Jose Lalin - * . + * The following parts are Copyright of the individual authors. + * www - http://www.harbour-project.org + * + * Copyright 1999 Victor Szel + * HB_HB_TRACEENABLE() * * See doc/license.txt for licensing terms. + * */ #include "extend.h" - -HARBOUR HB_TRACEON( void ) +HARBOUR HB_HB_TRACEENABLE( void ) { - hb_traceon(); + hb_retl( hb_traceenabled() ); + + if( ISLOG( 1 ) ) + hb_traceenable( hb_parl( 1 ) ? 1 : 0 ); } -HARBOUR HB_TRACEOFF( void ) +HARBOUR HB_HB_TRACEON( void ) { - hb_traceoff(); + hb_traceon(); } -HARBOUR HB_TRACELEVEL( void ) +HARBOUR HB_HB_TRACEOFF( void ) { - int old_level = 0; - int new_level = -1; - - if( hb_pcount() == 1 ) { - new_level = hb_parni( 1 ); - } - - old_level = hb_tracelevel(new_level); - hb_retni( old_level ); + hb_traceoff(); +} + +HARBOUR HB_HB_TRACELEVEL( void ) +{ + hb_retni( hb_tracelevel( ISNUM( 1 ) ? hb_parni( 1 ) : -1 ) ); }