示例#1
0
文件: gtcgi.c 项目: emazv72/core
static void hb_gt_cgi_Scroll( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight,
                              int iColor, HB_USHORT usChar, int iRows, int iCols )
{
   int iHeight, iWidth;

   HB_TRACE( HB_TR_DEBUG, ( "hb_gt_cgi_Scroll(%p,%d,%d,%d,%d,%d,%d,%d,%d)", ( void * ) pGT, iTop, iLeft, iBottom, iRight, iColor, usChar, iRows, iCols ) );

   /* Provide some basic scroll support for full screen */
   HB_GTSELF_GETSIZE( pGT, &iHeight, &iWidth );
   if( iCols == 0 && iRows > 0 &&
       iTop == 0 && iLeft == 0 &&
       iBottom >= iHeight - 1 && iRight >= iWidth - 1 )
   {
      PHB_GTCGI pGTCGI = HB_GTCGI_GET( pGT );

      /* scroll up the internal screen buffer */
      HB_GTSELF_SCROLLUP( pGT, iRows, iColor, usChar );
      /* update our internal row position */
      pGTCGI->iRow -= iRows;
      if( pGTCGI->iRow < 0 )
         pGTCGI->iRow = 0;
      pGTCGI->iLastCol = pGTCGI->iCol = 0;
   }
   else
      HB_GTSUPER_SCROLL( pGT, iTop, iLeft, iBottom, iRight, iColor, usChar, iRows, iCols );
}
示例#2
0
文件: gtcgi.c 项目: emazv72/core
static void hb_gt_cgi_Exit( PHB_GT pGT )
{
   PHB_GTCGI pGTCGI;

   HB_TRACE( HB_TR_DEBUG, ( "hb_gt_cgi_Exit(%p)", ( void * ) pGT ) );

   HB_GTSELF_REFRESH( pGT );

   pGTCGI = HB_GTCGI_GET( pGT );

   HB_GTSUPER_EXIT( pGT );

   if( pGTCGI )
   {
      /* update cursor position on exit */
      if( pGTCGI->iLastCol > 0 )
         hb_gt_cgi_newLine( pGTCGI );

#ifndef HB_GT_CGI_RAWOUTPUT
      if( pGTCGI->iLineBufSize > 0 )
         hb_xfree( pGTCGI->sLineBuf );
#endif
      if( pGTCGI->szCrLf )
         hb_xfree( pGTCGI->szCrLf );
      hb_xfree( pGTCGI );
   }
}
示例#3
0
static void hb_gt_cgi_Exit( PHB_GT pGT )
{
   PHB_GTCGI pGTCGI;

   HB_TRACE( HB_TR_DEBUG, ( "hb_gt_cgi_Exit(%p)", pGT ) );

   HB_GTSELF_REFRESH( pGT );

   pGTCGI = HB_GTCGI_GET( pGT );

   HB_GTSUPER_EXIT( pGT );

   if( pGTCGI )
   {
#if defined( HB_OS_WIN ) && ! defined( HB_OS_WIN_CE )
      if( IsValidCodePage( CP_UTF8 ) )
         SetConsoleOutputCP( pGTCGI->uiOldCP );
#endif

      /* update cursor position on exit */
      if( pGTCGI->iLastCol > 0 )
         hb_gt_cgi_newLine( pGTCGI );

#ifndef HB_GT_CGI_RAWOUTPUT
      if( pGTCGI->iLineBufSize > 0 )
         hb_xfree( pGTCGI->sLineBuf );
#endif
      if( pGTCGI->szCrLf )
         hb_xfree( pGTCGI->szCrLf );
      hb_xfree( pGTCGI );
   }
}
示例#4
0
文件: gtcgi.c 项目: emazv72/core
static void hb_gt_cgi_WriteAtW( PHB_GT pGT, int iRow, int iCol, const HB_WCHAR * szTextW, HB_SIZE nLength )
{
   PHB_CODEPAGE cdpTerm = HB_GTSELF_TERMCP( pGT );
   HB_SIZE nSize = hb_cdpU16AsStrLen( cdpTerm, szTextW, nLength, 0 );
   char * buffer = ( char * ) hb_xgrab( nSize );

   hb_cdpU16ToStr( cdpTerm, HB_CDP_ENDIAN_NATIVE, szTextW, nLength, buffer, nSize );
   hb_gt_cgi_conPos( HB_GTCGI_GET( pGT ), iRow, iCol );
   hb_gt_cgi_conOut( pGT, buffer, nSize, NULL, NULL );
   hb_xfree( buffer );
}
示例#5
0
文件: gtcgi.c 项目: emazv72/core
static void hb_gt_cgi_Bell( PHB_GT pGT )
{
   static const char s_szBell[] = { HB_CHAR_BEL, 0 };
   PHB_GTCGI pGTCGI;

   HB_TRACE( HB_TR_DEBUG, ( "hb_gt_cgi_Bell(%p)", ( void * ) pGT ) );

   pGTCGI = HB_GTCGI_GET( pGT );

   hb_gt_cgi_termOut( pGTCGI, s_szBell, 1 );
}
示例#6
0
文件: gtcgi.c 项目: emazv72/core
static void hb_gt_cgi_Refresh( PHB_GT pGT )
{
   int iHeight, iWidth;
   PHB_GTCGI pGTCGI;

   HB_TRACE( HB_TR_DEBUG, ( "hb_gt_cgi_Refresh(%p)", ( void * ) pGT ) );

   pGTCGI = HB_GTCGI_GET( pGT );
   HB_GTSELF_GETSIZE( pGT, &iHeight, &iWidth );
   iWidth *= HB_MAX_CHAR_LEN;
   if( pGTCGI->iLineBufSize < iWidth )
   {
      pGTCGI->sLineBuf = ( char * ) hb_xrealloc( pGTCGI->sLineBuf, iWidth );
      pGTCGI->iLineBufSize = iWidth;
   }
   HB_GTSUPER_REFRESH( pGT );
}
示例#7
0
文件: gtcgi.c 项目: emazv72/core
static void hb_gt_cgi_conOut( PHB_GT pGT, const char * szText, HB_SIZE nLength,
                              PHB_CODEPAGE cdpHost, PHB_CODEPAGE cdpTerm )
{
   PHB_GTCGI pGTCGI = HB_GTCGI_GET( pGT );

   if( cdpTerm && cdpHost && cdpTerm != cdpHost )
   {
      HB_SIZE nLen = nLength, nBufSize = 0;
      char * pBuf = NULL;
      const char * buffer = hb_cdpnDup3( szText, nLen,
                                         NULL, &nLen,
                                         &pBuf, &nBufSize,
                                         cdpHost, cdpTerm );
      hb_gt_cgi_termOut( pGTCGI, buffer, nLen );
      if( pBuf )
         hb_xfree( pBuf );
   }
   else
      hb_gt_cgi_termOut( pGTCGI, szText, nLength );

   while( nLength-- )
   {
      switch( *szText++ )
      {
         case HB_CHAR_BEL:
            break;

         case HB_CHAR_BS:
            if( pGTCGI->iCol )
               pGTCGI->iCol--;
            break;

         case HB_CHAR_LF:
            pGTCGI->iRow++;
            break;

         case HB_CHAR_CR:
            pGTCGI->iCol = 0;
            break;

         default:
            ++pGTCGI->iCol;
      }
   }
   HB_GTSUPER_SETPOS( pGT, pGTCGI->iRow, pGTCGI->iCol );
}
示例#8
0
文件: gtcgi.c 项目: emazv72/core
static void hb_gt_cgi_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
{
   int iColor;
   HB_BYTE bAttr;
   HB_USHORT usChar;
   int iLineFeed, iHeight, iWidth, iLen;
   PHB_GTCGI pGTCGI;

   HB_TRACE( HB_TR_DEBUG, ( "hb_gt_cgi_Redraw(%p,%d,%d,%d)", ( void * ) pGT, iRow, iCol, iSize ) );

   pGTCGI = HB_GTCGI_GET( pGT );
   HB_GTSELF_GETSIZE( pGT, &iHeight, &iWidth );
   iLineFeed = iLen = 0;

   if( pGTCGI->iRow != iRow )
   {
      iLineFeed = pGTCGI->iRow < iRow ? iRow - pGTCGI->iRow : 1;
      pGTCGI->iLastCol = pGTCGI->iCol = iCol = 0;
      iSize = iWidth;
   }
   else if( pGTCGI->iCol < iCol )
   {
      iSize += iCol - pGTCGI->iCol;
      iCol = pGTCGI->iCol;
   }
   else if( pGTCGI->iCol > iCol )
   {
      iLineFeed = 1;
      iCol = pGTCGI->iCol = pGTCGI->iLastCol = 0;
      iSize = iWidth;
   }

   while( iSize > 0 && iCol + iSize > pGTCGI->iLastCol &&
          HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol + iSize - 1, &iColor, &bAttr, &usChar ) )
   {
      if( usChar != ' ' )
         break;
      --iSize;
   }

   if( iSize > 0 )
   {
      PHB_CODEPAGE cdpTerm = HB_GTSELF_TERMCP( pGT );
      int iIndex = 0;

      while( --iLineFeed >= 0 )
         hb_gt_cgi_newLine( pGTCGI );
      pGTCGI->iRow = iRow;

      while( iLen < iSize )
      {
         if( ! HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol, &iColor, &bAttr, &usChar ) )
            break;
         iIndex += ( int ) hb_cdpTextPutU16( cdpTerm, pGTCGI->sLineBuf + iIndex,
                                                      pGTCGI->iLineBufSize - iIndex, usChar );
         ++iLen;
         ++iCol;
      }
      if( iIndex )
      {
         hb_gt_cgi_termOut( pGTCGI, pGTCGI->sLineBuf, iIndex );
         pGTCGI->iCol = iCol;
         if( pGTCGI->iCol > pGTCGI->iLastCol )
            pGTCGI->iLastCol = pGTCGI->iCol;
      }
   }
}
示例#9
0
文件: gtcgi.c 项目: emazv72/core
static void hb_gt_cgi_WriteAt( PHB_GT pGT, int iRow, int iCol, const char * szText, HB_SIZE nLength )
{
   hb_gt_cgi_conPos( HB_GTCGI_GET( pGT ), iRow, iCol );
   hb_gt_cgi_WriteCon( pGT, szText, nLength );
}