static void hb_gt_std_Exit( PHB_GT pGT ) { PHB_GTSTD pGTSTD; int iRow, iCol; HB_TRACE( HB_TR_DEBUG, ( "hb_gt_std_Exit(%p)", pGT ) ); HB_GTSELF_REFRESH( pGT ); HB_GTSELF_GETPOS( pGT, &iRow, &iCol ); pGTSTD = HB_GTSTD_GET( pGT ); HB_GTSUPER_EXIT( pGT ); if( pGTSTD ) { /* update cursor position on exit */ if( pGTSTD->fStdoutConsole && pGTSTD->iLastCol > 0 ) { hb_gt_std_newLine( pGTSTD ); ++pGTSTD->iRow; } while( ++pGTSTD->iRow <= iRow ) hb_gt_std_newLine( pGTSTD ); #if defined( HB_HAS_TERMIOS ) if( pGTSTD->fRestTTY ) tcsetattr( pGTSTD->hStdin, TCSANOW, &pGTSTD->saved_TIO ); #endif if( pGTSTD->iLineBufSize > 0 ) hb_xfree( pGTSTD->sLineBuf ); if( pGTSTD->nTransBufSize > 0 ) hb_xfree( pGTSTD->sTransBuf ); if( pGTSTD->szCrLf ) hb_xfree( pGTSTD->szCrLf ); hb_xfree( pGTSTD ); } }
static void hb_gt_std_DispLine( PHB_GT pGT, int iRow, int iFrom, int iSize ) { int iColor; HB_BYTE bAttr; HB_USHORT usChar; int iCol, iLastCol, iAll; HB_SIZE nLen, nI; PHB_CODEPAGE cdpTerm = HB_GTSELF_TERMCP( pGT ); PHB_GTSTD pGTSTD = HB_GTSTD_GET( pGT ); if( iSize < 0 ) { hb_gt_std_newLine( pGTSTD ); pGTSTD->iLastCol = iAll = 0; iSize = pGTSTD->iWidth; } else iAll = iSize; for( iCol = iLastCol = iFrom, nLen = nI = 0; iSize > 0; --iSize ) { if( ! HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol++, &iColor, &bAttr, &usChar ) ) break; if( usChar < 32 || usChar == 127 ) usChar = '.'; nI += hb_cdpTextPutU16( cdpTerm, pGTSTD->sLineBuf + nI, pGTSTD->iLineBufSize - nI, usChar ); if( iAll || usChar != ' ' ) { nLen = nI; iLastCol = iCol; } } if( nLen > 0 ) hb_gt_std_termOut( pGTSTD, pGTSTD->sLineBuf, nLen ); pGTSTD->iRow = iRow; pGTSTD->iCol = iLastCol; if( pGTSTD->iCol > pGTSTD->iLastCol ) pGTSTD->iLastCol = pGTSTD->iCol; }
static void hb_gt_std_DispLine( PHB_GT pGT, int iRow ) { BYTE bColor, bAttr; USHORT usChar; int iCol, iMin = 0; PHB_GTSTD pGTSTD = HB_GTSTD_GET( pGT ); for( iCol = 0; iCol < pGTSTD->iLineBufSize; ++iCol ) { if( !HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol, &bColor, &bAttr, &usChar ) ) break; if( usChar < 32 || usChar == 127 ) usChar = '.'; pGTSTD->sLineBuf[ iCol ] = ( BYTE ) usChar; if( usChar != ' ' ) iMin = iCol + 1; } hb_gt_std_newLine( pGTSTD ); if( iMin > 0 ) hb_gt_std_termOut( pGTSTD, pGTSTD->sLineBuf, iMin ); pGTSTD->iLastCol = pGTSTD->iCol = iMin; pGTSTD->iRow = iRow; }
static void hb_gt_std_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize ) { BYTE bColor, bAttr; USHORT usChar; int iLineFeed, iBackSpace, iLen, iMin; PHB_GTSTD pGTSTD; HB_TRACE( HB_TR_DEBUG, ( "hb_gt_std_Redraw(%p,%d,%d,%d)", pGT, iRow, iCol, iSize ) ); iLineFeed = iBackSpace = 0; pGTSTD = HB_GTSTD_GET( pGT ); if( pGTSTD->iRow != iRow ) { iLineFeed = pGTSTD->iRow < iRow ? iRow - pGTSTD->iRow : 1; iCol = 0; iSize = pGTSTD->iLineBufSize; } else if( pGTSTD->iCol < iCol ) { iSize += iCol - pGTSTD->iCol; iCol = pGTSTD->iCol; } else if( pGTSTD->iCol > iCol ) { if( pGTSTD->fStdoutConsole && pGTSTD->iCol <= pGTSTD->iLineBufSize ) { iBackSpace = pGTSTD->iCol - iCol; if( iBackSpace > iSize ) iSize = iBackSpace; } else { iLineFeed = 1; iCol = 0; iSize = pGTSTD->iLineBufSize; } } iMin = iLineFeed > 0 || pGTSTD->iLastCol <= iCol ? 0 : pGTSTD->iLastCol - iCol; while( iSize > iMin && HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol + iSize - 1, &bColor, &bAttr, &usChar ) ) { if( usChar != ' ' ) break; --iSize; } if( iSize > 0 ) { if( iLineFeed > 0 ) { /* * If you want to disable full screen redrawing in console (TTY) * output then comment out the 'if' block below, Druzus */ if( pGTSTD->fStdoutConsole ) { int i; if( pGTSTD->iRow > iRow ) { pGTSTD->iRow = -1; pGTSTD->fFullRedraw = TRUE; } for( i = pGTSTD->iRow + 1; i < iRow; ++i ) hb_gt_std_DispLine( pGT, i ); iLineFeed = 1; } do hb_gt_std_newLine( pGTSTD ); while( --iLineFeed ); pGTSTD->iLastCol = 0; } else if( iBackSpace > 0 ) { memset( pGTSTD->sLineBuf, HB_CHAR_BS, iBackSpace ); hb_gt_std_termOut( pGTSTD, pGTSTD->sLineBuf, iBackSpace ); } for( iLen = 0; iLen < iSize; ++iLen ) { if( !HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol, &bColor, &bAttr, &usChar ) ) break; if( usChar < 32 || usChar == 127 ) usChar = '.'; pGTSTD->sLineBuf[ iLen ] = ( BYTE ) usChar; ++iCol; } if( iLen ) { #ifndef HB_CDP_SUPPORT_OFF if( pGTSTD->fDispTrans ) hb_cdpnTranslate( ( char * ) pGTSTD->sLineBuf, pGTSTD->cdpHost, pGTSTD->cdpTerm, iLen ); #endif hb_gt_std_termOut( pGTSTD, pGTSTD->sLineBuf, iLen ); } pGTSTD->iRow = iRow; pGTSTD->iCol = iCol; if( pGTSTD->iCol > pGTSTD->iLastCol ) pGTSTD->iLastCol = pGTSTD->iCol; } }
static void hb_gt_std_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize ) { int iColor; HB_BYTE bAttr; HB_USHORT usChar; int iLineFeed, iBackSpace, iMin; PHB_GTSTD pGTSTD; HB_TRACE( HB_TR_DEBUG, ( "hb_gt_std_Redraw(%p,%d,%d,%d)", pGT, iRow, iCol, iSize ) ); iLineFeed = iBackSpace = 0; pGTSTD = HB_GTSTD_GET( pGT ); if( pGTSTD->iRow != iRow ) { iLineFeed = pGTSTD->iRow < iRow ? iRow - pGTSTD->iRow : 1; iCol = 0; iSize = pGTSTD->iWidth; } else if( pGTSTD->iCol < iCol ) { iSize += iCol - pGTSTD->iCol; iCol = pGTSTD->iCol; } else if( pGTSTD->iCol > iCol ) { if( pGTSTD->fStdoutConsole && pGTSTD->iCol <= pGTSTD->iWidth ) { iBackSpace = pGTSTD->iCol - iCol; if( iBackSpace > iSize ) iSize = iBackSpace; } else { iLineFeed = 1; iCol = 0; iSize = pGTSTD->iWidth; } } iMin = iLineFeed > 0 || pGTSTD->iLastCol <= iCol ? 0 : pGTSTD->iLastCol - iCol; while( iSize > iMin && HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol + iSize - 1, &iColor, &bAttr, &usChar ) ) { if( usChar != ' ' ) break; --iSize; } if( iSize > 0 ) { if( iLineFeed > 0 ) { /* * If you want to disable full screen redrawing in console (TTY) * output then comment out the 'if' block below, Druzus */ if( pGTSTD->fStdoutConsole ) { int i; if( pGTSTD->iRow > iRow ) { pGTSTD->iRow = -1; pGTSTD->fFullRedraw = HB_TRUE; } for( i = pGTSTD->iRow + 1; i < iRow; ++i ) hb_gt_std_DispLine( pGT, i, 0, -1 ); iLineFeed = 1; } do { hb_gt_std_newLine( pGTSTD ); } while( --iLineFeed ); pGTSTD->iLastCol = 0; } else if( iBackSpace > 0 ) { memset( pGTSTD->sLineBuf, HB_CHAR_BS, iBackSpace ); hb_gt_std_termOut( pGTSTD, pGTSTD->sLineBuf, iBackSpace ); } hb_gt_std_DispLine( pGT, iRow, iCol, iSize ); } }