diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 2b07130f99..3635b75a71 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,22 @@ 2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-02-20 13:18 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/vm/classes.c + * cleanup comment + + * harbour/source/rtl/gttrm/gttrm.c + + added support for HB_GTI_PALETTE - it's supported only by Linux console + and PuTTY/PTerm + + * harbour/source/rtl/gtxwc/gtxwc.c + * harbour/source/rtl/gtwvt/gtwvt.c + * harbour/contrib/gtwvg/gtwvg.c + ! fixed indexes in + hb_gtInfo( HB_GTI_PALLETE, [, ] ) + They should be the same as in our screen buffer: 0-based not one + based. + 2009-02-20 11:03 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * bin/postinst.sh ! Fix to prev HB_USR_LIBTOOL should be HB_USER_LIBTOOL to be diff --git a/harbour/contrib/gtwvg/gtwvg.c b/harbour/contrib/gtwvg/gtwvg.c index e7edae01de..1641ef2af7 100644 --- a/harbour/contrib/gtwvg/gtwvg.c +++ b/harbour/contrib/gtwvg/gtwvg.c @@ -3116,13 +3116,13 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) { int iIndex = hb_itemGetNI( pInfo->pNewVal ); - if( iIndex > 0 && iIndex <= 16 ) + if( iIndex >= 0 && iIndex < 16 ) { - pInfo->pResult = hb_itemPutNL( pInfo->pResult, pWVT->COLORS[ iIndex - 1 ] ); + pInfo->pResult = hb_itemPutNL( pInfo->pResult, pWVT->COLORS[ iIndex ] ); if( hb_itemType( pInfo->pNewVal2 ) & HB_IT_NUMERIC ) { - pWVT->COLORS[ iIndex - 1 ] = hb_itemGetNL( pInfo->pNewVal2 ); + pWVT->COLORS[ iIndex ] = hb_itemGetNL( pInfo->pNewVal2 ); if( pWVT->hWnd ) HB_GTSELF_EXPOSEAREA( pWVT->pGT, 0, 0, pWVT->ROWS, pWVT->COLS ); @@ -3137,8 +3137,8 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) pInfo->pResult = hb_itemNew( NULL ); } hb_arrayNew( pInfo->pResult, 16 ); - for( i = 1; i <= 16; i++ ) - hb_arraySetNL( pInfo->pResult, i, pWVT->COLORS[ i - 1 ] ); + for( i = 0; i < 16; i++ ) + hb_arraySetNL( pInfo->pResult, i + 1, pWVT->COLORS[ i ] ); if( hb_itemType( pInfo->pNewVal ) & HB_IT_ARRAY ) { diff --git a/harbour/source/rtl/gttrm/gttrm.c b/harbour/source/rtl/gttrm/gttrm.c index 041eacc0b0..a8647538fa 100644 --- a/harbour/source/rtl/gttrm/gttrm.c +++ b/harbour/source/rtl/gttrm/gttrm.c @@ -333,6 +333,8 @@ typedef struct _HB_GTTRM int chrattr[ 256 ]; int boxattr[ 256 ]; + int colors[ 16 ]; + int iOutBufSize; int iOutBufIndex; BYTE * pOutBuf; @@ -400,6 +402,9 @@ static const char * s_szMouseOn = "\033[?1001s\033[?1002h"; static const char * s_szMouseOff = "\033[?1002l\033[?1001r"; static const BYTE s_szBell[] = { HB_CHAR_BEL, 0 }; +/* conversion table for ANSI color indexes */ +static const int s_AnsiColors[] = { 0, 4, 2, 6, 1, 5, 3, 7 }; + /* The tables below are indexed by internal key value, * It cause that we don't have to make any linear scans * to access information proper ClipKeyCode entry @@ -1558,6 +1563,22 @@ static void hb_gt_trm_LinuxSetCursorStyle( PHB_GTTRM pTerm, int iStyle ) } } +static void hb_gt_trm_LinuxSetPalette( PHB_GTTRM pTerm, int iIndex ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_gt_trm_LinuxSetPalette(%p,%d)", pTerm, iIndex)); + + if( iIndex >= 0 && iIndex <= 15 ) + { + char szColor[ 11 ]; + int iAnsiIndex = s_AnsiColors[ iIndex & 0x07 ] | ( iIndex & 0x08 ); + hb_snprintf( szColor, sizeof( szColor ), "\033]P%X%02X%02X%02X", + iAnsiIndex, + ( pTerm->colors[ iIndex ] >> 16 ) & 0xff, + ( pTerm->colors[ iIndex ] >> 8 ) & 0xff, + ( pTerm->colors[ iIndex ] ) & 0xff ); + hb_gt_trm_termOut( pTerm, ( BYTE * ) szColor, 10 ); + } +} /* * XTERM terminal operations @@ -1589,8 +1610,6 @@ static BOOL hb_gt_trm_XtermSetMode( PHB_GTTRM pTerm, int * piRows, int * piCols static void hb_gt_trm_XtermSetAttributes( PHB_GTTRM pTerm, int iAttr ) { - static const int s_AnsiColors[] = { 0, 4, 2, 6, 1, 5, 3, 7 }; - HB_TRACE(HB_TR_DEBUG, ("hb_gt_trm_XtermSetAttributes(%p,%d)", pTerm, iAttr)); if( pTerm->iCurrentSGR != iAttr ) @@ -1860,8 +1879,6 @@ static void hb_gt_trm_AnsiSetCursorStyle( PHB_GTTRM pTerm, int iStyle ) static void hb_gt_trm_AnsiSetAttributes( PHB_GTTRM pTerm, int iAttr ) { - static const int s_AnsiColors[] = { 0, 4, 2, 6, 1, 5, 3, 7 }; - HB_TRACE(HB_TR_DEBUG, ("hb_gt_trm_AnsiSetAttributes(%p,%d)", pTerm, iAttr)); if( pTerm->iCurrentSGR != iAttr ) @@ -2092,6 +2109,17 @@ static void hb_gt_trm_PutStr( PHB_GTTRM pTerm, int iRow, int iCol, int iAttr, BY pTerm->iCol += iLen; } +static void hb_gt_trm_SetPalette( PHB_GTTRM pTerm, int iIndex ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_gt_trm_SetPalette(%p,%d)", pTerm, iIndex)); + + if( pTerm->terminal_type == TERM_LINUX || + ( pTerm->terminal_ext & TERM_PUTTY ) ) + { + hb_gt_trm_LinuxSetPalette( pTerm, iIndex ); + } +} + static void hb_gt_trm_SetKeyTrans( PHB_GTTRM pTerm, char * pSrcChars, char * pDstChars ) { int i; @@ -3478,6 +3506,41 @@ static BOOL hb_gt_trm_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) addKeyMap( pTerm, SET_CLIPKEY( iVal ), szVal ); break; + case HB_GTI_PALETTE: + if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) + { + iVal = hb_itemGetNI( pInfo->pNewVal ); + if( iVal >= 0 && iVal < 16 ) + { + pInfo->pResult = hb_itemPutNI( pInfo->pResult, pTerm->colors[ iVal ] ); + if( hb_itemType( pInfo->pNewVal2 ) & HB_IT_NUMERIC ) + { + pTerm->colors[ iVal ] = hb_itemGetNI( pInfo->pNewVal2 ); + hb_gt_trm_SetPalette( pTerm, iVal ); + hb_gt_trm_termFlush( pTerm ); + } + } + } + else + { + if( !pInfo->pResult ) + pInfo->pResult = hb_itemNew( NULL ); + hb_arrayNew( pInfo->pResult, 16 ); + for( iVal = 0; iVal < 16; iVal++ ) + hb_arraySetNI( pInfo->pResult, iVal + 1, pTerm->colors[ iVal ] ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_ARRAY && + hb_arrayLen( pInfo->pNewVal ) == 16 ) + { + for( iVal = 0; iVal < 16; iVal++ ) + { + pTerm->colors[ iVal ] = hb_arrayGetNI( pInfo->pNewVal, iVal + 1 ); + hb_gt_trm_SetPalette( pTerm, iVal ); + } + hb_gt_trm_termFlush( pTerm ); + } + } + break; + default: return HB_GTSUPER_INFO( pGT, iType, pInfo ); } diff --git a/harbour/source/rtl/gtwvt/gtwvt.c b/harbour/source/rtl/gtwvt/gtwvt.c index 8fa69735fa..8236e2e681 100644 --- a/harbour/source/rtl/gtwvt/gtwvt.c +++ b/harbour/source/rtl/gtwvt/gtwvt.c @@ -2545,13 +2545,13 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) { int iIndex = hb_itemGetNI( pInfo->pNewVal ); - if( iIndex > 0 && iIndex <= 16 ) + if( iIndex >= 0 && iIndex < 16 ) { - pInfo->pResult = hb_itemPutNL( pInfo->pResult, pWVT->COLORS[ iIndex - 1 ] ); + pInfo->pResult = hb_itemPutNL( pInfo->pResult, pWVT->COLORS[ iIndex ] ); if( hb_itemType( pInfo->pNewVal2 ) & HB_IT_NUMERIC ) { - pWVT->COLORS[ iIndex - 1 ] = hb_itemGetNL( pInfo->pNewVal2 ); + pWVT->COLORS[ iIndex ] = hb_itemGetNL( pInfo->pNewVal2 ); if( pWVT->hWnd ) HB_GTSELF_EXPOSEAREA( pWVT->pGT, 0, 0, pWVT->ROWS, pWVT->COLS ); @@ -2566,8 +2566,8 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) pInfo->pResult = hb_itemNew( NULL ); } hb_arrayNew( pInfo->pResult, 16 ); - for( i = 1; i <= 16; i++ ) - hb_arraySetNL( pInfo->pResult, i, pWVT->COLORS[ i - 1 ] ); + for( i = 0; i < 16; i++ ) + hb_arraySetNL( pInfo->pResult, i + 1, pWVT->COLORS[ i ] ); if( hb_itemType( pInfo->pNewVal ) & HB_IT_ARRAY ) { diff --git a/harbour/source/rtl/gtxwc/gtxwc.c b/harbour/source/rtl/gtxwc/gtxwc.c index 6cdf2713da..5ec26d6ed4 100644 --- a/harbour/source/rtl/gtxwc/gtxwc.c +++ b/harbour/source/rtl/gtxwc/gtxwc.c @@ -3985,7 +3985,7 @@ static BOOL hb_gt_xwc_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) case HB_GTI_PALETTE: if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) { - iVal = hb_itemGetNI( pInfo->pNewVal ) - 1; + iVal = hb_itemGetNI( pInfo->pNewVal ); if( iVal >= 0 && iVal < 16 ) { pInfo->pResult = hb_itemPutNI( pInfo->pResult, wnd->colors[ iVal ].value ); @@ -4000,7 +4000,6 @@ static BOOL hb_gt_xwc_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) { memset( wnd->pCurrScr, 0xFFFFFFFFL, wnd->cols * wnd->rows * sizeof( ULONG ) ); hb_gt_xwc_InvalidateChar( wnd, 0, 0, wnd->cols - 1, wnd->rows - 1 ); -// HB_GTSELF_EXPOSEAREA( pGT, 0, 0, wnd->rows - 1, wnd->cols - 1 ); } } } @@ -4012,7 +4011,7 @@ static BOOL hb_gt_xwc_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) pInfo->pResult = hb_itemNew( NULL ); hb_arrayNew( pInfo->pResult, 16 ); for( iVal = 0; iVal < 16; iVal++ ) - hb_arraySetNL( pInfo->pResult, iVal + 1, wnd->colors[ iVal ].value ); + hb_arraySetNI( pInfo->pResult, iVal + 1, wnd->colors[ iVal ].value ); if( hb_itemType( pInfo->pNewVal ) & HB_IT_ARRAY && hb_arrayLen( pInfo->pNewVal ) == 16 ) { @@ -4029,7 +4028,6 @@ static BOOL hb_gt_xwc_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) { memset( wnd->pCurrScr, 0xFFFFFFFFL, wnd->cols * wnd->rows * sizeof( ULONG ) ); hb_gt_xwc_InvalidateChar( wnd, 0, 0, wnd->cols - 1, wnd->rows - 1 ); -// HB_GTSELF_EXPOSEAREA( pGT, 0, 0, wnd->rows - 1, wnd->cols - 1 ); } } } diff --git a/harbour/source/vm/classes.c b/harbour/source/vm/classes.c index 25bb3f330f..89feae3cf3 100644 --- a/harbour/source/vm/classes.c +++ b/harbour/source/vm/classes.c @@ -2964,7 +2964,7 @@ static BOOL hb_clsAddMsg( USHORT uiClass, const char * szMessage, } /* - * __clsAddMsg( , , , , [xInit], , ) + * __clsAddMsg( , , , , [xInit], ) * * Add a message to the class. *